use of org.sat4j.core.Vec in project opt4j by felixreimann.
the class SAT4JSolver method addConstraintToSolver.
protected void addConstraintToSolver(Constraint constraint) {
VecInt lits = toVecInt(constraint.getLiterals());
IVec<BigInteger> coeffs = new Vec<BigInteger>();
for (Integer value : constraint.getCoefficients()) {
coeffs.push(BigInteger.valueOf(value));
}
BigInteger d = BigInteger.valueOf(constraint.getRhs());
Operator operator = constraint.getOperator();
try {
if (operator == LE || operator == EQ) {
solver.addPseudoBoolean(lits, coeffs, false, d);
}
if (operator == GE || operator == EQ) {
solver.addPseudoBoolean(lits, coeffs, true, d);
}
} catch (org.sat4j.specs.ContradictionException e) {
solverValid = false;
throw new ContradictionException(e);
}
}
Aggregations