Page 1 of 1

save variables as parameters

Posted: Sat May 29, 2021 12:25 pm
by parag_patil
Dear all,
My problem setting is as follows:

1. I have set of linear equations, the variables obtained after solving these are X1,X2...,Xn and Y1,Y2...,Yn.
2. Once the above variables are obtained, these are required as parameters in the rest of the problem.

Can you please tell me how to do it?

Re: save variables as parameters

Posted: Sun May 30, 2021 11:15 pm
by dirkse
Parag,

The variables levels are available after the solve using the .L attribute, e.g.

Code: Select all

set i / 1 * 3 /;
variable x(i);
* I don't list it here, but imagine some code to solve a model and by doing so setting the variable levels for x
* now x.L(i) is available, just like a parameter.
parameter c(i), v(i);
c(i) = x.L(i);
v(i) = ord(i) / [x.L(i) + 2];
Using the variable levels like this is fundamental stuff. It is described in the Rosenthal tutorial (just digest the whole tutorial, it is not wasted time) and in more detail in the chapter on variables.

https://www.gams.com/latest/docs/UG_Tutorial.html
https://www.gams.com/latest/docs/UG_Variables.html

-Steve

Re: save variables as parameters

Posted: Mon May 31, 2021 4:27 am
by parag_patil
Hi,

Thank you for your reply.