Problem Symbols

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.14.

Table 5.14: Problem Symbols






Number of variables



Variable array



Number of constraints



Constraint array



Number of presolved variables



Presolved variable array



Number of presolved constraints



Presolved constraint array



Current objective



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_ _var_.rc _var_.status;
   print _con_.body _con_.ub _con_.dual _con_.status;

The PRINT statement output is shown in Figure 5.61.

Figure 5.61: Problem Symbol Output

1 x1 1 0 B
2 x2 0 1 L
3 x3 3 0 B
4 x4 4 0 B
5 x5 2 0 B

1 a1 -1.7977E308 4 4.0000E+00 0 L
2 a2 -1.7977E308 6 6.0000E+00 0 B
3 a3 5 5 1.7977E+308 1 U
4 a4 2 2 1.7977E+308 0 U
5 a5 3 3 1.7977E+308 1 U