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