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, l_tc3_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?
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.
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 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.
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.