I'm implementing a similar solution for the Job-Shop problem with one difference: I don't know the machine that has to perform each task. Solving that is a part of the problem too. We can say, in fact, that I'm trying to solve a combination of the Nurse Problem and the Job-Shop Problem.
More concretely, I have some tasks T with duration D that have to be performed by some specific employees E due to their nature N (let's say fron-end tasks, back-end, and so on) in a specific order O.
I have:
A way to solve this is: first solve the assignment problem, then schedule the tasks. I have achieved this.
However I want to implement it as an unique solution.
I am stuck at this: How to create a disjunctive constraint that depends on the int vars I created before?
To those who need to see code:
for i in range(number_employees):
disj = solver.DisjunctiveConstraint([interval_var[task_id] if int_var[task_id] == i] ,'i_name')
[...]
Of course, that doesn't work.
I would really appreciate any suggestion.
Restrictions formulated as constraints make it possible to assign a value to an arbitrary variable. A constraint solver can propagate consequences of assignments to other variables and the order of variable assignments does not affect constraints.
Dismiss Got it. OR-Tools is open source software for combinatorial optimization, which seeks to find the best solution to a problem out of a very large set of possible solutions.
Module pywraplpThe class for constraints of a Mathematical Programming (MP) model. A constraint is represented as a linear equation or inequality. Expand source code. A constraint is represented as a linear equation or inequality. """
Should should have a look at the CP-SAT solver. It supports half-reified constraints.
That is, (in python):
model.AddNoOverlap([list of intervals]).OnlyEnforceIf(boolvar)
model.Add(x == i).OnlyEnforceIf(boolvar)
model.Add(x != i).OnlyEnforceIf(boolvar.Not())
See: https://github.com/google/or-tools/blob/master/ortools/sat/doc/index.md
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With