Skip to content

Commit

Permalink
Fix #1093
Browse files Browse the repository at this point in the history
  • Loading branch information
cprudhom committed May 7, 2024
1 parent 5ebd7a3 commit ab66b2d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ public void propagate(int idxVarInProp, int mask) throws ContradictionException
public ESat isEntailed() {
int cnt = 0;
for (int i = 0; i < vars.length - 1; i++) {
if (vars[i].getLB() > vars[i + 1].getLB() ||
vars[i].getUB() > vars[i + 1].getUB()) {
return ESat.FALSE;
} else if (vars[i].getUB() < vars[i + 1].getLB()) {
if (vars[i].getUB() + strict <= vars[i + 1].getLB()) {
cnt++;
} else if (vars[i].getLB() + strict > vars[i + 1].getUB()) {
return ESat.FALSE;
}
}
return cnt == vars.length ? ESat.TRUE : ESat.UNDEFINED;
return cnt == vars.length - 1 ? ESat.TRUE : ESat.UNDEFINED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.search.strategy.Search;
import org.chocosolver.solver.search.strategy.strategy.FullyRandom;
import org.chocosolver.solver.variables.BoolVar;
import org.chocosolver.solver.variables.IntVar;
import org.testng.Assert;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -115,4 +116,52 @@ public void test3d() {
Assert.assertEquals(s.getSolutionCount(), 1);
}

@Test(groups = "1s")
public void test040() {
Model m = new Model();
IntVar x = m.intVar("x", 1, 3);
IntVar y = m.intVar("y", 1, 3);
BoolVar b = m.increasing(new IntVar[]{x, y}, 0).reify();
m.arithm(b, "=", 1).post();
Solver s = m.getSolver();
s.findAllSolutions();
Assert.assertEquals(s.getSolutionCount(), 6);
}

@Test(groups = "1s")
public void test041() {
Model m = new Model();
IntVar x = m.intVar("x", 1, 3);
IntVar y = m.intVar("y", 1, 3);
BoolVar b = m.increasing(new IntVar[]{x, y}, 1).reify();
m.arithm(b, "=", 1).post();
Solver s = m.getSolver();
s.findAllSolutions();
Assert.assertEquals(s.getSolutionCount(), 3);
}

@Test(groups = "1s")
public void test050() {
Model m = new Model();
IntVar x = m.intVar("x", 1, 3);
IntVar y = m.intVar("y", 1, 3);
BoolVar b = m.increasing(new IntVar[]{x, y}, 0).reify();
m.arithm(b, "=", 0).post();
Solver s = m.getSolver();
s.findAllSolutions();
Assert.assertEquals(s.getSolutionCount(), 3);
}

@Test(groups = "1s")
public void test051() {
Model m = new Model();
IntVar x = m.intVar("x", 1, 3);
IntVar y = m.intVar("y", 1, 3);
BoolVar b = m.increasing(new IntVar[]{x, y}, 1).reify();
m.arithm(b, "=", 0).post();
Solver s = m.getSolver();
s.findAllSolutions();
Assert.assertEquals(s.getSolutionCount(), 6);
}

}

0 comments on commit ab66b2d

Please sign in to comment.