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 package org.sat4j.minisat.constraints.pb;
26
27 import java.math.BigInteger;
28
29 import org.sat4j.minisat.constraints.cnf.MixableCBClause;
30 import org.sat4j.minisat.core.ILits;
31 import org.sat4j.minisat.core.UnitPropagationListener;
32 import org.sat4j.specs.IVecInt;
33
34 public class MixableCBClausePB extends MixableCBClause implements PBConstr {
35
36
37
38
39 private static final long serialVersionUID = 1L;
40
41 public MixableCBClausePB(IVecInt ps, ILits voc, boolean learnt) {
42 super(ps, voc, learnt);
43 }
44
45 public MixableCBClausePB(IVecInt ps, ILits voc) {
46 super(ps, voc);
47 }
48
49 public static MixableCBClausePB brandNewClause(UnitPropagationListener s,
50 ILits voc, IVecInt literals) {
51 MixableCBClausePB c = new MixableCBClausePB(literals, voc);
52 c.register();
53 return c;
54 }
55
56
57
58
59
60
61 public IVecInt computeAnImpliedClause() {
62 return null;
63 }
64
65
66
67
68
69
70 public BigInteger getCoef(int literal) {
71 return BigInteger.ONE;
72 }
73
74
75
76
77
78
79 public BigInteger[] getCoefs() {
80 BigInteger[] tmp = new BigInteger[size()];
81 for (int i = 0; i < tmp.length; i++)
82 tmp[i] = BigInteger.ONE;
83 return tmp;
84 }
85
86
87
88
89
90
91 public BigInteger getDegree() {
92 return BigInteger.ONE;
93 }
94
95
96
97
98
99
100 public int[] getLits() {
101 int[] tmp = new int[size()];
102 System.arraycopy(lits, 0, tmp, 0, size());
103 return tmp;
104 }
105
106
107
108
109
110
111 public ILits getVocabulary() {
112 return voc;
113 }
114
115
116
117
118
119
120 @Override
121 public void assertConstraint(UnitPropagationListener s) {
122 for (int i = 0; i < size(); i++)
123 if (getVocabulary().isUnassigned(get(i))) {
124 boolean ret = s.enqueue(get(i), this);
125 assert ret;
126 break;
127 }
128 }
129
130 }