net.sourceforge.combean.mathprog.grooml
Class GSet

A set of values which can be bound to an index variable. The elements of the set can be traversed in a environment from which external definition are taken (if the definition of the set is dynamic and is only evaluated when the elements of the set are accessed) Used to generate sums with many terms, define multiple rows in an LP etc.

 
Constructor Summary
GSet()
           
 
Method Summary
static GSet convert(def setDef)
           Convert an object of arbitrary type to a set.
Iterator evaluate(Object env)
           Get an iterator through all elements in the set.
boolean isNumbered()
           Check whether the set also supports the methods of a numbered set as defined by the abstract class GNumberedSet
GSet multiply(def other)
           Override operator '*' in order to support a simple syntax for the definition of set products, e.g.
List toList(Object env)
          
int tupleSize()
           simple values and no tuples)
 

Constructor Detail

GSet

GSet()


Method Detail

convert

public static GSet convert(def setDef)
Convert an object of arbitrary type to a set. Supported types for conversion: - Sets (not much to be converted there ... the object is returned as-is) - Objects that implement the List interface - Integers or Strings (defining a set with exactly one element) - Closures: The closure defines a dynamic set and is evaluated within a given environment when the elements of the set are accessed
params:
setDef the object to be converted. if the type of the object cannot
be converted to an expression, an exception is thrown
returns:
a new set object based on the definition given by setDef


evaluate

public Iterator evaluate(Object env)
Get an iterator through all elements in the set. The elements in the set may depend on the current environment (if the definition of the set is dynamic).
params:
env the environment
returns:
an iterator through all elements in the set.


isNumbered

public boolean isNumbered()
Check whether the set also supports the methods of a numbered set as defined by the abstract class GNumberedSet
returns:
true if the set supports the GNumberedSet interface


multiply

public GSet multiply(def other)
Override operator '*' in order to support a simple syntax for the definition of set products, e.g. 'x * 1..10'.
params:
other the other set with which 'this' shall be multiplied.
Object must be convertable to a set.
returns:
the product of this and other


toList

public List toList(Object env)


tupleSize

public int tupleSize()
returns:
the size of the value tuples in the set (1 if the set contains
simple values and no tuples)