The OPTMODEL Procedure

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

[1] _VAR_.NAME _VAR_ _VAR_.RC _VAR_.STATUS
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] _CON_.NAME _CON_.LB _CON_.BODY _CON_.UB _CON_.DUAL _CON_.STATUS
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