1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.sat4j.minisat.constraints; |
8 |
| |
9 |
| import org.sat4j.minisat.constraints.cnf.Lits23; |
10 |
| import org.sat4j.minisat.constraints.cnf.WLClause; |
11 |
| import org.sat4j.minisat.core.Constr; |
12 |
| import org.sat4j.minisat.core.ILits; |
13 |
| import org.sat4j.minisat.core.ILits23; |
14 |
| import org.sat4j.specs.ContradictionException; |
15 |
| import org.sat4j.specs.IVecInt; |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| public class MixedDataStructureWithBinaryAndTernary extends |
22 |
| MixedDataStructureDaniel { |
23 |
| |
24 |
| private static final long serialVersionUID = 1L; |
25 |
| |
26 |
| private final ILits23 mlits = new Lits23(); |
27 |
| |
28 |
107
| public MixedDataStructureWithBinaryAndTernary() {
|
29 |
107
| lits = mlits;
|
30 |
| } |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
12047689
| @Override
|
38 |
| public ILits getVocabulary() { |
39 |
12047689
| return lits;
|
40 |
| } |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
251756
| @Override
|
48 |
| public Constr createClause(IVecInt literals) throws ContradictionException { |
49 |
251756
| IVecInt v = WLClause.sanityCheck(literals, lits, solver);
|
50 |
251756
| if (v == null)
|
51 |
13
| return null;
|
52 |
251743
| if (v.size() == 2) {
|
53 |
196980
| mlits.binaryClauses(v.get(0), v.get(1));
|
54 |
196980
| return null;
|
55 |
| } |
56 |
54763
| if (v.size() == 3) {
|
57 |
11129
| mlits.ternaryClauses(v.get(0), v.get(1), v.get(2));
|
58 |
11129
| return null;
|
59 |
| } |
60 |
43634
| return WLClause.brandNewClause(solver, lits, v);
|
61 |
| } |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
57240
| @Override
|
69 |
| public void learnConstraint(Constr constr) { |
70 |
57240
| if (constr.size() == 2) {
|
71 |
180
| mlits.binaryClauses(constr.get(0), constr.get(1));
|
72 |
| |
73 |
57060
| } else if (constr.size() == 3) {
|
74 |
202
| mlits.ternaryClauses(constr.get(0), constr.get(1), constr.get(2));
|
75 |
| |
76 |
| } else { |
77 |
56858
| super.learnConstraint(constr);
|
78 |
| } |
79 |
| } |
80 |
| |
81 |
| } |