本文整理汇总了Java中org.sat4j.pb.SolverFactory类的典型用法代码示例。如果您正苦于以下问题:Java SolverFactory类的具体用法?Java SolverFactory怎么用?Java SolverFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SolverFactory类属于org.sat4j.pb包,在下文中一共展示了SolverFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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() {
this.helper = new DependencyHelper<String, String>(
SolverFactory.newEclipseP2());
// helper = new
// DependencyHelper<String,String>(SolverFactory.newDefault(),10);
}
示例3: myImplicationTest
import org.sat4j.pb.SolverFactory; //导入依赖的package包/类
@Test
public void myImplicationTest() throws ContradictionException, TimeoutException {
DependencyHelper<String, String> dependencyHelper = new DependencyHelper<>(SolverFactory.newEclipseP2());
dependencyHelper.implication("A1", "A2", "A3").implies("A1");
// helper.atLeast("Xd", 2, "A1", "A4");
// helper.setTrue("A2", "User preferences");
// Before get a solution it must be checked
assertTrue(dependencyHelper.hasASolution());
IVec<String> solution = dependencyHelper.getSolution();
System.out.println(solution.toString());
}
示例4: InprocCardConstrLearningSolver
import org.sat4j.pb.SolverFactory; //导入依赖的package包/类
public InprocCardConstrLearningSolver(
LearningStrategy<PBDataStructureFactory> learner,
PBDataStructureFactory dsf, IOrder order, boolean noRemove) {
super(learner, dsf, order, noRemove);
this.coSolver = SolverFactory.newResolution();
this.cardFinder = new CardConstrFinder(this.coSolver);
configureSolver();
}
示例5: PreprocCardConstrLearningSolver
import org.sat4j.pb.SolverFactory; //导入依赖的package包/类
public PreprocCardConstrLearningSolver(IPBSolver solverToFill) {
super(solverToFill, SolverFactory.newPBCP(
new PBMaxClauseCardConstrDataStructure(), new VarOrderHeap()));
this.solvers.get(0).setVerbose(true);
this.solvers.get(1).setVerbose(false);
this.cardFinder = new CardConstrFinder(this.solvers.get(1));
}
示例6: 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);
}
示例7: 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);
}
示例8: 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());
}
示例9: 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));
}
示例10: 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));
}
示例11: 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));
}
示例12: 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));
}
示例13: createSolver
import org.sat4j.pb.SolverFactory; //导入依赖的package包/类
/**
* @see TestCase#setUp()
*/
@Override
protected IPBSolver createSolver() {
return SolverFactory.newPBCPAllPBWLPueblo();
}
示例14: createSolver
import org.sat4j.pb.SolverFactory; //导入依赖的package包/类
/**
* @see TestCase#setUp()
*/
@Override
protected IPBSolver createSolver() {
return SolverFactory.newPBResAllPBWLPueblo();
}
示例15: createSolver
import org.sat4j.pb.SolverFactory; //导入依赖的package包/类
@Override
protected IPBSolver createSolver() {
return SolverFactory.newMiniOPBClauseAtLeastMinPueblo();
}
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:5,代码来源:PuebloWatchedPbClauseAtLeastConstrWithPBConstrLearningTest.java