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 |
|
package org.sat4j.opt; |
27 |
|
|
28 |
|
import java.math.BigInteger; |
29 |
|
|
30 |
|
import org.sat4j.reader.ObjectiveFunction; |
31 |
|
import org.sat4j.specs.ContradictionException; |
32 |
|
import org.sat4j.specs.IOptimizationProblem; |
33 |
|
import org.sat4j.specs.ISolver; |
34 |
|
import org.sat4j.specs.TimeoutException; |
35 |
|
import org.sat4j.tools.SolverDecorator; |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 2 |
Complexity Density: 0,82 |
|
37 |
|
public class PseudoOptDecorator extends SolverDecorator implements |
38 |
|
IOptimizationProblem { |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
private static final long serialVersionUID = 1L; |
44 |
|
|
45 |
|
private ObjectiveFunction objfct; |
46 |
|
|
47 |
|
private int[] prevmodel; |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
0
|
public PseudoOptDecorator(ISolver solver) {... |
50 |
0
|
super(solver); |
51 |
|
} |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
0
|
public void setObjectTiveFunction(ObjectiveFunction objf) {... |
54 |
0
|
objfct = objf; |
55 |
|
} |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0,5 |
|
57 |
0
|
public boolean admitABetterSolution() throws TimeoutException {... |
58 |
0
|
boolean result = super.isSatisfiable(); |
59 |
0
|
if (result) |
60 |
0
|
prevmodel = super.model(); |
61 |
0
|
return result; |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
0
|
public boolean hasNoObjectiveFunction() {... |
65 |
0
|
return objfct == null; |
66 |
|
} |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
0
|
public boolean nonOptimalMeansSatisfiable() {... |
69 |
0
|
return true; |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
0
|
public Number calculateObjective() {... |
73 |
0
|
return objfct.calculateDegree(prevmodel); |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
0
|
public void discard() throws ContradictionException {... |
77 |
0
|
super.addPseudoBoolean(objfct.getVars(), objfct.getCoeffs(), false, |
78 |
|
objfct.calculateDegree(prevmodel).subtract(BigInteger.ONE)); |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
0
|
@Override... |
82 |
|
public int[] model() { |
83 |
0
|
return prevmodel; |
84 |
|
} |
85 |
|
|
86 |
|
} |