chocoteam/choco3 — pull request #138 by JLiangWaterloo (2013-11-17 21:03:30+00:00)
Title: Fixed element entails and satisfies.

Fixed isSatisfies and isEntailed.

For example:
```java
{
Solver s = new Solver();
s.post(ICF.element(
VF.enumerated("element", 0, 4, s),
new IntVar[]{VF.fixed(1, s), VF.fixed(2, s), VF.fixed(3, s)},
VF.fixed(5, s), 5));
System.out.println(s.findSolution() ? "Found a solution" : "No solution");
System.out.println(s);
}
{
// Opposite of the previous problem.
Solver s = new Solver();
s.post(ICF.element(
VF.enumerated("element", 0, 4, s),
new IntVar[]{VF.fixed(1, s), VF.fixed(2, s), VF.fixed(3, s)},
VF.fixed(0, s), 0).getOpposite());
System.out.println(s.findSolution() ? "Found a solution" : "No solution");
}
```
Would print:
```
Found a solution.
No solution.
```
but the second problem clearly has a solution.

Another example:
```java
{
Solver s = new Solver();
s.post(ICF.element(
VF.enumerated("element", 0, 4, s),
new IntVar[]{VF.fixed(1, s), VF.fixed(2, s), VF.fixed(3, s)},
VF.fixed(3, s), 0));
System.out.println(s.findSolution() ? "Found a solution" : "No solution");
}
{
// Same as the previous problem except use a reified variable.
Solver s = new Solver();
s.post(ICF.arithm(
ICF.element(
VF.enumerated("element", 0, 4, s),
new IntVar[]{VF.fixed(1, s), VF.fixed(2, s), VF.fixed(3, s)},
VF.fixed(3, s), 0).reif(), "=", 1));
System.out.println(s.findSolution() ? "Found a solution" : "No solution");
}
```
Would print:
```
No solution
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at solver.constraints.nary.element.PropElementV_fast.isEntailed(PropElementV_fast.java:179)
at solver.constraints.Constraint.isEntailed(Constraint.java:159)
at solver.constraints.reification.PropReif.propagate(PropReif.java:81)
at solver.propagation.PropagationTrigger.execute(PropagationTrigger.java:122)
at solver.propagation.PropagationTrigger.propagate(PropagationTrigger.java:109)
at solver.propagation.hardcoded.SevenQueuesPropagatorEngine.propagate(SevenQueuesPropagatorEngine.java:149)
at solver.search.loop.BinarySearchLoop.initialPropagation(BinarySearchLoop.java:60)
at solver.search.loop.AbstractSearchLoop.loop(AbstractSearchLoop.java:220)
at solver.search.loop.AbstractSearchLoop.launch(AbstractSearchLoop.java:199)
at solver.Solver.solve(Solver.java:680)
at solver.Solver.findSolution(Solver.java:604)
```