Clover coverage report -
Coverage timestamp: jeu. sept. 29 2005 23:57:39 CEST
file stats: LOC: 69   Methods: 2
NCLOC: 62   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    public class LanceurPseudo2005Dicho extends LanceurPseudo2005 {
 13   
 14  0 @Override
 15    public static void main(String[] args) {
 16  0 Lanceur lanceur = new LanceurPseudo2005Dicho();
 17  0 lanceur.run(args);
 18    }
 19   
 20  0 @Override
 21    protected void solve(IProblem problem) throws TimeoutException {
 22  0 obfct = ((OPBReader2005) reader).getObjectiveFunction();
 23  0 BigInteger min = BigInteger.ZERO, max = BigInteger.TEN;
 24  0 IVec<BigInteger> coefs = obfct.getCoeffs();
 25  0 for (BigInteger coef : coefs)
 26  0 if (coef.signum() < 0)
 27  0 min = min.add(coef);
 28   
 29  0 if (!solver.isSatisfiable()) {
 30  0 exitcode = ExitCode.UNSATISFIABLE;
 31  0 return;
 32    }
 33  0 exitcode = ExitCode.SATISFIABLE;
 34  0 bestSolution = problem.model();
 35  0 if (obfct == null)
 36  0 return; // not an optimization problem
 37  0 System.out.println("c SATISFIABLE");
 38  0 System.out.println("c OPTIMIZING...");
 39  0 IConstr lastadded = null;
 40  0 boolean isSatisfiable = true;
 41  0 BigInteger current = BigInteger.ZERO;
 42  0 while (min.compareTo(max) < 0) {
 43  0 if (isSatisfiable) {
 44  0 bestSolution = problem.model();
 45  0 max = obfct.calculateDegree(bestSolution);
 46    } else {
 47  0 min = current;
 48    assert lastadded != null;
 49  0 solver.removeConstr(lastadded);
 50    }
 51  0 current = min.add(max).divide(BigInteger.valueOf(2));
 52  0 if (current.equals(min)) {
 53  0 exitcode = ExitCode.OPTIMUM_FOUND;
 54  0 return;
 55    }
 56  0 System.out.printf(
 57    "c CURRENT OPTIMUM="+max+"/"+min+" \t\tCurrent CPU time: %.2f ms\n",
 58    (System.currentTimeMillis() - begintime) / 1000.0);
 59  0 try {
 60  0 lastadded = solver.addPseudoBoolean(obfct.getVars(), obfct
 61    .getCoeffs(), false, current);
 62  0 isSatisfiable = solver.isSatisfiable();
 63    } catch (ContradictionException ex) {
 64  0 isSatisfiable = false;
 65    }
 66    }
 67    }
 68   
 69    }