Clover coverage report -
Coverage timestamp: jeu. juin 15 2006 08:24:33 CEST
file stats: LOC: 48   Methods: 2
NCLOC: 30   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SolutionCounter.java 0% 0% 0% 0%
coverage
 1    package org.sat4j.tools;
 2   
 3    import org.sat4j.core.VecInt;
 4    import org.sat4j.specs.ContradictionException;
 5    import org.sat4j.specs.ISolver;
 6    import org.sat4j.specs.IVecInt;
 7    import org.sat4j.specs.TimeoutException;
 8   
 9    /**
 10    * Another solver decorator that counts the number of solutions.
 11    *
 12    * Note that this approach is quite naive so do not expect it to work on large examples.
 13    *
 14    * @author leberre
 15    *
 16    */
 17    public class SolutionCounter extends SolverDecorator {
 18   
 19    /**
 20    *
 21    */
 22    private static final long serialVersionUID = 1L;
 23   
 24  0 public SolutionCounter(ISolver solver) {
 25  0 super(solver);
 26    }
 27   
 28  0 public long countSolutions() throws TimeoutException {
 29  0 long nbsols = 0;
 30  0 boolean trivialfalsity = false;
 31   
 32  0 while (!trivialfalsity && isSatisfiable()) {
 33  0 nbsols++;
 34  0 int[] last = model();
 35  0 IVecInt clause = new VecInt(last.length);
 36  0 for (int q : last) {
 37  0 clause.push(-q);
 38    }
 39  0 try {
 40    // System.out.println("Sol number "+nbsols+" adding " + clause);
 41  0 addClause(clause);
 42    } catch (ContradictionException e) {
 43  0 trivialfalsity = true;
 44    }
 45    }
 46  0 return nbsols;
 47    }
 48    }