04 November 2022
Tags : quarkus, constraints, optaplanner, java
I have been meaning to look at OptaPlanner for ages. All i can say is "Sorry Geoffrey De Smet, you are a goddamn genius and i should have played with OptaPlanner way sooner".
So, i watched this video to see how to get started.
So much fun ! 😁 to code.
There were a couple of long learnt lessons i remembered whilst playing with the code.
(1) Domain Driven Design
To get at the heart of constraints programming you need a good object class hierarchy, one that is driven by your business domain. Thanks Eric Evans for the gift that keeps giving - DDD (and UML) is perfect to help you out here.
You need to have a clean and well thought out class heirarchy so that wiring in OptaPlanner will work for you. I can see several iterations and workshop sessions ensuing to get to a workable and correct understanding of the problem domain.
(2) Constraints Programming
I went looking for some code i helped write some 15 years ago ! A Constraint based programming model we had written in C++
We had a whole bunch of Production classes used for calculating different trades types and their values. You added these productions into a solver class heirarcy and if you had the right degrees of freedom your trade calculation would be successful. The beauty of it was the solver would spit out any parameter you had not specified, as long as it was possible to calculate it based on the production rules.
OptaPlanner viscerally reminded me of that code and experience, and started me thinking about how to use it for a similar use case.
I am now a fan 🥰
One last lesson from the OptaPlanner crew was their use of a a new static doc-generation system, their docs are a thing of beauty i have to say, JBake which I am using to write this blog with. Thanks for all the fish 🐟 🐠 Geoff.
OptaPlanner Quickstarts Code - https://github.com/kiegroup/optaplanner-quickstarts