本文整理汇总了Java中org.sat4j.pb.SolverFactory.newDefault方法的典型用法代码示例。如果您正苦于以下问题:Java SolverFactory.newDefault方法的具体用法?Java SolverFactory.newDefault怎么用?Java SolverFactory.newDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sat4j.pb.SolverFactory
的用法示例。
在下文中一共展示了SolverFactory.newDefault方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runSatSolver
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
private int[] runSatSolver(Path path){
ISolver solver = SolverFactory.newDefault();
solver.setTimeout(TIMEOUT_MINUTES);
Reader reader = new DimacsReader(solver);
IProblem problem = null;
try {
problem = reader.parseInstance(path.toString());
if (problem.isSatisfiable()) {
return problem.model();
} else {
logger.error("Problem described in " + path.getFileName() + " is unsatisfiable");
}
} catch (ContradictionException | TimeoutException | ParseFormatException | IOException e) {
logger.error("Error during SAT-solver processing", e);
}
return null;
}
示例2: setUp
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
@Before
public void setUp() {
IIntegerPBSolver integerSolver = new IntegerPBSolverDecorator(
SolverFactory.newDefault());
BigInteger weights[] = new BigInteger[3];
weights[0] = BigInteger.valueOf(1);
weights[1] = BigInteger.valueOf(2);
weights[2] = BigInteger.valueOf(3);
optimizer = new OrderedObjsOWAOptimizer(integerSolver, weights);
}
示例3: setUp
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
@Before
public void setUp() {
IIntegerPBSolver integerSolver = new IntegerPBSolverDecorator(
SolverFactory.newDefault());
BigInteger weights[] = new BigInteger[3];
weights[0] = BigInteger.valueOf(1);
weights[1] = BigInteger.valueOf(2);
weights[2] = BigInteger.valueOf(3);
this.optimizer = new MinSumOWAOptimizer(integerSolver, weights);
this.satAdapter = new OptToPBSATAdapter(optimizer);
}
示例4: testGlobalInconsistency
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
@Test
public void testGlobalInconsistency() throws ContradictionException,
TimeoutException {
XplainPB solver = new XplainPB(SolverFactory.newDefault());
solver.newVar(2);
IVec<BigInteger> coeffs = new Vec<BigInteger>();
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
IVecInt clause = new VecInt();
clause.push(1).push(2);
solver.addPseudoBoolean(clause, coeffs, true, BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(1).push(-2);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
solver.addPseudoBoolean(clause, coeffs, true, BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(-1).push(2);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
solver.addPseudoBoolean(clause, coeffs, true, BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(-1).push(-2);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
solver.addPseudoBoolean(clause, coeffs, true, BigInteger.ONE);
clause.clear();
coeffs.clear();
assertFalse(solver.isSatisfiable());
Collection<IConstr> explanation = solver.explain();
assertEquals(4, explanation.size());
}
示例5: testGlobalInconsistencyPB
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
@Test
public void testGlobalInconsistencyPB() throws ContradictionException,
TimeoutException {
XplainPB solver = new XplainPB(SolverFactory.newDefault());
solver.newVar(4);
IVec<BigInteger> coeffs = new Vec<BigInteger>();
coeffs.push(BigInteger.valueOf(3)).push(BigInteger.valueOf(2))
.push(BigInteger.ONE);
IVecInt clause = new VecInt();
clause.push(1).push(2).push(3);
IConstr c1 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.valueOf(4));
clause.clear();
coeffs.clear();
clause.push(-1).push(3).push(4);
coeffs.push(BigInteger.valueOf(3)).push(BigInteger.ONE)
.push(BigInteger.ONE);
IConstr c2 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.valueOf(4));
clause.clear();
coeffs.clear();
assertFalse(solver.isSatisfiable());
Collection<IConstr> explanation = solver.explain();
assertEquals(2, explanation.size());
System.out.println(explanation);
assertTrue(explanation.contains(c1));
assertTrue(explanation.contains(c2));
}
示例6: testAlmostGlobalInconsistencyPB
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
@Test
public void testAlmostGlobalInconsistencyPB()
throws ContradictionException, TimeoutException {
XplainPB solver = new XplainPB(SolverFactory.newDefault());
solver.newVar(4);
IVec<BigInteger> coeffs = new Vec<BigInteger>();
coeffs.push(BigInteger.valueOf(3)).push(BigInteger.valueOf(2))
.push(BigInteger.ONE);
IVecInt clause = new VecInt();
clause.push(1).push(2).push(3);
IConstr c1 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.valueOf(4));
clause.clear();
coeffs.clear();
clause.push(2).push(-3).push(4);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE).push(BigInteger.ONE);
solver.addPseudoBoolean(clause, coeffs, true, BigInteger.valueOf(2));
clause.clear();
coeffs.clear();
clause.push(-1).push(3).push(4);
coeffs.push(BigInteger.valueOf(3)).push(BigInteger.ONE)
.push(BigInteger.ONE);
IConstr c3 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.valueOf(4));
clause.clear();
coeffs.clear();
assertFalse(solver.isSatisfiable());
Collection<IConstr> explanation = solver.explain();
assertEquals(2, explanation.size());
assertTrue(explanation.contains(c1));
assertTrue(explanation.contains(c3));
}
示例7: testEclipsePatchEncoding
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
@Test
public void testEclipsePatchEncoding() throws ContradictionException,
TimeoutException {
XplainPB solver = new XplainPB(SolverFactory.newDefault());
solver.newVar(12);
IVecInt clause = new VecInt();
clause.push(-1).push(-2).push(3);
solver.addClause(clause);
clause.clear();
clause.push(-2).push(1).push(5);
solver.addClause(clause);
clause.clear();
clause.push(-7).push(-2).push(8);
solver.addClause(clause);
clause.clear();
clause.push(-2).push(7).push(5);
solver.addClause(clause);
clause.clear();
clause.push(3).push(5).push(8);
solver.addAtMost(clause, 1);
clause.clear();
clause.push(-12).push(1);
solver.addClause(clause);
clause.clear();
clause.push(-12).push(2);
IConstr patch = solver.addClause(clause);
clause.clear();
clause.push(-12).push(7);
solver.addClause(clause);
IVecInt assump = new VecInt();
assump.push(12);
assertFalse(solver.isSatisfiable(assump));
Collection<IConstr> explanation = solver.explain();
assertEquals(6, explanation.size());
assertTrue(explanation.contains(patch));
}
示例8: testUpdatedEclipsePatchEncoding
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
@Test
public void testUpdatedEclipsePatchEncoding()
throws ContradictionException, TimeoutException {
XplainPB solver = new XplainPB(SolverFactory.newDefault());
solver.newVar(12);
IVecInt clause = new VecInt();
clause.push(-1).push(-2).push(3);
solver.addClause(clause);
clause.clear();
clause.push(-7).push(-2).push(8);
solver.addClause(clause);
clause.clear();
clause.push(-2).push(7).push(5).push(1);
solver.addClause(clause);
clause.clear();
clause.push(3).push(5).push(8);
solver.addAtMost(clause, 1);
clause.clear();
clause.push(-12).push(1);
solver.addClause(clause);
clause.clear();
clause.push(-12).push(2);
solver.addClause(clause);
clause.clear();
clause.push(-12).push(7);
IConstr patch = solver.addClause(clause);
IVecInt assump = new VecInt();
assump.push(12);
assertFalse(solver.isSatisfiable(assump));
Collection<IConstr> explanation = solver.explain();
assertEquals(6, explanation.size());
assertTrue(explanation.contains(patch));
}
示例9: testAlmostGlobalInconsistency
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
@Test
public void testAlmostGlobalInconsistency() throws ContradictionException,
TimeoutException {
XplainPB solver = new XplainPB(SolverFactory.newDefault());
solver.newVar(3);
IVec<BigInteger> coeffs = new Vec<BigInteger>();
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
IVecInt clause = new VecInt();
clause.push(1).push(2);
IConstr c1 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(1).push(-2);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
IConstr c2 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(-1).push(2);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
IConstr c3 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(-1).push(-2);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
IConstr c4 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(1).push(3);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
solver.addPseudoBoolean(clause, coeffs, true, BigInteger.ONE);
clause.clear();
coeffs.clear();
assertFalse(solver.isSatisfiable());
Collection<IConstr> explanation = solver.explain();
assertEquals(4, explanation.size());
assertTrue(explanation.contains(c1));
assertTrue(explanation.contains(c2));
assertTrue(explanation.contains(c3));
assertTrue(explanation.contains(c4));
}
示例10: testAlmostGlobalInconsistencyII
import org.sat4j.pb.SolverFactory; //导入方法依赖的package包/类
@Test
public void testAlmostGlobalInconsistencyII()
throws ContradictionException, TimeoutException {
XplainPB solver = new XplainPB(SolverFactory.newDefault());
solver.newVar(3);
IVec<BigInteger> coeffs = new Vec<BigInteger>();
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
IVecInt clause = new VecInt();
clause.push(1).push(2);
IConstr c1 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(1).push(-2);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
IConstr c2 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(1).push(3);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
solver.addPseudoBoolean(clause, coeffs, true, BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(-1).push(2);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
IConstr c4 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.ONE);
clause.clear();
coeffs.clear();
clause.push(-1).push(-2);
coeffs.push(BigInteger.ONE).push(BigInteger.ONE);
IConstr c5 = solver.addPseudoBoolean(clause, coeffs, true,
BigInteger.ONE);
clause.clear();
coeffs.clear();
assertFalse(solver.isSatisfiable());
Collection<IConstr> explanation = solver.explain();
assertEquals(4, explanation.size());
assertTrue(explanation.contains(c1));
assertTrue(explanation.contains(c2));
assertTrue(explanation.contains(c4));
assertTrue(explanation.contains(c5));
}