chocoteam / chocoteam/choco-solver
[BUG] IntVar.eq(...) creating new variables in the model.
- Dominant language
- Java
- Stars
- 779
- Forks
- 159
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 10
Description
I found out that posting an equality constraint on IntVar can create new variables in the model. An example of code showing that variables are created is the following:
```java
import org.chocosolver.solver.Model;
import org.chocosolver.solver.variables.IntVar;
public class TestModel {
public static Model generateModel() {
Model model = new Model("TestModel");
IntVar[] vars = model.intVarArray("x", 4, 1, 2);
for (int j = 0; j < 3; j++) {
vars[j].eq(j%2+1).post();
}
return model;
}
}
```
On the first time executing the line when posting the constraint, two variables are created, on the second time, one variable is created, and on the third time no variable is created.
After testing a little, it seems that creation of variables depends on the lower bound of the variables, and on the constant in the equality (in this case, the constants are either 1 or 2, so only two different variables are created).
Contributor guide
Assessment
This issue has not been assessed yet.