save variables as parameters Topic is solved

Problems with modeling
Post Reply
parag_patil
User
User
Posts: 30
Joined: 2 years ago
Location: Ahmedabad
Contact:

save variables as parameters

Post 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?
User avatar
dirkse
Moderator
Moderator
Posts: 214
Joined: 7 years ago
Location: Fairfax, VA

Re: save variables as parameters

Post 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
parag_patil
User
User
Posts: 30
Joined: 2 years ago
Location: Ahmedabad
Contact:

Re: save variables as parameters

Post by parag_patil »

Hi,

Thank you for your reply.
Post Reply