Hi all,
I got really confused about how dynamic sets work in the loop. I tried to use dynamic sets to make my iterative model more efficient, but when I checked the output, it failed. The following is how I defined my dynamic sets:
Sets
g_ava(g) dynamic set
l_ava(l) dynamic set;
g_ava(g)(G_avail0(g)) = yes; l_ava(l)(L_avail0(l)) = yes;
“G_avail0(g)” and “L_avail0(l)” are parameters of 0th iteration.
Then the following is how I refresh the dynamic set within a loop:
Loop(itera,
… …
g_ava(g)(G_avail(g, itera)) = yes;
l_ava(l)(L_avail(l, itera)) = yes;
… …
);
“G_avail(g, itera)” and “L_avail(l, itera)” are parameters with respect to iterations. In fact, these parameters only contained binary parameters and I wished to use these parameters to refresh my dynamic sets. The following shows the output of 1st iteration:
---- 420 PARAMETER G_avail
itera1
g1 1.000
g2 1.000
g3 1.000
---- 420 PARAMETER L_avail
itera1
l1 1.000
l2 1.000
l3 1.000
l4 1.000
l5 1.000
---- 425 SET g_ava dynamic set
g1, g2, g3
---- 425 SET l_ava dynamic set
l1, l2, l3, l4, l5
We can see that they worked pretty well, just what I needed. But when they went to the 2nd iteration, it failed:
---- 420 PARAMETER G_avail
itera1 itera2
g1 1.000
g2 1.000
g3 1.000
---- 420 PARAMETER L_avail
itera1 itera2
l1 1.000
l2 1.000
l4 1.000
l5 1.000 1.000
---- 425 SET g_ava dynamic set
g1, g2, g3
---- 425 SET l_ava dynamic set
l1, l2, l3, l4, l5
If it had worked correctly, it should have shown that g_ava only contains g3 and l_ava only contains l5.
Would you guys mind helping me figure this out? Do I need to use the way like “g_ava(g, itera)” to define my dynamic set?
Thank you!