Efficient OR-Tools equivalent of the CPO "alternative" constraint #2252
-
|
Hello, In a context of scheduling, I am look for an efficient (in the sense "uses as many Or-Tools global constraints as possible") way to model the CPO "alternative" constraints. This constraint has the following behavior :
How would you do it without efficiently ? Is there a direct and algorithmically optimized way to do it in Or-Tools CP-SAT solver ? Or should we simply rely on a "x = sum over i {yi}" and then on synchronization constraints conditioned by x with some BigM ? Thank you ! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
This is not an issue. I moved it to discussions |
Beta Was this translation helpful? Give feedback.
-
|
Just look at the flexible jobshop python example. Note, it does not use big-M as the solver naturally understands half reified constraints. |
Beta Was this translation helpful? Give feedback.
-
|
Now, you can go a bit deeper and look at the jobshop_sat.cc examples. By default, as it is simpler, each copy has its own variables. Then you use the performed literal to enforce the synchronization between the main interval and the selected copy. The sharing approach forces you to be very careful on the constraints between copies, as they need to be protected by the performed status of these copies. At this point, it is unclear which version is faster. |
Beta Was this translation helpful? Give feedback.
Now, you can go a bit deeper and look at the jobshop_sat.cc examples.
In particular, you can decide to share the start, and end variables between the main interval and its copies.
By default, as it is simpler, each copy has its own variables. Then you use the performed literal to enforce the synchronization between the main interval and the selected copy.
The sharing approach forces you to be very careful on the constraints between copies, as they need to be protected by the performed status of these copies.
At this point, it is unclear which version is faster.