chocoteam/choco3 — pull request #202 by JLiangWaterloo (2014-04-29 21:35:19+00:00)
Title: Fixed scale view instantiateTo, nextValue, and previousValue.

For example, the following code will find an incorrect solution, assuming views are *enabled*.

```java
public static void main(String[] args) {
Solver solver = new Solver();
IntVar i = VF.enumerated("i", -2, 2, solver);
solver.post(ICF.arithm(
VF.scale(i, 3),
"=",
2));
if(solver.findSolution()) {
do{
System.out.println(solver);
System.out.println(solver.isSatisfied());
}while(solver.nextSolution());
}
}
```

The is due to this code in ScaleView.java

```java
public boolean instantiateTo(int value, ICause cause) throws ContradictionException {
assert cause != null;
boolean done = var.instantiateTo(value / cste, this);
if (done) {
notifyPropagators(EventType.INSTANTIATE, cause);
return true;
}
return false;
}
```

So when "value=2", then the inner variable is instantiated to 0, which is the case for the example above. The bug has to do with the division by cste.

Likewise, nextValue and previousValue are bugged for a similar reason. For example, the following code will print "0" and "0" but the expected values are "-3" and "3".

```java
public static void main(String[] args) {
Solver solver = new Solver();
IntVar i = VF.enumerated("i", -2, 2, solver);
System.out.println(VF.scale(i, 3).nextValue(-5));
System.out.println(VF.scale(i, 3).previousValue(5));
}