Package solver.variables

Examples of solver.variables.IntVar


        for (int i = 0; i < data.prefPerPeople(); i++) {
            int pa = data.preferences()[(2 * i)];
            int pb = data.preferences()[2 * i + 1];


      IntVar k = VariableFactory.bounded(StringUtils.randomName(),-20000,20000,solver);
      solver.post(IntConstraintFactory.sum(new IntVar[]{positions[pb], k}, positions[pa]));
      dist[i] = VariableFactory.abs(k);

            solver.post(
                    ifThenElse(viols[i],
View Full Code Here


                for (int i = 0; i < size; i++) {
                    this.vars[i].duplicate(solver, identitymap);
                    aVars[i] = (IntVar) identitymap.get(this.vars[i]);
                }
                this.vars[size].duplicate(solver, identitymap);
                IntVar M = (IntVar) identitymap.get(this.vars[size]);
                identitymap.put(this, new PropMin(aVars, M));
            }
    }
View Full Code Here

    public void propagate(int evtmask) throws ContradictionException {
        if (PropagatorEventType.isFullPropagation(evtmask)) {
            poss.clear();
            int nbMandForSure = 0;
            for (int i = 0; i < nb_vars; i++) {
                IntVar var = vars[i];
                int nb = 0;
                for (int j : values) {
                    if (var.contains(j)) {
                        nb++;
                    }
                }
                if (nb == var.getDomainSize()) {
                    nbMandForSure++;
                } else if (nb > 0) {
                    poss.add(i);
                }
            }
View Full Code Here

    @Override
    public ESat isEntailed() {
        BitSet values = new BitSet(n2);
        BitSet mandatoryValues = new BitSet(n2);
        IntVar v;
        int ub;
        for (int i = 0; i < n; i++) {
            v = vars[i];
            ub = v.getUB();
            if (v.isInstantiated()) {
                mandatoryValues.set(map.get(ub));
            }
            for (int j = v.getLB(); j <= ub; j++) {
                values.set(map.get(j));
            }
        }
        if (mandatoryValues.cardinality() >= vars[n].getUB()) {
            return ESat.TRUE;
View Full Code Here

    public void propagate(int vidx, int evtmask) throws ContradictionException {
        if (vidx == nb_vars) {
            forcePropagate(PropagatorEventType.CUSTOM_PROPAGATION);
        } else {
            if (poss.contain(vidx)) {
                IntVar var = vars[vidx];
                int nb = 0;
                for (int j : values) {
                    if (var.contains(j)) {
                        nb++;
                    }
                }
                if (nb == var.getDomainSize()) {
                    nbSure.add(1);
                    poss.remove(vidx);
                    vars[nb_vars].updateLowerBound(nbSure.get(), aCause);
                } else if (nb == 0) {
                    poss.remove(vidx);
View Full Code Here

                    mandatories[i].clear();
                    possibles[i].clear();
                    valueToCompute.add(i);
                }
                for (int i = 0; i < n; i++) {
                    IntVar v = vars[i];
                    int ub = v.getUB();
                    if (v.isInstantiated()) {
                        if (map.containsKey(v.getValue())) {
                            int j = map.get(v.getValue());
                            mandatories[j].add(i);
                        }
                    } else {
                        for (int k = v.getLB(); k <= ub; k = v.nextValue(k)) {
                            if (map.containsKey(k)) {
                                int j = map.get(k);
                                possibles[j].add(i);
                            }
                        }
View Full Code Here

            for (int i = 0; i < size; i++) {
                this.vars[i].duplicate(solver, identitymap);
                aVars[i] = (IntVar) identitymap.get(this.vars[i]);
            }
            this.vars[size].duplicate(solver, identitymap);
            IntVar aVar = (IntVar) identitymap.get(this.vars[size]);
            identitymap.put(this, new PropAtLeastNValues_AC(aVars, aVar));
        }
    }
View Full Code Here

    @Override
    public void propagate(int idxVarInProp, int mask) throws ContradictionException {
        hasChanged.clear();
        hasChanged.addLast(vars[idxVarInProp]);
        while (!hasChanged.isEmpty()) {
            IntVar var = hasChanged.pollFirst();
            TIntList nogoods = vars2nogood.get(var.getId());
            TIntList indices = vars2idxinng.get(var.getId());
            for (int i = 0; i < nogoods.size(); i++) {
                INogood ng = allnogoods.get(nogoods.get(i));
                int idx = ng.awakeOnInst(indices.get(i), this);
                if (idx > -1) {
                    hasChanged.addLast(ng.getVar(idx));
View Full Code Here

        }
    }

    protected void backPropRemPoss() throws ContradictionException {
        for (int i = poss.getFirstElement(); i >= 0; i = poss.getNextElement()) {
            IntVar v = vars[i];
            if (v.hasEnumeratedDomain()) {
                for (int value : values) {
                    v.removeValue(value, this);
                }
                poss.remove(i);
            } else {
                int newLB = v.getLB();
                int newUB = v.getUB();
                for (int val = v.getLB(); val <= newUB; val = v.nextValue(val)) {
                    if (setValues.contains(val)) {
                        newLB = val + 1;
                    } else {
                        break;
                    }
                }
                for (int val = newUB; val >= newLB; val = v.previousValue(val)) {
                    if (setValues.contains(val)) {
                        newUB = val - 1;
                    } else {
                        break;
                    }
                }
                v.updateLowerBound(newLB, this);
                v.updateUpperBound(newUB, this);
                if (newLB > values[values.length - 1] || newUB < values[0]) {
                    poss.remove(i);
                }
            }
        }
View Full Code Here

    public void explain(Deduction d, Explanation e) {
        e.add(solver.getExplainer().getPropagatorActivation(this));
        e.add(this);
        if (d != null && d.getmType() == Deduction.Type.ValRem) {
            ValueRemoval vr = (ValueRemoval) d;
            IntVar var = (IntVar) vr.getVar();
            int val = vr.getVal();
            TIntList nogoods = vars2nogood.get(var.getId());
            TIntList indices = vars2idxinng.get(var.getId());
            for (int i = 0; i < nogoods.size(); i++) {
                INogood ng = allnogoods.get(nogoods.get(i));
                int idx = indices.get(i);
                if (val == ng.getVal(idx)) {
                    for (int j = 0; j < ng.size(); j++) {
View Full Code Here

TOP

Related Classes of solver.variables.IntVar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.