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


Java IVecInt.copyTo方法代码示例

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


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

示例1: or

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
/**
 * translate y <=> x1 \/ x2 \/ ... \/ xn into clauses.
 * 
 * @param y
 * @param literals
 * @throws ContradictionException
 * @since 2.1
 */
public IConstr[] or(int y, IVecInt literals) throws ContradictionException {
	// y <=> OR x1 x2 ...xn
	// y => x1 x2 ... xn
	IConstr[] constrs = new IConstr[literals.size() + 1];
	IVecInt clause = new VecInt(literals.size() + 2);
	literals.copyTo(clause);
	clause.push(-y);
	constrs[0] = processClause(clause);
	clause.clear();
	for (int i = 0; i < literals.size(); i++) {
		// xi => y
		clause.clear();
		clause.push(y);
		clause.push(-literals.get(i));
		constrs[i + 1] = processClause(clause);
	}
	return constrs;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:27,代码来源:GateTranslator.java

示例2: 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

示例3: expensiveSimplification

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
private void expensiveSimplification(IVecInt conflictToReduce) {
	// Simplify conflict clause (a lot):
	//
	int i, j;
	// (maintain an abstraction of levels involved in conflict)
	analyzetoclear.clear();
	conflictToReduce.copyTo(analyzetoclear);
	for (i = 1, j = 1; i < conflictToReduce.size(); i++)
		if (voc.getReason(conflictToReduce.get(i)) == null
				|| !analyzeRemovable(conflictToReduce.get(i)))
			conflictToReduce.moveTo(j++, i);
	conflictToReduce.shrink(i - j);
	stats.reducedliterals += (i - j);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:15,代码来源:Solver.java

示例4: expensiveSimplificationWLOnly

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
private void expensiveSimplificationWLOnly(IVecInt conflictToReduce) {
	// Simplify conflict clause (a lot):
	//
	int i, j;
	// (maintain an abstraction of levels involved in conflict)
	analyzetoclear.clear();
	conflictToReduce.copyTo(analyzetoclear);
	for (i = 1, j = 1; i < conflictToReduce.size(); i++)
		if (voc.getReason(conflictToReduce.get(i)) == null
				|| !analyzeRemovableWLOnly(conflictToReduce.get(i)))
			conflictToReduce.moveTo(j++, i);
	conflictToReduce.shrink(i - j);
	stats.reducedliterals += (i - j);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:15,代码来源:Solver.java

示例5: primeImplicant

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public int[] primeImplicant() {
	IVecInt currentD = new VecInt(decisions.size());
	decisions.copyTo(currentD);
	IVecInt assumptions = new VecInt(implied.size() + decisions.size());
	implied.copyTo(assumptions);
	decisions.copyTo(assumptions);
	IVecInt prime = new VecInt(assumptions.size());
	implied.copyTo(prime);
	for (int i = 0; i < currentD.size(); i++) {
		int p = currentD.get(i);
		assumptions.remove(p);
		assumptions.push(-p);
		try {
			if (isSatisfiable(assumptions)) {
				assumptions.pop();
				assumptions.push(-p);
			} else {
				prime.push(p);
				assumptions.pop();
				assumptions.push(p);
			}
		} catch (TimeoutException e) {
			throw new IllegalStateException("Should not timeout here", e);
		}
	}
	int[] implicant = new int[prime.size()];
	prime.copyTo(implicant);
	return implicant;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:30,代码来源:Solver.java

示例6: xor

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
/**
 * translate y <=> x1 xor x2 xor ... xor xn into clauses.
 * 
 * @param y
 * @param literals
 * @throws ContradictionException
 * @since 2.1
 */
public IConstr[] xor(int y, IVecInt literals) throws ContradictionException {
	literals.push(-y);
	int[] f = new int[literals.size()];
	literals.copyTo(f);
	IVec<IConstr> vconstrs = new Vec<IConstr>();
	xor2Clause(f, 0, false, vconstrs);
	IConstr[] constrs = new IConstr[vconstrs.size()];
	vconstrs.copyTo(constrs);
	return constrs;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:19,代码来源:GateTranslator.java

示例7: iff

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
/**
 * translate y <=> (x1 <=> x2 <=> ... <=> xn) into clauses.
 * 
 * @param y
 * @param literals
 * @throws ContradictionException
 * @since 2.1
 */
public IConstr[] iff(int y, IVecInt literals) throws ContradictionException {
	literals.push(y);
	int[] f = new int[literals.size()];
	literals.copyTo(f);
	IVec<IConstr> vconstrs = new Vec<IConstr>();
	iff2Clause(f, 0, false, vconstrs);
	IConstr[] constrs = new IConstr[vconstrs.size()];
	vconstrs.copyTo(constrs);
	return constrs;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:19,代码来源:GateTranslator.java

示例8: 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

示例9: findModel

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

示例10: isSatisfiable

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

示例11: UnitClauses

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public UnitClauses(IVecInt values) {
	literals = new int[values.size()];
	values.copyTo(literals);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:5,代码来源:UnitClauses.java

示例12: addCriterion

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public void addCriterion(IVecInt literals) {
	IVecInt copy = new VecInt(literals.size());
	literals.copyTo(copy);
	criteria.add(copy);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:6,代码来源:LexicoDecorator.java

示例13: 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();
	IVecInt results = new VecInt(firstExplanation.size());
	if (firstExplanation.size() == 1) {
		results.push(-firstExplanation.get(0));
		return results;
	}
	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();
	}
	for (int i = 0; i < firstExplanation.size();) {
		if (assumps.contains(firstExplanation.get(i))) {
			firstExplanation.delete(i);
		} else {
			i++;
		}
	}
	Set<Integer> constraintsVariables = constrs.keySet();
	IVecInt remainingVariables = new VecInt(constraintsVariables.size());
	for (Integer v : constraintsVariables) {
		remainingVariables.push(v);
	}
	int p;
	for (IteratorInt it = firstExplanation.iterator(); it.hasNext();) {
		p = it.next();
		if (p < 0) {
			p = -p;
		}
		remainingVariables.remove(p);
		encodingAssumptions.push(p);
	}
	int unsatcorelimit = encodingAssumptions.size() - 1;

	remainingVariables.copyTo(encodingAssumptions);
	computeExplanation(solver, constrs, encodingAssumptions,
			assumps.size(), unsatcorelimit, results);
	return results;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:50,代码来源:QuickXplainStrategy.java


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