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

OptaPlanner Shadow Variables for the Vehicle Routing Problem and Task Assignment

OptaPlanner Shadow Variables for the Vehicle Routing Problem and Task Assignment

Learn how to simplify your OptaPlanner models with shadow variables and tackle otherwise near impossible constraints.

Link to this presentation: http://red.ht/KieLive22

KieLive#22: OptaPlanner Shadow Variables for the Vehicle Routing Problem and Task Assignment

Some OptaPlanner use cases, such as the Vehicle Routing Problem (especially with Time Windows) and Task Assignment use shadow variables. A shadow variable is something that changes during planning, but unlike a genuine planning variable, doesn’t do so freely, it’s not decided by OptaPlanner directly. Instead, it’s value is deterministically defined by the values of the genuine planning variables. For example in VRP, the arrival time of a vehicle at each visit, is determined by the order of the visits of that vehicle and the departure time of the vehicle.

About the invited speaker:
Geoffrey De Smet is the founder and lead of OptaPlanner (www.optaplanner.org), the open source AI constraint solver in Java that is used across the globe to automatically solve employee rostering, vehicle routing, task assignment, maintenance scheduling and other planning problems. He's an international speaker.

Twitter: https://twitter.com/GeoffreyDeSmet

KIE Community

January 20, 2021
Tweet

More Decks by KIE Community

Other Decks in Technology

Transcript

  1. Shadow variables Shadow variables for VRP for VRP and task

    assignment and task assignment by Geoffrey De Smet OptaPlanner lead
  2. What is a shadow variable? What is a shadow variable?

    (Genuine) planning variable Integer a with a value range of 1-10
  3. What is a shadow variable? What is a shadow variable?

    (Genuine) planning variable Integer a with a value range of 1-10 Shadow variable Integer b = a + 100
  4. What is a shadow variable? What is a shadow variable?

    (Genuine) planning variable Integer a with a value range of 1-10 Shadow variable Integer b = a + 100 Behavior: If a = 1 then b = 101
  5. What is a shadow variable? What is a shadow variable?

    (Genuine) planning variable Integer a with a value range of 1-10 Shadow variable Integer b = a + 100 Behavior: If a = 1 then b = 101 If a = 2 then b = 102
  6. What is a shadow variable? What is a shadow variable?

    (Genuine) planning variable Integer a with a value range of 1-10 Shadow variable Integer b = a + 100 Behavior: If a = 1 then b = 101 If a = 2 then b = 102 If a = 7 then b = 107
  7. Why are shadow variables useful? Why are shadow variables useful?

    int a; int getA() { return a; } // This is NOT a shadow variable, it's non-simple getter int getB() { return a + 100; }
  8. Don't overuse shadow variables Don't overuse shadow variables Shadow vars

    are de-normalization information duplication Shadow vars work incrementally Shadow variable corruption is possible!
  9. Don't overuse shadow variables Don't overuse shadow variables Shadow vars

    are de-normalization information duplication Shadow vars work incrementally Shadow variable corruption is possible! Shadow var Room.getLessonCount() is probably not worth it.
  10. Vehicle Routing Problem with Time Vehicle Routing Problem with Time

    Windows (VRPTW) Windows (VRPTW) Swing demo!
  11. VRPTW Customer visit properties VRPTW Customer visit properties Input: readyTime:

    Time window start dueTime: Time window end serviceTime Change during planning:
  12. VRPTW Customer visit properties VRPTW Customer visit properties Input: readyTime:

    Time window start dueTime: Time window end serviceTime Change during planning: arrivalTime = previousDepartureTime + travelTim
  13. VRPTW Customer visit properties VRPTW Customer visit properties Input: readyTime:

    Time window start dueTime: Time window end serviceTime Change during planning: arrivalTime = previousDepartureTime + travelTim startTime = max(readyTime, arrivalTime
  14. VRPTW Customer visit properties VRPTW Customer visit properties Input: readyTime:

    Time window start dueTime: Time window end serviceTime Change during planning: arrivalTime = previousDepartureTime + travelTim startTime = max(readyTime, arrivalTime departureTime = startTime + serviceTim
  15. VRPTW Customer visit properties VRPTW Customer visit properties Input: readyTime:

    Time window start dueTime: Time window end serviceTime Change during planning: arrivalTime = previousDepartureTime + travelTim startTime = max(readyTime, arrivalTime departureTime = startTime + serviceTim Hard constraint: departureTime <= dueTime
  16. VRPTW with lunches VRPTW with lunches Original: arrivalTime = previousDepartureTime

    + travelTim startTime = max(readyTime, arrivalTime Extra logic to allow for lunch: If travelTime contains 12:00, add 1 hour to transitTime for lunch. Else serviceTime contains 12:00, add 1 hour to serviceTime for lunch.
  17. VRPTW with lunches VRPTW with lunches Original: arrivalTime = previousDepartureTime

    + travelTim startTime = max(readyTime, arrivalTime Extra logic to allow for lunch: If travelTime contains 12:00, add 1 hour to transitTime for lunch. Else serviceTime contains 12:00, add 1 hour to serviceTime for lunch. All this logic ends up in the VariableListener.
  18. Quick starts Quick starts github.com/kiegroup/optaplanner-quickstarts (https://github.com/kiegroup/optaplanner- quickstarts) $ git clone

    [email protected]:kiegroup/optaplanner-quickstarts.git ... $ cd optaplanner-quickstarts $ cd quarkus-school-timetabling $ mvn quarkus:dev ...
  19. @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)