0

I'm looking for a library to help me solve a constraint based logic problem where I need to schedule a number of different events of varying duration. The events have different attributes associated with them and my main issue is that I need to encode "preferences" based on these attributes. These preferences aren't hard constraints, but I would like to maximise how well they are satisfied in the solution. There are also different preferences of competing priorities.

I've taken a look at a few constraint solvers (Sat4j, clasp, Glucose, GlueMiniSat, etc.) but from what I've seen they all seem to only deal with fixed constraints, and setting up preferences would be non-trivial.

I don't care too much about what technology/language it's in - I'm happy to write a wrapper around it.

  • Off-topic in the current form but can be reformulated as "how to solve a problem with flexible constraints". For the latter purpose, it's currently too vague. I've no idea what "encode attributes into "preferences"" means, i.e. what are the variables and the optimization function. – ivan_pozdeev Nov 15 '15 at 23:31
  • If this is a [constraint satisfaction problem](https://en.wikipedia.org/wiki/Constraint_satisfaction_problem), then it may be possible to solve it using an [SMT solver](https://en.wikipedia.org/wiki/Satisfiability_modulo_theories) such as [Z3](https://github.com/Z3Prover/z3). – Anderson Green Feb 03 '19 at 06:05

4 Answers4

1

Absolutely, Choco Solver is a powerful Java constraint solver that is often used for scheduling and planning.

Let's take the following example: "it would be nice if x = 10"

You can encode preferences in different ways.

1) through variables and constraints.

1.1) reify the constraint with a binary variables

ICF.arithm(x,"=",10).reifyWith(b);

it basically means b = 1 <=> x = 10 (so the constraint may or may not be satisfied), then you can maximise b (possibly with a weight)

1.2) through gap variables

solver.post(ICF.arithm(x,'-',gap,"=",10);

then you can minimise the absolute value of gap (possibly with a weight) to the constraint.

2) through search : when solving the problem ask the search strategy to try x=10 before trying another value. There is not optimality proof but it works quite well in practice.

Hope this help. Please feel free to contact us for more support on Choco Solver www.cosling.com

best,

0

I think OptaPlanner is a tool that can help you to solve this problem, check this:

OptaPlanner is a constraint satisfaction solver. It optimizes business resource planning. Every organization faces scheduling puzzles: assign a limited set of constrained resources (employees, assets, time and money) to provide products or services to customers. OptaPlanner optimizes such planning problems to do more business with less resources. Use cases include Vehicle Routing, Employee Rostering, Job Scheduling, Bin Packing and many more.

OptaPlanner is a lightweight, embeddable planning engine. It enables normal Java™ programmers to solve optimization problems efficiently. Constraints apply on plain domain objects and can reuse existing code. There’s no need to input difficult mathematical equations. Under the hood, OptaPlanner combines sophisticated optimization heuristics and metaheuristics (such as Tabu Search, Simulated Annealing and Late Acceptance) with very efficient score calculation.

OptaPlanner is open source software, released under the Apache Software License. It is written in 100% pure Java™, runs on any JVM and is available in the Maven Central repository too.

Source:

http://www.optaplanner.org/

It's part of Drools, which has another interesting tools:

http://www.drools.org/

Alberto Anderick Jr
  • 1,129
  • 7
  • 24
0

Another actively-maintained library is "choco-solver".

Vyacheslav Enis
  • 1,676
  • 12
  • 17
0

Another alternative is the Gecode Toolkit. It is an open-source and modern Constraint Programming Solver.

Arton Dorneles
  • 1,629
  • 14
  • 18