Dear All,
I have build a gams model that that uses binary variable.
set t /1100/
c /13/
;
parameter
block(cn)
ltc1_time(cn)
j(cn)
w;
block(cn)=;
ltc1_time(cn)=0;
j(cn)=0;
w=0;
Equation… (not important here)
(Assume that model works fine)
Objective… Z=E= …
Main or Master loop ****************************************
while (w eq 0,
*********************** Condition check start*******************
loop(cn,
block1(cn+1)=ltc1_time(cn+1)(ltc1_time(cn) eq ltc1_time(cn+1))+ltc1_time(cn)(ltc1_time(cn) ne ltc1_time(cn+1));
w1=1$(ltc1_time(cn) ne ltc1_time(cn+1) and ltc1_time(cn+1) ne ltc1_time(cn+2));
);
*********************** Condition check end**************************************
************ Slave loop *******************************
loop(cn,
delay1=block1(cn);
(delay is a parameter that is used in the model due to which variable timing index value changes).
Solve Model using MIP minimizing Z;
**************** getting time value from binary variable *******************
loop(t$(j(cn)=0),
ltc1_time(cn)=ltc1_time(cn)(variable1.l(t) ne 2)+ord(t)(variable1.l(t) eq 2);
j1(cn)=1$(variable1.l(t) eq 2);
);
);
display ltc1_time;
);
I believe that understanding of the model is not important here but the parameters (ltc1_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 a variable used in the model in each index of ltc1_time(cn). It store it the index value when its current value is 2.
In second iteration using some criteria in master loop, the time index value t of the variable changed due to change in paramater delay and it should be (1 38, 2 37 3 37) that I can be seen in solves output (that proves that in the model, it has been updated) but they are not updated in ltc1_time(cn) during the second iteration and it shown the values that is being stored during first iteration. In other words, ltc1_time(cn) is not being updated even there is been some changed occurred during simulation. After second iteration:
PARAMETER ltc1_time
1 38.000, 2 38.000, 3 38.000 (that is same as iteration one)
Any idea or clue what is wrong here.
Thanks