Repository navigation
NoOverlapOptional and CumulativeOptional mapping to MiniZinc - #1083
WoutPiessens wants to merge 9 commits into
Conversation
IgnaceBleukx
left a comment
There was a problem hiding this comment.
You can use a bunch more minizinc features actually, so you don't have to manually handle all of the opt-stuff : )
|
|
||
| # absent tasks consume no resources | ||
| demand_str = "[{}]".format(",".join( | ||
| "if {} then {} else 0 endif".format(self._convert_expression(p), self._convert_expression(d)) |
There was a problem hiding this comment.
This is not actually required, minizinc handles this themself.
The only difference between the non-optional cumulative and the optinonal one should be the array of start vars (it does get some getting used to)
https://docs.minizinc.dev/en/2.9.3/lib-globals-scheduling.html#mzn-ref-globals-scheduling-cumulative
The starts become optional integers, which you can do just using an if statement
[s | i, s in enumerate(_convert_expression(start)) if is_present[i]]
I forgot what the exact minizinc-equivalent is of enumerate(start) but you get the point : )
There was a problem hiding this comment.
Yes that's better, also more similar to NoOverlapOptional that way. I'll also use the same syntax as NoOverlapOptional, for the same reason as discussed in that comment
…optional-globals-minizinc
|
Lets first determine what we do with #1103, we might need to change to disjunctive_strict here as well |
|
Because we decided on non-strict semantics in all cases (see #1105), this PR already respects the desired semantics. |
|
Merged current master in this one with the new tests for nooverlap and cumulative. There two tests failing locally on my macine |
|
It seems to have something to do with an inconsistency in how Gecode handles CumulativeOptional. It seems that Gecode has the strict semantics here, unlike Chuffed and CP-SAT. We can just hard code in our transformation that zero-duration tasks are always inactive to fix it. But I'll try to understand a bit better what's happening exactly first. |
…s in optional globals
|
Under certain conditions, MiniZinc’s cumulative_optional global can fall back to Gecode’s native cumulative_optional, which uses strict semantics. Because zero-duration tasks are not treated consistently, a preventive fix is to treat zero-duration tasks as inactive. |
|
This seems to be a MiniZinc issue then, so we should tell them : ) |
|
The following code ( The reason why disjunctive_optional doesn't have the same issue is because there is no native Gecode override. The default decomposition respects the non-strict semantics, just like for cumulative_optional. On which repo should we open an issue for this? |
|
Ok good, you can open an issue at https://github.com/MiniZinc/libminizinc with an example model and the expected output. |
|
Issue opened: MiniZinc/libminizinc#1070 |
This PR addresses the two global constraints left in #966: NoOverlapOptional and CumulativeOptional, which were not yet mapped to the MiniZinc interface. Similar to the mappings for NoOverlap and Cumulative respectively, except for the necessary changes for optional tasks.