MiniZinc / libminizinc

The MiniZinc compiler
http://www.minizinc.org
Other
514 stars 80 forks source link

Simple >= constraint ignored in 2.7.3, not in 2.7.2. #684

Closed PerMildner closed 1 year ago

PerMildner commented 1 year ago

I have a model with many constraints. One of the constraints is:

constraint number_of_kung_fu_lessons >= 0;

Running this in the IDE or from command line outputs intermediate solutions:


2.7.3: % /Applications/MiniZincIDE.app/Contents/Resources/minizinc --all-solutions models/suitor_schedule.mzn data/suitor_scheduleC_0.dzn | head -10
...
number_of_kung_fu_lessons = -21474836;
...
2.7.2 % /Applications/MiniZincIDE-2.7.2.app/Contents/Resources/minizinc --all-solutions models/suitor_schedule.mzn data/suitor_scheduleC_0.dzn | head -10
...
number_of_kung_fu_lessons = 0;
...
2.6.1: % /Applications/MiniZincIDE\ 2.6.1.app/Contents/Resources/minizinc --all-solutions models/suitor_schedule.mzn data/suitor_scheduleC_0.dzn | head -10
...
number_of_kung_fu_lessons = 0;
...
% 

That is, MiniZinc IDE 2.7.3 starts at MIN_INT and seems to ignore the constraint. The older versions do the expected thing and try increasing values starting from zero.

The model is an Coursera assignment so I will send the reproducer to @Dekker1 directly.

Dekker1 commented 1 year ago

Resolved by b2b528277bb4b14d1c48cd624fa295c805d76d57

Dekker1 commented 1 year ago

Just a note that this problem occurred because x >= 0 is added to CSE and then included in the domain of x. When the 0..infinity domain is transformed back to a constraint, the compiler will assume that x >= 0 (created from mzn_internal_set_in) does not need to be added because it is already in CSE.

A workaround is to just set the domain to be 0..infinity yourself. Then the constraint should still be posted.