本文整理汇总了Java中org.sat4j.specs.IVecInt.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java IVecInt.iterator方法的具体用法?Java IVecInt.iterator怎么用?Java IVecInt.iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sat4j.specs.IVecInt
的用法示例。
在下文中一共展示了IVecInt.iterator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addClause
import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public IConstr addClause(IVecInt literals) throws ContradictionException {
if (firstConstr) {
if (!fixedNbClauses) {
firstCharPos = 7 + Integer.toString(nbvars).length();
out.append(" ");
out.append("\n");
nbclauses = 0;
}
firstConstr = false;
}
if (!fixedNbClauses) {
nbclauses++;
}
for (IteratorInt iterator = literals.iterator(); iterator.hasNext();) {
out.append(iterator.next()).append(" ");
}
out.append("0\n");
return null;
}
示例2: knownValues
import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public List<Literal> knownValues() {
LinkedList<Literal> list = new LinkedList<Literal>();
try {
IVecInt bone = RemiUtils.backbone(solver);
IteratorInt iter = bone.iterator();
while (iter.hasNext()) {
int value = iter.next();
Object var = intToVar.get(Math.abs(value));
Literal literal = new Literal(var, value > 0);
list.add(literal);
}
} catch (TimeoutException e) {
e.printStackTrace();
}
return list;
}
示例3: addAtMost
import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public IConstr addAtMost(IVecInt literals, int degree)
throws ContradictionException {
int n = literals.size();
IVecInt opliterals = new VecInt(n);
for (IteratorInt iterator = literals.iterator(); iterator.hasNext();) {
opliterals.push(-iterator.next());
}
return addAtLeast(opliterals, n - degree);
}
示例4: 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;
}
示例5: 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;
}
示例6: explain
import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
/**
* @since 2.1
* @return
* @throws TimeoutException
*/
public Collection<IConstr> explain() throws TimeoutException {
IVecInt keys = explanationKeys();
Collection<IConstr> explanation = new ArrayList<IConstr>(keys.size());
for (IteratorInt it = keys.iterator(); it.hasNext();) {
explanation.add(constrs.get(it.next()));
}
return explanation;
}
示例7: explain
import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
/**
* @since 2.1
* @return
* @throws TimeoutException
*/
public Collection<Integer> explain() throws TimeoutException {
IVecInt keys = explanationKeys();
Collection<Integer> explanation = new HashSet<Integer>(keys.size());
for (IteratorInt it = keys.iterator(); it.hasNext();) {
explanation.add(constrs.get(it.next()));
}
return explanation;
}
示例8: addClause
import org.sat4j.specs.IVecInt; //导入方法依赖的package包/类
public IConstr addClause(IVecInt literals) throws ContradictionException {
if (firstConstr) {
if (!fixedNbClauses) {
out.println(" XXXXXX");
}
firstConstr = false;
}
for (IteratorInt iterator = literals.iterator(); iterator.hasNext();) {
out.print(iterator.next() + " ");
}
out.println("0");
return null;
}
示例9: 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;
}