本文整理汇总了Java中org.sat4j.tools.OptToSatAdapter类的典型用法代码示例。如果您正苦于以下问题:Java OptToSatAdapter类的具体用法?Java OptToSatAdapter怎么用?Java OptToSatAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OptToSatAdapter类属于org.sat4j.tools包,在下文中一共展示了OptToSatAdapter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTimeoutConflictsLoop
import org.sat4j.tools.OptToSatAdapter; //导入依赖的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()));
}
}
示例2: setUp
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
@Before
public void setUp() throws ContradictionException {
solver = new OptToSatAdapter(new MinOneDecorator(
SolverFactory.newDefault()));
solver.newVar(100);
IVecInt clause = new VecInt();
for (int i = 2; i < 100; i++) {
clause.push(-1).push(i);
solver.addClause(clause);
clause.clear();
clause.push(-i).push(i + 1);
solver.addClause(clause);
}
clause.clear();
for (int i = 1; i <= 10; i++) {
clause.push(i);
}
solver.addClause(clause);
}
示例3: setUp
import org.sat4j.tools.OptToSatAdapter; //导入依赖的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();
}
示例4: testMaxSAtIteratorIfSat
import org.sat4j.tools.OptToSatAdapter; //导入依赖的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());
}
示例5: testMaxSAtIterator
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
@Test
public void testMaxSAtIterator() throws ContradictionException,
TimeoutException {
ISolver solver = new ModelIterator(new OptToSatAdapter(
new MaxSatDecorator(SolverFactory.newDefault())));
solver.newVar(2);
IVecInt literals = new VecInt();
literals.push(-1).push(-2);
solver.addClause(literals);
literals.clear();
literals.push(-1).push(2);
solver.addClause(literals);
literals.clear();
literals.push(1).push(-2);
solver.addClause(literals);
literals.clear();
literals.push(1).push(2);
solver.addClause(literals);
assertTrue(solver.isSatisfiable());
assertEquals(2, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2));
assertTrue(solver.isSatisfiable());
assertEquals(2, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2));
assertTrue(solver.isSatisfiable());
assertEquals(2, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2));
assertTrue(solver.isSatisfiable());
assertEquals(2, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2));
assertFalse(solver.isSatisfiable());
}
示例6: testBugReport
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
@Test
public void testBugReport() throws ContradictionException, TimeoutException {
ISolver theSolver = SolverFactory.newDefault();
ModelIterator solver = new ModelIterator(new OptToSatAdapter(
new MaxSatDecorator(SolverFactory.newDefault())));
System.out.println("Taille de voc : " + solver.nVars());
solver.newVar(3);
solver.setExpectedNumberOfClauses(3);
solver.addClause(new VecInt(new int[] { 1, 2 }));
solver.addClause(new VecInt(new int[] { 1, 3 }));
solver.addClause(new VecInt(new int[] { 2, 3 }));
System.out.println("Taille de voc : " + solver.nVars());
if (solver.isSatisfiable()) {
System.out.println("Taille du modèle : " + solver.model().length);
for (int i = 1; i <= solver.model().length; i++) {
System.out.print(solver.model(i) + " ");
}
System.out.println();
}
solver.reset();
System.out.println("Taille de voc : " + solver.nVars());
solver.newVar(2);
solver.setExpectedNumberOfClauses(2);
solver.addClause(new VecInt(new int[] { 1, 2 }));
solver.addClause(new VecInt(new int[] { 2 }));
System.out.println("Taille de voc : " + solver.nVars());
if (solver.isSatisfiable()) {
System.out.println("Taille du modèle : " + solver.model().length);
for (int i = 1; i <= solver.model().length; i++) {
System.out.print(solver.model(i) + " ");
}
System.out.println();
}
System.out.println("The End.");
}
示例7: testMaxSAtIterator
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
@Test
public void testMaxSAtIterator() throws ContradictionException,
TimeoutException {
ISolver solver = new ModelIterator(new OptToSatAdapter(
new MaxSatDecorator(SolverFactory.newDefault())));
solver.newVar(2);
IVecInt literals = new VecInt();
literals.push(-1).push(-2);
solver.addClause(literals);
literals.clear();
literals.push(-1).push(2);
solver.addClause(literals);
literals.clear();
literals.push(1).push(-2);
solver.addClause(literals);
literals.clear();
literals.push(1).push(2);
solver.addClause(literals);
assertTrue(solver.isSatisfiable());
assertEquals(2, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2));
assertTrue(solver.isSatisfiable());
assertEquals(2, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2));
assertTrue(solver.isSatisfiable());
assertEquals(2, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2));
assertTrue(solver.isSatisfiable());
assertEquals(2, solver.model().length);
System.out.println("" + solver.model(1) + solver.model(2));
assertFalse(solver.isSatisfiable());
}
示例8: testBugReport
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
@Test
public void testBugReport() throws ContradictionException, TimeoutException {
ModelIterator solver = new ModelIterator(new OptToSatAdapter(
new MaxSatDecorator(SolverFactory.newDefault())));
System.out.println("Taille de voc : " + solver.nVars());
solver.newVar(3);
solver.setExpectedNumberOfClauses(3);
solver.addClause(new VecInt(new int[] { 1, 2 }));
solver.addClause(new VecInt(new int[] { 1, 3 }));
solver.addClause(new VecInt(new int[] { 2, 3 }));
System.out.println("Taille de voc : " + solver.nVars());
if (solver.isSatisfiable()) {
System.out.println("Taille du modèle : " + solver.model().length);
for (int i = 1; i <= solver.model().length; i++) {
System.out.print(solver.model(i) + " ");
}
System.out.println();
}
solver.reset();
System.out.println("Taille de voc : " + solver.nVars());
solver.newVar(2);
solver.setExpectedNumberOfClauses(2);
solver.addClause(new VecInt(new int[] { 1, 2 }));
solver.addClause(new VecInt(new int[] { 2 }));
System.out.println("Taille de voc : " + solver.nVars());
if (solver.isSatisfiable()) {
System.out.println("Taille du modèle : " + solver.model().length);
for (int i = 1; i <= solver.model().length; i++) {
System.out.print(solver.model(i) + " ");
}
System.out.println();
}
System.out.println("The End.");
}
示例9: testBugReport
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
@Test
public void testBugReport() throws ContradictionException, TimeoutException {
ModelIterator solver = new ModelIterator(new OptToSatAdapter(
new MaxSatDecorator(SolverFactory.newDefault())));
// MaxSatDecorator solver = new
// MaxSatDecorator(SolverFactory.newDefault());
System.out.println("Taille de voc : " + solver.nVars());
solver.newVar(13);
solver.setExpectedNumberOfClauses(24);
solver.addClause(new VecInt(new int[] { -1 }));
solver.addClause(new VecInt(new int[] { -2 }));
solver.addClause(new VecInt(new int[] { -3, 4 }));
solver.addClause(new VecInt(new int[] { -3, 5 }));
solver.addClause(new VecInt(new int[] { -3, 6 }));
solver.addClause(new VecInt(new int[] { -1, 7 }));
solver.addClause(new VecInt(new int[] { -2, 6 }));
solver.addClause(new VecInt(new int[] { -4, 3 }));
solver.addClause(new VecInt(new int[] { -5, 3 }));
solver.addClause(new VecInt(new int[] { -6, 3, 2 }));
solver.addClause(new VecInt(new int[] { -7, 1 }));
solver.addClause(new VecInt(new int[] { 3, -1, 8 }));
solver.addClause(new VecInt(new int[] { -3, 1, 8 }));
solver.addClause(new VecInt(new int[] { -3, -1, 9 }));
solver.addClause(new VecInt(new int[] { -9 }));
solver.addClause(new VecInt(new int[] { 1, -2, 10 }));
solver.addClause(new VecInt(new int[] { -1, 2, 10 }));
solver.addClause(new VecInt(new int[] { -1, -2, 11 }));
solver.addClause(new VecInt(new int[] { -10 }));
solver.addClause(new VecInt(new int[] { -11 }));
solver.addClause(new VecInt(new int[] { 3, -1, 12 }));
solver.addClause(new VecInt(new int[] { -3, 1, 12 }));
solver.addClause(new VecInt(new int[] { -3, -1, 13 }));
solver.addClause(new VecInt(new int[] { -13 }));
System.out.println("Taille de voc : " + solver.nVars());
if (solver.isSatisfiable()) {
System.out.println("Taille du modèle : " + solver.model().length);
for (int i = 1; i <= solver.model().length; i++) {
System.out.print(solver.model(i) + " ");
}
System.out.println();
}
}
示例10: testBugReport
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
@Test
public void testBugReport() throws ContradictionException, TimeoutException {
ModelIterator solver = new ModelIterator(new OptToSatAdapter(
new MaxSatDecorator(SolverFactory.newDefault())));
// MaxSatDecorator solver = new
// MaxSatDecorator(SolverFactory.newDefault());
System.out.println("Taille de voc : " + solver.nVars());
solver.newVar(13);
solver.setExpectedNumberOfClauses(24);
solver.addClause(new VecInt(new int[] { -1 }));
solver.addClause(new VecInt(new int[] { -2 }));
solver.addClause(new VecInt(new int[] { -3, 4 }));
solver.addClause(new VecInt(new int[] { -3, 5 }));
solver.addClause(new VecInt(new int[] { -3, 6 }));
solver.addClause(new VecInt(new int[] { -1, 7 }));
solver.addClause(new VecInt(new int[] { -2, 6 }));
solver.addClause(new VecInt(new int[] { -4, 3 }));
solver.addClause(new VecInt(new int[] { -5, 3 }));
solver.addClause(new VecInt(new int[] { -6, 3, 2 }));
solver.addClause(new VecInt(new int[] { -7, 1 }));
solver.addClause(new VecInt(new int[] { 3, -1, 8 }));
solver.addClause(new VecInt(new int[] { -3, 1, 8 }));
solver.addClause(new VecInt(new int[] { -3, -1, 9 }));
solver.addClause(new VecInt(new int[] { -9 }));
solver.addClause(new VecInt(new int[] { 1, -2, 10 }));
solver.addClause(new VecInt(new int[] { -1, 2, 10 }));
solver.addClause(new VecInt(new int[] { -1, -2, 11 }));
solver.addClause(new VecInt(new int[] { -10 }));
solver.addClause(new VecInt(new int[] { -11 }));
solver.addClause(new VecInt(new int[] { 3, -1, 12 }));
solver.addClause(new VecInt(new int[] { -3, 1, 12 }));
solver.addClause(new VecInt(new int[] { -3, -1, 13 }));
solver.addClause(new VecInt(new int[] { -13 }));
System.out.println("Taille de voc : " + solver.nVars());
if (solver.isSatisfiable()) {
System.out.println("Taille du modèle : " + solver.model().length);
for (int i = 1; i <= solver.model().length; i++) {
System.out.print(solver.model(i) + " ");
}
System.out.println();
}
}
示例11: setUp
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
@Before
public void setUp() {
maxsat = new MaxSatDecorator(SolverFactory.newDefault());
optimizer = new OptToSatAdapter(maxsat);
}
示例12: testMaxSAtIteratorIfSat
import org.sat4j.tools.OptToSatAdapter; //导入依赖的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));
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());
}
示例13: newMinOneSolver
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
/**
* @return a solver computing models with a minimum number of satisfied
* literals.
*/
public static ISolver newMinOneSolver() {
return new OptToSatAdapter(new MinOneDecorator(newDefault()));
}
示例14: newMinOneSolver
import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
/**
* @return a solver computing models with a minimum number of satisfied
* literals.
*/
public static ISolver newMinOneSolver() {
return new OptToSatAdapter(new MinOneDecorator(newDefault()));
}