GDX reading Topic is solved

Problems with modeling
Post Reply
Hussain_TUT
User
User
Posts: 11
Joined: 7 years ago

GDX reading

Post by Hussain_TUT »

Dear All,

I am solving an optimization problem that works well. For further extension, I need the value to save the value of a variable (var) in a parameter (par). They both have same dimension. I have read in the help section and one way is to use GDX facility. I saved my variable in an gdx file results3.gdx. Now, I want to read the current value (.l) this but it end it an error "cannot load/unload this suffix". Does it occurs due to some syntax problem or due the logic? Or is there any other way to save/copy variable value in a parameter? This a general code

set t /1*50/

parameter par(t);

variable var(t)
** solve optimization problem**

execute_unload 'results3.gdx',
var.l;

$gdxin results3
$load par=var.l
$gdxin



Thanks
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: GDX reading

Post by Renger »

Hi
You are mixing the execution and compile time versions of gdx. You read the data with the compile time command $gdxin.. $load, but the file results3.gdx is not available yet, because it is generated in the execution phase. For more information see

Code: Select all

https://www.gams.com/latest/docs/UG_Gam ... ll_TwoPass.
.

This will work:

Code: Select all

execute_unload 'results3.gdx',var.l;

execute_load 'results3.gdx', par=var.l;

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Hussain_TUT
User
User
Posts: 11
Joined: 7 years ago

Re: GDX reading

Post by Hussain_TUT »

Hi,

Thank you for your message and your help worked. You were right, I was mixing execution and compilation mode commands. Thanks for the help.

Cheers,
Post Reply