The OPTMODEL Procedure

Index Sets

An index set represents a set of combinations of members from the component set expressions. The index set notation is used in PROC OPTMODEL to describe collections of valid array indices and to specify sets of values with which to perform an operation. Index sets can declare local dummy parameters and can further restrict the set of combinations by a selection expression.

In { index-set }, the index-set consists of one or more index-set-items that are separated by commas. Each index-set-item can include local dummy parameter declarations. An optional selection expression follows the list of index-set-items. This syntax describes an index-set:

index-set-item [, ...index-set-item] [ : logic-expression ]

Index-set-item has these forms:

set-expression
name IN set-expression
< name-1 [, ...name-n] > IN set-expression

Names preceding the IN keyword in index-set-items declare local dummy parameter names. Dummy parameters correspond to the dummy index variables in mathematical expressions. For example, the following code outputs the number 385:

  
    proc optmodel; 
       put (sum{i in 1..10} i**2);
 


The preceding code evaluates this summation:

\sum_{i = 1}^{10} i^2 = 385

In both the code and the summation the index name is i.

The last form of index-set-item in the list can be modified to use the SLICE expression implicitly. See the section "More on Index Sets" for details.

Array index sets cannot be defined using functions that return different values each time the functions are called. See the section "Indexing" for details.

PROC OPTMODEL will produce this output:

  
    {<2000,'Q1'>,<2000,'Q2'>,<2000,'Q3'>,<2000,'Q4'>, 
    <2001,'Q1'>,<2001,'Q2'>,<2001,'Q3'>,<2001,'Q4'>}
 

The set order that results from other operations, such as the UNION operator, is not specified. This actual order could differ each time the operation is performed. However once a set value is assigned to a parameter the order will not change unless the parameter needs to be recomputed.

Previous Page | Next Page | Top of Page