| 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.tools; |
| 26 |
|
|
| 27 |
|
import java.io.Serializable; |
| 28 |
|
|
| 29 |
|
import org.sat4j.core.VecInt; |
| 30 |
|
import org.sat4j.specs.ContradictionException; |
| 31 |
|
import org.sat4j.specs.IProblem; |
| 32 |
|
import org.sat4j.specs.ISolver; |
| 33 |
|
import org.sat4j.specs.IVecInt; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@author |
| 43 |
|
@author |
| 44 |
|
@author |
| 45 |
|
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 3 |
Complexity Density: 0,44 |
|
| 46 |
|
public class DimacsArrayReader implements Serializable { |
| 47 |
|
|
| 48 |
|
private static final long serialVersionUID = 1L; |
| 49 |
|
|
| 50 |
|
protected final ISolver solver; |
| 51 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 52 |
0
|
public DimacsArrayReader(ISolver solver) {... |
| 53 |
0
|
this.solver = solver; |
| 54 |
|
} |
| 55 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
| 56 |
0
|
protected boolean handleConstr(int gateType, int output, int[] inputs)... |
| 57 |
|
throws ContradictionException { |
| 58 |
0
|
IVecInt literals = new VecInt(inputs); |
| 59 |
0
|
solver.addClause(literals); |
| 60 |
0
|
return true; |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
@param |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
@param |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
@param |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
@param |
| 76 |
|
|
| 77 |
|
@throws |
| 78 |
|
|
| 79 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0,4 |
|
| 80 |
0
|
public IProblem parseInstance(int[] gateType, int[] outputs,... |
| 81 |
|
int[][] inputs, int maxVar) throws ContradictionException { |
| 82 |
0
|
solver.reset(); |
| 83 |
0
|
solver.newVar(maxVar); |
| 84 |
0
|
for (int i = 0; i < outputs.length; ++i) { |
| 85 |
0
|
handleConstr(gateType[i], outputs[i], inputs[i]); |
| 86 |
|
} |
| 87 |
0
|
return solver; |
| 88 |
|
} |
| 89 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0,33 |
|
| 90 |
0
|
public String decode(int[] model) {... |
| 91 |
0
|
StringBuilder stb = new StringBuilder(4 * model.length); |
| 92 |
0
|
for (int i = 0; i < model.length; i++) { |
| 93 |
0
|
stb.append(model[i]); |
| 94 |
0
|
stb.append(" "); |
| 95 |
|
} |
| 96 |
0
|
stb.append("0"); |
| 97 |
0
|
return stb.toString(); |
| 98 |
|
} |
| 99 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 100 |
0
|
protected ISolver getSolver() {... |
| 101 |
0
|
return solver; |
| 102 |
|
} |
| 103 |
|
} |