The OPTMODEL procedure declares a number of symbols that are aliases for model components in the current problem. These symbols allow the model components to be accessed uniformly. These symbols are described in Table 5.17.
Table 5.17: Problem Symbols
Symbol |
Indexing |
Description |
_NVAR_ |
Number of variables |
|
_VAR_ |
{1.._NVAR_} |
Variable array |
_NCON_ |
Number of constraints |
|
_CON_ |
{1.._NCON_} |
Constraint array |
_S_NVAR_ |
Number of presolved variables |
|
_S_VAR_ |
{1.._S_VAR_} |
Presolved variable array |
_S_NCON_ |
Number of presolved constraints |
|
_S_CON_ |
{1.._S_CON_} |
Presolved constraint array |
_OBJ_ |
Current objective |
|
_PROBLEM_ |
Current problem |
If the table specifies indexing, then the corresponding symbol is accessed as an array. For example, if the problem includes
two variables, x
and y
, then the value of _NVAR_ is 2 and the current variable values can be accessed as _var_[1]
and _var_[2]
. The problem variables prefixed with _S are restricted to model components in the problem after processing by the OPTMODEL
presolver.
The following statements define a simple linear programming model and then use the problem symbols to print out some of the
problem results. The .name
suffix is used in the PRINT statements to display the actual variable and constraint names. Any of the suffixes that apply
to a model component can be applied to the corresponding generic symbol.
proc optmodel printlevel=0; var x1 >= 0, x2 >= 0, x3 >= 0, x4 >= 0, x5 >= 0; minimize z = x1 + x2 + x3 + x4; con a1: x1 + x2 + x3 <= 4; con a2: x4 + x5 <= 6; con a3: x1 + x4 >= 5; con a4: x2 + x5 >= 2; con a5: x3 >= 3; solve with lp; print _var_.name _var_ _var_.rc _var_.status; print _con_.name _con_.lb _con_.body _con_.ub _con_.dual _con_.status;
The PRINT statement output is shown in Figure 5.65.
Figure 5.65: Problem Symbol Output