Page 1 of 1

Execute load and unload

Posted: Wed Apr 19, 2017 2:49 pm
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.

Re: Execute load and unload

Posted: Thu Apr 20, 2017 2:06 pm
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]
.......

Re: Execute load and unload

Posted: Wed Aug 02, 2017 6:22 pm
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;