本文整理汇总了Java中kodkod.ast.Expression.IDEN属性的典型用法代码示例。如果您正苦于以下问题:Java Expression.IDEN属性的具体用法?Java Expression.IDEN怎么用?Java Expression.IDEN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类kodkod.ast.Expression
的用法示例。
在下文中一共展示了Expression.IDEN属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interpret
/**
* Returns a {@link kodkod.engine.bool.BooleanMatrix matrix} m of
* {@link kodkod.engine.bool.BooleanValue boolean formulas} representing the
* specified constant expression.
*
* @return { m: BooleanMatrix | let dset = [0..this.universe.size()^c.arity)
* | m.dimensions.dimensions = [0..c.arity) ->one
* this.universe.size() && c = UNIV => m.elements[dset] = TRUE, c =
* NONE => m.elements[dset] = FALSE, c = IDEN => (all i: dset |
* (some j: int | i = j*(1+this.universe.size())) => m.elements[i] =
* TRUE, m.elements[i] = FALSE), c = INT => (all i: dset | (some j:
* int | this.interpret(j)=i) => m.elements[i] = TRUE, m.elements[i]
* = FALSE }
*/
public final BooleanMatrix interpret(ConstantExpression c) {
final int univSize = universe().size();
if (c == Expression.UNIV) {
final IntSet all = Ints.rangeSet(Ints.range(0, univSize - 1));
return factory().matrix(Dimensions.square(univSize, 1), all, all);
} else if (c == Expression.IDEN) {
final Dimensions dim2 = Dimensions.square(univSize, 2);
final IntSet iden = Ints.bestSet(dim2.capacity());
for (int i = 0; i < univSize; i++) {
iden.add(i * univSize + i);
}
return factory().matrix(dim2, iden, iden);
} else if (c == Expression.NONE) {
return factory().matrix(Dimensions.square(univSize, 1), Ints.EMPTY_SET, Ints.EMPTY_SET);
} else if (c == Expression.INTS) {
final IntSet ints = Ints.bestSet(univSize);
for (IntIterator iter = ints().iterator(); iter.hasNext();) {
ints.add(interpret(iter.next()));
}
return factory().matrix(Dimensions.square(univSize, 1), ints, ints);
} else {
throw new IllegalArgumentException("unknown constant expression: " + c);
}
}
示例2: visit
/** {@inheritDoc} */
public void visit(ConstantExpression x) {
if (map.containsKey(x))
return;
String newname = null;
if (x == Expression.NONE)
newname = "Expression.NONE";
else if (x == Expression.UNIV)
newname = "Expression.UNIV";
else if (x == Expression.IDEN)
newname = "Expression.IDEN";
else if (x == Expression.INTS)
newname = "Expression.INTS";
else
throw new RuntimeException("Unknown kodkod ConstantExpression \"" + x + "\" encountered");
map.put(x, newname);
}
示例3: interpret
/**
* Returns a {@link kodkod.engine.bool.BooleanMatrix matrix} m of
* {@link kodkod.engine.bool.BooleanValue boolean formulas} representing
* the specified constant expression.
* @return { m: BooleanMatrix | let dset = [0..this.universe.size()^c.arity) |
* m.dimensions.dimensions = [0..c.arity) ->one this.universe.size() &&
* c = UNIV => m.elements[dset] = TRUE, c = NONE => m.elements[dset] = FALSE,
* c = IDEN => (all i: dset | (some j: int | i = j*(1+this.universe.size())) => m.elements[i] = TRUE, m.elements[i] = FALSE),
* c = INT => (all i: dset | (some j: int | this.interpret(j)=i) => m.elements[i] = TRUE, m.elements[i] = FALSE }
*/
public final BooleanMatrix interpret(ConstantExpression c) {
final int univSize = universe().size();
if (c==Expression.UNIV) {
final IntSet all = Ints.rangeSet(Ints.range(0, univSize-1));
return factory().matrix(Dimensions.square(univSize, 1), all, all);
} else if (c==Expression.IDEN) {
final Dimensions dim2 = Dimensions.square(univSize, 2);
final IntSet iden = Ints.bestSet(dim2.capacity());
for(int i = 0; i < univSize; i++) {
iden.add(i*univSize + i);
}
return factory().matrix(dim2, iden, iden);
} else if (c==Expression.NONE) {
return factory().matrix(Dimensions.square(univSize, 1), Ints.EMPTY_SET, Ints.EMPTY_SET);
} else if (c==Expression.INTS) {
final IntSet ints = Ints.bestSet(univSize);
for(IntIterator iter = ints().iterator(); iter.hasNext(); ) {
ints.add(interpret(iter.next()));
}
return factory().matrix(Dimensions.square(univSize, 1), ints, ints);
} else {
throw new IllegalArgumentException("unknown constant expression: " + c);
}
}
示例4: visit
/** {@inheritDoc} */
public void visit(ConstantExpression x) {
if (map.containsKey(x)) return;
String newname=null;
if (x==Expression.NONE) newname="Expression.NONE";
else if (x==Expression.UNIV) newname="Expression.UNIV";
else if (x==Expression.IDEN) newname="Expression.IDEN";
else if (x==Expression.INTS) newname="Expression.INTS";
else throw new RuntimeException("Unknown kodkod ConstantExpression \""+x+"\" encountered");
map.put(x,newname);
}