Examples of IVecInt


Examples of org.sat4j.specs.IVecInt

     * (non-Javadoc)
     *
     * @see org.sat4j.minisat.DataStructureFactory#createClause(org.sat4j.datatype.VecInt)
     */
    public Constr createClause(IVecInt literals) throws ContradictionException {
        IVecInt v = Clauses.sanityCheck(literals, getVocabulary(), solver);
        if (v == null)
            return null;
      if (v.size()==2) {
        return OriginalBinaryClause.brandNewClause(solver, getVocabulary(), v);
      }
        return OriginalHTClause.brandNewClause(solver, getVocabulary(), v);
    }
View Full Code Here

Examples of org.sat4j.specs.IVecInt

     */
    public void and(int y, IVecInt literals) throws ContradictionException {
        // y <=> AND x1 ... xn

        // y <= x1 .. xn
        IVecInt clause = new VecInt(literals.size() + 2);
        clause.push(y);
        for (int i = 0; i < literals.size(); i++) {
            clause.push(-literals.get(i));
        }
        processClause(clause);
        clause.clear();
        for (int i = 0; i < literals.size(); i++) {
            // y => xi
            clause.clear();
            clause.push(-y);
            clause.push(literals.get(i));
            processClause(clause);
        }
    }
View Full Code Here

Examples of org.sat4j.specs.IVecInt

     * @param x1
     * @param x2
     * @throws ContradictionException
     */
    public void and(int y, int x1, int x2) throws ContradictionException {
        IVecInt clause = new VecInt(4);
        clause.push(-y);
        clause.push(x1);
        addClause(clause);
        clause.clear();
        clause.push(-y);
        clause.push(x2);
        addClause(clause);
        clause.clear();
        clause.push(y);
        clause.push(-x1);
        clause.push(-x2);
        addClause(clause);
    }
View Full Code Here

Examples of org.sat4j.specs.IVecInt

     * (non-Javadoc)
     *
     * @see org.sat4j.minisat.DataStructureFactory#createClause(org.sat4j.datatype.VecInt)
     */
    public Constr createClause(IVecInt literals) throws ContradictionException {
        IVecInt v = Clauses.sanityCheck(literals, getVocabulary(), solver);
        if (v == null)
            return null;
        return MixableCBClause.brandNewClause(solver, getVocabulary(), v);
    }
View Full Code Here

Examples of org.sat4j.specs.IVecInt

    voc.ensurePool(howmany);
    return voc.nVars();
  }

  public IConstr addClause(IVecInt literals) throws ContradictionException {
    IVecInt vlits = dimacs2internal(literals);
    return addConstr(dsfactory.createClause(vlits));
  }
View Full Code Here

Examples of org.sat4j.specs.IVecInt

  }

  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.specs.IVecInt

    return addAtLeast(opliterals, n - degree);
  }

  public IConstr addAtLeast(IVecInt literals, int degree)
      throws ContradictionException {
    IVecInt vlits = dimacs2internal(literals);
    return addConstr(dsfactory.createCardinalityConstraint(vlits, degree));
  }
View Full Code Here

Examples of org.sat4j.specs.IVecInt

     * @throws ContradictionException
     */
    public void or(int y, IVecInt literals) throws ContradictionException {
        // y <=> OR x1 x2 ...xn
        // y => x1 x2 ... xn
        IVecInt clause = new VecInt(literals.size() + 2);
        literals.copyTo(clause);
        clause.push(-y);
        processClause(clause);
        clause.clear();
        for (int i = 0; i < literals.size(); i++) {
            // xi => y
            clause.clear();
            clause.push(y);
            clause.push(-literals.get(i));
            processClause(clause);
        }
    }
View Full Code Here

Examples of org.sat4j.specs.IVecInt

     * @param y
     * @param x
     * @throws ContradictionException
     */
    public void not(int y, int x) throws ContradictionException {
        IVecInt clause = new VecInt(3);
        // y <=> not x
        // y => not x = not y or not x
        clause.push(-y).push(-x);
        processClause(clause);
        // y <= not x = y or x
        clause.clear();
        clause.push(y).push(x);
        processClause(clause);
    }
View Full Code Here

Examples of org.sat4j.specs.IVecInt

    }

    private void xor2Clause(int[] f, int prefix, boolean negation)
            throws ContradictionException {
        if (prefix == f.length - 1) {
            IVecInt clause = new VecInt(f.length + 1);
            for (int i = 0; i < f.length - 1; ++i) {
                clause.push(f[i]);
            }
            clause.push(f[f.length - 1] * (negation ? -1 : 1));
            processClause(clause);
            return;
        }

        if (negation) {
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.