Upgrade to Pro — share decks privately, control downloads, hide ads and more …

KieLive#15: OptaPlanner domain models and design patterns

KieLive#15: OptaPlanner domain models and design patterns

In this live session, we'll learn how to properly choose your @PlanningVariable

Link to the presentation: http://red.ht/KieLive15

KieLive#15: OptaPlanner domain models and design patterns

Picking the right model for your first optimization problem is notoriously hard. Luckily it gets a lot easier the more practice you have. In this session, I’ll walk you through a number of OptaPlanner models and explain the motivation for the design of each model.

About the invited speaker:
Geoffrey De Smet is the founder and lead of OptaPlanner, the open source AI constraint solver in Java that is used across the globe for all kinds of planning and scheduling operations.

2c8520502587d8827bad79bd2317299b?s=128

KIE Community

January 20, 2021
Tweet

Transcript

  1. Domain models Domain models and and design patterns design patterns

    by Geoffrey De Smet OptaPlanner lead
  2. Announcements Announcements OptaPlanner Quick Starts repository github.com/kiegroup/optaplanner-quickstarts (https://github.com/kiegroup/optaplanner- quickstarts)

  3. Announcements Announcements OptaPlanner Quick Starts repository Quick Starts Showcase github.com/kiegroup/optaplanner-quickstarts

    (https://github.com/kiegroup/optaplanner- quickstarts)
  4. Announcements Announcements OptaPlanner Quick Starts repository Quick Starts Showcase DEMO

    github.com/kiegroup/optaplanner-quickstarts (https://github.com/kiegroup/optaplanner- quickstarts)
  5. Why is modeling hard? (*) Why is modeling hard? (*)

  6. Why is modeling hard? (*) Why is modeling hard? (*)

    (*) at least the rst few times
  7. Given a text like this... School timetabling School timetabling Optimize

    a school timetable of lessons to assign teachers and students in the best room at the best time.
  8. Given a text like this... School timetabling School timetabling Optimize

    a school timetable of lessons to assign teachers and students in the best room at the best time. Come up with a model like this...
  9. None
  10. Let's take it step by step... School timetabling School timetabling

    Optimize a school timetable of lessons to assign teachers and students in the best room at the best time.
  11. What changes during planning? What changes during planning?

  12. None
  13. None
  14. None
  15. DEMO DEMO

  16. What changes during planning? What changes during planning? The assigned

    timeslot of each lesson The assigned room of each lesson
  17. None
  18. What are the constraints? What are the constraints?

  19. What are the constraints? What are the constraints? 1. Which

    hard constraints are build-in in our model?
  20. What are the constraints? What are the constraints? 1. Which

    hard constraints are build-in in our model? 2. Which constraints affect our planning variables?
  21. Constraints inventory Constraints inventory Each lesson must have one timeslot

    Each lesson must have one room No lessons in the same room together No teacher with lessons at the same time Students must be able to attend all lessons Use each teacher's time ef ciently Give students variety in subjects
  22. Constraints inventory Constraints inventory Each lesson must have one timeslot

    (hard) Each lesson must have one room No lessons in the same room together No teacher with lessons at the same time Students must be able to attend all lessons Use each teacher's time ef ciently Give students variety in subjects
  23. Constraints inventory Constraints inventory Each lesson must have one timeslot

    (hard) Each lesson must have one room (hard) No lessons in the same room together No teacher with lessons at the same time Students must be able to attend all lessons Use each teacher's time ef ciently Give students variety in subjects
  24. Constraints inventory Constraints inventory Each lesson must have one timeslot

    (hard) Each lesson must have one room (hard) No lessons in the same room together (hard) No teacher with lessons at the same time Students must be able to attend all lessons Use each teacher's time ef ciently Give students variety in subjects
  25. Constraints inventory Constraints inventory Each lesson must have one timeslot

    (hard) Each lesson must have one room (hard) No lessons in the same room together (hard) No teacher with lessons at the same time (hard) Students must be able to attend all lessons Use each teacher's time ef ciently Give students variety in subjects
  26. Constraints inventory Constraints inventory Each lesson must have one timeslot

    (hard) Each lesson must have one room (hard) No lessons in the same room together (hard) No teacher with lessons at the same time (hard) Students must be able to attend all lessons (hard) Use each teacher's time ef ciently Give students variety in subjects
  27. Constraints inventory Constraints inventory Each lesson must have one timeslot

    (hard) Each lesson must have one room (hard) No lessons in the same room together (hard) No teacher with lessons at the same time (hard) Students must be able to attend all lessons (hard) Use each teacher's time ef ciently (soft) Give students variety in subjects
  28. Constraints inventory Constraints inventory Each lesson must have one timeslot

    (hard) Each lesson must have one room (hard) No lessons in the same room together (hard) No teacher with lessons at the same time (hard) Students must be able to attend all lessons (hard) Use each teacher's time ef ciently (soft) Give students variety in subjects (soft)
  29. Which hard constraints are build-in Which hard constraints are build-in

    in our model? in our model?
  30. Which hard constraints are build-in Which hard constraints are build-in

    in our model? in our model? Each lesson must have one timeslot (build-in hard)
  31. Which hard constraints are build-in Which hard constraints are build-in

    in our model? in our model? Each lesson must have one timeslot (build-in hard) Each lesson must have one room (build-in hard)
  32. None
  33. Hard constraints (not build-in) Hard constraints (not build-in) Room con

    ict: No 2 lessons in the same room at the same time Teacher con ict: No 2 lessons for the same teacher at the same time Student con ict: No 2 lessons for the same student group at the same time
  34. Hard constraints (not build-in) Hard constraints (not build-in) Room con

    ict: No 2 lessons in the same room at the same time Teacher con ict: No 2 lessons for the same teacher at the same time Student con ict: No 2 lessons for the same student group at the same time Formalize your constraints.
  35. Soft constraints Soft constraints Teacher time ef ciently: No gap

    between teacher lessons Subject variety: No sequential lessons on the same subject
  36. Some constraints affect the Some constraints affect the planning variables.

    planning variables. Most don't.
  37. Some constraints affect the Some constraints affect the planning variables.

    planning variables. Most don't. Learn to tell them apart: Do these planning variables hinder any of the constraints?
  38. None
  39. Constraints that Constraints that don't affect the model don't affect

    the model Skill requirements and af nity Availability and unavailability Fairness and load balancing Time windows, ... (many more)
  40. Constraints that Constraints that don't affect the model don't affect

    the model Skill requirements and af nity Availability and unavailability Fairness and load balancing Time windows, ... (many more) Most constraints do not affect the model!
  41. The PlanningSolution is easy The PlanningSolution is easy

  42. Modeling tips Modeling tips

  43. None
  44. None
  45. None
  46. None
  47. None
  48. None
  49. None
  50. None
  51. None
  52. The PlanningSolution is easy The PlanningSolution is easy to determine

    to determine
  53. None
  54. None
  55. None
  56. None
  57. Exercises Exercises

  58. None
  59. None
  60. None
  61. None
  62. None
  63. None
  64. None
  65. None
  66. None
  67. Assigning to time Assigning to time

  68. None
  69. None
  70. None
  71. None
  72. None
  73. None
  74. None
  75. None
  76. None
  77. None
  78. None
  79. Shadow variables Shadow variables

  80. None
  81. None
  82. None
  83. None
  84. None
  85. None
  86. None
  87. None
  88. None
  89. None
  90. None
  91. None
  92. Exercises Exercises

  93. None
  94. None
  95. None
  96. None
  97. Getting started Getting started

  98. Quick starts Quick starts github.com/kiegroup/optaplanner-quickstarts (https://github.com/kiegroup/optaplanner- quickstarts) $ git clone

    git@github.com:kiegroup/optaplanner-quickstarts.git ... $ cd optaplanner-quickstarts $ cd quarkus-school-timetabling $ mvn quarkus:dev ...
  99. @GeoffreyDeSmet Q & A Q & A Homepage Slides User

    guide Feedback www.optaplanner.org (https://www.optapl www.optaplanner.org/learn/slides.html (https://www.optaplanner.org/learn/slides www.optaplanner.org/learn/documentatio (https://www.optaplanner.org/learn/docum @GeoffreyDeSmet (https://twitter.com/GeoffreyDeSmet)