Modelstat: Tmodstat

Top  Previous  Next

Upon solution a model attribute indicative of model status (Modelstat) is set by a solver and passed back to GAMS.  This attribute can have the following values

 

Value of ModelstatIndicated Model Solution Status

 

 1Optimal solution achieved
 2Local optimal solution achieved (Only type found in an NLP)
 3Unbounded model found
 4Infeasible model found
 5Locally infeasible model found (in NLPs)
 6Solver terminated early and model was infeasible
 7Solver terminated early and model was feasible but not yet optimal
 8Integer solution model found
 9Solver terminated early with a non integer solution found (only in MIPs)
10No feasible integer solution could be found
11Licensing problem
12Error achieved – No cause known
13Error achieved – No solution attained
14No solution returned from CNS models
15Feasible in a CNS models
16Locally feasible in a CNS models
17Singular in a CNS models
18Unbounded – no solution
19Infeasible – no solution

 

A set of modelstat constants are defined where

 ModelStat.Optimal has a numerical value of 1

 ModelStat.Locally Optimal has a numerical value of 2
 ModelStat.Unbounded has a numerical value of 3
 ModelStat.Infeasible has a numerical value of 4
 ModelStat.Locally Infeasible has a numerical value of 5
 ModelStat.Intermediate Infeasible has a numerical value of 6
 ModelStat.Intermediate Nonoptimal has a numerical value of 7
 ModelStat.Integer Solution has a numerical value of 8
 ModelStat.Intermediate Non-Integer has a numerical value of 9
 ModelStat.Integer Infeasible has a numerical value of 10
 ModelStat.Licensing Problems has a numerical value of 11
 ModelStat.Error Unknown has a numerical value of 12
 ModelStat.Error No Solution has a numerical value of 13
 ModelStat.No Solution Returned has a numerical value of 14
 ModelStat.Solved Unique has a numerical value of 15
 ModelStat.Solved has a numerical value of 16
 ModelStat.Solved Singular has a numerical value of 17
 ModelStat.Unbounded - No Solution has a numerical value of 18
 ModelStat.Infeasible - No Solution has a numerical value of 19

 
These values are fixed and cannot be manipulated.

 

In addition, the model attribute .Tmodstat contains internally assigned text describing the model optimality status and can be used in put files to print out a text indication of model optimality status.

Examples:

( varmodatt.gms )

scalar xx;

xX=transport.Modelstat;

Display xx,transport.Modelstat;

If(transport.Modelstat gt %ModelStat.Locally Optimal%,

      Display '**** Model did not terminate with normal solution',

                 transport.Modelstat;)

set scenarios /goodone,toomuchdemand/;

set casewithbadanswer(scenarios,*);

loop (scenarios,

      solve transport using lp minimizing cost;

      demand(sink)=demand(sink)*1.1;

      casewithbadanswer(scenarios,"model")

           $(transport.Modelstat gt 2)=yes;

);

display casewithbadanswer;

Notes:

In the example above note we are basically using this attribute so I can keep a record or generate output relative to model solution status.
The user can assign values to Modelstat, but ordinarily this is not desirable.
In a set of looped solves this provides the best way to keep track of whether the solves worked properly and if the numerical values are stored to record an indication of the type of problem.
.Tmodstat contains internally assigned text describing the model optimality status and can be used in put files to print out a text indication of that status.