• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IteratorInt类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



IteratorInt类属于org.sat4j.specs包,在下文中一共展示了IteratorInt类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addClause

import org.sat4j.specs.IteratorInt; //导入依赖的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;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:20,代码来源:DimacsStringSolver.java


示例2: knownValues

import org.sat4j.specs.IteratorInt; //导入依赖的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;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:17,代码来源:SatSolver.java


示例3: compute

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
public IVecInt compute(ISolver solver, int[] implicant,
        IVecInt assumptions, IVecInt filter) throws TimeoutException {
    nbSatTests = 0;
    BitSet assumptionsSet = new BitSet(solver.nVars());
    for (IteratorInt it = assumptions.iterator(); it.hasNext();) {
        assumptionsSet.set(Math.abs(it.next()));
    }
    BitSet filterSet = new BitSet();
    for (IteratorInt it = filter.iterator(); it.hasNext();) {
        filterSet.set(Math.abs(it.next()));
    }
    IVecInt litsToTest = new VecInt();
    for (int p : implicant) {
        if (!assumptionsSet.get(Math.abs(p))
                && filterSet.get(Math.abs(p))) {
            litsToTest.push(-p);
        }
    }
    return compute(solver, assumptions, litsToTest);
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:21,代码来源:Backbone.java


示例4: addClause

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
public IConstr addClause(IVecInt literals) throws ContradictionException {
    if (this.firstConstr) {
        if (!this.fixedNbClauses) {
            this.firstCharPos = 0;
            this.out.append("                    ");
            this.out.append("\n");
            this.nbclauses = 0;
        }
        this.firstConstr = false;
    }
    if (!this.fixedNbClauses) {
        this.nbclauses++;
    }
    for (IteratorInt iterator = literals.iterator(); iterator.hasNext();) {
        this.out.append(iterator.next()).append(" ");
    }
    this.out.append("0\n");
    return null;
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:20,代码来源:DimacsStringSolver.java


示例5: unsatExplanation

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
@Override
public IVecInt unsatExplanation() {
    IVecInt internal = super.unsatExplanation();
    IVecInt external = new VecInt(internal.size());
    int p;
    Integer group;
    for (IteratorInt it = internal.iterator(); it.hasNext();) {
        p = it.next();
        if (p > 0) {
            group = varToHighLevel.get(p);
        } else {
            Integer negGroup = varToHighLevel.get(-p);
            group = (negGroup == null) ? (null) : (-negGroup);
        }
        if (group != null) {
            external.push(group);
        }
    }
    return external;
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:21,代码来源:GroupClauseSelectorSolver.java


示例6: iterator

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
public IteratorInt iterator() {
    return new IteratorInt() {
        private int i = 0;

        public boolean hasNext() {
            return this.i < VecInt.this.nbelem;
        }

        public int next() {
            if (this.i == VecInt.this.nbelem) {
                throw new NoSuchElementException();
            }
            return VecInt.this.myarray[this.i++];
        }
    };
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:17,代码来源:VecInt.java


示例7: createSumAndLexObjs

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
private void createSumAndLexObjs() {
    IVecInt auxObjsVars = new VecInt();
    IVec<BigInteger> sumObjCoeffs = new Vec<BigInteger>();
    IVec<BigInteger> lexObjCoeffs = new Vec<BigInteger>();
    BigInteger lexFactor = BigInteger.ONE;
    for (Iterator<IntegerVariable> intVarIt = objBoundVariables.iterator(); intVarIt
            .hasNext();) {
        BigInteger sumFactor = BigInteger.ONE;
        IntegerVariable nextBoundVar = intVarIt.next();
        for (IteratorInt nextBoundVarLitsIt = nextBoundVar.getVars()
                .iterator(); nextBoundVarLitsIt.hasNext();) {
            auxObjsVars.push(nextBoundVarLitsIt.next());
            sumObjCoeffs.push(sumFactor);
            sumFactor = sumFactor.shiftLeft(1);
            lexObjCoeffs.push(lexFactor);
            lexFactor = lexFactor.shiftLeft(1);
        }
    }
    this.sumObj = new ObjectiveFunction(auxObjsVars, sumObjCoeffs);
    this.lexObj = new ObjectiveFunction(auxObjsVars, lexObjCoeffs);
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:22,代码来源:SumLeximinDecompositionOWAOptimizer.java


示例8: addAtLeast

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
public IConstr addAtLeast(IVecInt literals, IVecInt coeffs, int degree,
        int groupId) throws ContradictionException {
    int newvar = getGroupVar(literals, groupId);
    literals.push(newvar);
    if (degree >= 0) {
        coeffs.push(degree);
    } else {
        int sum = 0;
        for (IteratorInt ite = coeffs.iterator(); ite.hasNext();) {
            sum = sum + ite.next();
        }
        sum = sum - degree;
        coeffs.push(-sum);
    }
    return decorated().addAtLeast(literals, coeffs, degree);
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:17,代码来源:GroupPBSelectorSolver.java


示例9: addClause

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
@Override
public IConstr addClause(IVecInt literals) throws ContradictionException {
    StringBuffer out = getOut();
    this.nbOfConstraints++;
    int negationweight = 0;
    int lit;
    for (IteratorInt iterator = literals.iterator(); iterator.hasNext();) {
        lit = iterator.next();
        if (lit > 0) {
            out.append("+1 x" + lit + " ");
        } else {
            out.append("-1 x" + -lit + " ");
            negationweight++;
        }
    }
    out.append(">= " + (1 - negationweight) + " ;\n");
    return FAKE_CONSTR;
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:19,代码来源:OPBStringSolver.java


示例10: init

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
public void init() {
    if (getObjectiveFunction() != null) {
        this.objWeightsMap = new HashMap<Integer, BigInteger>();
        IteratorInt litsIt = getObjectiveFunction().getVars().iterator();
        Iterator<BigInteger> weightsIt = getObjectiveFunction().getCoeffs()
                .iterator();
        for (; litsIt.hasNext();)
            this.objWeightsMap.put(litsIt.next(), weightsIt.next());
    }
    if (this.preprocessing) {
        sat4jPreprocessing();
    } else if (this.rissLocation != null) {
        rissPreprocessing();
    } else {
        noPreprocessing();
    }
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:18,代码来源:PreprocCardConstrLearningSolver.java


示例11: updateObjMinBound

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
private void updateObjMinBound(AtLeastCard card) {
    AtMostCard atMost = card.toAtMost();
    if (this.objWeightsMap == null)
        return;
    List<BigInteger> weights = new ArrayList<BigInteger>();
    for (IteratorInt it = atMost.getLits().iterator(); it.hasNext();) {
        BigInteger weight = this.objWeightsMap.get(-it.next());
        if (weight != null)
            weights.add(weight);
    }
    Collections.sort(weights);
    BigInteger newMinBound = BigInteger.ZERO;
    for (int i = 0; i < weights.size() - atMost.getDegree(); ++i) {
        newMinBound = newMinBound.add(weights.get(i));
    }
    if (this.objMinBound == null
            || this.objMinBound.compareTo(newMinBound) == -1)
        this.objMinBound = newMinBound;
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:20,代码来源:PreprocCardConstrLearningSolver.java


示例12: addPseudoBoolean

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
private IConstr addPseudoBoolean(IVecInt lits, IVecInt coeffs,
        boolean moreThan, int d) throws ContradictionException {
    int newvar = createNewVar(lits);
    lits.push(newvar);
    if (moreThan && d >= 0) {
        coeffs.push(d);
    } else {
        int sum = 0;
        for (IteratorInt ite = coeffs.iterator(); ite.hasNext();) {
            sum += ite.next();
        }
        sum = sum - d;
        coeffs.push(-sum);
    }
    IConstr constr = moreThan ? decorated().addAtLeast(lits, coeffs, d)
            : decorated().addAtMost(lits, coeffs, d);
    if (constr == null) {
        // constraint trivially satisfied
        discardLastestVar();
        // System.err.println(lits.toString()+"/"+coeffs+"/"+(moreThan?">=":"<=")+d);
    } else {
        getConstrs().put(newvar, constr);
    }
    return constr;
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:26,代码来源:XplainPB.java


示例13: addAtLeast

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
public IConstr addAtLeast(IVecInt literals, IVecInt coeffs, int degree)
        throws ContradictionException {
    assertConstraintIsCard(coeffs);
    Set<Integer> negLitsSet = new HashSet<Integer>(literals.size());
    for (IteratorInt it = literals.iterator(); it.hasNext();)
        negLitsSet.add(-it.next());
    int clausesDegree = literals.size() - degree + 1;
    ConstrGroup group = new ConstrGroup(false);
    CombinationIterator combIt = new CombinationIterator(literals.size()
            - degree, negLitsSet);
    for (Set<Integer> comb : combIt) {
        for (IteratorInt it = literals.iterator(); it.hasNext();) {
            int lit = it.next();
            if (!comb.contains(-lit)) {
                IVecInt clause = new VecInt(clausesDegree);
                clause.push(lit);
                for (Integer negLit : comb) {
                    clause.push(-negLit);
                }
                group.add(addClause(clause));
            }
        }
    }
    return group;
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:26,代码来源:PBAdapter.java


示例14: equals

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    AtLeastCard other = (AtLeastCard) obj;
    if (degree != other.degree)
        return false;
    if (lits == null) {
        if (other.lits != null)
            return false;
    }
    Set<Integer> litsSet1 = new HashSet<Integer>();
    for (IteratorInt it = lits.iterator(); it.hasNext();)
        litsSet1.add(it.next());
    Set<Integer> litsSet2 = new HashSet<Integer>();
    for (IteratorInt it = other.lits.iterator(); it.hasNext();)
        litsSet2.add(it.next());
    if (!litsSet1.equals(litsSet2))
        return false;
    return true;
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:26,代码来源:AtLeastCard.java


示例15: impliedBy

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
/**
 * Compute the objects implied by the assumptions.
 * 
 * @param assumptions
 *            already satisfied objects (e.g. user choices)
 * @param satisfied
 *            the objects that are always satisfied under assumptions
 *            (includes the objects from assumptions)
 * @param falsified
 *            the objects that are always falsified under assumptions.
 * @return the set of objects fixed
 * @throws TimeoutException
 * @since 2.3.3
 */
public void impliedBy(Collection<T> assumptions, Collection<T> satisfied,
        Collection<T> falsified) throws TimeoutException {
    IVecInt assump = new VecInt(assumptions.size());
    for (T thing : assumptions) {
        assump.push(getIntValue(thing));
    }
    IVecInt implied = Backbone.instance().compute(solver, assump);
    int p;
    for (IteratorInt it = implied.iterator(); it.hasNext();) {
        p = it.next();
        if (p > 0) {
            satisfied.add(mapToDomain.get(p));
        } else {
            falsified.add(mapToDomain.get(-p));
        }
    }
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:32,代码来源:DependencyHelper.java


示例16: implies

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
public ImplicationNamer<T, C> implies(T... things)
        throws ContradictionException {
    IVecInt clause = new VecInt();
    for (T t : things) {
        clause.push(this.helper.getIntValue(t));
    }
    int p;
    IConstr constr;
    for (IteratorInt it = this.literals.iterator(); it.hasNext();) {
        p = it.next();
        clause.push(p);
        constr = this.helper.solver.addClause(clause);
        if (constr == null) {
            throw new IllegalStateException(
                    "Constraints are not supposed to be null when using the helper");
        }
        this.toName.push(constr);
        clause.remove(p);
    }
    return new ImplicationNamer<T, C>(this.helper, this.toName);
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:22,代码来源:DisjunctionRHS.java


示例17: pushIntegerVariables

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
private void pushIntegerVariables(IVecInt literals,
        IVec<BigInteger> coeffs, IVec<IntegerVariable> integerVars,
        IVec<BigInteger> integerVarsCoeffs) {
    if (integerVars.size() != integerVarsCoeffs.size()) {
        throw new IllegalArgumentException(
                "different number of integer variables and integer variables coeffs");
    }
    Iterator<IntegerVariable> intVarsIt = integerVars.iterator();
    Iterator<BigInteger> intVarsCoeffsIt = integerVarsCoeffs.iterator();
    while (intVarsIt.hasNext()) {
        BigInteger factor = intVarsCoeffsIt.next();
        IteratorInt intVarLitsIt = intVarsIt.next().getVars().iterator();
        while (intVarLitsIt.hasNext()) {
            literals.push(intVarLitsIt.next());
            coeffs.push(factor);
            factor = factor.shiftLeft(1);
        }
    }
}
 
开发者ID:TakehideSoh,项目名称:Scarab,代码行数:20,代码来源:IntegerPBSolverDecorator.java


示例18: iterator

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
public IteratorInt iterator() {
	return new IteratorInt() {
		int cursor = 0;

		public boolean hasNext() {
			return cursor < vec.length;
		}

		public int next() {
			if (!hasNext())
				throw new NoSuchElementException();
			return vec[cursor++];
		}
	};
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:16,代码来源:SAT4J.java


示例19: iterator

import org.sat4j.specs.IteratorInt; //导入依赖的package包/类
public IteratorInt iterator() {
	return new IteratorInt() {
		int cursor = 0;
		public boolean hasNext() {
			return cursor < vec.length;
		}
		public int next() {
			if (!hasNext()) 
				throw new NoSuchElementException();
			return vec[cursor++];
		}
	};
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:14,代码来源:SAT4J.java


示例20: addAtMost

import org.sat4j.specs.IteratorInt; //导入依赖的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);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:10,代码来源:Solver.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EdmPrimitiveType类代码示例发布时间:2022-05-23
下一篇:
Java Mouse类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap