Permalink
Browse files

Relates to #5: Test case for the xor-chain formula

  • Loading branch information...
1 parent 27e75ae commit 9cd8ef2db307737fbe449bd3516a6d0465f96104 @dmitrygusev dmitrygusev committed Jan 25, 2011
@@ -0,0 +1,85 @@
+package com.anjlab.sat3;
+
+import static org.junit.Assert.fail;
+
+import java.util.Properties;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import cern.colt.list.ObjectArrayList;
+
+import com.anjlab.sat3.EmptyStructureException;
+import com.anjlab.sat3.Helper;
+import com.anjlab.sat3.ICompactTripletsStructure;
+import com.anjlab.sat3.IHyperStructure;
+import com.anjlab.sat3.ITabularFormula;
+
+public class TestXorChain
+{
+ @BeforeClass
+ public static void setup()
+ {
+ Helper.UsePrettyPrint = true;
+ Helper.EnableAssertions = true;
+ System.out.println(TestXorChain.class.getName());
+ }
+
+ @Test
+ public void testStructuresFromReducedHSS() throws Exception
+ {
+ ObjectArrayList cts = new ObjectArrayList(
+ new ITabularFormula[] {
+ Helper.loadFromFile("target/test-classes/xor-chain/basic-cts.cnf"),
+ Helper.loadFromFile("target/test-classes/xor-chain/hss-0-other-cts.cnf"),
+ }
+ );
+
+ Helper.prettyPrint((ITabularFormula) cts.get(0));
+ Helper.prettyPrint((ITabularFormula) cts.get(1));
+
+ try
+ {
+ ObjectArrayList hss = Helper.createHyperStructuresSystem(
+ cts, (ICompactTripletsStructure) cts.get(0), new Properties());
+
+ System.out.println("Writing HSS(0) image to filesystem...");
+ Helper.writeToImage((IHyperStructure) hss.get(0), null, null, "target/test-classes/xor-chain/hs.png");
+ System.out.println("Done");
+
+ fail("Non-empty HSS for UNSAT instance can't be built according to the Theorem 1");
+ }
+ catch (EmptyStructureException e)
+ {
+ // Okay
+ }
+
+ // Save CTS set into a single CNF file
+// SimpleFormula formula = new SimpleFormula();
+// for (int i = 0; i < cts.size(); i++)
+// {
+// ICompactTripletsStructure s = (ICompactTripletsStructure) cts.get(i);
+//
+// for (int j = 0; j < s.getTiers().size(); j++)
+// {
+// ITier tier = s.getTier(j);
+// tier.inverse();
+//
+//// if (tier.isEmpty()) continue;
+//
+// Iterator<ITripletValue> iterator = tier.iterator();
+// while (iterator.hasNext())
+// {
+// ITripletValue tripletValue = iterator.next();
+//
+// formula.add(new SimpleTriplet(
+// tier.getAName() * (tripletValue.isNotA() ? -1 : 1),
+// tier.getBName() * (tripletValue.isNotB() ? -1 : 1),
+// tier.getCName() * (tripletValue.isNotC() ? -1 : 1)));
+// }
+//
+// }
+// }
+// Helper.saveToDIMACSFileFormat(formula, "target/test-classes/xor-chain/formula.cnf");
+ }
+}
@@ -0,0 +1,116 @@
+p cnf 48 115
+-8 42 37 0
+42 37 7 0
+37 7 2 0
+7 2 -24 0
+2 -24 33 0
+-24 33 32 0
+33 32 10 0
+32 10 15 0
+32 10 -15 0
+10 15 11 0
+10 -15 -11 0
+15 11 34 0
+-15 -11 34 0
+11 34 -43 0
+-11 34 -43 0
+34 -43 -22 0
+-43 -22 18 0
+-22 18 20 0
+-22 18 -20 0
+18 20 -38 0
+18 -20 38 0
+20 -38 -19 0
+-20 38 -19 0
+38 -19 36 0
+38 -19 -36 0
+-38 -19 36 0
+-38 -19 -36 0
+-19 36 -39 0
+-19 -36 39 0
+36 -39 28 0
+-36 39 28 0
+39 28 27 0
+-39 28 27 0
+28 27 23 0
+27 23 47 0
+27 23 -47 0
+23 47 9 0
+23 47 -9 0
+23 -47 9 0
+23 -47 -9 0
+47 9 -16 0
+47 -9 16 0
+-47 9 -16 0
+-47 -9 16 0
+9 -16 48 0
+9 -16 -48 0
+-9 16 48 0
+-9 16 -48 0
+16 48 41 0
+16 48 -41 0
+16 -48 41 0
+16 -48 -41 0
+-16 48 41 0
+-16 48 -41 0
+-16 -48 41 0
+-16 -48 -41 0
+48 41 45 0
+48 41 -45 0
+48 -41 45 0
+48 -41 -45 0
+-48 41 45 0
+-48 41 -45 0
+-48 -41 45 0
+-48 -41 -45 0
+41 45 46 0
+41 -45 -46 0
+-41 45 -46 0
+-41 -45 46 0
+45 46 4 0
+45 -46 4 0
+-45 46 4 0
+-45 -46 4 0
+46 4 31 0
+46 4 -31 0
+-46 4 31 0
+-46 4 -31 0
+4 31 -21 0
+4 -31 21 0
+31 -21 17 0
+-31 21 17 0
+21 17 -1 0
+-21 17 -1 0
+17 -1 29 0
+-1 29 -25 0
+29 -25 13 0
+29 -25 -13 0
+-25 13 -14 0
+-25 -13 14 0
+13 -14 30 0
+13 -14 -30 0
+-13 14 30 0
+-13 14 -30 0
+14 30 12 0
+14 30 -12 0
+14 -30 12 0
+14 -30 -12 0
+-14 30 12 0
+-14 30 -12 0
+-14 -30 12 0
+-14 -30 -12 0
+30 12 6 0
+30 -12 6 0
+-30 12 6 0
+-30 -12 6 0
+12 6 5 0
+12 6 -5 0
+-12 6 5 0
+-12 6 -5 0
+6 5 -40 0
+6 -5 -40 0
+5 -40 -26 0
+-5 -40 -26 0
+-40 -26 3 0
+-26 3 -35 0
+3 -35 -44 0
@@ -0,0 +1,120 @@
+p cnf 48 119
+-43 7 17 0
+7 17 4 0
+17 4 -44 0
+4 -44 23 0
+-44 23 -26 0
+23 -26 34 0
+-26 34 3 0
+34 3 18 0
+3 18 -35 0
+18 -35 27 0
+-35 27 6 0
+27 6 32 0
+6 32 42 0
+32 42 15 0
+32 42 -15 0
+42 15 46 0
+42 15 -46 0
+42 -15 46 0
+42 -15 -46 0
+15 46 9 0
+15 -46 -9 0
+-15 46 -9 0
+-15 -46 9 0
+46 9 31 0
+46 9 -31 0
+46 -9 31 0
+46 -9 -31 0
+-46 9 31 0
+-46 9 -31 0
+-46 -9 31 0
+-46 -9 -31 0
+9 31 -21 0
+9 -31 21 0
+-9 31 -21 0
+-9 -31 21 0
+31 -21 -19 0
+-31 21 -19 0
+21 -19 33 0
+-21 -19 33 0
+-19 33 2 0
+33 2 -1 0
+2 -1 -22 0
+-1 -22 -40 0
+-22 -40 37 0
+-40 37 -25 0
+37 -25 -8 0
+-25 -8 29 0
+-8 29 45 0
+-8 29 -45 0
+29 45 -38 0
+29 -45 38 0
+45 -38 11 0
+45 -38 -11 0
+-45 38 11 0
+-45 38 -11 0
+38 11 39 0
+38 11 -39 0
+38 -11 39 0
+38 -11 -39 0
+-38 11 39 0
+-38 11 -39 0
+-38 -11 39 0
+-38 -11 -39 0
+11 39 14 0
+11 -39 -14 0
+-11 39 -14 0
+-11 -39 14 0
+39 14 -24 0
+39 -14 -24 0
+-39 14 -24 0
+-39 -14 -24 0
+14 -24 -13 0
+-14 -24 13 0
+-24 13 16 0
+-24 13 -16 0
+-24 -13 16 0
+-24 -13 -16 0
+13 16 -5 0
+13 -16 5 0
+-13 16 5 0
+-13 -16 -5 0
+16 5 36 0
+16 5 -36 0
+16 -5 36 0
+16 -5 -36 0
+-16 5 36 0
+-16 5 -36 0
+-16 -5 36 0
+-16 -5 -36 0
+5 36 30 0
+5 -36 -30 0
+-5 36 -30 0
+-5 -36 30 0
+36 30 20 0
+36 30 -20 0
+36 -30 20 0
+36 -30 -20 0
+-36 30 20 0
+-36 30 -20 0
+-36 -30 20 0
+-36 -30 -20 0
+30 20 12 0
+30 -20 -12 0
+-30 20 -12 0
+-30 -20 12 0
+20 12 -41 0
+20 -12 41 0
+-20 12 -41 0
+-20 -12 41 0
+12 -41 10 0
+-12 41 10 0
+41 10 28 0
+-41 10 28 0
+10 28 47 0
+10 28 -47 0
+28 47 48 0
+28 47 -48 0
+28 -47 48 0
+28 -47 -48 0
Oops, something went wrong.

0 comments on commit 9cd8ef2

Please sign in to comment.