3. Introduction to OptaPlanner
•Planning Engine / Constraint Solver
•Made in Java: Library & Standalone
•Uses heuristics and metaheuristics
under the hood
3 / 15
https://www.optaplanner.org/
4. Advantages – Disadvantages
4 / 15
Advantages
•Offers many state of
the art algorithms,
ready to use
•Open source, free for
any use case
•Embeddable, easily
integrated with any
JVM language
Disadvantages:
•Correct modeling is
tricky
•Generic Solver:
•Configuration can be hard
to tune
•Performance
5. What is a Planning Problem?
•“Optimize goals with limited resources
under a set of constraints”
5 / 15
Goal
• Minimize
drivers cost
• Minimize
technicians
cost
• ….
Resources
• Trucks
• Technicians
Constraints
• Delivery
Window
• Technicians
skills
• …
8. Model
8 / 15
• Model Routes using Chains of elements
Truck 1 Req 5 Req 4
Truck 2 Req 3
Tech 1 Req 5 Req 3 Req 4
(Truck/Technician always as first element)
9. Model: Scoring
•Scoring: neutral way to compare two
different solutions.
•Hard / Soft score approach:
•Hard Score: broken constraints
•Soft Score: total cost
9 / 15
Hard Score ≠ 0 Not a valid solution!
13. Results
13 / 15
Example instance, full results and more info available in verolog2019.ortec.com
14. Conclusions
•Fast prototyping.
•Easily test of different strategies.
•Generate results with low effort.
•Even if the generated solutions are not
good enough, it is always nice to have a
baseline.
14 / 15
15. Thank you! – Questions?
Using Optaplanner for the Solver Challenge.
Raúl Martín Santamaría (raul.martin@urjc.es)
Editor's Notes
Intro myself, name group university
I am going to talk about my approach to the Verolog solver challenge
This is the outline of my talk
First I am going to introduce the used tool, Optaplanner, with it's advantages and disadvantages.
Then how I have used it to model and solve the problem
And finally the results and the conclusion.
OptaPlanner is an opensource planning engine or constraint solver, made in Java, that can both work as a library, integrated into any other application, or standalaone, as a solver server.
It uses heuristics and metaheuristics under the hood to solve planning problems.
So why did I choose Optaplanner?
Offers a wide variety of algorithms ready to use.
Open Source: under the Apache Commons license. Free for any use case, including comercial ones
Embeddable, which means it can be easily integrated into any existing application
However, it has some inconvenients
Creating a correct model can be tricky
Generic Solver: Config can be hard to prepare for an specific purpouse, getting good performance requires effort.
I said earlier that Optaplanner solves planning problems, but, what is exactly a Planning Problem?
Definition source: OptaPlanner docs
The formal definition is too long and boring, so I opted to include a simpler one, {…}
In our case, the goal, is to minize both the drivers cost and the technicians cost
The resources are the trucks, technicians
And we have several constraints that we must met {…}
So how do we solve this problem using Optaplanner?
We can simplify the whole process in three steps: Modeling the problem, configuring the algorithms, and running the app and getting feedback.
Start with a simple model, add complexity if necessary.
We will model the routes using chains of elements, we have 3 classes Truck, Request and Technician
Trucks and requests form the transport chain, while technicians and requests form the technician chain.
And what do they all have in common? They are all Planning entities, which means they are going to be modified by the solver
This is another way to view the chains, here you can see the chain is started either by a Truck or a Technician, depending on the chain type, and the elements are concatenated one after another.
Hard Score: Number of broken constraints, such us overloaded trucks, invalid technicians assigments
Softscore: the sum of all the independent costs
DOES NOT MATTER HOW GOOD THE SOFTSCORE IS IF THE HARDSCORE IS NOT 0, the solution is not feasible.
We first select a Constructive strategy from the available ones: First fit, first fit decreasing, regret insertion, cheapest insertion,
Then, we select the local search neighborhoods, and configure them if necessary
Finally we choose an improvement strategy (Tabu Search)
How is this done from the programmers viewpoint? Simple, with an XML file.
This is an example configuration, in fact one of the firsts versions for the challenge (SIMPLIFIED)
I will highlight the most important bits {…}
And that’s all, we are ready to launch the application and start solving.
With this fragment of code, we load the instance, generate a solution and save it. And that’s all.
You may think, this is too simple, you cant get good results with that but…..
In average, the solutions rank in the middle – upper middle of the scoreboard.
This is one of the bests results, as you can see it is the fifth of thirteen participants.
Note that even if this is not the best solution, the score is not really far from the best.
To sum it up,
You dont know how different strategies will work for a given problem, why waste time programming or building an approach that may not be the best?
And one last point, {….}. This can be the case if, for example, you are on a paper, and there arent previous works, OptaPlanner can be used to compare the results.
Thank you, and I am ready for your questions.
If there arent any (more) questions, I hope you have enjoyed this presentation and thank you for your time.