GAMS parameter issue

Problems with modeling
Post Reply
Hussain_TUT
User
User
Posts: 11
Joined: 7 years ago

GAMS parameter issue

Post by Hussain_TUT »

Hello,
I have two loops in my model. The first (while) loop is more like a master loop and the other (for) loop is a slave one. The master loop contains the slave loop. The slave loop runs and calculates some values . The master loop use those values and make some decision which are passed to the slave one and this process continuous until some stopping criteria met.

I am using Parameter e.g, ltc3_time(cn) inside the slave loop which is initialized with zero value during the model. It stored some values related to the variables that i used in my model. Here, cn is the set value that shows how many times we want to run the slave loop (or the model). During the slave loop, some values is assigned to each of index of ltc3_time(cn) and stored.

During the first iteration, values inside ltc3_time(cn) are stored perfectly which are used by the master loop for some decision. But in the second iteration, values inside ltc3_time(cn) are supposed to be updated (that i can confirm from the variable values that are updated) but the values inside parameter ltc3_time(cn) are not updated. It does not matter how many times i run the master loop, the values inside ltc3_time(cn) remains the same as it was in the first iteration. Any solution or idea about the problem?

Thanks
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: GAMS parameter issue

Post by Renger »

Hi Hussain

Although you describe your problem well, it is hard to help as you don't show the code.
Try at least to reproduce the problem in a small example and send it to the forum if your code is too big.

Cheers

Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Hussain_TUT
User
User
Posts: 11
Joined: 7 years ago

Re: GAMS parameter issue

Post by Hussain_TUT »

Hi,
Thank you for the message. A simplified version of the code in attached. I believe that understanding of the model is not important here but the parameters (ltc1_time(cn), ltc2_time(cn) and ltc3_time(cn)) used in the master and slave loop is the issue. An an example from the code: after first iteration,
PARAMETER ltc1_time

1 38.000, 2 38.000, 3 38.000

the values are the same since it call the same model 3 times and store the index t of the binary variable ltc1(t) used in the model in each index of ltc1_time(cn).
In second iteration using some criteria in master loop, the index values of the binary variable ltc1(t) changed and it should be (1 38, 2 37 3 37) that can be seen in solves output but they are not updated in ltc1_time(cn) and it shown the values that is being stored in first iteration. After second iteration:

PARAMETER ltc1_time

1 38.000, 2 38.000, 3 38.000
Attachments
test.gms
(5.27 KiB) Downloaded 220 times
Fred
Posts: 372
Joined: 7 years ago

Re: GAMS parameter issue

Post by Fred »

Hussain,

parameter ltc1_time is updated in a loop that has dollar condition (j1(cn)=0). In the first iteration of the outer while loop you set j1(cn)=1 for all cn. Hence, the loop that updates ltc1_time is never entered again in subsequent iterations.

I hope this helps!

Fred
Hussain_TUT
User
User
Posts: 11
Joined: 7 years ago

Re: GAMS parameter issue

Post by Hussain_TUT »

Hi,
I have not noticed that . It works.

Thanks
mohammadyDave
User
User
Posts: 1
Joined: 5 years ago

Re: GAMS parameter issue

Post by mohammadyDave »

Hello dear friends,
I have written the Vehicle Routing Problem. But I have faced some Errors in terms of defining sets and fixed indexes. I was wondering if you could help me.
Here is the GAMS code.

B1(i,j,m,r)=e=ZI(m)*((ZI(m)-1)+(1-ZI(m))*(v('2',r)/v('3',r)-1);

B2(i,j,m,r)=e=SZI('1')*(d(i,j)/v('1',r))+SZI('2')*(d(i,j)/v('3',r)+(1-v('2',r)/v('3',r))*a)+SZI('3')*(d(i,j)/v('3',r));

b(i,j,m)=e=SZI(1)*(a-d(i,j)/v('1',r))+SZI('2')*(a)+SZI('3')*(LN);
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: GAMS parameter issue

Post by Renger »

Hi
As written in the Rules to this forum

...send the self-contained, executable GAMS code that reproduces your problem to the group.
...describe your problem as clearly as possible.

You might try to reformulate your question, so people will be able to answer it.

CHeers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply