Package solver.variables

Examples of solver.variables.BoolVar


    @Override
    public void propagate(int evtmask) throws ContradictionException {
    sat_.initPropagator();
    applyEarlyDeductions();
    for (int i = 0; i < vars.length; ++i) {
      BoolVar var = vars[i];
      if (var.isInstantiated()) {
        VariableBound(i);
      }
        }
    }
View Full Code Here


     */
    private void setWatchLiteral(int otherWL) throws ContradictionException {
        int i = 0;
        int cnt = 0;

        BoolVar bv;
        for (; i < nbvars; i++) {
            bv = vars[i];
            if (bv.isInstantiated()) {
                if (bv.getValue() == 1) {
                    setPassive();
                    return;
                } else {
                    cnt++;
                }
View Full Code Here

        } else {
            // search for watch literals and check the clause
            int n = vars.length;
            int i = 0, wl = 0, cnt = 0;
            while (i < n && wl < 2) {
                BoolVar bv = vars[i];
                if (bv.isInstantiated()) {
                    if (bv.getValue() == 1) {
                        setPassive();
                        return;
                    } else {
                        cnt++;
                    }
View Full Code Here

        }
        List<BoolVar> booleans = new ArrayList<BoolVar>();
        //disjunctive
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                BoolVar boolVar = VariableFactory.bool("b_" + i + "_" + j, solver);
                booleans.add(boolVar);

                Constraint c1 = precedence(planes[i], data[i][ST + j], planes[j]);
                Constraint c2 = precedence(planes[j], data[j][ST + i], planes[i]);
                Constraint cr = LogicalConstraintFactory.ifThenElse(boolVar, c1, c2);
View Full Code Here

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

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

        }
        List<BoolVar> booleans = new ArrayList<BoolVar>();
        //disjunctive
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                BoolVar boolVar = VariableFactory.bool("b_" + i + "_" + j, solver);
                booleans.add(boolVar);

                Constraint c1 = precedence(planes[i], data[i][ST + j], planes[j]);
                Constraint c2 = precedence(planes[j], data[j][ST + i], planes[i]);
                Constraint cr = LogicalConstraintFactory.ifThenElse(boolVar, c1, c2);
View Full Code Here

    @Override
    public void duplicate(Solver solver, THashMap<Object, Object> identitymap) {
        if (!identitymap.containsKey(this)) {
            this.bool.duplicate(solver, identitymap);
            BoolVar bool = (BoolVar) identitymap.get(this.bool);

            this.bool.not().duplicate(solver, identitymap);
            BoolVar notbool = (BoolVar) identitymap.get(this.bool.not());

            this.trueCons.duplicate(solver, identitymap);
            Constraint trueCons = (Constraint) identitymap.get(this.trueCons);
            trueCons.boolReif = bool;
View Full Code Here

                _vars[k] = vars[j];
                _durs[k] = 1;
            }
            for (int l = 0; l < _vars.length - 1; l++) {
                for (int m = l + 1; m < _vars.length; m++) {
                    BoolVar bvar = VariableFactory.bool("b" + l + "_" + m, solver);
                    lbvars.add(bvar);
                    Constraint c1 = LogicalConstraintFactory.ifThenElse(bvar, precedence(_vars[l], _durs[l], _vars[m]), precedence(_vars[m], _durs[m], _vars[l]));
                    solver.post(c1);
                }
            }
View Full Code Here

                        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]),
                        arithm(v2, ">=", rankMen[o][w])
                ));

View Full Code Here

TOP

Related Classes of solver.variables.BoolVar

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.