7 ms·
Taking this opportunity to promote the author of this article (Geoffrey de Smet) and the project he's been the lead of for some very long amount of time (Optapl
by gavinray 5y ago
Taking this opportunity to promote the author of this article (Geoffrey de Smet) and the project he's been the lead of for some very long amount of time (Optaplanner):
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/ConstraintStreams.html 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_single/index.html#quarkusJavaQuickStart https://docs.optaplanner.org/latest/optaplanner-docs/html_si...
- vips7L 5y agoI recently got super interested in constraint problems after reading Classical Computer Science Problems in Java. They were really fascinating (along with all the problems in the book).
- scns 5y agoThank you very much for the recommdation, looks like an amazing resource. Hopefully i'll be able to schedule time work through this. Would have loved to study CS but awesome/time consuming events in my life prevented it, which is totally fine.
- vips7L 5y agoThe author also wrote the book for Python or Swift if you’re not into Java.
- WoodenChair 5y agoAuthor here... thanks really appreciate the shoutout! The Java version is the most recent and probably the best version if you know multiple of the languages and have to choose between them. The Python and Java versions cover all of the same problems. The Swift version (the oldest) is missing a couple. You can find out more about all three, including links to translations in 9 languages, here: https://classicproblems.com/ https://classicproblems.com/
- scns 5y agoThank you very much for writing it. Lucky me, i'm most proficient in Java even though i used all three. May do it in Kotlin, we'll see. You deserve way more than a shoutout, submitted it <edit> so Pythonistas and Swift developers may discover it too</edit>.
- darksaints 5y agoI would also add that Constraint Programming has a small but very dedicated community, and the amount of innovation in the space is incredible given how niche it is. Some things I find amazing: * Dozens of solvers with hundreds of search methodologies * Intermediate Language specifications (FlatZinc) to allow solvers written in one language to interact with completely different languages via a common intermediate language. * Entire catalogs of useful constraints https://sofdem.github.io/gccat/ https://sofdem.github.io/gccat/ * Solver Competitions https://www.minizinc.org/challenge.html https://www.minizinc.org/challenge.html * Peer Reviewed journals https://www.springer.com/journal/10601 https://www.springer.com/journal/10601