Skip to content

Commit

Permalink
Fix #1102
Browse files Browse the repository at this point in the history
  • Loading branch information
cprudhom committed Sep 23, 2024
1 parent 9e77e96 commit 34d5970
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ void reset() {
@Override
void support(int value) {
value -= offset;
ac.set(value);
if(value > -1) {
ac.set(value);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.chocosolver.solver.constraints.Constraint;
import org.chocosolver.solver.constraints.extension.Tuples;
import org.chocosolver.solver.constraints.extension.TuplesFactory;
import org.chocosolver.solver.constraints.extension.hybrid.HybridTuples;
import org.chocosolver.solver.constraints.extension.hybrid.ISupportable;
import org.chocosolver.solver.constraints.extension.nary.TuplesLargeTable;
import org.chocosolver.solver.constraints.extension.nary.TuplesTable;
import org.chocosolver.solver.constraints.extension.nary.TuplesVeryLargeTable;
Expand All @@ -33,12 +35,14 @@
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

import static java.lang.System.out;
import static org.chocosolver.solver.constraints.extension.TuplesFactory.generateTuples;
import static org.chocosolver.solver.constraints.extension.TuplesFactory.scalar;
import static org.chocosolver.solver.constraints.extension.hybrid.HybridTuples.*;
import static org.chocosolver.solver.search.strategy.Search.randomSearch;
import static org.testng.Assert.assertEquals;

Expand Down Expand Up @@ -942,4 +946,22 @@ public void testForbidden2(String a) {
Assert.assertEquals(model.getSolver().getSolutionCount(), (int) Math.pow(3, 3) - 3);
}

@Test(groups = "1s")
public void testHybrid() {
Model m = new Model();
IntVar[] intVars = m.intVarArray(3, 0, 5);
ISupportable[][] htuples = new ISupportable[][]{
{eq(1), gt(2), le(col(0))},
{eq(2), le(2), ne(col(1))}

};
HybridTuples ht = new HybridTuples();
ht.add(htuples);
m.table(intVars, ht).post();
for (int i = 0; i < 7; i++) {
m.getSolver().solve();
out.println(Arrays.toString(intVars));
}
}

}

0 comments on commit 34d5970

Please sign in to comment.