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


Java IVecInt.size方法代码示例

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


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

示例1: and

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

示例2: simpleSimplification

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
private void simpleSimplification(IVecInt conflictToReduce) {
	int i, j;
	final boolean[] seen = mseen;
	for (i = j = 1; i < conflictToReduce.size(); i++) {
		IConstr r = voc.getReason(conflictToReduce.get(i));
		if (r == null) {
			conflictToReduce.moveTo(j++, i);
		} else {
			for (int k = 0; k < r.size(); k++)
				if (voc.isFalsified(r.get(k)) && !seen[r.get(k) >> 1]
						&& (voc.getLevel(r.get(k)) != 0)) {
					conflictToReduce.moveTo(j++, i);
					break;
				}
		}
	}
	conflictToReduce.shrink(i - j);
	stats.reducedliterals += (i - j);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:20,代码来源:Solver.java

示例3: copyTo

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public void copyTo(IVecInt arg0) {
	int argLength = arg0.size();
	final int[] workArray = vec; // faster access
	arg0.ensure(argLength + workArray.length);
	for (int i : workArray) {
		arg0.set(argLength++, i);
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:9,代码来源:SAT4J.java

示例4: copyTo

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public void copyTo(IVecInt arg0) {
	int argLength = arg0.size();
	arg0.ensure(argLength + vec.length);
	for(int i : vec) {
		arg0.set(argLength++, i);
	}
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:8,代码来源:SAT4J.java

示例5: AtLeast

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
/**
 * @param ps
 *            a vector of literals
 * @param degree
 *            the minimal number of satisfied literals
 */
protected AtLeast(ILits voc, IVecInt ps, int degree) {
	maxUnsatisfied = ps.size() - degree;
	this.voc = voc;
	counter = 0;
	lits = new int[ps.size()];
	ps.moveTo(lits);
	for (int q : lits) {
		voc.watch(q ^ 1, this);
	}
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:17,代码来源:AtLeast.java

示例6: minimalExplanation

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public int[] minimalExplanation() throws TimeoutException {
	IVecInt keys = explanationKeys();
	keys.sort();
	List<Integer> allKeys = new ArrayList<Integer>(constrs.keySet());
	Collections.sort(allKeys);
	int[] model = new int[keys.size()];
	int i = 0;
	for (IteratorInt it = keys.iterator(); it.hasNext();) {
		model[i++] = allKeys.indexOf(it.next()) + 1;
	}
	return model;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:13,代码来源:Xplain.java

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

示例8: minWatchCardNew

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
/**
 * Constructs a cardinality constraint with a minimal set of watched
 * literals Permet la cr?ation de contrainte de cardinalit? ? observation
 * minimale
 * 
 * @param s
 *            tool for propagation
 * @param voc
 *            vocalulary used by the constraint
 * @param ps
 *            literals involved in the constraint
 * @param moreThan
 *            sign of the constraint. Should be ATLEAST or ATMOST.
 * @param degree
 *            degree of the constraint
 * @return a new cardinality constraint, null if it is a tautology
 * @throws ContradictionException
 */
public static Constr minWatchCardNew(UnitPropagationListener s, ILits voc,
		IVecInt ps, boolean moreThan, int degree)
		throws ContradictionException {

	int mydegree = degree + linearisation(voc, ps);

	if (ps.size() < mydegree) {
		throw new ContradictionException();
	} else if (ps.size() == mydegree) {
		for (int i = 0; i < ps.size(); i++)
			if (!s.enqueue(ps.get(i))) {
				throw new ContradictionException();
			}
		return new UnitClauses(ps);
	}

	// La contrainte est maintenant cr??e
	MinWatchCard retour = new MinWatchCard(voc, ps, moreThan, mydegree);

	if (retour.degree <= 0)
		return null;

	retour.computeWatches();

	retour.computePropagation(s);

	return retour;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:47,代码来源:MinWatchCard.java

示例9: createUnregisteredClause

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public Constr createUnregisteredClause(IVecInt literals) {
	if (literals.size() == 1) {
		return new UnitClause(literals.last());
	}
	if (literals.size() == 2) {
		return new LearntBinaryClause(literals, getVocabulary());
	}
	return new LearntHTClause(literals, getVocabulary());
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:10,代码来源:MixedDataStructureDanielHT.java

示例10: propagationCheck

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
/**
 * Check if this clause is null or unit
 * 
 * @param p
 *            the list of literals (supposed to be clean as after a call to
 *            sanityCheck())
 * @param s
 *            the object responsible for unit propagation
 * @return true iff the clause should be ignored (because it's unit)
 * @throws ContradictionException
 *             when detected by unit propagation
 */
static boolean propagationCheck(IVecInt ps, UnitPropagationListener s)
		throws ContradictionException {
	if (ps.size() == 0) {
		throw new ContradictionException("Creating Empty clause ?"); //$NON-NLS-1$
	} else if (ps.size() == 1) {
		if (!s.enqueue(ps.get(0))) {
			throw new ContradictionException("Contradictory Unit Clauses"); //$NON-NLS-1$
		}
		return true;
	}

	return false;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:26,代码来源:Clauses.java

示例11: createClause

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public Constr createClause(IVecInt literals) throws ContradictionException {
	IVecInt v = Clauses.sanityCheck(literals, getVocabulary(), solver);
	if (v == null)
		return null;
	if (v.size() == 2) {
		return OriginalBinaryClause.brandNewClause(solver, getVocabulary(),
				v);
	}
	return OriginalWLClause.brandNewClause(solver, getVocabulary(), v);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:11,代码来源:MixedDataStructureDanielWL.java

示例12: dimacs2internal

import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
protected IVecInt dimacs2internal(IVecInt in) {
	__dimacs_out.clear();
	__dimacs_out.ensure(in.size());
	int p;
	for (int i = 0; i < in.size(); i++) {
		p = in.get(i);
		if (p == 0) {
			throw new IllegalArgumentException(
					"0 is not a valid variable identifier");
		}
		__dimacs_out.unsafePush(voc.getFromPool(p));
	}
	return __dimacs_out;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:15,代码来源:Solver.java

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

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

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


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