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


Java IVecInt.push方法代码示例

本文整理汇总了Java中org.sat4j.specs.IVecInt.push方法的典型用法代码示例。如果您正苦于以下问题:Java IVecInt.push方法的具体用法?Java IVecInt.push怎么用?Java IVecInt.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sat4j.specs.IVecInt的用法示例。


在下文中一共展示了IVecInt.push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSolverClauses

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
protected void addSolverClauses(ISolver solver) throws Exception {
		super.addSolverClauses(solver);		
		// add extra constraints
		for( PropositionalFormula formula : featureModel.getConstraints() ) {
			for( CNFClause clause : formula.toCNFClauses() ) {
				IVecInt vectInt = new VecInt(clause.countLiterals());
				for( CNFLiteral literal : clause.getLiterals() ) {
					int signal = literal.isPositive() ? 1 : -1;
					int varID = getVariableIndex(literal.getVariable().getID());
					vectInt.push(signal * varID);
				}
				solver.addClause(vectInt);
//				System.out.println("EC: " + vectInt);
			}
		}		
	}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:17,代码来源:FMReasoningWithSAT.java

示例2: testTrivialSatNewVar

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
@Deprecated
public void testTrivialSatNewVar() throws TimeoutException {
    try {
        solver.newVar(0);
        solver.newVar();
        IVecInt vec = new VecInt();
        vec.push(1);
        solver.addClause(vec);
        vec.clear();
        solver.newVar();
        vec.push(-2);
        solver.addClause(vec);
        assertTrue(solver.isSatisfiable());
    } catch (ContradictionException e) {
        fail();
    }
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:18,代码来源:TestsFonctionnels.java

示例3: test5Sat

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public void test5Sat() throws TimeoutException {
    try {
        solver.reset();
        // 2 variables
        solver.newVar(2);
        // premi\x{FFFD}re contrainte de cardinalit\x{FFFD}
        // a + not b <=0
        IVecInt vecLit = new VecInt();
        vecLit.push(1);
        vecLit.push(-2);

        solver.addAtMost(vecLit, 0);

        boolean isSat = solver.isSatisfiable();

        assertTrue(isSat);
    } catch (ContradictionException e) {
        assertTrue(false);
    }
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:21,代码来源:TestAtMost.java

示例4: test2Sat

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public void test2Sat() throws TimeoutException {
    try {
        solver.reset();
        // 2 variables
        solver.newVar(2);
        // premi?re contrainte de cardinalit?
        // a + not b <=3
        IVecInt vecLit = new VecInt();
        vecLit.push(1);
        vecLit.push(-2);
        solver.addAtMost(vecLit, 3);

        boolean isSat = solver.isSatisfiable();

        assertTrue(isSat);
    } catch (ContradictionException e) {
        assertTrue(false);
    }
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:20,代码来源:TestAtMost.java

示例5: testFolletExample

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
@Test
public void testFolletExample() throws ContradictionException,
		TimeoutException {
	IVecInt clause = new VecInt();
	clause.push(1);
	solver.addClause(clause);
	clause.clear();
	clause.push(2).push(3);
	solver.addClause(clause);
	clause.clear();
	clause.push(3);
	solver.addClause(clause);
	clause.clear();
	assertTrue(solver.isSatisfiable());
	int[] model = solver.model();
	System.out.println(new VecInt(model));
	assertEquals(3, model.length);
	int[] implicant = solver.primeImplicant();
	System.out.println(new VecInt(implicant));
	assertEquals(2, implicant.length);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:TestPrimeComputation.java

示例6: testEclipseTestCase

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
@Test
public void testEclipseTestCase() throws ContradictionException,
		TimeoutException {
	solver.newVar(3);
	IVecInt clause = new VecInt();
	clause.push(-1);
	solver.addClause(clause);
	clause.clear();
	clause.push(-2).push(3);
	solver.addClause(clause);
	clause.clear();
	clause.push(-2).push(1);
	solver.addClause(clause);
	clause.clear();
	clause.push(2);
	solver.addClause(clause);
	clause.clear();
	assertFalse(solver.isSatisfiable());
	Collection<IConstr> explanation = solver.explain();
	assertEquals(3, explanation.size());
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:AbstractXplainTest.java

示例7: testTrivialUnsat

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public void testTrivialUnsat() {
    solver.newVar(1);
    IVecInt vec = new VecInt();
    vec.push(1);
    try {
        solver.addClause(vec);
    } catch (ContradictionException e) {
        fail();
    }
    vec.clear();
    vec.push(-1);
    try {
        solver.addClause(vec);
        fail();
    } catch (ContradictionException e1) {
    }
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:18,代码来源:TestsFonctionnels.java

示例8: addClause

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
@Override
public IConstr addClause(IVecInt literals) throws ContradictionException {
	if (literals.equals(lastClause)) {
		// System.err.println("c Duplicated entry: " + literals);
		return null;
	}
	lastClause.clear();
	literals.copyTo(lastClause);
	int newvar = createNewVar(literals);
	literals.push(newvar);
	lastConstr = super.addClause(literals);
	if (lastConstr == null) {
		discardLastestVar();
	} else {
		constrs.put(newvar, lastConstr);
	}
	return lastConstr;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:19,代码来源:Xplain.java

示例9: calcReason

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public void calcReason(int p, IVecInt outReason) {
	int c = (p == ILits.UNDEFINED) ? -1 : 0;
	for (int q : lits) {
		if (voc.isFalsified(q)) {
			outReason.push(q ^ 1);
			if (++c == maxUnsatisfied)
				return;
		}
	}
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:11,代码来源:AtLeast.java

示例10: count

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
private long count(int size) throws ContradictionException,
		TimeoutException {
	SolutionCounter counter = new SolutionCounter(
			SolverFactory.newDefault());
	IVecInt clause = new VecInt();
	for (int i = 1; i <= size; i++) {
		clause.push(i);
	}
	counter.addClause(clause);
	counter.setTimeout(10);
	return counter.countSolutions();
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:13,代码来源:ModelIteratorTest.java

示例11: explain

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public IVecInt explain(ISolver solver, Map<Integer, ?> constrs,
		IVecInt assumps) throws TimeoutException {
	computationCanceled = false;
	IVecInt encodingAssumptions = new VecInt(constrs.size()
			+ assumps.size());
	assumps.copyTo(encodingAssumptions);
	IVecInt firstExplanation = solver.unsatExplanation();
	if (solver.isVerbose()) {
		System.out.print(solver.getLogPrefix() + "initial unsat core ");
		firstExplanation.sort();
		for (IteratorInt it = firstExplanation.iterator(); it.hasNext();) {
			System.out.print(constrs.get(-it.next()));
			System.out.print(" ");
		}
		System.out.println();
	}
	Set<Integer> constraintsVariables = constrs.keySet();
	int p;
	for (int i = 0; i < firstExplanation.size(); i++) {
		if (constraintsVariables.contains(p = -firstExplanation.get(i))) {
			encodingAssumptions.push(p);
		}
	}
	IVecInt results = new VecInt(encodingAssumptions.size());
	computeExplanation(solver, encodingAssumptions, assumps.size(),
			encodingAssumptions.size() - 1, results);
	return results;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:29,代码来源:QuickXplain2001Strategy.java

示例12: isSatisfiable

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
@Override
public boolean isSatisfiable() throws TimeoutException {
	assump = VecInt.EMPTY;
	IVecInt extraVariables = new VecInt();
	for (Integer p : constrs.keySet()) {
		extraVariables.push(-p);
	}
	return super.isSatisfiable(extraVariables);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:10,代码来源:HighLevelXplain.java

示例13: tearDDown

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
@Before
public void tearDDown() throws ContradictionException {
	solver = new ModelIterator(SolverFactory.newDefault());
	IVecInt clause = new VecInt();
	for (int i = 1; i <= 1000; i++)
		clause.push(-i);
	solver.addClause(clause);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:9,代码来源:TestGroupedTimeoutModelEnumeration.java

示例14: testTrivialSat

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public void testTrivialSat() throws TimeoutException {
    solver.reset();
    solver.newVar(2);
    try {
        IVecInt vec = new VecInt();
        vec.push(1);
        solver.addClause(vec);
        vec.clear();
        vec.push(-2);
        solver.addClause(vec);
        assertTrue(solver.isSatisfiable());
    } catch (ContradictionException e) {
        fail();
    }
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:16,代码来源:TestsFonctionnels.java

示例15: primeImplicant

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
@Override
public int[] primeImplicant() {
	int[] last = super.primeImplicant();
	nbModelFound += Math.pow(2, nVars() - last.length);
	IVecInt clause = new VecInt(last.length);
	for (int q : last) {
		clause.push(-q);
	}
	try {
		addBlockingClause(clause);
	} catch (ContradictionException e) {
		trivialfalsity = true;
	}
	return last;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:16,代码来源:ModelIterator.java


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