本文整理汇总了Java中org.sat4j.minisat.SolverFactory.newDefault方法的典型用法代码示例。如果您正苦于以下问题:Java SolverFactory.newDefault方法的具体用法?Java SolverFactory.newDefault怎么用?Java SolverFactory.newDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sat4j.minisat.SolverFactory
的用法示例。
在下文中一共展示了SolverFactory.newDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeleteGroup
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void testDeleteGroup() throws ContradictionException {
ISolver solver = SolverFactory.newDefault();
ConstrGroup g1 = new ConstrGroup();
IVecInt clause = new VecInt(new int[] { 1, 2, -3 });
solver.addClause(clause);
// starting group
clause.clear();
clause.push(2).push(-3).push(-5);
g1.add(solver.addClause(clause));
clause.clear();
clause.push(-3).push(-2).push(-4);
g1.add(solver.addClause(clause));
assertEquals(3, solver.nConstraints());
g1.removeFrom(solver);
assertEquals(1, solver.nConstraints());
}
示例2: checkItWorksAfterRunningTheSolver
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void checkItWorksAfterRunningTheSolver() throws ContradictionException, TimeoutException {
ISolver solver = SolverFactory.newDefault();
ConstrGroup g1 = new ConstrGroup();
IVecInt clause = new VecInt(new int[] { 1 });
solver.addClause(clause);
// starting group
clause.clear();
clause.push(-1).push(-2).push(-3);
g1.add(solver.addClause(clause));
clause.clear();
clause.push(-1).push(2).push(-3);
g1.add(solver.addClause(clause));
assertEquals(3, solver.nConstraints());
assertTrue(solver.isSatisfiable());
assertTrue(solver.model(1));
assertFalse(solver.model(3));
g1.removeFrom(solver);
assertEquals(1, solver.nConstraints());
}
示例3: verifySatICPL_3
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void verifySatICPL_3() throws IOException, ParseFormatException, ContradictionException, org.sat4j.specs.TimeoutException, CSVException{
ISolver solver = SolverFactory.newDefault();
Reader reader = new LecteurDimacs(solver);
IProblem problem = reader.parseInstance("TestData/Realistic/2.6.28.6-icse11.dimacs");
assertTrue(problem.isSatisfiable());
CNF cnf = new CNF("TestData/Realistic/2.6.28.6-icse11.dimacs", CNF.type.dimacs);
CoveringArray ca = new CoveringArrayFile("reports/bestcoverages/2.6.28.6-icse11-size469-1thread.dimacs.ca2.csv");
for(int n = 0; n < ca.getRowCount(); n++){
// Convert
Integer[] solinteger = ca.getRow(n);
int[] sol = new int[solinteger.length];
for(int i = 0; i < sol.length; i++){
sol[i] = cnf.getNr(ca.getId(i+1));
if(solinteger[i]==1) sol[i] = -sol[i];
}
IVecInt assumps = new VecInt(sol);
//System.out.println(n + ", " + assumps.size());
// Test
assertTrue(problem.isSatisfiable(assumps));
}
}
示例4: testEmptyBackbone
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void testEmptyBackbone() throws ContradictionException,
TimeoutException {
ISolver solver = SolverFactory.newDefault();
IVecInt clause = new VecInt();
clause.push(1).push(2).push(3);
solver.addClause(clause);
clause.clear();
clause.push(-1).push(-2);
solver.addClause(clause);
clause.clear();
clause.push(-1).push(-3);
solver.addClause(clause);
clause.clear();
IVecInt backbone = Backbone.instance().compute(solver);
assertEquals(0, backbone.size());
}
示例5: setUp
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws ContradictionException {
solver = SolverFactory.newDefault();
minOne = new MinOneDecorator(solver);
adapter = new OptToSatAdapter(minOne);
IVecInt clause = new VecInt();
clause.push(1).push(2);
minOne.addClause(clause);
clause.clear();
clause = new VecInt();
clause.push(1).push(-3);
minOne.addClause(clause);
clause.clear();
clause = new VecInt();
clause.push(1).push(3).push(4);
minOne.addClause(clause);
clause.clear();
}
示例6: testTimeoutConflictsLoop
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void testTimeoutConflictsLoop() throws ContradictionException,
TimeoutException, NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException {
for (int i = 0; i < 1000; i++) {
solver = new OptToSatAdapter(new MaxSatDecorator(
SolverFactory.newDefault()));
IVecInt clause = new VecInt();
clause.push(1).push(2).push(3);
solver.addClause(clause);
solver.setTimeoutOnConflicts(10);
assertTrue(solver.isSatisfiable());
Field field = solver.getSolvingEngine().getClass()
.getDeclaredField("timer");
field.setAccessible(true);
assertNull(field.get(solver.getSolvingEngine()));
}
}
示例7: testModelIterator
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void testModelIterator() throws ContradictionException,
TimeoutException {
ModelIterator iterator = new ModelIterator(SolverFactory.newDefault());
iterator.addClause(new VecInt(new int[] { 1, 2 }));
iterator.addClause(new VecInt(new int[] { -1, -2 }));
iterator.addClause(new VecInt(new int[] { -3, -4 }));
iterator.addClause(new VecInt(new int[] { 5, 6 }));
iterator.addClause(new VecInt(new int[] { -5, -6 }));
iterator.addClause(new VecInt(new int[] { -1, 3 }));
int counter = 0;
int[] sub = new int[0];
while (iterator.isSatisfiable()) {
sub = iterator.model();
counter++;
}
assertEquals(8, counter);
assertEquals(6, sub.length);
}
示例8: testDeleteGroup
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void testDeleteGroup() throws ContradictionException {
ISolver solver = SolverFactory.newDefault();
ConstrGroup g1 = new ConstrGroup();
IVecInt clause = new VecInt(new int[] { 1, 2, -3 });
solver.addClause(clause);
// starting group
clause.clear();
clause.push(2).push(-3).push(-5);
g1.add(solver.addClause(clause));
clause.clear();
clause.push(-3).push(-2).push(-4);
g1.add(solver.addClause(clause));
assertEquals(3, solver.nConstraints());
g1.removeFrom(solver);
assertEquals(1, solver.nConstraints());
}
示例9: checkBugReportedByThomas
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void checkBugReportedByThomas() throws ContradictionException {
ISolver solver = SolverFactory.newDefault();
ConstrGroup g1 = new ConstrGroup();
IVecInt clause = new VecInt(new int[] { 1 });
solver.addClause(clause);
// starting group
clause.clear();
clause.push(2).push(-3).push(-5);
g1.add(solver.addClause(clause));
clause.clear();
clause.push(-3).push(-2).push(-4);
g1.add(solver.addClause(clause));
assertEquals(3, solver.nConstraints());
g1.removeFrom(solver);
assertEquals(1, solver.nConstraints());
}
示例10: implicitDeclarationOfVariables
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void implicitDeclarationOfVariables() throws ContradictionException,
TimeoutException {
ISolver solver = SolverFactory.newDefault();
assertEquals(0, solver.nVars());
assertEquals(0, solver.realNumberOfVariables());
solver.addClause(new VecInt(new int[] { 1, 2, 3 }));
assertEquals(3, solver.nVars());
assertEquals(3, solver.realNumberOfVariables());
for (int i = 0; i < 10; i++) {
solver.nextFreeVarId(true);
}
assertEquals(13, solver.nVars());
assertEquals(13, solver.realNumberOfVariables());
int[] model1 = solver.findModel();
assertEquals(3, model1.length);
int[] model2 = solver.modelWithInternalVariables();
assertEquals(3, model2.length);
}
示例11: configureSolver
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Override
protected ISolver configureSolver(String[] args) {
String problemName = args[args.length - 1];
if (problemName.endsWith(".gcnf")) {
highLevel = true;
}
ISolver solver;
if (highLevel) {
HighLevelXplain<ISolver> hlxp = new HighLevelXplain<ISolver>(
SolverFactory.newDefault());
xplain = hlxp;
solver = hlxp;
} else {
Xplain<ISolver> xp = new Xplain<ISolver>(SolverFactory.newDefault());
xplain = xp;
solver = xp;
}
if (args.length == 2) {
// retrieve minimization strategy
String className = "org.sat4j.tools.xplain." + args[0] + "Strategy";
try {
xplain.setMinimizationStrategy((MinimizationStrategy) Class
.forName(className).newInstance());
} catch (Exception e) {
log(e.getMessage());
}
}
solver.setTimeout(Integer.MAX_VALUE);
solver.setDBSimplificationAllowed(true);
getLogWriter().println(solver.toString(COMMENT_PREFIX)); //$NON-NLS-1$
return solver;
}
示例12: testBinaryClauseInFormula
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void testBinaryClauseInFormula() throws ContradictionException,
TimeoutException {
final ISolver solver = SolverFactory.newDefault();
solver.addClause(new VecInt(new int[] { 1, 2 }));
assertFalse(solver.isSatisfiable(new VecInt(new int[] { -1, -2 })));
IVecInt explanation = solver.unsatExplanation();
assertTrue(explanation.contains(-1));
assertTrue(explanation.contains(-2));
assertEquals(2, explanation.size());
}
示例13: testMaxSAtIteratorIfSat
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test
public void testMaxSAtIteratorIfSat() throws ContradictionException,
TimeoutException {
ISolver solver = new ModelIterator(new OptToSatAdapter(
new MaxSatDecorator(SolverFactory.newDefault())));
solver.newVar(3);
IVecInt literals = new VecInt();
literals.push(-1).push(-2).push(3);
solver.addClause(literals);
literals.clear();
literals.push(-1).push(2);
solver.addClause(literals);
literals.clear();
literals.push(-1).push(-3);
solver.addClause(literals);
literals.clear();
assertTrue(solver.isSatisfiable());
assertEquals(3, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2)
+ solver.model(3));
assertTrue(solver.isSatisfiable());
assertEquals(3, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2)
+ solver.model(3));
assertTrue(solver.isSatisfiable());
assertEquals(3, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2)
+ solver.model(3));
assertTrue(solver.isSatisfiable());
assertEquals(3, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2)
+ solver.model(3));
assertFalse(solver.isSatisfiable());
}
示例14: setUp
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws FileNotFoundException, ParseFormatException,
IOException, ContradictionException {
xplain = new Xplain<ISolver>(SolverFactory.newDefault());
xplain.setTimeout(3600); // 1 hour timeout
Reader reader = new DimacsReader(xplain);
String dimacs = "src/test/testfiles/eb42.dimacs";
reader.parseInstance(dimacs);
}
示例15: cannotPutAUnitClauseInAGroup
import org.sat4j.minisat.SolverFactory; //导入方法依赖的package包/类
@Test(expected = java.lang.IllegalArgumentException.class)
public void cannotPutAUnitClauseInAGroup() throws ContradictionException {
ISolver solver = SolverFactory.newDefault();
ConstrGroup g1 = new ConstrGroup();
IVecInt clause = new VecInt(new int[] { 1 });
g1.add(solver.addClause(clause));
}