Skip to content

Commit

Permalink
Fix #1095
Browse files Browse the repository at this point in the history
  • Loading branch information
cprudhom committed May 16, 2024
1 parent ab66b2d commit 2c65dce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.chocosolver.solver.exception.ContradictionException;
import org.chocosolver.solver.variables.BoolVar;
import org.chocosolver.solver.variables.Variable;
import org.chocosolver.solver.variables.events.PropagatorEventType;
import org.chocosolver.util.ESat;
import org.chocosolver.util.tools.ArrayUtils;

Expand Down Expand Up @@ -97,7 +96,7 @@ public void activate(int idx) throws ContradictionException {
for (int p = indices[idx]; p < indices[idx + 1]; p++) {
assert (propagators[p].isReifiedAndSilent());
propagators[p].setReifiedTrue();
propagators[p].propagate(PropagatorEventType.FULL_PROPAGATION.getMask());
model.getSolver().getEngine().execute(propagators[p]);
model.getSolver().getEngine().onPropagatorExecution(propagators[p]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.chocosolver.solver.exception.ContradictionException;
import org.chocosolver.solver.variables.BoolVar;
import org.chocosolver.solver.variables.Variable;
import org.chocosolver.solver.variables.events.PropagatorEventType;
import org.chocosolver.util.ESat;
import org.chocosolver.util.tools.ArrayUtils;

Expand Down Expand Up @@ -107,7 +106,7 @@ public void activate(int idx) throws ContradictionException {
for (int p = indices[idx]; p < indices[idx + 1]; p++) {
assert (propagators[p].isReifiedAndSilent());
propagators[p].setReifiedTrue();
propagators[p].propagate(PropagatorEventType.FULL_PROPAGATION.getMask());
model.getSolver().getEngine().execute(propagators[p]);
model.getSolver().getEngine().onPropagatorExecution(propagators[p]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package org.chocosolver.solver.constraints.nary;

import org.chocosolver.solver.Model;
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.search.strategy.Search;
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 @@ -137,4 +139,24 @@ private static int factorial(int n) {
private static int parmi(int k, int n) {
return factorial(n) / (factorial(k) * factorial(n - k));
}

@Test(groups = "1s")
public void testThomSerg1() {
int n = 3;
Model model = new Model();

IntVar[] nodes = model.intVarArray(3, 0, n - 1);
IntVar length = model.intVar(0, n);

BoolVar a = model.subCircuit(nodes, 0, length).reify();
model.arithm(a, "=", 1).post();

model.arithm(nodes[0], "!=", 0).post();
model.arithm(nodes[1], "=", 1).post();
model.arithm(nodes[2], "!=", 2).post();

Solver solver = model.getSolver();
solver.showDecisions();
Assert.assertNotNull(solver.findSolution());
}
}

0 comments on commit 2c65dce

Please sign in to comment.