User Tools

Site Tools


interfaces:send_model_status_to_a_gdx_file

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
interfaces:send_model_status_to_a_gdx_file [2010/02/19 10:22]
support
interfaces:send_model_status_to_a_gdx_file [2020/05/20 12:44] (current)
Frederik Fiand
Line 1: Line 1:
 ====== Sending the model status to a GDX file ====== ====== Sending the model status to a GDX file ======
  
-Q: //I'm using GDX to read 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?//​+Q: //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?//​
  
-Currently model attributes can not be  stored directly ​ in a gdx file. However you can save the model status plus some other model attributes  +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.+in a parameter and write that parameter to a gdx file as illustrated by the following example.
 <​code>​ <​code>​
-$call 'gamslib ​1' +* load the tranport model from the GAMS model library 
-$include ​trnsport.gms+$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; parameter modrep;
 modrep('​transport','​solvestat'​) = transport.solvestat;​ modrep('​transport','​solvestat'​) = transport.solvestat;​
Line 13: Line 18:
 modrep('​transport','​resusd' ​  ) = transport.resusd;​ modrep('​transport','​resusd' ​  ) = transport.resusd;​
 modrep('​transport','​objval'​) ​   = transport.objval;​ modrep('​transport','​objval'​) ​   = transport.objval;​
-display modrep; +$offecho 
-Execute_Unload "stat.gdx",​modrep; ​            + 
 +*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
 </​code>​ </​code>​
  
IMPRESSUM / LEGAL NOTICEPRIVACY POLICY interfaces/send_model_status_to_a_gdx_file.txt · Last modified: 2020/05/20 12:44 by Frederik Fiand