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
26
27
28
29
30 package org.sat4j.maxsat;
31
32 import org.sat4j.core.ASolverFactory;
33 import org.sat4j.minisat.constraints.MixedDataStructureDanielWL;
34 import org.sat4j.minisat.core.DataStructureFactory;
35 import org.sat4j.minisat.core.SearchParams;
36 import org.sat4j.minisat.core.Solver;
37 import org.sat4j.minisat.learning.MiniSATLearning;
38 import org.sat4j.minisat.orders.VarOrderHeap;
39 import org.sat4j.minisat.restarts.MiniSATRestarts;
40 import org.sat4j.pb.IPBSolver;
41
42 public class SolverFactory extends ASolverFactory<IPBSolver> {
43
44 private static final long serialVersionUID = 1L;
45
46 private static SolverFactory instance;
47
48
49
50
51
52
53
54 public static Solver<DataStructureFactory> newMiniMaxSAT() {
55 MiniSATLearning<DataStructureFactory> learning = new MiniSATLearning<DataStructureFactory>();
56 Solver<DataStructureFactory> solver = new Solver<DataStructureFactory>(
57 learning, new MixedDataStructureDanielWL(), new SearchParams(
58 1.2, 100000), new VarOrderHeap(), new MiniSATRestarts());
59 learning.setDataStructureFactory(solver.getDSFactory());
60 learning.setVarActivityListener(solver);
61 return solver;
62 }
63
64
65
66
67
68
69 private SolverFactory() {
70
71 }
72
73 private static synchronized void createInstance() {
74 if (instance == null) {
75 instance = new SolverFactory();
76 }
77 }
78
79
80
81
82
83
84 public static SolverFactory instance() {
85 if (instance == null) {
86 createInstance();
87 }
88 return instance;
89 }
90
91 @Override
92 public IPBSolver defaultSolver() {
93 return newDefault();
94 }
95
96 @Override
97 public IPBSolver lightSolver() {
98 return newLight();
99 }
100
101 public static IPBSolver newDefault() {
102 return org.sat4j.pb.SolverFactory.newDefault();
103 }
104
105 public static IPBSolver newLight() {
106 return org.sat4j.pb.SolverFactory.newLight();
107 }
108 }