Package solver.variables

Examples of solver.variables.IntVar


            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 PropKLoops(aVars, this.offSet, aVar));
        }
    }
View Full Code Here


            for (int i = 0; i < size; i++) {
                sets[i].duplicate(solver, identitymap);
                svars[i] = (SetVar) identitymap.get(sets[i]);
            }
            nbEmpty.duplicate(solver, identitymap);
            IntVar C = (IntVar) identitymap.get(nbEmpty);

            identitymap.put(this, new PropNbEmpty(svars, C));
        }
    }
View Full Code Here

    }

    @SuppressWarnings({"unchecked"})
    @Override
    public Decision getDecision() {
        IntVar variable = variableSelector.getVariable(vars);
        return computeDecision(variable);
    }
View Full Code Here

        if (!identitymap.containsKey(this)) {
            set.duplicate(solver, identitymap);
            SetVar S = (SetVar) identitymap.get(set);

            min.duplicate(solver, identitymap);
            IntVar M = (IntVar) identitymap.get(min);

            identitymap.put(this, new PropMinElement(S, M, notEmpty));
        }
    }
View Full Code Here

            }
            set.duplicate(solver, identitymap);
            SetVar S = (SetVar) identitymap.get(set);

            index.duplicate(solver, identitymap);
            IntVar I = (IntVar) identitymap.get(index);

            identitymap.put(this, new PropElement(I, aVars, offSet, S));
        }
    }
View Full Code Here

    @Override
    public void duplicate(Solver solver, THashMap<Object, Object> identitymap) {
        if (!identitymap.containsKey(this)) {
            this.vars[0].duplicate(solver, identitymap);
            IntVar X = (IntVar) identitymap.get(this.vars[0]);
            this.vars[1].duplicate(solver, identitymap);
            IntVar Y = (IntVar) identitymap.get(this.vars[1]);

            identitymap.put(this, new PropEqualX_YC(new IntVar[]{X, Y}, this.cste));
        }
    }
View Full Code Here

        /*
        IntVar b1 = solver.makeIsGreaterCstVar(
                        solver.makeElement(rankMen[m], wife[m]).var(),
                        rankMen[m][o]);
        */
                IntVar v1 = enumerated("v1", 0, n - 1, solver);
                solver.post(element(v1, rankMen[m], wife[m], 0, "detect"));

                BoolVar b1 = bool("b1", solver);
                solver.post(LogicalConstraintFactory.ifThenElse(b1,
                        arithm(v1, ">", rankMen[m][o]),
                        arithm(v1, "<=", rankMen[m][o])
                ));


        /*
        IntVar b2 = solver.makeIsLessCstVar(
                        solver.makeElement(rankWomen[o], husband[o]).var(),
                        rankWomen[o][m]);
        */
                IntVar v2 = enumerated("v2", 0, n - 1, solver);
                solver.post(element(v2, rankWomen[o], husband[o], 0, "detect"));

                BoolVar b2 = bool("b2", solver);
                solver.post(LogicalConstraintFactory.ifThenElse(b2,
                        arithm(v2, "<", rankWomen[o][m]),
                        arithm(v2, ">=", rankWomen[o][m])
                ));


                   
        /*
        solver.addConstraint(
            solver.makeLessOrEqual(
                solver.makeDifference(b1, b2), 0));
        */

                // b1 -> b2
                LogOp t = LogOp.implies(b1, b2);
                SatFactory.addClauses(t, solver);

                // solver.post(IntConstraintFactory.arithm(b1, "<=", b2));


            }
        }

        //   forall(w in Women, o in Men)
        //      cp.post(rankWomen[w,o] < rankWomen[w,husband[w]] =>
        //              rankMen[o,wife[o]] < rankMen[o,w]);
        for (int w = 0; w < n; w++) {
            for (int o = 0; o < n; o++) {
        /*
        IntVar b1 = solver.makeIsGreaterCstVar(
                        solver.makeElement(rankWomen[w], husband[w]).var(),
                        rankWomen[w][o]);
        */
                IntVar v1 = enumerated("v1", 0, n - 1, solver);
                solver.post(element(v1, rankWomen[w], husband[w], 0, "detect"));

                BoolVar b1 = bool("b1", solver);
                solver.post(LogicalConstraintFactory.ifThenElse(b1,
                        arithm(v1, ">", rankWomen[w][o]),
                        arithm(v1, "<=", rankWomen[w][o])
                ));


        /*
        IntVar b2 = solver.makeIsLessCstVar(
                        solver.makeElement(rankMen[o], wife[o]).var(),
                        rankMen[o][w]);
        */
                IntVar v2 = enumerated("v2", 0, n - 1, solver);
                solver.post(element(v2, rankMen[o], wife[o], 0, "detect"));

                BoolVar b2 = bool("b2", solver);
                solver.post(LogicalConstraintFactory.ifThenElse(b2,
                        arithm(v2, "<", rankMen[o][w]),
View Full Code Here

    @Override
    public void duplicate(Solver solver, THashMap<Object, Object> identitymap) {
        if (!identitymap.containsKey(this)) {
            this.vars[0].duplicate(solver, identitymap);
            IntVar X = (IntVar) identitymap.get(this.vars[0]);
            this.vars[1].duplicate(solver, identitymap);
            IntVar Y = (IntVar) identitymap.get(this.vars[1]);

            identitymap.put(this, new PropBinAC2001(X, Y, (CouplesTable) relation.duplicate()));
        }
    }
View Full Code Here

            return a;
        } else if (b.getLB() >= a.getUB()) {
            return b;
        } else {
            Solver solver = a.getSolver();
            IntVar z = new IntervalIntVarImpl(StringUtils.randomName(),
                    Math.max(a.getLB(), b.getLB()), Math.max(a.getUB(), b.getUB()), solver);
            solver.post(IntConstraintFactory.maximum(z, a, b));
            return z;
        }
    }
View Full Code Here

    vectors = new IntVar[(n*(n-1))/2];
    IntVar[][] diff = new IntVar[n][n];
    int idx = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i+1; j < n; j++) {
        IntVar k = VariableFactory.enumerated(StringUtils.randomName(), -n, n, solver);
        solver.post(ICF.arithm(k,"!=",0));
        solver.post(IntConstraintFactory.sum(new IntVar[]{vars[i],k},vars[j]));
        vectors[idx] = VariableFactory.offset(k, 2 * n * (j - i));
        diff[i][j] = k;
        idx++;
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.