Search in sources :

Example 11 with BooleanMatrix

use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.

the class BooleanMatrixTest method assertDotProductFalse.

private final void assertDotProductFalse(BooleanMatrix mF, BooleanMatrix m) {
    BooleanMatrix product = mF.dot(m);
    assertEquals(0, product.density());
    assertTrue(equivalent(mF.dimensions().dot(m.dimensions()), product.dimensions()));
}
Also used : BooleanMatrix(kodkod.engine.bool.BooleanMatrix)

Example 12 with BooleanMatrix

use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.

the class Evaluator method evaluate.

/**
 * Evaluates the specified expession with respect to the relation-tuple mappings
 * given by this.instance and using this.options.
 *
 * @return {@link kodkod.instance.TupleSet set} of tuples to which the
 *         expression evaluates given the mappings in this.instance and the
 *         options in this.options.
 * @throws kodkod.engine.fol2sat.HigherOrderDeclException the expression
 *             contains a higher order declaration
 * @throws kodkod.engine.fol2sat.UnboundLeafException the expression contains an
 *             undeclared variable or a relation not mapped by this.instance
 */
public TupleSet evaluate(Expression expression) {
    if (expression == null)
        throw new NullPointerException("expression");
    final BooleanMatrix sol = Translator.evaluate(expression, instance, options);
    this.wasOverflow = sol.defCond().getAccumOverflow() == BooleanConstant.TRUE;
    return instance.universe().factory().setOf(expression.arity(), sol.denseIndices());
}
Also used : BooleanMatrix(kodkod.engine.bool.BooleanMatrix)

Example 13 with BooleanMatrix

use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.

the class BooleanMatrixTest method testTranspose.

public final void testTranspose() {
    BooleanMatrix mF43t = mF43.transpose();
    assertEquals(mF43.density(), mF43t.density());
    assertTrue(equivalent(dim43.transpose(), mF43t.dimensions()));
    fill(mF43, range(0, dim43.capacity() - 1));
    BooleanValue[] result = new BooleanValue[dim43.capacity()];
    final int a = dim43.dimension(0), b = dim43.dimension(1);
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            result[j * a + i] = vars[i * b + j];
        }
    }
    mF43t = mF43.transpose();
    assertEquals(mF43.density(), mF43t.density());
    assertTrue(equivalent(dim43.transpose(), mF43t.dimensions()));
    assertTrue(equivalent(mF43t, result));
}
Also used : BooleanValue(kodkod.engine.bool.BooleanValue) BooleanMatrix(kodkod.engine.bool.BooleanMatrix)

Example 14 with BooleanMatrix

use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.

the class BooleanMatrixTest method assertCrossProductFalse.

private final void assertCrossProductFalse(BooleanMatrix mF, BooleanMatrix m) {
    BooleanMatrix product = mF.cross(m);
    assertEquals(0, product.density());
    assertTrue(equivalent(mF.dimensions().cross(m.dimensions()), product.dimensions()));
}
Also used : BooleanMatrix(kodkod.engine.bool.BooleanMatrix)

Example 15 with BooleanMatrix

use of kodkod.engine.bool.BooleanMatrix in project org.alloytools.alloy by AlloyTools.

the class BooleanMatrixTest method testNot.

public final void testNot() {
    fill(mT324, mCells, mR[1]);
    fill(mT324, mCells, mR[3]);
    for (int i = mR[1].min(); i <= mR[1].max(); i++) {
        mCells[i] = f.not(mCells[i]);
    }
    for (int i = mR[3].min(); i <= mR[3].max(); i++) {
        mCells[i] = f.not(mCells[i]);
    }
    mT324.set(mR[1].max() + 1, FALSE);
    mCells[mR[1].max() + 1] = TRUE;
    BooleanMatrix mNot = mT324.not();
    assertTrue(equivalent(mT324.dimensions(), mNot.dimensions()));
    assertTrue(equivalent(mNot, mCells));
// System.out.println(mT324);
// System.out.println(mNot);
}
Also used : BooleanMatrix(kodkod.engine.bool.BooleanMatrix)

Aggregations

BooleanMatrix (kodkod.engine.bool.BooleanMatrix)30 BooleanValue (kodkod.engine.bool.BooleanValue)13 BooleanFactory (kodkod.engine.bool.BooleanFactory)7 Decl (kodkod.ast.Decl)5 IntSet (kodkod.util.ints.IntSet)5 Int (kodkod.engine.bool.Int)4 ExprOperator (kodkod.ast.operator.ExprOperator)3 IntIterator (kodkod.util.ints.IntIterator)3 BooleanAccumulator (kodkod.engine.bool.BooleanAccumulator)2 ArrayList (java.util.ArrayList)1 BinaryExpression (kodkod.ast.BinaryExpression)1 Comprehension (kodkod.ast.Comprehension)1 Expression (kodkod.ast.Expression)1 IfExpression (kodkod.ast.IfExpression)1 IntExpression (kodkod.ast.IntExpression)1 IntToExprCast (kodkod.ast.IntToExprCast)1 Relation (kodkod.ast.Relation)1 SumExpression (kodkod.ast.SumExpression)1 Variable (kodkod.ast.Variable)1 ExprCompOperator (kodkod.ast.operator.ExprCompOperator)1