### How to update parameters iteratively within a Loop?

Posted:

**Wed Mar 28, 2018 6:12 pm**Hi All,

Sorry for asking so many questions but I really need help. I tried to use iteratively updated parameters to do my algorithm, named Column and Constraint Generation, which has been enlightened by the Benders Decomposition. Then I am a little bit confused about how I can update my parameters from the previous one with some conditions. These parameters are all Binary. Here shows how I define the iteration set:
Then I modeled my problem with these updating parameters, and here shows parts of the equations definition:
These codes ensured that in each iteration these constraints would be added repeatedly with different parameters.

Then I tried to use the following codes to update my parameters.
What I got in 1st iteration are like follows. There is no problem since my xl.l results were l1, l2, l4, l5 = 1.000, l3 = 0.
When it came to the 2nd iteration, problem occurred.
The results for xl.l were only l3 = 1, but it seemed that it could only adapt the xl.l results without inheriting the itera1's result. What I imagined to go is itera2 would firstly copy the itera1, then apply the xl.l. Then my ideal result should be like follows.
How can I achieve that? Sorry for posting too many codes, but my goal is simple. I know I cannot achieve this by adding a simple one line code like:
Thanks for reading all of these.

Sorry for asking so many questions but I really need help. I tried to use iteratively updated parameters to do my algorithm, named Column and Constraint Generation, which has been enlightened by the Benders Decomposition. Then I am a little bit confused about how I can update my parameters from the previous one with some conditions. These parameters are all Binary. Here shows how I define the iteration set:

Code: Select all

```
Set itera /itera1*itera50/;
Set columnset(itera) dynamic set;
columnset(itera) = no;
Parameter L_avail; * this is my planned updating parameter
Loop(itera, * Here is how I insert the 1st iteration result, "L_avail0(l)" is a fixed parameter.
if(ord(itera) ge 2,
break;);
L_avail(l, itera) = L_avail0(l);
);
```

Code: Select all

```
... ...
Llim10(l, columnset).. f(l) =g= - L_avail(l, columnset) * LDATA(l, 'FLmax');
Llim20(l, columnset).. f(l) =l= L_avail(l, columnset) * LDATA(l, 'FLmax');
... ...
```

Then I tried to use the following codes to update my parameters.

Code: Select all

```
Loop(itera,
if(ord(itera) ge 2, * bc the 1st results have been stored and fixed.
Solve ... ...
Loop(l,
if(xl.l(l) = 1, * xl.l are solutions.
L_avail(l, itera) = 1); * update
);
);
```

Code: Select all

```
---- 445 PARAMETER L_avail
itera1
l1 1.000
l2 1.000
l4 1.000
l5 1.000
```

Code: Select all

```
---- 420 PARAMETER L_avail
itera1 itera2
l1 1.000
l2 1.000
l3 1.000
l4 1.000
l5 1.000
```

Code: Select all

```
---- 420 PARAMETER L_avail
itera1 itera2
l1 1.000 1.000
l2 1.000 1.000
l3 1.000
l4 1.000 1.000
l5 1.000 1.000
```

Code: Select all

```
L_avail(l, itera) = L_avail(l, itera-1)
Loop(l,
if(xl.l(l) = 1,
L_avail(l, itera) = 1);
);
```