optaplanner | AI constraint solver in Java to optimize the vehicle routing problem, employee rostering, task assig
kandi X-RAY | optaplanner Summary
kandi X-RAY | optaplanner Summary
It will save you and us a lot of time by setting up your development environment correctly. It solves all known pitfalls that can disrupt your development. It also describes all guidelines, tips and tricks. If you want your pull requests (or patches) to be merged into main, please respect those guidelines.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Overrides superclass to override the weight of the constraint
- Adds the soft constraint with the softScores
- Append the multi constraint
- Adds a soft - constraint with the soft - level constraint
- Adjusts the weight of the constraint based on the constraint weight
- Registers a hard - constraint with the hard - score constraint
- Registers a soft - constraint with the soft - level constraint
- Adds the multi - constraint constraint
- Updates the given tuple
- Evaluates the given constraint
- Build a WeightedScoreImpact based on the given constraints
- Computes the score of the given constraint
- Builds the score operator
- Update the right index
- Builds the weighted score
- Updates the right
- Updates the left index properties of the given left tuple
- Builds a WeightedScoreImpact with the given constraints
- Updates the index properties
- Calculate a WeightedScoreImpact for the given constraint
- Builds a WeightedScoreImpact based on the given weight
- Build a WeightedScoreImpact with the given weight
- Sets the weight of the constraint
- Builds a WeightedScoreImpact from the given constraint and the given constraint weight
- Builds a WeightedScoreImpact with the given soft - constraint weight
- Builds a WeightedScoreImpact based on the given constraint and the given weight
optaplanner Key Features
optaplanner Examples and Code Snippets
description: OptaPlanner optimizes business resource usage. It is a lightweight\\, embeddable\\, open source planning engine\\, written in 100% Java.
Community Discussions
Trending Discussions on optaplanner
QUESTION
I need a sum functionality that sums up double values for my ConstraintProviding functionality. Currently OptaPlanner offers sum() and sumBigDecimal() functionality, where the first is only summing integer values and the second BigDecimal values. So therefore I started with the compose approach as described in the manual chapter 6.4.5.3. for implementing my own functionality (didn't want to override the original one).
Deriving from there and taking the implementation of the sum functionality from the ConstraintCollector.java class of the OptaPlanner source code itself, I ended up with the following code:
...ANSWER
Answered 2022-Apr-11 at 11:11Have you considered using a different type, e.g. long
, to represent values you need to sum()
in your constraint?
Using floating-point numbers in the score calculation is generally not recommended as it may lead to score corruption.
QUESTION
Optaplanner school timetabling examples show different problems than what I need to solve.
The problem:
Let's have three courses: Math, English, History
All these courses offer multiple timeslots (parallels) and the student gets to choose one of them for each.
Let's say:
Math: Monday: 9:00 - 10:00, Tuesday: 10:00 - 11:00
English: Monday: 9:00 - 10:00, Tuesday: 11:00 - 12:00, 14:00 - 15:00, Friday: 16:00 - 17:00
History: Tuesday: 10:00 - 11:00, Friday: 10:00 - 11:00
I would like to find the best possible timeslot for each of these courses. By the best I mean the one with the least amount of gaps and, more importantly, the one which lets you have the most free days.
The optimal solution for the example problem might be something like
Tuesday: Math: 9:00 - 10:00, History: 10:00 - 11:00, English: 11:00 - 12:00
leaving no gap and simultaneously giving 4 free days.
Is this possible with OptaPlanner or should I use a different solver? I noticed that the Lesson
object only has a single TimeSlot
instead of a list, which makes me think that this kind of timetable optimisation is not supported.
ANSWER
Answered 2022-Mar-23 at 14:39From the description, it appears your problem is "Student planning their own schedule" (whereas school timetabling is "Teachers planning the school timetable for all students").
I would model it like this:
QUESTION
I'm trying to use the OptaPlanner Benchmarking module. My benchmark config file is being rejected due to the following error:
...ANSWER
Answered 2022-Mar-21 at 07:26I think that you are passing the benchmark-config.xml
to the wrong method; createFromSolverConfigXmlResource
expects a solver-config.xml
. It creates a basic benchmark from an existing solver configuration.
In fact, the solver config is a subset of the benchmark config, but they have a separate XML namespace.
Please take a look at the method createFromXmlResource
, which expects the benchmark-config.xml
.
QUESTION
I am trying to add a constraint_factory using OptaPy, the Python variant of OptaPlanner, (using the School Timetabling quickstart as a base) for scheduling sports matches. Each match has 2 teams, so there are 2 variables in the Match class : team1 and team2 along with a time_slot and pitch.
How can I have a constraint where I can reward or penalise if a team (in either team1 or team2 variable) has been assigned more than 2 matches in a day?
...ANSWER
Answered 2021-Dec-07 at 10:10I suggest to approach it differently. Start from Team
, join
with Match
where either of the teams are equal, and count()
that in a groupBy()
. You will need to add a composite group key in that groupBy, your team
and your match day.
This is how such a constraint would look in Java, the native language of OptaPlanner:
QUESTION
I am using the Optapy library in python, and I am using the school timetabling instance on GitHub as a base. I have few questions regarding the library configurations:
- How do I choose the optimisation algorithm (e.g. tabu search or simulated annealing)?
- How do Optapy calculate the score of a solution? Do I have the option to change the score calculation type in python?
- How can I decide the weights for each constraint, except hard or soft constraint?
I was looking at OptaPlanner User Guide, but I am not sure how to implement it on python.
Guidance appreciated.
...ANSWER
Answered 2022-Feb-23 at 14:57OptaPy can be configured using the programmatic API. The config classes can be found in the optapy.config
package. In particular, you choose the optimisation algorithm via withPhases
:
QUESTION
I'm running an Optaplanner application on Heroku with:
...ANSWER
Answered 2022-Feb-15 at 20:07moveThreadCount
refers to how many threads the solver will use on a single machine, and if set to AUTO
, it will use as many cores as are available to the JVM with the upper bound of 4.
OptaPlanner does not (yet) support horizontal scaling across the cloud. The orchestration for that would have to be hand-rolled.
QUESTION
I am using Quarkus optaplanner, so instead of using SolverFactory to build a solver, I us ethe Quarkus way to inject a solverManager then let it solve the problem:
...ANSWER
Answered 2022-Feb-14 at 12:25Yes, that is possible with SolverManager
and you don't need to obtain a Solver
instance.
Use SolverManager.solverAndListen(problemId, problemFinder, bestSolutionConsumer)
. The third argument is a consumer where you can do whatever you want with each best solution that is found. It could look something like this in your case:
QUESTION
I have a project in Eclipse which uses OptaPlanner (v8.12.0). I want to be able to write temporary debug statements within the OptaPlanner code itself, so I:
- cloned the repo,
- checked out branch
8.12.x
, - built using
mvn
, - imported as a pre-existing Maven project
optaplanner-core
(again, Eclipse), and - removed the
optaplanner-core
dependency from my Gradle dependencies
Everything compiles and runs just fine, but OptaPlanner no longer responds to my log config changes.
We're using Log4j2 and, when pulling OptaPlanner using the standard build process (Gradle), I can set the log level just fine using the Log4j2 config. But, with the src as a project dependency, it's not working.
I have tried:
- Including a local
logback.xml
- Adding adding as a vm arg:
-Dlogging.level.org.optaplanner=trace
- Adding adding as a vm arg:
-Dlog4j.configurationFile=C:\path\to\log4j2.xml
- Setting an environment variable
LOGGING_CONFIG=C:\path\to\logback.xml
- Setting the level programmatically using
Configurator
ANSWER
Answered 2022-Jan-31 at 15:42OptaPlanner only has Logback as a scoped-to-test dependency.
To get a local copy of OptaPlanner to pick up your log config, you need to (locally) add your logging dependency to the OptaPlanner buildpath.
For me, this meant adding a Log4j2 dependency to the OptaPlanner pom.xml
:
QUESTION
I’m using Optaplanner 8.15.0 to solve a variant of the redistricting problem: Geographic areas with an expected revenue are assembled to sales districts that must be contiguous and should be balanced and compact.
The initial solution is generated by a custom phase using a greedy heuristic. Afterwards a local search hill climbing phase makes big and obvious improvements to that using custom moves. Only then, the “real” optimization starts with a tabu search.
The configuration of the first two phases:
...ANSWER
Answered 2022-Jan-31 at 11:15The answer is no, when the problem is specified like this. However, we could maybe change the problem statement a bit. If you run multiple independent solvers and, at the end, pick the best result, you can then pass that to a new solver which will start from there. This would be a variant of multi-bet solving. It is not supported out of the box, but would be relatively easy to code yourself, using either the Solver
or SolverManager
APIs.
That said, your entire approach is very unconventional. Custom construction heuristic is understandable, as are custom moves. But the fact that you feel the need to separate the moves into different phases makes me curious. Have you benchmarked this to be the best possible approach?
I would think that using the default local search (late acceptance), with your custom moves and our generic moves all thrown into the mix, would yield decent results already. If that fails to happen, then generally either your constraints need to be faster, or the solver needs to run for longer. For large problems, multi-threaded solving can help, too.
QUESTION
I have a problem with planning employees shifts where employees are distributed uniformly (randomly) across the shifts.
In my minimal example I use Spring boot, Lombock and Optaplanner spring boot starter (8.15.0.Final) package.
My minimal example in one file:
...ANSWER
Answered 2022-Jan-27 at 23:00You have no constraints. You have not told OptaPlanner what to optimize for, and therefore all solutions are equally favorable to OptaPlanner.
(In fact, I am quite surprised that this code does not fail. A situation with no constraints should have thrown an exception.)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install optaplanner
You can use optaplanner like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the optaplanner component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page