Package gnu.trove.list

Examples of gnu.trove.list.TIntList


     */
    public static boolean addBoolOrArrayEqVar(BoolVar[] BOOLVARS, BoolVar TARGET) {
        Solver solver = TARGET.getSolver();
        PropSat sat = solver.getMinisat().getPropSat();
        int target_lit = sat.Literal(TARGET);
        TIntList lits = new TIntArrayList(BOOLVARS.length + 1);
        for (int i = 0; i < BOOLVARS.length; i++) {
            lits.add(sat.Literal(BOOLVARS[i]));
        }
        lits.add(SatSolver.negated(target_lit));
        sat.addClause(lits);
        for (int i = 0; i < BOOLVARS.length; i++) {
            sat.addClause(target_lit, SatSolver.negated(sat.Literal(BOOLVARS[i])));
        }
        return true;
View Full Code Here


     */
    public static boolean addBoolAndArrayEqVar(BoolVar[] BOOLVARS, BoolVar TARGET) {
        Solver solver = TARGET.getSolver();
        PropSat sat = solver.getMinisat().getPropSat();
        int target_lit = sat.Literal(TARGET);
        TIntList lits = new TIntArrayList(BOOLVARS.length + 1);
        for (int i = 0; i < BOOLVARS.length; i++) {
            lits.add(SatSolver.negated(sat.Literal(BOOLVARS[i])));
        }
        lits.add(target_lit);
        sat.addClause(lits);
        for (int i = 0; i < BOOLVARS.length; i++) {
            sat.addClause(SatSolver.negated(target_lit), sat.Literal(BOOLVARS[i]));
        }
        return true;
View Full Code Here

     * @return true if the clause has been added to the clause store
     */
    public static boolean addBoolOrArrayEqualTrue(BoolVar[] BOOLVARS) {
        Solver solver = BOOLVARS[0].getSolver();
        PropSat sat = solver.getMinisat().getPropSat();
        TIntList lits = new TIntArrayList(BOOLVARS.length);
        for (int i = 0; i < BOOLVARS.length; i++) {
            lits.add(sat.Literal(BOOLVARS[i]));
        }
        sat.addClause(lits);
        return true;
    }
View Full Code Here

     * @return true if the clause has been added to the clause store
     */
    public static boolean addAtMostOne(BoolVar[] BOOLVARS) {
        Solver solver = BOOLVARS[0].getSolver();
        PropSat sat = solver.getMinisat().getPropSat();
        TIntList lits = new TIntArrayList(BOOLVARS.length);
        for (int i = 0; i < BOOLVARS.length; i++) {
            lits.add(SatSolver.negated(sat.Literal(BOOLVARS[i])));
        }
        for (int i = 0; i < lits.size() - 1; i++) {
            for (int j = i + 1; j < lits.size(); ++j) {
                sat.addClause(lits.get(i), lits.get(j));
            }
        }
        return true;
    }
View Full Code Here

     * @return true if the clause has been added to the clause store
     */
    public static boolean addAtMostNMinusOne(BoolVar[] BOOLVARS) {
        Solver solver = BOOLVARS[0].getSolver();
        PropSat sat = solver.getMinisat().getPropSat();
        TIntList lits = new TIntArrayList(BOOLVARS.length);
        for (int i = 0; i < BOOLVARS.length; i++) {
            lits.add(SatSolver.negated(sat.Literal(BOOLVARS[i])));
        }
        sat.addClause(lits);
        return true;
    }
View Full Code Here

     * @return true if the clause has been added to the clause store
     */
    public static boolean addSumBoolArrayGreaterEqVar(BoolVar[] BOOLVARS, BoolVar TARGET) {
        Solver solver = BOOLVARS[0].getSolver();
        PropSat sat = solver.getMinisat().getPropSat();
        TIntList lits = new TIntArrayList(BOOLVARS.length + 1);
        for (int i = 0; i < BOOLVARS.length; ++i) {
            lits.add(sat.Literal(BOOLVARS[i]));
        }
        lits.add(SatSolver.negated(sat.Literal(TARGET)));
        sat.addClause(lits);
        return true;
    }
View Full Code Here

        }

        BoolVar extra = VF.bool(StringUtils.randomName(), solver);
        int tlit = sat.Literal(TARGET);
        int elit = sat.Literal(extra);
        TIntList lits = new TIntArrayList(BOOLVARS.length + 1);
        for (int i = 0; i < BOOLVARS.length; ++i) {
            lits.add(sat.Literal(BOOLVARS[i]));
        }
        lits.add(SatSolver.negated(elit));
        sat.addClause(lits);
        for (int i = 0; i < BOOLVARS.length; ++i) {
            sat.addClause(elit, SatSolver.negated(sat.Literal(BOOLVARS[i])));
        }
        sat.addClause(SatSolver.negated(elit), tlit);
View Full Code Here

    }

    protected int[][] readVAR(String filename) {
        FileReader f;
        String line;
        TIntList values = new TIntArrayList();
        try {
            f = new FileReader(filename);
            BufferedReader r = new BufferedReader(f);
            List<int[]> ints = new ArrayList<int[]>();
            while ((line = r.readLine()) != null) {
                Scanner sc = new Scanner(line);
                while (sc.hasNextInt()) {
                    values.add(sc.nextInt());
                }
                ints.add(values.toArray());
                values.clear();
            }
            int[][] data = new int[ints.size()][];
            for (int i = 0; i < ints.size(); i++) {
                data[i] = ints.get(i);
            }
View Full Code Here


    protected int[][] readCTR(String filename) {
        FileReader f;
        String line;
        TIntList values = new TIntArrayList();
        try {
            f = new FileReader(filename);
            BufferedReader r = new BufferedReader(f);
            List<int[]> ints = new ArrayList<int[]>();
            while ((line = r.readLine()) != null) {
                Scanner sc = new Scanner(line);
                values.add(sc.nextInt());
                values.add(sc.nextInt());
                sc.next();
                values.add(sc.next().equals("=") ? 0 : 1);
                values.add(sc.nextInt());
                ints.add(values.toArray());
                values.clear();
            }
            int[][] data = new int[ints.size()][];
            for (int i = 0; i < ints.size(); i++) {
                data[i] = ints.get(i);
            }
View Full Code Here

            uncheckedEnqueue(ps.get(0));
            return (ok_ = propagate());
            case 2:
                int l0 = ps.get(0);
                int l1 = ps.get(1);
                TIntList i0 = implies_.get(negated(l0));
                if (i0 == null) {
                    i0 = new TIntArrayList();
                    implies_.put(negated(l0), i0);
                }
                i0.add(l1);

                TIntList i1 = implies_.get(negated(l1));
                if (i1 == null) {
                    i1 = new TIntArrayList();
                    implies_.put(negated(l1), i1);
                }
                i1.add(l0);
                break;
            default:
            Clause cr = new Clause(ps.toArray());
            clauses.add(cr);
            attachClause(cr);
View Full Code Here

TOP

Related Classes of gnu.trove.list.TIntList

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.