|
1 |
| package org.sat4j.reader; |
|
2 |
| |
|
3 |
| import java.math.BigInteger; |
|
4 |
| |
|
5 |
| import org.sat4j.specs.IVec; |
|
6 |
| |
|
7 |
| public class ObjectifFunction { |
|
8 |
| |
|
9 |
| |
|
10 |
| private final IVec<BigInteger> coeffs; |
|
11 |
| |
|
12 |
0
| public ObjectifFunction(IVec<BigInteger> coeffs) {
|
|
13 |
0
| this.coeffs = coeffs;
|
|
14 |
| } |
|
15 |
| |
|
16 |
| |
|
17 |
0
| public BigInteger calculateDegree(int[] model) {
|
|
18 |
| assert coeffs.size() == model.length; |
|
19 |
0
| BigInteger tempDegree = BigInteger.ZERO;
|
|
20 |
| |
|
21 |
0
| for (int i = 0; i < coeffs.size(); i++) {
|
|
22 |
0
| if (model[i] > 0) {
|
|
23 |
0
| tempDegree = tempDegree.add(coeffs.get(i));
|
|
24 |
| } |
|
25 |
| } |
|
26 |
0
| return tempDegree;
|
|
27 |
| } |
|
28 |
| |
|
29 |
| } |