kodkod.engine
Class Evaluator

java.lang.Object
  extended by kodkod.engine.Evaluator

public final class Evaluator
extends java.lang.Object

An evaluator for relational formulas and expressions with respect to a given instance and options.

Note: you may observe surprising (though correct) evaluator behavior if you do not use the same set of integer options (i.e. intEncoding and bitwidth when evaluating and solving a formula. For example, suppose that that an Instance i is a solution to a formula f found using options o. If you create an evaluator e such that e.instance = i, but e.options is an Options object with different integer settings than o, e.evalate(f) may return false.

Author:
Emina Torlak
specfield:
options: Options
instance: Instance

Constructor Summary
Evaluator(Instance instance)
          Constructs a new Evaluator for the given instance, using a default Options object.
Evaluator(Instance instance, Options options)
          Constructs a new Evaluator for the given instance and options
 
Method Summary
 TupleSet evaluate(Expression expression)
          Evaluates the specified expession with respect to the relation-tuple mappings given by this.instance and using this.options.
 boolean evaluate(Formula formula)
          Evaluates the specified formula with respect to the relation-tuple mappings given by this.instance and using this.options.
 int evaluate(IntExpression intExpr)
          Evaluates the specified int expession with respect to the relation-tuple mappings given by this.instance and using this.options.
 Instance instance()
          Returns this.instance.
 Options options()
          Returns the Options object used by this evaluator.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Evaluator

public Evaluator(Instance instance)
Constructs a new Evaluator for the given instance, using a default Options object.

Throws:
java.lang.NullPointerException - - instance = null
effects:
this.instance' = instance && this.options' = new Options()

Evaluator

public Evaluator(Instance instance,
                 Options options)
Constructs a new Evaluator for the given instance and options

Throws:
java.lang.NullPointerException - - instance = null || options = null
effects:
this.instance' = instance && this.options' = options
Method Detail

options

public Options options()
Returns the Options object used by this evaluator.

Returns:
this.options

instance

public Instance instance()
Returns this.instance. Any modifications to the returned object will be reflected in the behavior of the evaluate methods.

Returns:
this.instance

evaluate

public boolean evaluate(Formula formula)
Evaluates the specified formula with respect to the relation-tuple mappings given by this.instance and using this.options.

Returns:
true if formula is true with respect to this.instance and this.options; otherwise returns false
Throws:
HigherOrderDeclException - - the formula contains a higher order declaration
UnboundLeafException - - the formula contains an undeclared variable or a relation not mapped by this.instance

evaluate

public TupleSet evaluate(Expression expression)
Evaluates the specified expession with respect to the relation-tuple mappings given by this.instance and using this.options.

Returns:
set of tuples to which the expression evaluates given the mappings in this.instance and the options in this.options.
Throws:
HigherOrderDeclException - - the expression contains a higher order declaration
UnboundLeafException - - the expression contains an undeclared variable or a relation not mapped by this.instance

evaluate

public int evaluate(IntExpression intExpr)
Evaluates the specified int expession with respect to the relation-tuple mappings given by this.instance and using this.options.

Returns:
the integer to which the expression evaluates given the mappings in this.instance and the options in this.options.
Throws:
HigherOrderDeclException - - intExpr contains a higher order declaration
UnboundLeafException - - intExpr contains an undeclared variable or a relation not mapped by this.instance

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()