execute_unload for zero-dimension variable

Problems with syntax of GAMS
Post Reply
djdmlwns
User
User
Posts: 2
Joined: 4 years ago

execute_unload for zero-dimension variable

Post by djdmlwns »

Hi, I am trying to save an optimal solution of variable x (with zero dimension) to gdx file, and retrieve it from gdx to a parameter.
So code looks like this.

Variable
x;

Parameter
par;

Equation
***
Solve the problem

Execute_unload 'save.gdx', x;
Execute_load 'save.gdx', par = x.l;

However, the above code does not work with error message "Cannot load/unload symbol with unknown dimension".
If I change the dimension of variable x with an arbitrary set (for example x(i)) and do the same thing, the same code works just fine. But this is not what I want, because I need to introduce redundant sets for all variables then.

So my question is how to load the level value of a variable with zero dimension from gdx file to a parameter.
Thank you.
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: execute_unload for zero-dimension variable

Post by abhosekar »

The error you are getting must be coming from execute_load statement. It is because when you declare parameter par, GAMS does not know its size (could be a vector or just one element).
One way to fix this is by simply initializing the parameter to some value before execute_load.
let's say
par = 0;
execute_load 'save.gdx' par;

This should work.

- Atharv
Post Reply