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 |
| |
26 |
| package org.sat4j.minisat.constraints.pb; |
27 |
| |
28 |
| import java.io.Serializable; |
29 |
| import java.math.BigInteger; |
30 |
| |
31 |
| import org.sat4j.core.Vec; |
32 |
| import org.sat4j.core.VecInt; |
33 |
| import org.sat4j.minisat.core.ILits; |
34 |
| import org.sat4j.minisat.core.UnitPropagationListener; |
35 |
| import org.sat4j.specs.ContradictionException; |
36 |
| import org.sat4j.specs.IVec; |
37 |
| import org.sat4j.specs.IVecInt; |
38 |
| |
39 |
| public class PuebloMinWatchPb extends MinWatchPb implements Serializable { |
40 |
| |
41 |
| private static final long serialVersionUID = 1L; |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
| |
54 |
| |
55 |
| |
56 |
| |
57 |
305863
| private PuebloMinWatchPb(ILits voc, IDataStructurePB mpb) {
|
58 |
| |
59 |
305863
| super(voc, mpb);
|
60 |
| } |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
| |
71 |
| |
72 |
| |
73 |
| |
74 |
| |
75 |
| |
76 |
830
| public static PuebloMinWatchPb minWatchPbNew(UnitPropagationListener s,
|
77 |
| ILits voc, IVecInt ps, IVecInt coefs, boolean moreThan, int degree) |
78 |
| throws ContradictionException { |
79 |
830
| return minWatchPbNew(s, voc, ps, toVecBigInt(coefs), moreThan,
|
80 |
| toBigInt(degree)); |
81 |
| } |
82 |
| |
83 |
| |
84 |
| |
85 |
| |
86 |
| |
87 |
| |
88 |
| |
89 |
| |
90 |
| |
91 |
| |
92 |
| |
93 |
| |
94 |
| |
95 |
| |
96 |
| |
97 |
279814
| public static PuebloMinWatchPb minWatchPbNew(UnitPropagationListener s,
|
98 |
| ILits voc, IVecInt ps, IVec<BigInteger> coefs, boolean moreThan, |
99 |
| BigInteger degree) throws ContradictionException { |
100 |
| |
101 |
279814
| VecInt litsVec = new VecInt(ps.size());
|
102 |
279814
| IVec<BigInteger> coefsVec = new Vec<BigInteger>(coefs.size());
|
103 |
279814
| ps.copyTo(litsVec);
|
104 |
279814
| coefs.copyTo(coefsVec);
|
105 |
| |
106 |
| |
107 |
279814
| IDataStructurePB mpb = niceParameters(litsVec, coefsVec, moreThan,
|
108 |
| degree, voc); |
109 |
279812
| PuebloMinWatchPb outclause = new PuebloMinWatchPb(voc, mpb);
|
110 |
| |
111 |
279812
| if (outclause.degree.signum() <= 0) {
|
112 |
0
| return null;
|
113 |
| } |
114 |
| |
115 |
279812
| outclause.computeWatches();
|
116 |
| |
117 |
279797
| outclause.computePropagation(s);
|
118 |
| |
119 |
279797
| return outclause;
|
120 |
| |
121 |
| } |
122 |
| |
123 |
0
| public static PuebloMinWatchPb minWatchPbNew(UnitPropagationListener s,
|
124 |
| ILits voc, IDataStructurePB mpb) throws ContradictionException { |
125 |
0
| PuebloMinWatchPb outclause = new PuebloMinWatchPb(voc, mpb);
|
126 |
| |
127 |
0
| if (outclause.degree.signum() <= 0) {
|
128 |
0
| return null;
|
129 |
| } |
130 |
| |
131 |
0
| outclause.computeWatches();
|
132 |
| |
133 |
0
| outclause.computePropagation(s);
|
134 |
| |
135 |
0
| return outclause;
|
136 |
| |
137 |
| } |
138 |
| |
139 |
| |
140 |
| |
141 |
| |
142 |
0
| public static WatchPb watchPbNew(ILits voc, IVecInt lits, IVecInt coefs,
|
143 |
| boolean moreThan, int degree) { |
144 |
0
| return watchPbNew(voc, lits, toVecBigInt(coefs), moreThan,
|
145 |
| toBigInt(degree)); |
146 |
| } |
147 |
| |
148 |
| |
149 |
| |
150 |
| |
151 |
26051
| public static WatchPb watchPbNew(ILits voc, IVecInt lits,
|
152 |
| IVec<BigInteger> coefs, boolean moreThan, BigInteger degree) { |
153 |
26051
| IDataStructurePB mpb = null;
|
154 |
26051
| mpb = niceCheckedParameters(lits, coefs, moreThan, degree, voc);
|
155 |
26051
| return new PuebloMinWatchPb(voc, mpb);
|
156 |
| } |
157 |
| |
158 |
0
| public static WatchPb normalizedWatchPbNew(ILits voc, IDataStructurePB mpb) {
|
159 |
0
| return new PuebloMinWatchPb(voc, mpb);
|
160 |
| } |
161 |
| |
162 |
92349748
| protected BigInteger maximalCoefficient(int pIndice) {
|
163 |
92349748
| return coefs[0];
|
164 |
| } |
165 |
| |
166 |
92349748
| protected BigInteger updateWatched(BigInteger mc, int pIndice) {
|
167 |
92349748
| BigInteger maxCoef = mc;
|
168 |
92349748
| if (watchingCount < size()) {
|
169 |
76454880
| BigInteger upWatchCumul = watchCumul.subtract(coefs[pIndice]);
|
170 |
76454880
| BigInteger borneSup = degree.add(maxCoef);
|
171 |
76454880
| for (int ind = 0; ind < lits.length
|
172 |
| && upWatchCumul.compareTo(borneSup) < 0; ind++) { |
173 |
720574903
| if (!voc.isFalsified(lits[ind]) && !watched[ind]) {
|
174 |
54010629
| upWatchCumul = upWatchCumul.add(coefs[ind]);
|
175 |
54010629
| watched[ind] = true;
|
176 |
| assert watchingCount < size(); |
177 |
54010629
| watching[watchingCount++] = ind;
|
178 |
54010629
| voc.watch(lits[ind] ^ 1, this);
|
179 |
| } |
180 |
| } |
181 |
76454880
| watchCumul = upWatchCumul.add(coefs[pIndice]);
|
182 |
| } |
183 |
92349748
| return maxCoef;
|
184 |
| } |
185 |
| |
186 |
| } |