Clover coverage report -
Coverage timestamp: sam. avr. 22 2006 13:18:09 CEST
file stats: LOC: 78   Methods: 2
NCLOC: 63   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LanceurPseudo2005Dicho.java 0% 0% 0% 0%
coverage
 1    package org.sat4j;
 2   
 3    import java.math.BigInteger;
 4   
 5    import org.sat4j.reader.OPBReader2005;
 6    import org.sat4j.specs.ContradictionException;
 7    import org.sat4j.specs.IConstr;
 8    import org.sat4j.specs.IProblem;
 9    import org.sat4j.specs.IVec;
 10    import org.sat4j.specs.TimeoutException;
 11   
 12    /**
 13    * That launcher has not been tested thoroughtly.
 14    *
 15    * Beware, since clause removal might currently be buggy.
 16    *
 17    * @author leberre
 18    *
 19    */
 20    public class LanceurPseudo2005Dicho extends LanceurPseudo2005 {
 21   
 22  0 @Override
 23    public static void main(String[] args) {
 24  0 AbstractLauncher lanceur = new LanceurPseudo2005Dicho();
 25  0 lanceur.run(args);
 26  0 System.exit(lanceur.getExitCode().value());
 27    }
 28   
 29  0 @Override
 30    protected void solve(IProblem problem) throws TimeoutException {
 31  0 obfct = ((OPBReader2005) getReader()).getObjectiveFunction();
 32  0 BigInteger min = BigInteger.ZERO, max = BigInteger.TEN;
 33  0 IVec<BigInteger> coefs = obfct.getCoeffs();
 34  0 for (BigInteger coef : coefs)
 35  0 if (coef.signum() < 0)
 36  0 min = min.add(coef);
 37   
 38  0 if (!solver.isSatisfiable()) {
 39  0 setExitCode(ExitCode.UNSATISFIABLE);
 40  0 return;
 41    }
 42  0 setExitCode(ExitCode.SATISFIABLE);
 43  0 bestSolution = problem.model();
 44  0 if (obfct == null)
 45  0 return; // not an optimization problem
 46  0 System.out.println("c SATISFIABLE");
 47  0 System.out.println("c OPTIMIZING...");
 48  0 IConstr lastadded = null;
 49  0 boolean isSatisfiable = true;
 50  0 BigInteger current = BigInteger.ZERO;
 51  0 while (min.compareTo(max) < 0) {
 52  0 if (isSatisfiable) {
 53  0 bestSolution = problem.model();
 54  0 max = obfct.calculateDegree(bestSolution);
 55    } else {
 56  0 min = current;
 57    assert lastadded != null;
 58  0 solver.removeConstr(lastadded);
 59    }
 60  0 current = min.add(max).divide(BigInteger.valueOf(2));
 61  0 if (current.equals(min)) {
 62  0 setExitCode(ExitCode.OPTIMUM_FOUND);
 63  0 return;
 64    }
 65  0 System.out.printf(
 66    "c CURRENT OPTIMUM="+max+"/"+min+" \t\tCurrent CPU time: %.2f ms\n",
 67    (System.currentTimeMillis() - getBeginTime()) / 1000.0);
 68  0 try {
 69  0 lastadded = solver.addPseudoBoolean(obfct.getVars(), obfct
 70    .getCoeffs(), false, current);
 71  0 isSatisfiable = solver.isSatisfiable();
 72    } catch (ContradictionException ex) {
 73  0 isSatisfiable = false;
 74    }
 75    }
 76    }
 77   
 78    }