1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.sat4j.tools; |
8 |
| |
9 |
| import org.sat4j.minisat.constraints.MixedDataStructureWithBinary; |
10 |
| import org.sat4j.minisat.core.Solver; |
11 |
| import org.sat4j.minisat.orders.VarOrder; |
12 |
| import org.sat4j.specs.ISolver; |
13 |
| import org.sat4j.specs.TimeoutException; |
14 |
| |
15 |
| public class SATRaceDecorator extends SolverDecorator { |
16 |
| |
17 |
| private boolean configChanged; |
18 |
| private int nbvars; |
19 |
| |
20 |
1
| public SATRaceDecorator(ISolver solver) {
|
21 |
1
| super(solver);
|
22 |
| } |
23 |
| |
24 |
1
| @Override
|
25 |
| public int newVar(int howmany) { |
26 |
1
| nbvars = howmany;
|
27 |
1
| return super.newVar(howmany);
|
28 |
| } |
29 |
| |
30 |
| |
31 |
1
| @Override
|
32 |
| public void setExpectedNumberOfClauses(int nb) { |
33 |
1
| if (nbvars>800000||nb>2000000) {
|
34 |
| |
35 |
0
| System.err.println("CHANGING DATA STRUCTURES");
|
36 |
0
| Solver solver = (Solver) decorated();
|
37 |
| |
38 |
0
| solver.setDataStructureFactory(new MixedDataStructureWithBinary());
|
39 |
| |
40 |
0
| solver.setSimplifier(Solver.NO_SIMPLIFICATION);
|
41 |
0
| configChanged = true;
|
42 |
0
| super.newVar(nbvars);
|
43 |
| } |
44 |
| |
45 |
1
| super.setExpectedNumberOfClauses(nb);
|
46 |
| } |
47 |
| |
48 |
1
| @Override
|
49 |
| public boolean isSatisfiable() throws TimeoutException { |
50 |
1
| if (configChanged) {
|
51 |
0
| System.out.println("c WARNING: used specific Binary Clause representation and disabled reason Simplification to save memory!");
|
52 |
| } |
53 |
1
| return super.isSatisfiable();
|
54 |
| } |
55 |
| |
56 |
| |
57 |
| } |