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?
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:
* 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