net.sourceforge.combean.mathprog.grooml
Class GIndexBinding

Manages a set of index variables and their binding to concrete values in a given environment. An index binding consists of - an environment - a set of pairs of an index variable name (given as String) and a set of values to which the corresponding variable shall be bound. When the index binding is traversed, the index variables are set one-by-one to the values occurring in their corresponding value set.

todo:
stream-line class hierarchy: separate GIndexBinding for normal GSets and for
GNumberedSets

Field Summary
 List idxVarNames
           
 GSet valueSet
           
 
Constructor Summary
GIndexBinding(String idxVarName, Object valueSetDef)
            Constructor (given a single index variable name and a value set) bound; type must be convertable to a set.
GIndexBinding(List idxVarNames, Object valueSetDef)
            Constructor (given a list of index variable names and a set of tuples) bound; type must be convertable to a set.
GIndexBinding(List idxVarNames, List valueSets)
            Constructor (given a list of index names and a corresponding list of value sets).
GIndexBinding(Map bindDef)
           
 
Method Summary
void assertNumbered()
          
static GIndexBinding convert(Object bindDef)
           Convert an object of arbitrary type to an expression.
Iterator evaluate(Object env)
          
Object getElem(int idx)
          
List getIdxVarNames()
          
GSet getSet()
          
int indexOf(Object elem)
          
void init(List idxVarNames, GSet valueSet)
          
boolean isNumbered()
          
GSet multiply(def other)
          
void remove()
           Needs to be implemented to satisfy ResettableIterator interface.
void setIdxVars(Object values, Object env)
           Internal helper function: Assign a list of values to the variables in the binding.
void setNthBinding(int n, Object env)
           Set the binding to the n-th value in the value set
int size()
          
String toString()
          
int tupleSize()
          
 

Constructor Detail

GIndexBinding

public GIndexBinding(String idxVarName, Object valueSetDef)
Constructor (given a single index variable name and a value set)
params:
idxVarName the name of the index variable in the binding
params:
valueSetDef the set of value to which the index variable shall be
bound; type must be convertable to a set.
params:
env the environment in which the binding shall be made


GIndexBinding

public GIndexBinding(List idxVarNames, Object valueSetDef)
Constructor (given a list of index variable names and a set of tuples)
params:
idxVarNames the names of the index variables in the binding
params:
valueSetDef the set of value to which the index variable shall be
bound; type must be convertable to a set. (note that the set must contain value tuples such that the cardinality of the tuple and the number of the index variables match)
params:
env the environment in which the binding shall be made


GIndexBinding

public GIndexBinding(List idxVarNames, List valueSets)
Constructor (given a list of index names and a corresponding list of value sets). The value sets are stored internally by constructing a product set from them.


GIndexBinding

public GIndexBinding(Map bindDef)


Method Detail

assertNumbered

void assertNumbered()


convert

public static GIndexBinding convert(Object bindDef)
Convert an object of arbitrary type to an expression. Supported types for conversion: - Index bindings (not much to be converted there ... the object is returned as-is) - Maps (key type: String for a single variable name or a list of Strings if multiple variables shall be bound to values of a set of tuples) - Lists: The default index variable it is used and the List is interpreted as the list of index values
params:
bindDef the object to be converted. if the type of the object cannot
be converted to an expression, an exception is thrown
params:
env the environment that shall be set when the binding is
constructed
returns:
a new index binding object based on the definition given by bindDef
todo:
instantiate multiple variables in a deterministic order


evaluate

public Iterator evaluate(Object env)


getElem

public Object getElem(int idx)


getIdxVarNames

public List getIdxVarNames()


getSet

public GSet getSet()


indexOf

public int indexOf(Object elem)


init

void init(List idxVarNames, GSet valueSet)


isNumbered

public boolean isNumbered()


multiply

public GSet multiply(def other)


remove

public void remove()
Needs to be implemented to satisfy ResettableIterator interface. Not implemented.


setIdxVars

void setIdxVars(Object values, Object env)
Internal helper function: Assign a list of values to the variables in the binding.


setNthBinding

public void setNthBinding(int n, Object env)
Set the binding to the n-th value in the value set
params:
n the index of the value to be set in the binding


size

public int size()


toString

public String toString()


tupleSize

public int tupleSize()