|
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 |
| { |
|
29 |
106
| lits = mlits;
|
|
30 |
| } |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
10162744
| @Override
|
|
38 |
| public ILits getVocabulary() { |
|
39 |
10162744
| return lits;
|
|
40 |
| } |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
251341
| @Override
|
|
48 |
| public Constr createClause(IVecInt literals) throws ContradictionException { |
|
49 |
251341
| IVecInt v = WLClause.sanityCheck(literals, lits, solver);
|
|
50 |
251341
| if (v == null)
|
|
51 |
13
| return null;
|
|
52 |
251328
| if (v.size() == 2) {
|
|
53 |
196575
| mlits.binaryClauses(v.get(0), v.get(1));
|
|
54 |
196575
| return null;
|
|
55 |
| } |
|
56 |
54753
| if (v.size() == 3) {
|
|
57 |
11129
| mlits.ternaryClauses(v.get(0), v.get(1), v.get(2));
|
|
58 |
11129
| return null;
|
|
59 |
| } |
|
60 |
43624
| return WLClause.brandNewClause(solver, lits, v);
|
|
61 |
| } |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
3312485
| @Override
|
|
69 |
| public void learnConstraint(Constr constr) { |
|
70 |
3312485
| if (constr.size() == 2) {
|
|
71 |
178
| mlits.binaryClauses(constr.get(0), constr.get(1));
|
|
72 |
| |
|
73 |
3312307
| } else if (constr.size() == 3) {
|
|
74 |
195
| mlits.ternaryClauses(constr.get(0), constr.get(1), constr.get(2));
|
|
75 |
| |
|
76 |
| } else { |
|
77 |
3312112
| super.learnConstraint(constr);
|
|
78 |
| } |
|
79 |
| } |
|
80 |
| |
|
81 |
| } |