1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.sat4j.minisat.constraints.cnf; |
8 |
| |
9 |
| import java.io.Serializable; |
10 |
| |
11 |
| import org.sat4j.core.VecInt; |
12 |
| import org.sat4j.minisat.core.Constr; |
13 |
| import org.sat4j.minisat.core.ILits; |
14 |
| import org.sat4j.minisat.core.UnitPropagationListener; |
15 |
| import org.sat4j.specs.IVecInt; |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| public class BinaryClauses implements Constr, Serializable { |
22 |
| |
23 |
| private static final long serialVersionUID = 1L; |
24 |
| |
25 |
| private final ILits voc; |
26 |
| |
27 |
| private final IVecInt clauses = new VecInt(); |
28 |
| |
29 |
| private final int reason; |
30 |
| |
31 |
| private int conflictindex = -1; |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
74407
| public BinaryClauses(ILits voc, int p) {
|
37 |
74407
| this.voc = voc;
|
38 |
74407
| this.reason = p;
|
39 |
| } |
40 |
| |
41 |
1177560
| public void addBinaryClause(int p) {
|
42 |
1177560
| clauses.push(p);
|
43 |
| } |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
0
| public void remove() {
|
51 |
| |
52 |
| } |
53 |
| |
54 |
| |
55 |
| |
56 |
| |
57 |
| |
58 |
| |
59 |
| |
60 |
426416761
| public boolean propagate(UnitPropagationListener s, int p) {
|
61 |
| assert voc.isFalsified(this.reason); |
62 |
426416761
| voc.watch(p, this);
|
63 |
426416761
| for (int i = 0; i < clauses.size(); i++) {
|
64 |
| int q = clauses.get(i); |
65 |
| if (!s.enqueue(q,this)) { |
66 |
25356420
| conflictindex = i;
|
67 |
25356420
| return false;
|
68 |
| } |
69 |
| } |
70 |
401060341
| return true;
|
71 |
| } |
72 |
| |
73 |
| |
74 |
| |
75 |
| |
76 |
| |
77 |
| |
78 |
0
| public boolean simplify() {
|
79 |
0
| for (int i = 0; i < clauses.size(); i++) {
|
80 |
0
| if (voc.isSatisfied(clauses.get(i))) {
|
81 |
0
| return true;
|
82 |
| } |
83 |
0
| if (voc.isFalsified(clauses.get(i))) {
|
84 |
0
| clauses.delete(i);
|
85 |
| } |
86 |
| |
87 |
| } |
88 |
0
| return false;
|
89 |
| } |
90 |
| |
91 |
| |
92 |
| |
93 |
| |
94 |
| |
95 |
| |
96 |
0
| public void undo(int p) {
|
97 |
| |
98 |
| } |
99 |
| |
100 |
| |
101 |
| |
102 |
| |
103 |
| |
104 |
| |
105 |
213308653
| public void calcReason(int p, IVecInt outReason) {
|
106 |
213308653
| outReason.push(this.reason ^ 1);
|
107 |
213308653
| if (p == ILits.UNDEFINED) {
|
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| assert conflictindex > -1; |
113 |
25356383
| outReason.push(clauses.get(conflictindex) ^ 1);
|
114 |
| } |
115 |
| } |
116 |
| |
117 |
| |
118 |
| |
119 |
| |
120 |
| |
121 |
| |
122 |
213308653
| public boolean learnt() {
|
123 |
213308653
| return false;
|
124 |
| } |
125 |
| |
126 |
| |
127 |
| |
128 |
| |
129 |
| |
130 |
| |
131 |
0
| public void incActivity(double claInc) {
|
132 |
| |
133 |
| } |
134 |
| |
135 |
| |
136 |
| |
137 |
| |
138 |
| |
139 |
| |
140 |
0
| public double getActivity() {
|
141 |
| |
142 |
0
| return 0;
|
143 |
| } |
144 |
| |
145 |
| |
146 |
| |
147 |
| |
148 |
| |
149 |
| |
150 |
0
| public boolean locked() {
|
151 |
0
| return false;
|
152 |
| } |
153 |
| |
154 |
| |
155 |
| |
156 |
| |
157 |
| |
158 |
| |
159 |
0
| public void setLearnt() {
|
160 |
| |
161 |
| } |
162 |
| |
163 |
| |
164 |
| |
165 |
| |
166 |
| |
167 |
| |
168 |
0
| public void register() {
|
169 |
| |
170 |
| } |
171 |
| |
172 |
| |
173 |
| |
174 |
| |
175 |
| |
176 |
| |
177 |
0
| public void rescaleBy(double d) {
|
178 |
| |
179 |
| } |
180 |
| |
181 |
| |
182 |
| |
183 |
| |
184 |
| |
185 |
| |
186 |
802829098
| public int size() {
|
187 |
802829098
| return clauses.size();
|
188 |
| } |
189 |
| |
190 |
| |
191 |
| |
192 |
| |
193 |
| |
194 |
| |
195 |
0
| public int get(int i) {
|
196 |
| |
197 |
0
| throw new UnsupportedOperationException();
|
198 |
| } |
199 |
| |
200 |
0
| public void assertConstraint(UnitPropagationListener s) {
|
201 |
0
| throw new UnsupportedOperationException();
|
202 |
| } |
203 |
| } |