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


Java SolverFactory.newDefault方法代码示例

本文整理汇总了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;
}
 
开发者ID:Vapsel,项目名称:social-media-analytic-system,代码行数:19,代码来源:SATSolverManagerImpl.java

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

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

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

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

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

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

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

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

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


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