Execute load and unload

questions about GAMS' tools
Post Reply
CurtisL
User
User
Posts: 3
Joined: 7 years ago

Execute load and unload

Post by CurtisL »

Dear Gams users:

I am working on a problem that part of the solution of file A is the condition for file B. My intention is to run file A and unload the part of solution needed by file B. After that, file B will load the solution from file A. Regarding my intention, my code is as following:

File A,
variable x y z;
solve problem using lp;
execute_unload "x.gdx", x=xsol;
execute_unload "y.gdx", y=ysol;
execute_unload "z.gdx", z=zsol;

File B,
variable x y z;
execute_load "x.gdx", x=xsol;
execute_load "y.gdx", y=ysol;
execute_load "z.gdx", z=zsol;

When I run the file A, everything looks fine. However, there are errors when I run file B: cannot load/unload symbols with unknown dimension. Can anyone help me? Thank you very much. Besides, is there any way that I can execute an external file in GAMS? Thanks again.
CurtisL
User
User
Posts: 3
Joined: 7 years ago

Re: Execute load and unload

Post by CurtisL »

I figured it out. I need to give a dimension to the variable. So it should be like
variables x[a], y[a], z[a]
.......
Manassaldi
User
User
Posts: 118
Joined: 7 years ago
Location: Rosario - Argentina

Re: Execute load and unload

Post by Manassaldi »

Hi, i think this can work:

File A
variable x(a), y(a), z(a);
solve problem using lp;
execute_unload "x.gdx" x.l
execute_unload "y.gdx", y.l
execute_unload "z.gdx", x.l

File B,
variable x(a), y(a), z(a);
parameter xsol(a), ysol(a), zsol(a);
execute_load "x.gdx", xsol=x;
execute_load "y.gdx", ysol=y;
execute_load "z.gdx", zsol=z;
Post Reply