Clover Coverage Report
Coverage timestamp: mer. juin 27 2007 07:27:16 CEST
20   94   6   10
8   47   0,35   2
2     3,5  
1    
 
  WatchPbTest       Line # 30 20 6 96,7% 0.96666664
 
  (1)
 
1    /*
2    * Created on 18 sept. 2004
3    *
4    * To change the template for this generated file go to
5    * Window>Preferences>Java>Code Generation>Code and Comments
6    */
7    package org.sat4j.minisat.constraints.pb;
8   
9    import java.math.BigInteger;
10   
11    import junit.framework.TestCase;
12   
13    import org.sat4j.core.Vec;
14    import org.sat4j.core.VecInt;
15    import org.sat4j.minisat.SolverFactory;
16    import org.sat4j.minisat.constraints.PBMaxDataStructure;
17    import org.sat4j.minisat.core.DataStructureFactory;
18    import org.sat4j.minisat.core.ILits;
19    import org.sat4j.minisat.core.Solver;
20    import org.sat4j.specs.ContradictionException;
21    import org.sat4j.specs.IVec;
22    import org.sat4j.specs.IVecInt;
23   
24    /**
25    * @author leberre
26    *
27    * To change the template for this generated type comment go to
28    * Window>Preferences>Java>Code Generation>Code and Comments
29    */
 
30    public class WatchPbTest extends TestCase {
31   
32    /**
33    * Constructor for WatchPbTest.
34    *
35    * @param arg0
36    */
 
37  1 toggle public WatchPbTest(String arg0) {
38  1 super(arg0);
39    }
40   
 
41  1 toggle public void testNormalize() {
42    // String test = "BILANCIO: +202 A1 +404 A2 +606 A3 +808 A4 +1010 A5
43    // +1212 A6 +1414 A7 +1616 A8 +1818 A9 "
44    // +"-79 B1 -158 B2 -237 B3 -316 B4 -395 B5 -474 B6 -553 B7 -632 B8 -711
45    // B9 "
46    // +" +100023 C1 +200046 C2 +300069 C3 +400092 C4 +500115 C5 +600138 C6
47    // +700161 C7 +800184 C8 +900207 C9 "
48    // +" -89810 D1 -179620 D2 -269430 D3 -359240 D4 -449050 D5 -538860 D6
49    // -628670 D7 -718480 D8 -808290 D9 "
50    // +" -9980 E1 -19960 E2 -29940 E3 -39920 E4 -49900 E5 -59880 E6 -69860
51    // E7 -79840 E8 -89820 E9 "
52    // +" +1000 F1 +2000 F2 +3000 F3 +4000 F4 +5000 F5 +6000 F6 +7000 F7
53    // +8000 F8 +9000 F9 "
54    // +" +100 G1 +200 G2 +300 G3 +400 G4 +500 G5 +600 G6 +700 G7 +800 G8
55    // +900 G9 "
56    // +" +10000 H1 +20000 H2 +30000 H3 +40000 H4 +50000 H5 +60000 H6 +70000
57    // H7 +80000 H8 +90000 H9 "
58    // +" +100 I1 +200 I2 +300 I3 +400 I4 +500 I5 +600 I6 +700 I7 +800 I8
59    // +900 I9 "
60    // +" -L1 -2 L2 -3 L3 -4 L4 -5 L5 -6 L6 -7 L7 -8 L8 -9 L9 = 0";
61   
62    // create literals
63  1 IVecInt expectedLits = new VecInt();
64  91 for (int i = 1; i <= 90; i++) {
65  90 expectedLits.push(i);
66    }
67    // create coeffs
68  1 IVec<BigInteger> expectedCoeffs = new Vec<BigInteger>();
69  1 BigInteger sum = BigInteger.ZERO;
70  1 BigInteger coef;
71  1 int[] values = { 202, -79, 100023, -89810, -9980, 1000, 100, 10000,
72    100, -1 };
73   
74  11 for (int j = 0; j < values.length; j++) {
75  100 for (int i = 1; i <= 9; i++) {
76  90 expectedCoeffs.push(coef = BigInteger.valueOf(values[j] * i));
77  90 if (coef.signum() > 0) {
78  54 sum = sum.add(coef);
79    }
80    }
81    }
82  1 DataStructureFactory<ILits> daf = new PBMaxDataStructure();
83  1 Solver<ILits> solver = (Solver<ILits>) SolverFactory.newMiniLearning(daf);
84  1 daf.getVocabulary().ensurePool(100);
85  1 try {
86  1 solver.addPseudoBoolean(expectedLits, expectedCoeffs, false,
87    BigInteger.ZERO);
88  1 assertEquals(sum, ((WatchPb) solver.getIthConstr(0)).getDegree());
89    } catch (ContradictionException e) {
90  0 fail("The constraint is not a contradiction!!!");
91    }
92    }
93   
94    }