net.sourceforge.combean.mathprog.grooml
Class GExpression

A sequence of (abstract) terms. The terms are abstract, i.e., they still contain abstract indices which are not yet mapped to concrete indices in a specific LP model. An expression can be bound to a given environment which contains definitions that the expression can then refer to. The environment is accessed by setting it is delegate when a dynamic part of the expression is evaluated. Per default, the expression has its own separate environment. If the environment is modified, this also refers to all inner expressions that the expression is composed off. The individual terms in the expression can be accessed through iteration.

todo:
Separate the iterator functionality from the core class.

 
Constructor Summary
GExpression()
           
 
Method Summary
static GExpression combine(List l)
          
static GExpression convert(def exprDef)
           Convert an object of arbitrary type to an expression.
Iterator evaluate(Object env)
           Iterate through the terms in the expression for generics of Groovy.
Set getVarIds(Object env)
           Get all variables names that occur in the the expression.
GExpression minus(def other)
          
GExpression plus(def other)
          
String termsToString(Object env)
           Iterate through the terms in the expression for generics of Groovy.
 

Constructor Detail

GExpression

GExpression()


Method Detail

combine

public static GExpression combine(List l)


convert

public static GExpression convert(def exprDef)
Convert an object of arbitrary type to an expression. Supported types for conversion: - Expressions (not much to be converted there ... the object is returned as-is) - Strings and GStrings - Closures
params:
exprDef the object to be converted. if the type of the object cannot
be converted to an expression, an exception is thrown
returns:
a new expression object based on the definition given by exprDef


evaluate

public Iterator evaluate(Object env)
Iterate through the terms in the expression
params:
env environment in which the expression shall be evaluated
todo:
check if type Iterator works with current support
for generics of Groovy.


getVarIds

public Set getVarIds(Object env)
Get all variables names that occur in the the expression. Default implementation: Iterate through the expression. Special GExpression subclasses should provide a more efficient implementation if possible.
returns:
a set with all variable names that occur in the the expression.


minus

public GExpression minus(def other)


plus

public GExpression plus(def other)


termsToString

public String termsToString(Object env)
Iterate through the terms in the expression
params:
env environment in which the expression shall be evaluated
todo:
check if type Iterator works with current support
for generics of Groovy.