Page 1 of 1

GAMS parameter issue

Posted: Mon Jun 11, 2018 3:22 pm
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

Re: GAMS parameter issue

Posted: Tue Jun 12, 2018 9:03 am
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

Re: GAMS parameter issue

Posted: Tue Jun 12, 2018 12:01 pm
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

Re: GAMS parameter issue

Posted: Tue Jun 12, 2018 4:47 pm
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

Re: GAMS parameter issue

Posted: Wed Jun 13, 2018 10:44 am
by Hussain_TUT
Hi,
I have not noticed that . It works.

Thanks

Re: GAMS parameter issue

Posted: Wed Jul 11, 2018 6:40 am
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);

Re: GAMS parameter issue

Posted: Thu Jul 12, 2018 7:29 am
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