当前位置: 首页>>代码示例>>Java>>正文


Java OptToSatAdapter类代码示例

本文整理汇总了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()));
    }
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:20,代码来源:BugSAT117.java

示例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);

}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:21,代码来源:BugSAT107.java

示例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();
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:19,代码来源:BugSAT95.java

示例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());
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:35,代码来源:Bug275101.java

示例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());
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:33,代码来源:Bug275101.java

示例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.");

}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:38,代码来源:BugFatih.java

示例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());
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:33,代码来源:Bug275101.java

示例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.");

}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:37,代码来源:BugFatih.java

示例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();
	}
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:43,代码来源:BugFatih2.java

示例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();
    }
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:43,代码来源:BugFatih2.java

示例11: setUp

import org.sat4j.tools.OptToSatAdapter; //导入依赖的package包/类
@Before
public void setUp() {
    maxsat = new MaxSatDecorator(SolverFactory.newDefault());
    optimizer = new OptToSatAdapter(maxsat);
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:6,代码来源:TestMaxSatDecorator.java

示例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());
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:51,代码来源:Bug275101.java

示例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()));
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:8,代码来源:SolverFactory.java

示例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()));
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:8,代码来源:SolverFactory.java


注:本文中的org.sat4j.tools.OptToSatAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。