| 1 | 
      
 | 
     | 
        
| 2 | 
      
 | 
     | 
        
| 3 | 
      
 | 
     | 
        
| 4 | 
      
 | 
     | 
        
| 5 | 
      
 | 
     | 
        
| 6 | 
      
 | 
     | 
        
| 7 | 
      
 | 
    package org.sat4j.minisat; | 
        
| 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.core.ILits; | 
        
| 16 | 
      
 | 
    import org.sat4j.minisat.core.Solver; | 
        
| 17 | 
      
 | 
    import org.sat4j.specs.ContradictionException; | 
        
| 18 | 
      
 | 
    import org.sat4j.specs.ISolver; | 
        
| 19 | 
      
 | 
    import org.sat4j.specs.IVec; | 
        
| 20 | 
      
 | 
    import org.sat4j.specs.IVecInt; | 
        
| 21 | 
      
 | 
     | 
        
| 22 | 
      
 | 
     | 
        
| 23 | 
      
 | 
    @author | 
        
| 24 | 
      
 | 
     | 
        
| 25 | 
      
 | 
     | 
        
| 26 | 
      
 | 
     | 
        
| 27 | 
      
 | 
     | 
           
        | 
             
         | 
        
       
        | 
       
           
           
            | 91,4% | 
           Uncovered Elements: 3 (35) | 
           Complexity: 3 | 
           Complexity Density: 0,19 | 
                        
            
        | 
    
  
| 28 | 
      
 | 
    public class WatchedPBConstrWithPBConstrLearningOnCNFTest extends | 
        
| 29 | 
      
 | 
            AbstractM2Test { | 
        
| 30 | 
      
 | 
     | 
        
| 31 | 
      
 | 
         | 
        
| 32 | 
      
 | 
    @param | 
        
| 33 | 
      
 | 
     | 
           
        | 
             
         | 
        
       
        | 
       
           
           
            | 100% | 
           Uncovered Elements: 0 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
| 34 | 
     103
 | 
         public WatchedPBConstrWithPBConstrLearningOnCNFTest(String arg0) {... | 
        
| 35 | 
     103
 | 
            super(arg0); | 
        
| 36 | 
      
 | 
        } | 
        
| 37 | 
      
 | 
     | 
        
| 38 | 
      
 | 
         | 
        
| 39 | 
      
 | 
    @see | 
        
| 40 | 
      
 | 
     | 
           
        | 
             
         | 
        
       
        | 
       
           
           
            | 100% | 
           Uncovered Elements: 0 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
| 41 | 
     103
 | 
         @Override... | 
        
| 42 | 
      
 | 
        protected ISolver createSolver() { | 
        
| 43 | 
     103
 | 
            return SolverFactory.newMiniOPBMin(); | 
        
| 44 | 
      
 | 
        } | 
        
| 45 | 
      
 | 
     | 
           
        | 
             
         | 
        
       
        | 
       
           
           
            | 89,5% | 
           Uncovered Elements: 2 (19) | 
           Complexity: 2 | 
           Complexity Density: 0,11 | 
                              1
    PASS
   | 
                        
            
        | 
    
  
| 46 | 
     1
 | 
         public void testPropagation() {... | 
        
| 47 | 
     1
 | 
            solver.newVar(3); | 
        
| 48 | 
     1
 | 
            IVecInt lits = new VecInt(); | 
        
| 49 | 
     1
 | 
            lits.push(1); | 
        
| 50 | 
     1
 | 
            lits.push(2); | 
        
| 51 | 
     1
 | 
            lits.push(3); | 
        
| 52 | 
     1
 | 
            IVec<BigInteger> coefs = new Vec<BigInteger>(); | 
        
| 53 | 
     1
 | 
            coefs.growTo(lits.size(), BigInteger.ONE); | 
        
| 54 | 
     1
 | 
            Solver<ILits> mysolver = (Solver<ILits>) solver; | 
        
| 55 | 
     1
 | 
            try { | 
        
| 56 | 
     1
 | 
                mysolver.addPseudoBoolean(lits, coefs, true, BigInteger.ONE); | 
        
| 57 | 
     1
 | 
                mysolver.assume(3);  | 
        
| 58 | 
     1
 | 
                assertNull(mysolver.propagate()); | 
        
| 59 | 
     1
 | 
                assertTrue(mysolver.getVocabulary().isSatisfied(3)); | 
        
| 60 | 
     1
 | 
                mysolver.assume(5);  | 
        
| 61 | 
     1
 | 
                assertNull(mysolver.propagate()); | 
        
| 62 | 
     1
 | 
                assertTrue(mysolver.getVocabulary().isSatisfied(5)); | 
        
| 63 | 
     1
 | 
                assertTrue(mysolver.getVocabulary().isSatisfied(6)); | 
        
| 64 | 
      
 | 
            } catch (ContradictionException e) { | 
        
| 65 | 
     0
 | 
                e.printStackTrace(); | 
        
| 66 | 
     0
 | 
                fail(); | 
        
| 67 | 
      
 | 
            } | 
        
| 68 | 
      
 | 
     | 
        
| 69 | 
      
 | 
        } | 
        
| 70 | 
      
 | 
     | 
           
        | 
             
         | 
        
       
        | 
       
           
           
            | 90% | 
           Uncovered Elements: 1 (10) | 
           Complexity: 2 | 
           Complexity Density: 0,2 | 
                              1
    PASS
   | 
                        
            
        | 
    
  
| 71 | 
     1
 | 
         public void testPropagation2() {... | 
        
| 72 | 
     1
 | 
            solver.newVar(3); | 
        
| 73 | 
     1
 | 
            IVecInt lits = new VecInt(); | 
        
| 74 | 
     1
 | 
            lits.push(1); | 
        
| 75 | 
     1
 | 
            lits.push(2); | 
        
| 76 | 
     1
 | 
            lits.push(3); | 
        
| 77 | 
     1
 | 
            IVec<BigInteger> coefs = new Vec<BigInteger>(); | 
        
| 78 | 
     1
 | 
            coefs.growTo(lits.size(), BigInteger.ONE); | 
        
| 79 | 
     1
 | 
            try { | 
        
| 80 | 
     1
 | 
                solver.addPseudoBoolean(lits, coefs, true, BigInteger.valueOf(4)); | 
        
| 81 | 
     0
 | 
                fail(); | 
        
| 82 | 
      
 | 
            } catch (ContradictionException e) { | 
        
| 83 | 
      
 | 
                 | 
        
| 84 | 
      
 | 
            } | 
        
| 85 | 
      
 | 
        } | 
        
| 86 | 
      
 | 
     | 
        
| 87 | 
      
 | 
    } |