Commit 1bf3594d authored by lonca's avatar lonca
Browse files

Refactored tests.

git-svn-id: svn+ssh://svn.forge.ow2.org/svnroot/sat4j/maven/trunk@2547 ba638df5-4473-46d1-82f8-c3ae2a17a6e1
parent eee4ccab
......@@ -25,7 +25,7 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiff() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2));
String ctrSection = "<allDifferent> i0 i1 i2 </allDifferent>\n";
String ctrSection = TestUtils.buildConstraintsSection("<allDifferent> i0 i1 i2 </allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 1 2", "0 2 1", "1 0 2", "1 2 0", "2 0 1", "2 1 0");
}
......@@ -34,7 +34,7 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiff2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(1, 0, 2));
String ctrSection = "<allDifferent> i0 i0 </allDifferent>\n";
String ctrSection = TestUtils.buildConstraintsSection("<allDifferent> i0 i0 </allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, new String[]{});
}
......@@ -43,10 +43,11 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiffExcept() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2));
String ctrSection = "<allDifferent>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<allDifferent>"
+ "<list> i0 i1 i2 </list>"
+ "<except> 0 </except>"
+ "</allDifferent>\n";
+ "</allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
List<String> expectedModels = new ArrayList<String>();
for(int i=0; i<=2; ++i) {
......@@ -67,10 +68,11 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiffExcept2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(1, 0, 2));
String ctrSection = "<allDifferent>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<allDifferent>"
+ "<list> i0 i0 </list>"
+ "<except> 0 </except>"
+ "</allDifferent>\n";
+ "</allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0", "1", "2");
}
......@@ -79,11 +81,12 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiffList() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildBinaryVars(6));
String ctrSection = "<allDifferent>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<allDifferent>"
+ "<list> b0 b1 </list>"
+ "<list> b2 b3 </list>"
+ "<list> b4 b5 </list>"
+ "</allDifferent>\n";
+ "</allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
List<String> expectedModels = new ArrayList<String>();
for(int i=0; i<=3; ++i) {
......@@ -104,10 +107,11 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiffList2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildBinaryVars(2));
String ctrSection = "<allDifferent>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<allDifferent>"
+ "<list> b0 b0 </list>"
+ "<list> b1 b1 </list>"
+ "</allDifferent>\n";
+ "</allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 1", "1 0");
}
......@@ -116,10 +120,11 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiffList3() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildBinaryVars(2));
String ctrSection = "<allDifferent>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<allDifferent>"
+ "<list> b0 b1 </list>"
+ "<list> b0 b1 </list>"
+ "</allDifferent>\n";
+ "</allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, new String[]{});
}
......@@ -128,13 +133,14 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiffMatrix() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(6, 0, 2));
String ctrSection = "<allDifferent>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<allDifferent>"
+ "<matrix>"
+ "(i0,i1)"
+ "(i2,i3)"
+ "(i4,i5)"
+ "</matrix>"
+ "</allDifferent>\n";
+ "</allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
List<String> expectedModels = new ArrayList<String>();
int[] values = new int[6];
......@@ -184,12 +190,13 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiffMatrix2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(2, 0, 2));
String ctrSection = "<allDifferent>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<allDifferent>"
+ "<matrix>"
+ "(i0,i1)"
+ "(i1,i0)"
+ "</matrix>"
+ "</allDifferent>\n";
+ "</allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 1", "0 2", "1 0", "1 2", "2 0", "2 1");
......@@ -199,12 +206,12 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiffMatrix3() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(2, 0, 2));
String ctrSection = "<allDifferent>"
String ctrSection = TestUtils.buildConstraintsSection("<allDifferent>"
+ "<matrix>"
+ "(i0,i0)"
+ "(i1,i1)"
+ "</matrix>"
+ "</allDifferent>\n";
+ "</allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, new String[]{});
......@@ -214,12 +221,12 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllDiffMatrix4() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(2, 0, 2));
String ctrSection = "<allDifferent>"
String ctrSection = TestUtils.buildConstraintsSection("<allDifferent>"
+ "<matrix>"
+ "(i0,i1)"
+ "(i0,i1)"
+ "</matrix>"
+ "</allDifferent>\n";
+ "</allDifferent>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, new String[]{});
......@@ -229,7 +236,7 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllEqual() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2));
String ctrSection = "<allEqual> i0 i1 i2 </allEqual>\n";
String ctrSection = TestUtils.buildConstraintsSection("<allEqual> i0 i1 i2 </allEqual>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 0 0", "1 1 1", "2 2 2");
}
......@@ -238,7 +245,7 @@ public class ComparisonCtrBuilderTest {
public void testCtrAllEqual2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(1, 0, 2));
String ctrSection = "<allEqual> i0 i0 i0 </allEqual>\n";
String ctrSection = TestUtils.buildConstraintsSection("<allEqual> i0 i0 i0 </allEqual>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0", "1", "2");
}
......@@ -247,10 +254,11 @@ public class ComparisonCtrBuilderTest {
public void testCtrOrdered1() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 3));
String ctrSection = "<ordered>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<ordered>"
+ "<list>i0 i1 i2</list>"
+ "<operator> gt </operator>"
+ "</ordered>\n";
+ "</ordered>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "2 1 0", "3 1 0", "3 2 0", "3 2 1");
}
......@@ -259,10 +267,11 @@ public class ComparisonCtrBuilderTest {
public void testCtrOrdered2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 1));
String ctrSection = "<ordered>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<ordered>"
+ "<list>i0 i1 i2</list>"
+ "<operator> le </operator>"
+ "</ordered>\n";
+ "</ordered>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 0 0", "0 0 1", "0 1 1", "1 1 1");
}
......@@ -271,10 +280,11 @@ public class ComparisonCtrBuilderTest {
public void testCtrOrdered3() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(1, 0, 1));
String ctrSection = "<ordered>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<ordered>"
+ "<list>i0 i0 i0</list>"
+ "<operator> le </operator>"
+ "</ordered>\n";
+ "</ordered>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0", "1");
}
......@@ -283,10 +293,11 @@ public class ComparisonCtrBuilderTest {
public void testCtrOrdered4() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(1, 0, 1));
String ctrSection = "<ordered>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<ordered>"
+ "<list>i0 i0 i0</list>"
+ "<operator> lt </operator>"
+ "</ordered>\n";
+ "</ordered>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, new String[]{});
}
......@@ -295,11 +306,12 @@ public class ComparisonCtrBuilderTest {
public void testLex1() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(6, 0, 1));
String ctrSection = "<lex>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<lex>"
+ "<list> i0 i1 i2 </list>"
+ "<list> i3 i4 i5 </list>"
+ "<operator> lt </operator>"
+ "</lex>";
+ "</lex>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels,
"0 0 0 0 0 1", "0 0 0 0 1 0", "0 0 0 0 1 1", "0 0 0 1 0 0", "0 0 0 1 0 1", "0 0 0 1 1 0", "0 0 0 1 1 1",
......@@ -338,11 +350,12 @@ public class ComparisonCtrBuilderTest {
public void testLex3() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 1));
String ctrSection = "<lex>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<lex>"
+ "<list> i0 i1 i2 </list>"
+ "<list> i0 i1 i2 </list>"
+ "<operator> lt </operator>"
+ "</lex>";
+ "</lex>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, new String[]{});
}
......@@ -351,11 +364,12 @@ public class ComparisonCtrBuilderTest {
public void testLex4() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(2, 0, 1));
String ctrSection = "<lex>"
String ctrSection = TestUtils.buildConstraintsSection(""
+ "<lex>"
+ "<list> i0 i0 i0 </list>"
+ "<list> i1 i1 i1 </list>"
+ "<operator> lt </operator>"
+ "</lex>";
+ "</lex>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 1");
}
......
......@@ -24,7 +24,7 @@ public class ConnectionCtrBuilderTest {
public void testChannel1() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(4, 0, 3));
String ctrSection = "<channel> i0 i1 i2 i3 </channel>\n";
String ctrSection = TestUtils.buildConstraintsSection("<channel> i0 i1 i2 i3 </channel>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 1 2 3", "0 1 3 2", "0 2 1 3", "0 3 2 1", "1 0 2 3", "1 0 3 2", "2 1 0 3", "2 3 0 1", "3 1 2 0", "3 2 1 0");
}
......@@ -33,9 +33,9 @@ public class ConnectionCtrBuilderTest {
public void testChannel2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(4, 1, 4));
String ctrSection = "<channel>"
String ctrSection = TestUtils.buildConstraintsSection("<channel>"
+ "<list startIndex=\"1\"> i0 i1 i2 i3 </list>"
+ "</channel>\n";
+ "</channel>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "1 2 3 4", "1 2 4 3", "1 3 2 4", "1 4 3 2", "2 1 3 4", "2 1 4 3", "3 2 1 4", "3 4 1 2", "4 2 3 1", "4 3 2 1");
}
......@@ -44,10 +44,10 @@ public class ConnectionCtrBuilderTest {
public void testChannel3() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(6, 0, 2));
String ctrSection = "<channel>"
String ctrSection = TestUtils.buildConstraintsSection("<channel>"
+ "<list> i0 i1 i2 </list>"
+ "<list> i3 i4 i5 </list>"
+ "</channel>\n";
+ "</channel>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 1 2 0 1 2", "0 2 1 0 2 1", "1 0 2 1 0 2", "1 2 0 2 0 1", "2 0 1 1 2 0", "2 1 0 2 1 0");
}
......@@ -56,10 +56,10 @@ public class ConnectionCtrBuilderTest {
public void testChannel4() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 1, 3)+TestUtils.buildIntegerVars(3, 0, 2, 3));
String ctrSection = "<channel>"
String ctrSection = TestUtils.buildConstraintsSection("<channel>"
+ "<list startIndex=\"0\"> i0 i1 i2 </list>"
+ "<list startIndex=\"1\"> i3 i4 i5 </list>"
+ "</channel>\n";
+ "</channel>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "1 2 3 0 1 2", "1 3 2 0 2 1", "2 1 3 1 0 2", "2 3 1 2 0 1", "3 1 2 1 2 0", "3 2 1 2 1 0");
}
......@@ -68,7 +68,7 @@ public class ConnectionCtrBuilderTest {
public void testChannel5() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(2, 0, 1));
String ctrSection = "<channel> i0 i0 </channel>\n";
String ctrSection = TestUtils.buildConstraintsSection("<channel> i0 i0 </channel>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, new String[]{});
}
......@@ -77,10 +77,10 @@ public class ConnectionCtrBuilderTest {
public void testChannel6() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(2, 0, 1));
String ctrSection = "<channel>"
String ctrSection = TestUtils.buildConstraintsSection("<channel>"
+ "<list> i0 i1 </list>"
+ "<list> i0 i1 </list>"
+ "</channel>\n";
+ "</channel>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 1", "1 0");
}
......@@ -89,10 +89,10 @@ public class ConnectionCtrBuilderTest {
public void testChannel7() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(2, 0, 1));
String ctrSection = "<channel>"
String ctrSection = TestUtils.buildConstraintsSection("<channel>"
+ "<list> i0 i0 </list>"
+ "<list> i1 i1 </list>"
+ "</channel>\n";
+ "</channel>\n");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, new String[]{});
}
......@@ -101,10 +101,10 @@ public class ConnectionCtrBuilderTest {
public void testElement1() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildBinaryVars(4));
String ctrSection = "<element>"
String ctrSection = TestUtils.buildConstraintsSection("<element>"
+ "<list startIndex=\"1\"> b1 b2 b3 </list>"
+ "<value> b0 </value>"
+ "</element>";
+ "</element>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 0 0 0", "0 0 0 1", "0 0 1 0", "0 0 1 1", "0 1 0 0", "0 1 0 1", "0 1 1 0", "1 0 0 1", "1 0 1 0", "1 0 1 1", "1 1 0 0", "1 1 0 1", "1 1 1 0", "1 1 1 1");
}
......@@ -113,11 +113,11 @@ public class ConnectionCtrBuilderTest {
public void testElement2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(1, 0, 2)+TestUtils.buildBinaryVars(4));
String ctrSection = "<element>"
String ctrSection = TestUtils.buildConstraintsSection("<element>"
+ "<list startIndex=\"1\"> b1 b2 b3 </list>"
+ "<index rank=\"any\"> i0 </index>"
+ "<value> b0 </value>"
+ "</element>";
+ "</element>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
String[] models = new String[42];
int cpt = 0;
......@@ -134,11 +134,11 @@ public class ConnectionCtrBuilderTest {
public void testElement3() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(1, 0, 2)+TestUtils.buildBinaryVars(4));
String ctrSection = "<element>"
String ctrSection = TestUtils.buildConstraintsSection("<element>"
+ "<list startIndex=\"0\"> b1 b2 b3 </list>"
+ "<index rank=\"first\"> i0 </index>"
+ "<value> b0 </value>"
+ "</element>";
+ "</element>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 0 0 0 0", "0 0 0 0 1", "0 0 0 1 0", "0 0 0 1 1", "0 1 1 0 0", "0 1 1 0 1", "0 1 1 1 0", "0 1 1 1 1",
"1 0 1 0 0", "1 0 1 0 1", "1 1 0 1 0", "1 1 0 1 1",
......@@ -149,11 +149,11 @@ public class ConnectionCtrBuilderTest {
public void testElement4() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(1, 1, 3)+TestUtils.buildBinaryVars(4));
String ctrSection = "<element>"
String ctrSection = TestUtils.buildConstraintsSection("<element>"
+ "<list startIndex=\"1\"> b1 b2 b3 </list>"
+ "<index rank=\"last\"> i0 </index>"
+ "<value> b0 </value>"
+ "</element>";
+ "</element>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "1 0 0 1 1", "1 1 1 0 0",
"2 0 0 0 1", "2 0 1 0 1", "2 1 0 1 0", "2 1 1 1 0",
......@@ -164,10 +164,10 @@ public class ConnectionCtrBuilderTest {
public void testElement5() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildBinaryVars(3));
String ctrSection = "<element>"
String ctrSection = TestUtils.buildConstraintsSection("<element>"
+ "<list> b0 b1 b2 </list>"
+ "<value> 0 </value>"
+ "</element>";
+ "</element>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 0 0", "0 0 1", "0 1 0", "0 1 1", "1 0 0", "1 0 1", "1 1 0");
}
......@@ -176,10 +176,10 @@ public class ConnectionCtrBuilderTest {
public void testElement6() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildBinaryVars(1));
String ctrSection = "<element>"
String ctrSection = TestUtils.buildConstraintsSection("<element>"
+ "<list> b0 b0 b0 </list>"
+ "<value> 0 </value>"
+ "</element>";
+ "</element>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0");
}
......@@ -188,10 +188,10 @@ public class ConnectionCtrBuilderTest {
public void testElement7() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildBinaryVars(1));
String ctrSection = "<element>"
String ctrSection = TestUtils.buildConstraintsSection("<element>"
+ "<list> b0 b0 b0 </list>"
+ "<value> b0 </value>"
+ "</element>";
+ "</element>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0", "1");
}
......@@ -200,11 +200,11 @@ public class ConnectionCtrBuilderTest {
public void testElement8() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildBinaryVars(1)+TestUtils.buildIntegerVars(1, 0, 2));
String ctrSection = "<element>"
String ctrSection = TestUtils.buildConstraintsSection("<element>"
+ "<list> b0 b0 b0 </list>"
+ "<index rank=\"first\"> i0 </index>"
+ "<value> b0 </value>"
+ "</element>";
+ "</element>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 0", "1 0");
}
......@@ -213,11 +213,11 @@ public class ConnectionCtrBuilderTest {
public void testElement9() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildBinaryVars(1)+TestUtils.buildIntegerVars(1, 0, 2));
String ctrSection = "<element>"
String ctrSection = TestUtils.buildConstraintsSection("<element>"
+ "<list> b0 b0 b0 </list>"
+ "<index rank=\"last\"> i0 </index>"
+ "<value> b0 </value>"
+ "</element>";
+ "</element>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 2", "1 2");
}
......@@ -226,10 +226,10 @@ public class ConnectionCtrBuilderTest {
public void testMaximum1() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2));
String ctrSection = "<maximum>"
String ctrSection = TestUtils.buildConstraintsSection("<maximum>"
+ "<list> i0 i1 i2 </list>"
+ "<condition> (eq,2) </condition>"
+ "</maximum>";
+ "</maximum>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 0 2", "0 1 2", "0 2 0", "0 2 1", "0 2 2",
"1 0 2", "1 1 2", "1 2 0", "1 2 1", "1 2 2",
......@@ -240,10 +240,10 @@ public class ConnectionCtrBuilderTest {
public void testMaximum2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2));
String ctrSection = "<maximum>"
String ctrSection = TestUtils.buildConstraintsSection("<maximum>"
+ "<list> i1 i2 </list>"
+ "<condition> (eq,i0) </condition>"
+ "</maximum>";
+ "</maximum>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 0 0", "1 0 1", "1 1 0", "1 1 1", "2 0 2", "2 1 2", "2 2 0", "2 2 1", "2 2 2");
}
......@@ -252,10 +252,10 @@ public class ConnectionCtrBuilderTest {
public void testMaximum3() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(1, 0, 2));
String ctrSection = "<maximum>"
String ctrSection = TestUtils.buildConstraintsSection("<maximum>"
+ "<list> i0 i0 </list>"
+ "<condition> (eq,i0) </condition>"
+ "</maximum>";
+ "</maximum>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0", "1", "2");
}
......@@ -264,11 +264,11 @@ public class ConnectionCtrBuilderTest {
public void testMaximum4() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2) + "<var id=\"i3\"> 2 </var><var id=\"i4\"> 1 </var>");
String ctrSection = "<maximum>"
String ctrSection = TestUtils.buildConstraintsSection("<maximum>"
+ "<list> i0 i1 i2 </list>"
+ "<index rank=\"first\"> i4 </index>"
+ "<condition> (eq,i3) </condition>"
+ "</maximum>";
+ "</maximum>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 2 0 2 1", "0 2 1 2 1", "0 2 2 2 1",
"1 2 0 2 1", "1 2 1 2 1", "1 2 2 2 1");
......@@ -278,11 +278,11 @@ public class ConnectionCtrBuilderTest {
public void testMaximum5() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2) + "<var id=\"i3\"> 2 </var><var id=\"i4\"> 2 </var>");
String ctrSection = "<maximum>"
String ctrSection = TestUtils.buildConstraintsSection("<maximum>"
+ "<list startIndex=\"1\"> i0 i1 i2 </list>"
+ "<index rank=\"first\"> i4 </index>"
+ "<condition> (eq,i3) </condition>"
+ "</maximum>";
+ "</maximum>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 2 0 2 2", "0 2 1 2 2", "0 2 2 2 2",
"1 2 0 2 2", "1 2 1 2 2", "1 2 2 2 2");
......@@ -292,11 +292,11 @@ public class ConnectionCtrBuilderTest {
public void testMaximum6() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2) + "<var id=\"i3\"> 2 </var><var id=\"i4\"> 2 </var>");
String ctrSection = "<maximum>"
String ctrSection = TestUtils.buildConstraintsSection("<maximum>"
+ "<list startIndex=\"1\"> i0 i1 i2 </list>"
+ "<index rank=\"last\"> i4 </index>"
+ "<condition> (eq,i3) </condition>"
+ "</maximum>";
+ "</maximum>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "0 2 0 2 2", "0 2 1 2 2", "1 2 0 2 2", "1 2 1 2 2", "2 2 0 2 2", "2 2 1 2 2");
}
......@@ -306,10 +306,10 @@ public class ConnectionCtrBuilderTest {
public void testMinimum1() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2));
String ctrSection = "<minimum>"
String ctrSection = TestUtils.buildConstraintsSection("<minimum>"
+ "<list> i0 i1 i2 </list>"
+ "<condition> (eq,2) </condition>"
+ "</minimum>";
+ "</minimum>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);
TestUtils.assertEqualsSortedModels(sortedModels, "2 2 2");
}
......@@ -318,10 +318,10 @@ public class ConnectionCtrBuilderTest {
public void testMinimum2() {
XMLCSP3Reader reader = new XMLCSP3Reader(solver);
String varSection = TestUtils.buildVariablesSection(TestUtils.buildIntegerVars(3, 0, 2));
String ctrSection = "<minimum>"
String ctrSection = TestUtils.buildConstraintsSection("<minimum>"
+ "<list> i1 i2 </list>"
+ "<condition> (eq,i0) </condition>"
+ "</minimum>";
+ "</minimum>");
List<String> sortedModels = TestUtils.computeModels(reader, solver, varSection, ctrSection);