Sending the model status to a GDX file

Frequently asked questions about GAMS

Moderator: aileen

Forum rules
Please ask questions in the other sub-forums
Locked
aileen
User
User
Posts: 136
Joined: 4 years ago

Sending the model status to a GDX file

Post by aileen »

I'm using GDX to store model results. I export the results of my models using the following command when I launch the model: gams model.gms gdx=out.gdx. All the information is there, except information on the status of the model. Is there any option to export the model status (normal completion, infeasibilities, etc.) to the GDX file once the model is completed?
aileen
User
User
Posts: 136
Joined: 4 years ago

Re: Sending the model status to a GDX file

Post by aileen »

Model attributes can not be stored directly in a GDX file. However you can save the model status (plus some other model attributes) in a parameter and write that parameter to a GDX file as illustrated by the following example:

Code: Select all

* load the tranport model from the GAMS model library
$call gamslib trnsport
$ife errorlevel<>0 $abort Failed loading transpoitr model

*append the following code to trnsport.gms
$onecho >> trnsport.gms
* Declare paremeter modrep to store the model attributes that should be unloaded to GDX.
parameter modrep;
modrep('transport','solvestat') = transport.solvestat;
modrep('transport','modelstat') = transport.modelstat;
modrep('transport','resusd'   ) = transport.resusd;
modrep('transport','objval')    = transport.objval;
$offecho

*Run trnsport.gms and store all the data in out.gdx.
$call gams trnsport gdx=out.gdx
$ife errorlevel<>0 $abort Failed running transport model
Locked