| 
 1 | 
  
 |  | 
| 
 2 | 
  
 |  | 
| 
 3 | 
  
 |  | 
| 
 4 | 
  
 |  | 
| 
 5 | 
  
 |  | 
| 
 6 | 
  
 |  | 
| 
 7 | 
  
 | package org.sat4j; | 
| 
 8 | 
  
 |  | 
| 
 9 | 
  
 | import static java.lang.System.out; | 
| 
 10 | 
  
 |  | 
| 
 11 | 
  
 | import org.sat4j.minisat.SolverFactory; | 
| 
 12 | 
  
 | import org.sat4j.minisat.core.IOrder; | 
| 
 13 | 
  
 | import org.sat4j.minisat.core.Solver; | 
| 
 14 | 
  
 | import org.sat4j.minisat.orders.VarOrderHeapObjective; | 
| 
 15 | 
  
 | import org.sat4j.opt.PseudoOptDecorator; | 
| 
 16 | 
  
 | import org.sat4j.reader.OPBReader2005; | 
| 
 17 | 
  
 | import org.sat4j.reader.OPBReader2006; | 
| 
 18 | 
  
 | import org.sat4j.reader.ObjectiveFunction; | 
| 
 19 | 
  
 | import org.sat4j.reader.Reader; | 
| 
 20 | 
  
 | import org.sat4j.specs.IProblem; | 
| 
 21 | 
  
 | import org.sat4j.specs.ISolver; | 
| 
 22 | 
  
 | import org.sat4j.specs.TimeoutException; | 
| 
 23 | 
  
 |  | 
| 
 24 | 
  
 |  | 
| 
 25 | 
  
 |  | 
| 
 26 | 
  
 |  | 
| 
 27 | 
  
 |  | 
| 
 28 | 
  
 |  | 
| 
 29 | 
  
 |  | 
| 
 30 | 
  
 | public class LanceurPseudo2005 extends AbstractOptimizationLauncher { | 
| 
 31 | 
  
 |  | 
| 
 32 | 
  
 |      | 
| 
 33 | 
  
 |  | 
| 
 34 | 
  
 |  | 
| 
 35 | 
  
 |     private static final long serialVersionUID = 1L; | 
| 
 36 | 
  
 |  | 
| 
 37 | 
  
 |      | 
| 
 38 | 
  
 |  | 
| 
 39 | 
  
 |  | 
| 
 40 | 
  
 |  | 
| 
 41 | 
  
 |  | 
| 
 42 | 
  
 |  | 
| 
 43 | 
  
 |  | 
| 
 44 | 
 0
 |     public static void main(String[] args) {
 | 
| 
 45 | 
 0
 |         AbstractLauncher lanceur = new LanceurPseudo2005();
 | 
| 
 46 | 
 0
 |         lanceur.run(args);
 | 
| 
 47 | 
 0
 |         System.exit(lanceur.getExitCode().value());
 | 
| 
 48 | 
  
 |     } | 
| 
 49 | 
  
 |  | 
| 
 50 | 
  
 |     protected ObjectiveFunction obfct; | 
| 
 51 | 
  
 |  | 
| 
 52 | 
  
 |      | 
| 
 53 | 
  
 |  | 
| 
 54 | 
  
 |  | 
| 
 55 | 
  
 |  | 
| 
 56 | 
  
 |  | 
| 
 57 | 
 0
 |     @Override
 | 
| 
 58 | 
  
 |     protected Reader createReader(ISolver solver, String problemname) { | 
| 
 59 | 
 0
 |         return new OPBReader2006(solver);
 | 
| 
 60 | 
  
 |     } | 
| 
 61 | 
  
 |  | 
| 
 62 | 
  
 |      | 
| 
 63 | 
 0
 |     @Override
 | 
| 
 64 | 
  
 |     protected void solve(IProblem problem) throws TimeoutException { | 
| 
 65 | 
 0
 |         ObjectiveFunction obj = ((OPBReader2005)getReader()).getObjectiveFunction();
 | 
| 
 66 | 
 0
 |         ((PseudoOptDecorator)problem).setObjectTiveFunction(obj);
 | 
| 
 67 | 
 0
 |         IOrder order = ((Solver)((PseudoOptDecorator)problem).decorated()).getOrder();
 | 
| 
 68 | 
 0
 |         if (order instanceof VarOrderHeapObjective) {
 | 
| 
 69 | 
 0
 |             ((VarOrderHeapObjective)order).setObjectiveFunction(obj);
 | 
| 
 70 | 
  
 |         } | 
| 
 71 | 
 0
 |         super.solve(problem);
 | 
| 
 72 | 
  
 |     } | 
| 
 73 | 
  
 |  | 
| 
 74 | 
  
 |  | 
| 
 75 | 
  
 |      | 
| 
 76 | 
  
 |  | 
| 
 77 | 
  
 |  | 
| 
 78 | 
  
 |  | 
| 
 79 | 
  
 |  | 
| 
 80 | 
 0
 |     @Override
 | 
| 
 81 | 
  
 |     protected ISolver configureSolver(String[] args) { | 
| 
 82 | 
 0
 |         ISolver solver = new PseudoOptDecorator(SolverFactory.newMiniOPBClauseCardConstrMaxSpecificOrder());
 | 
| 
 83 | 
 0
 |         solver.setTimeout(Integer.MAX_VALUE);
 | 
| 
 84 | 
 0
 |         out.println(solver.toString(COMMENT_PREFIX)); 
 | 
| 
 85 | 
 0
 |         return solver;
 | 
| 
 86 | 
  
 |     } | 
| 
 87 | 
  
 |  | 
| 
 88 | 
 0
 |     @Override
 | 
| 
 89 | 
  
 |     protected void usage() { | 
| 
 90 | 
 0
 |         out.println("java -jar sat4jPseudo instancename.opb"); 
 | 
| 
 91 | 
  
 |     } | 
| 
 92 | 
  
 |  | 
| 
 93 | 
 0
 |     @Override
 | 
| 
 94 | 
  
 |     protected String getInstanceName(String[] args) { | 
| 
 95 | 
  
 |         assert args.length == 1; | 
| 
 96 | 
 0
 |         return args[0];
 | 
| 
 97 | 
  
 |     } | 
| 
 98 | 
  
 | } |