Writing model status to external file

Hello everyone,

I am trying to write the model status to an external file after the solve statement:

[...]
Model ref / all / ;
Solve ref using lp minimising totex ;
$echo %ref.modelStat% > model_status.txt

The last statement does not work this way. I end up with %ref.modelStat% in the file. What would be a correct syntax / a better way to achieve this? How can write the model status to an external file?

Thank you, best regads

Daniel

Hi,

You need to understand the difference between compile and execution time in GAMS. See e.g. https://www.gams.com/latest/docs/UG_GamsCall.html#UG_GamsCall_TwoPass. Creating a file at execution time is done via the put facility, see https://www.gams.com/latest/docs/UG_Put.html

-Michael

Dear Michael,

thank you for your very pertinent advice, helping me lots even beyond my concrete problem, much appreciated!

Best regards,

Daniel

For the record, the original problem can be solved by:

[...]
Model ref / all / ;
Solve ref using lp minimising totex ;
File status  /model_status.txt/;
put status "Model Status:" ref.modelStat;
putclose;