1 package org.sat4j.multicore;
2
3 import java.math.BigInteger;
4
5 import org.sat4j.core.ASolverFactory;
6 import org.sat4j.pb.IPBSolver;
7 import org.sat4j.pb.ObjectiveFunction;
8 import org.sat4j.specs.ContradictionException;
9 import org.sat4j.specs.IConstr;
10 import org.sat4j.specs.IVec;
11 import org.sat4j.specs.IVecInt;
12 import org.sat4j.tools.ConstrGroup;
13
14 public class ManyCorePB extends ManyCore<IPBSolver> implements IPBSolver {
15
16
17
18
19 private static final long serialVersionUID = 1L;
20
21 public ManyCorePB(ASolverFactory<IPBSolver> factory, String... solverNames) {
22 super(factory, solverNames);
23 }
24
25 public IConstr addPseudoBoolean(IVecInt lits, IVec<BigInteger> coeffs,
26 boolean moreThan, BigInteger d) throws ContradictionException {
27 ConstrGroup group = new ConstrGroup(false);
28 for (int i = 0; i < numberOfSolvers; i++) {
29 group.add(solvers.get(i)
30 .addPseudoBoolean(lits, coeffs, moreThan, d));
31 }
32 return group;
33 }
34
35 public void setObjectiveFunction(ObjectiveFunction obj) {
36 for (int i = 0; i < numberOfSolvers; i++) {
37 solvers.get(i).setObjectiveFunction(obj);
38 }
39 }
40
41 public ObjectiveFunction getObjectiveFunction() {
42 return solvers.get(0).getObjectiveFunction();
43 }
44
45 }