Clover Coverage Report
Coverage timestamp: mer. juin 27 2007 07:27:16 CEST
12   120   2   1,71
2   63   0,67   7
7     1,14  
1    
 
  AbstractPBDataStructureFactory       Line # 47 12 2 76,2% 0.7619048
 
  (181)
 
1    /*
2    * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2006 Daniel Le Berre
3    *
4    * Based on the original minisat specification from:
5    *
6    * An extensible SAT solver. Niklas E?n and Niklas S?rensson. Proceedings of the
7    * Sixth International Conference on Theory and Applications of Satisfiability
8    * Testing, LNCS 2919, pp 502-518, 2003.
9    *
10    * This library is free software; you can redistribute it and/or modify it under
11    * the terms of the GNU Lesser General Public License as published by the Free
12    * Software Foundation; either version 2.1 of the License, or (at your option)
13    * any later version.
14    *
15    * This library is distributed in the hope that it will be useful, but WITHOUT
16    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17    * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
18    * details.
19    *
20    * You should have received a copy of the GNU Lesser General Public License
21    * along with this library; if not, write to the Free Software Foundation, Inc.,
22    * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23    *
24    */
25   
26    package org.sat4j.minisat.constraints;
27   
28    import java.math.BigInteger;
29   
30    import org.sat4j.core.VecInt;
31    import org.sat4j.minisat.constraints.cnf.LearntWLClause;
32    import org.sat4j.minisat.constraints.cnf.Lits;
33    import org.sat4j.minisat.constraints.cnf.WLClause;
34    import org.sat4j.minisat.constraints.pb.IInternalPBConstraintCreator;
35    import org.sat4j.minisat.constraints.pb.PBConstr;
36    import org.sat4j.minisat.core.Constr;
37    import org.sat4j.minisat.core.ILits;
38    import org.sat4j.specs.ContradictionException;
39    import org.sat4j.specs.IConstr;
40    import org.sat4j.specs.IVec;
41    import org.sat4j.specs.IVecInt;
42   
43    /**
44    * @author leberre To change the template for this generated type comment go to
45    * Window>Preferences>Java>Code Generation>Code and Comments
46    */
 
47    public abstract class AbstractPBDataStructureFactory extends
48    AbstractDataStructureFactory<ILits> implements IInternalPBConstraintCreator {
49   
 
50  1005364 toggle public Constr createClause(IVecInt literals) throws ContradictionException {
51  1005364 IVecInt v = WLClause.sanityCheck(literals, getVocabulary(), solver);
52  1005364 if (v == null)
53  52 return null;
54  1005312 IVecInt coefs = new VecInt(v.size(), 1);
55  1005312 return constraintFactory(v, coefs, true, 1);
56    }
57   
 
58  16663481 toggle public Constr createUnregisteredClause(IVecInt literals) {
59  16663481 return new LearntWLClause(literals, getVocabulary());
60    }
61   
 
62  0 toggle @Override
63    public Constr createCardinalityConstraint(IVecInt literals, int degree)
64    throws ContradictionException {
65  0 IVecInt coefs = new VecInt(literals.size(), 1);
66  0 return constraintFactory(literals, coefs, true, degree);
67    }
68   
 
69  1678500 toggle @Override
70    public Constr createPseudoBooleanConstraint(IVecInt literals,
71    IVec<BigInteger> coefs, boolean moreThan, BigInteger degree)
72    throws ContradictionException {
73  1678500 return constraintFactory(literals, coefs, moreThan, degree);
74    }
75   
76    /**
77    * @param literals
78    * @param coefs
79    * @param moreThan
80    * @param degree
81    * @return
82    */
83    protected abstract PBConstr constraintFactory(IVecInt literals,
84    IVecInt coefs, boolean moreThan, int degree)
85    throws ContradictionException;
86   
87    protected abstract PBConstr constraintFactory(IVecInt literals,
88    IVec<BigInteger> coefs, boolean moreThan, BigInteger degree)
89    throws ContradictionException;
90   
 
91  1281625 toggle @Override
92    public Constr createUnregisteredPseudoBooleanConstraint(IVecInt literals,
93    IVec<BigInteger> coefs, BigInteger degree) {
94  1281625 return constraintFactory(literals, coefs, degree);
95    }
96   
 
97  0 toggle public IConstr createUnregisteredPseudoBooleanConstraint(IVecInt literals,
98    IVec<BigInteger> coefs, boolean moreThan, BigInteger degree)
99    throws ContradictionException {
100  0 return constraintFactory(literals, coefs, moreThan, degree);
101    }
102   
103    /**
104    * @param literals
105    * @param coefs
106    * @param degree
107    * @return
108    */
109    protected abstract PBConstr constraintFactory(IVecInt literals,
110    IVecInt coefs, int degree);
111   
112    protected abstract PBConstr constraintFactory(IVecInt literals,
113    IVec<BigInteger> coefs, BigInteger degree);
114   
 
115  1165 toggle @Override
116    protected ILits createLits() {
117  1165 return new Lits();
118    }
119   
120    }