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.opt.MaxSatDecorator; |
13 |
| import org.sat4j.opt.WeightedMaxSatDecorator; |
14 |
| import org.sat4j.reader.DimacsReader; |
15 |
| import org.sat4j.reader.Reader; |
16 |
| import org.sat4j.specs.ISolver; |
17 |
| |
18 |
| public class MaxSatLauncher extends AbstractOptimizationLauncher { |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| private static final long serialVersionUID = 1L; |
24 |
| |
25 |
0
| @Override
|
26 |
| protected void usage() { |
27 |
0
| out.println("java -jar sat4jmax instance-name");
|
28 |
| } |
29 |
| |
30 |
0
| @Override
|
31 |
| protected Reader createReader(ISolver solver, String problemname) { |
32 |
0
| if (problemname.endsWith(".wcnf")) {
|
33 |
0
| return new DimacsReader(solver,"wcnf");
|
34 |
| } |
35 |
0
| return new DimacsReader(solver);
|
36 |
| } |
37 |
| |
38 |
0
| @Override
|
39 |
| protected String getInstanceName(String[] args) { |
40 |
0
| return args[0];
|
41 |
| } |
42 |
| |
43 |
0
| @Override
|
44 |
| protected ISolver configureSolver(String[] args) { |
45 |
0
| int problemindex = args.length-1;
|
46 |
0
| if (args[problemindex].endsWith(".wcnf")) {
|
47 |
0
| return new WeightedMaxSatDecorator(SolverFactory.newMinimalOPBMinPueblo());
|
48 |
| } |
49 |
0
| return new MaxSatDecorator(SolverFactory.instance().defaultSolver());
|
50 |
| } |
51 |
| |
52 |
0
| public static void main(String[] args) {
|
53 |
0
| AbstractLauncher lanceur = new MaxSatLauncher();
|
54 |
0
| lanceur.run(args);
|
55 |
| } |
56 |
| } |