| 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.reader.csp; |
| 26 |
|
|
| 27 |
|
import java.util.HashMap; |
| 28 |
|
import java.util.Map; |
| 29 |
|
import java.util.Set; |
| 30 |
|
import java.util.TreeSet; |
| 31 |
|
|
| 32 |
|
import org.sat4j.core.VecInt; |
| 33 |
|
import org.sat4j.specs.ContradictionException; |
| 34 |
|
import org.sat4j.specs.ISolver; |
| 35 |
|
import org.sat4j.specs.IVec; |
| 36 |
|
import org.sat4j.specs.IVecInt; |
| 37 |
|
|
|
|
|
| 0% |
Uncovered Elements: 45 (45) |
Complexity: 9 |
Complexity Density: 0,68 |
|
| 38 |
|
public class GeneralizedSupportEncoding implements Encoding { |
| 39 |
|
|
| 40 |
|
private final Map<Set<Integer>, IVecInt> supports = new HashMap<Set<Integer>, IVecInt>(); |
| 41 |
|
|
| 42 |
|
private static final Encoding instance = new GeneralizedSupportEncoding(); |
| 43 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 44 |
0
|
private GeneralizedSupportEncoding() {... |
| 45 |
|
|
| 46 |
|
} |
| 47 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 48 |
0
|
public static Encoding instance() {... |
| 49 |
0
|
return instance; |
| 50 |
|
} |
| 51 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 52 |
0
|
public void onFinish(ISolver solver, IVec<Var> scope)... |
| 53 |
|
throws ContradictionException { |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
} |
| 57 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
| 58 |
0
|
public void onInit(ISolver solver, IVec<Var> scope) {... |
| 59 |
0
|
supports.clear(); |
| 60 |
0
|
int[] acc = new int[scope.size()]; |
| 61 |
0
|
fill(0, scope, acc, supports); |
| 62 |
|
} |
| 63 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 64 |
0
|
public void onNogood(ISolver solver, IVec<Var> scope,... |
| 65 |
|
Map<Evaluable, Integer> tuple) throws ContradictionException { |
| 66 |
|
|
| 67 |
|
} |
| 68 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0,5 |
|
| 69 |
0
|
public void onSupport(ISolver solver, IVec<Var> scope,... |
| 70 |
|
Map<Evaluable, Integer> tuple) throws ContradictionException { |
| 71 |
0
|
for (int i = 0; i < scope.size(); i++) { |
| 72 |
0
|
Set<Integer> set = new TreeSet<Integer>(); |
| 73 |
0
|
Var vari = scope.get(i); |
| 74 |
0
|
for (int j = 0; j < scope.size(); j++) { |
| 75 |
0
|
if (i != j) { |
| 76 |
0
|
set.add(scope.get(j).translate(tuple.get(vari))); |
| 77 |
|
} |
| 78 |
|
} |
| 79 |
0
|
IVecInt support = supports.get(set); |
| 80 |
0
|
assert support != null; |
| 81 |
0
|
support.push(vari.translate(tuple.get(vari))); |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
} |
| 85 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0,6 |
|
| 86 |
0
|
private void fill(int n, IVec<Var> scope, int[] acc,... |
| 87 |
|
Map<Set<Integer>, IVecInt> supports) { |
| 88 |
0
|
if (n == scope.size()) { |
| 89 |
0
|
for (int j = 0; j < acc.length; j++) { |
| 90 |
0
|
Set<Integer> set = new TreeSet<Integer>(); |
| 91 |
0
|
for (int i = 0; i < acc.length; i++) |
| 92 |
0
|
if (i != j) |
| 93 |
0
|
set.add(scope.get(i).translate(acc[i])); |
| 94 |
0
|
supports.put(set, new VecInt()); |
| 95 |
|
} |
| 96 |
|
} else |
| 97 |
0
|
for (int i : scope.get(n).domain()) { |
| 98 |
0
|
acc[n] = i; |
| 99 |
0
|
fill(n + 1, scope, acc, supports); |
| 100 |
|
} |
| 101 |
|
|
| 102 |
|
} |
| 103 |
|
} |