1 |
| package org.sat4j.minisat.orders; |
2 |
| |
3 |
| import static org.sat4j.minisat.core.LiteralsUtils.neg; |
4 |
| import static org.sat4j.minisat.core.LiteralsUtils.var; |
5 |
| |
6 |
| import java.math.BigInteger; |
7 |
| |
8 |
| import org.sat4j.reader.ObjectiveFunction; |
9 |
| import org.sat4j.specs.IVec; |
10 |
| import org.sat4j.specs.IVecInt; |
11 |
| |
12 |
| public class VarOrderHeapObjective extends VarOrderHeap { |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| private static final long serialVersionUID = 1L; |
18 |
| |
19 |
| private ObjectiveFunction obj; |
20 |
| |
21 |
0
| public void setObjectiveFunction(ObjectiveFunction obj) {
|
22 |
0
| this.obj = obj;
|
23 |
| } |
24 |
| |
25 |
1
| @Override
|
26 |
| public void init() { |
27 |
1
| super.init();
|
28 |
1
| if (obj != null) {
|
29 |
0
| IVecInt vars = obj.getVars();
|
30 |
0
| IVec<BigInteger> coefs = obj.getCoeffs();
|
31 |
0
| for (int i = 0; i < vars.size(); i++) {
|
32 |
0
| int p = lits.getFromPool(vars.get(i));
|
33 |
0
| BigInteger c = coefs.get(i);
|
34 |
0
| if (c.signum() < 0) {
|
35 |
0
| p = neg(p);
|
36 |
| } |
37 |
0
| int var = var(p);
|
38 |
0
| activity[var] = c.abs().doubleValue();
|
39 |
0
| if (heap.inHeap(var))
|
40 |
0
| heap.increase(var);
|
41 |
0
| phase[var] = neg(p);
|
42 |
| } |
43 |
| } |
44 |
| } |
45 |
| } |