If you've never heard of constraints programming -- it's really interesting (personal opinion).
It lets you programmatically state "rules" and "goals" of some system, and solvers will automatically attempt to find the best solution.
Optaplanner is one of the most advanced of such engines that I'm aware of:
Under the hood, OptaPlanner combines sophisticated Artificial Intelligence optimization algorithms (such as Tabu Search, Simulated Annealing, Late Acceptance and other metaheuristics) with very efficient score calculation and other state-of-the-art constraint solving techniques.
But it's also really approachable since they re-wrote it in 2020 to accept regular code for rules, instead of the custom DSL language they used before (Drools).https://www.optaplanner.org/blog/2020/04/07/ConstraintStream...
I got interested in this area some years ago, and reached out to Geoffrey personally. He took the time to reply to me and answer a few questions. Great person, he's brilliant and super passionate about the domain.
If you have any sort of practical usecase for this (scheduling, vehicle routing, cost optimization, etc) and this sounds at all interesting, highly recommend giving it a shot!
As an example of what you can do in a few lines with this, here's one from the docs:
The following code snippet first groups all processes by the computer they run on, sums up all the power required by the processes on that computer using the ConstraintCollectors.sum(… ) collector, and finally penalizes every computer whose processes consume more power than is available.
private Constraint requiredCpuPowerTotal(ConstraintFactory constraintFactory) {
return constraintFactory.from(CloudProcess.class)
.groupBy(CloudProcess::getComputer, sum(CloudProcess::getRequiredCpuPower))
.filter((computer, requiredCpuPower) -> requiredCpuPower > computer.getCpuPower())
.penalize("requiredCpuPowerTotal",
HardSoftScore.ONE_HARD,
(computer, requiredCpuPower) -> requiredCpuPower - computer.getCpuPower());
}
---As a bonus, it's natively integrated into Quarkus and the Quarkus ecosystem. Quarkus is the best thing since sliced bread if you're on the JVM and are writing API's.
https://docs.optaplanner.org/latest/optaplanner-docs/html_si...