Previous Page | Next Page

The OPTMODEL Procedure

Macro Variable _OROPTMODEL_

The OPTMODEL procedure creates a macro variable named _OROPTMODEL_. You can inspect the execution of the most recently invoked solver from the value of the macro variable. The macro variable is defined at the start of the procedure and updated after each SOLVE statement is executed. The OPTMODEL procedure also updates the macro variable when an error is detected.

The _OROPTMODEL_ value is a string consisting of several "KEYWORD=value" items in sequence, separated by blanks; for example:

   STATUS=OK SOLUTION_STATUS=OPTIMAL OBJECTIVE=9 ITERATIONS=1 
   PRESOLVE_TIME=0 SOLUTION_TIME=0

The information contained in _OROPTMODEL_ varies according to which solver was last called. For lists of keywords and possible values, see the individual solver chapters.

If a value has not been computed, then the corresponding element is not included in the value of the macro variable. When PROC OPTMODEL starts, for instance, the macro variable value is set to "STATUS=OK" because no SOLVE statement has been executed. If the STATUS= indicates an error, then the other values from the solver might not be available, depending on when the error occurred.

Note that PROC OPTMODEL reads a complete statement, such as a DO statement , before executing any code in it. But macro language statements are processed as the code is read. So you must be careful when using the _OROPTMODEL_ macro variable in code involving SOLVE statements nested in loops or DO statements. The following code demonstrates one example of this behavior:

   proc optmodel;
      var x, y;
      min z=x**2 + (x*y-1)**2;
      for {n in 1..3} do;
         fix x=n;
         solve;
         %put Line 1 &_OROPTMODEL_;
         put 'Line 2 ' (symget("_OROPTMODEL_"));
      end;
   quit;

In the preceding code the %PUT statement is executed once, before any SOLVE statements are executed. It displays PROC OPTMODEL’s initial setting of the macro variable. But the PUT statement is executed after each SOLVE statement, and indicates the expected solution status.

Previous Page | Next Page | Top of Page