chocoteam / choco-solver

An open-source Java library for Constraint Programming
http://choco-solver.org/
BSD 4-Clause "Original" or "Old" License
690 stars 143 forks source link

[BUG] Unwanted warning when posting ifThen with instantiated variable #984

Closed Holt59 closed 1 year ago

Holt59 commented 1 year ago

Describe the bug

When posting a ifThen constraint via Model.ifThen with a boolean variable (first argument) instantiated to 0, a warning is emitted saying the then constraint is free.

To Reproduce

final Model model = new Model();
final IntVar intVar = model.intVar(1, 10);
final BoolVar boolVar = model.boolVar();

boolVar.instantiateTo(0, Cause.Null);
model.ifThen(boolVar, model.arithm(intVar, "=", 5));

model.getSolver().findAllSolutions();

This will output something like

At least one constraint is free, i.e., neither posted or reified. ).
ARITHM ([IV_1 = 5]) is free

Expected behavior

I do not expect such warning since, yes, the constraint was not posted nor reified but it was done due to how Choco work, not because I forgot to post it or reify it.

Environment (please complete the following information):