Examples of VecInt


Examples of org.sat4j.core.VecInt

    /** lit les clauses et les ajoute dans le vecteur donn? en param?tre
     * @throws ParseFormatException */
    private void ajouterClauses(char car) throws IOException,
            ContradictionException, ParseFormatException {
        final IVecInt lit = new VecInt();
        int val = 0;
        boolean neg = false;
        for (;;) {
            /* on lit le signe du literal */
            if (car == '-') {
                neg = true;
                car = (char) in.read();
            } else if (car == '+')
                car = (char) in.read();
            else /* on le 1er chiffre du literal */
            if (car >= '0' && car <= '9') {
                val = car - '0';
                car = (char) in.read();
            } else
                throw new ParseFormatException("Unknown character "+car);
            /* on lit la suite du literal */
            while (car >= '0' && car <= '9') {
                val = (val * 10) + car - '0';
                car = (char) in.read();
            }
            if (val == 0) { // on a lu toute la clause
                s.addClause(lit);
                lit.clear();
            } else {
                /* on ajoute le literal au vecteur */
                // s.newVar(val-1);
                lit.push(neg ? -val : val);
                neg = false;
                val = 0; /* on reinitialise les variables */
            }
            if (car != EOF)
                car = passerEspaces();
            if (car == EOF) {
              if (!lit.isEmpty()) {
                s.addClause(lit);
              }
                break; /* on a lu tout le fichier */
            }
        }
View Full Code Here

Examples of org.sat4j.core.VecInt

        this.solver = solver;
    }

    protected boolean handleConstr(int gateType, int output, int[] inputs)
            throws ContradictionException {
        IVecInt literals = new VecInt(inputs);
        solver.addClause(literals);
        return true;
    }
View Full Code Here

Examples of org.sat4j.core.VecInt

        for (int i = 2; i < marks.length; i++)
            resetMark(i);
    }

    public IVecInt getMarkedLiterals() {
        IVecInt marked = new VecInt();
        for (int i = 2; i < marks.length; i++) {
            if (isMarked(i))
                marked.push(i);
        }
        return marked;
    }
View Full Code Here

Examples of org.sat4j.core.VecInt

        }
        return marked;
    }

    public IVecInt getMarkedLiterals(int mark) {
        IVecInt marked = new VecInt();
        for (int i = 2; i < marks.length; i++) {
            if (getMark(i) == mark)
                marked.push(i);
        }
        return marked;
    }
View Full Code Here

Examples of org.sat4j.core.VecInt

        }
        return marked;
    }

    public IVecInt getMarkedVariables() {
        IVecInt marked = new VecInt();
        for (int i = 2; i < marks.length; i += 2) {
            if (isMarked(i) || isMarked(i + 1))
                marked.push(i >> 1);
        }
        return marked;
    }
View Full Code Here

Examples of org.sat4j.core.VecInt

        }
        return marked;
    }

    public IVecInt getMarkedVariables(int mark) {
        IVecInt marked = new VecInt();
        for (int i = 2; i < marks.length; i += 2) {
            if (getMark(i) == mark || getMark(i + 1) == mark)
                marked.push(i >> 1);
        }
        return marked;
    }
View Full Code Here

Examples of org.sat4j.core.VecInt

  }

  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);
  }
View Full Code Here

Examples of org.sat4j.core.VecInt

     * @param y a variable to falsify
     * @throws ContradictionException iff a trivial inconsistency is found.
     */
    public void gateFalse(int y)
            throws ContradictionException {
        IVecInt clause = new VecInt(2);
        clause.push(-y);
        processClause(clause);
    }
View Full Code Here

Examples of org.sat4j.core.VecInt

     * @param y a variable to verify
     * @throws ContradictionException
     */
    public void gateTrue(int y)
            throws ContradictionException {
        IVecInt clause = new VecInt(2);
        clause.push(y);
        processClause(clause);
    }
View Full Code Here

Examples of org.sat4j.core.VecInt

     * @param x2
     * @param x3
     * @throws ContradictionException
     */
    public void ite(int y, int x1, int x2, int x3) throws ContradictionException {
        IVecInt clause = new VecInt(5);
        // y <=> (x1 -> x2) and (not x1 -> x3)
        // y -> (x1 -> x2) and (not x1 -> x3)
        clause.push(-y).push(-x1).push(x2);
        processClause(clause);
        clause.clear();
        clause.push(-y).push(x1).push(x3);
        processClause(clause);
        // y <- (x1 -> x2) and (not x1 -> x3)
        // not(x1 -> x2) or not(not x1 -> x3) or y
        // x1 and not x2 or not x1 and not x3 or y
        // (x1 and not x2) or ((not x1 or y) and (not x3 or y))
        // (x1 or not x1 or y) and (not x2 or not x1 or y) and (x1 or not x3 or
        // y) and (not x2 or not x3 or y)
        // not x1 or not x2 or y and x1 or not x3 or y and not x2 or not x3 or y
        clause.clear();
        clause.push(-x1).push(-x2).push(y);
        processClause(clause);
        clause.clear();
        clause.push(x1).push(-x3).push(y);
        processClause(clause);
        clause.clear();
        clause.push(-x2).push(-x3).push(y);
        processClause(clause);
        // taken from Niklas Een et al SAT 2007 paper
        // Adding the following redundant clause will improve unit propagation
        // y -> x2 or x3
        clause.clear();
        clause.push(-y).push(x2).push(x3);
        processClause(clause);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.