1 package org.sat4j.pb; 2 3 import static org.junit.Assert.assertTrue; 4 5 import java.io.StringReader; 6 7 import org.junit.Test; 8 import org.sat4j.pb.reader.OPBReader2010; 9 import org.sat4j.reader.ParseFormatException; 10 import org.sat4j.specs.ContradictionException; 11 import org.sat4j.specs.TimeoutException; 12 13 public class BugSAT61 { 14 15 private static final String DUPLICATED_CONJUNCTS = "* #variable= 11 #constraint= 1\n" 16 + "-1 x1 -2 x9 x4 -3 x10 x4 -4 x11 x4 +5 x8 x4 -6 x9 x4 -7 x10 x4 -8 x11 x4 +9 x8 x4 -10 x9 x4 -11 x10 x4 -12 x11 x4 +13 x8 x4 -14 x9 x4 -15 x10 x4 -16 x11 x4 +17 x8 x4 -18 x9 x4 -19 x10 x4 -20 x11 x4 +21 x8 x4 = 9;\n"; 17 18 private static final String NORMALIZED_CONJUNCTS = "* #variable= 11 #constraint= 1\n" 19 + "-1 x1 -50 x9 x4 -55 x10 x4 -60 x11 x4 +65 x8 x4 = 9;"; 20 21 @Test 22 public void testDuplicatedConjuncts() throws ParseFormatException, 23 ContradictionException, TimeoutException { 24 IPBSolver solver = SolverFactory.newDefaultNonNormalized(); 25 OPBReader2010 reader = new OPBReader2010(solver); 26 reader.parseInstance(new StringReader(DUPLICATED_CONJUNCTS)); 27 assertTrue(solver.isSatisfiable()); 28 } 29 30 @Test 31 public void testNoDuplicatedConjuncts() throws ParseFormatException, 32 ContradictionException, TimeoutException { 33 IPBSolver solver = SolverFactory.newDefaultNonNormalized(); 34 OPBReader2010 reader = new OPBReader2010(solver); 35 reader.parseInstance(new StringReader(NORMALIZED_CONJUNCTS)); 36 assertTrue(solver.isSatisfiable()); 37 } 38 }