use the loop index list to fix a variable Topic is solved

Problems with modeling
Post Reply
shaparak
User
User
Posts: 11
Joined: 2 years ago

use the loop index list to fix a variable

Post by shaparak »

Hello every one
I want to use the loop index list to fix an element of a variable. I used this code:

Code: Select all

loop(i,
attack.fx(i)=0;
solve T maximizing o using mip;
);
but the output is not exactly what I need. in every loop, it fixes some elements of attack variable up to i value. It means, in the last run of the solve command, all elements of attack are fixed! can anyone help me, please?
GFA
User
User
Posts: 50
Joined: 5 years ago

Re: use the loop index list to fix a variable

Post by GFA »

Hi Shaparak,

Not sure what you want to achieve, but you might want to free the attack variable again after the solve, that way the variable only is fixed for the index i it is currently looping over.

Regards,
GFA

Code: Select all

loop(i,
attack.fx(i)=0;
solve T maximizing o using mip;
attack.lo(i) = -inf;
attack.up(i) = inf;
);
shaparak
User
User
Posts: 11
Joined: 2 years ago

Re: use the loop index list to fix a variable

Post by shaparak »

[/quote]
GFA wrote: 2 years ago Hi Shaparak,

Not sure what you want to achieve, but you might want to free the attack variable again after the solve, that way the variable only is fixed for the index i it is currently looping over.

Regards,
GFA

Code: Select all

loop(i,
attack.fx(i)=0;
solve T maximizing o using mip;
attack.lo(i) = -inf;
attack.up(i) = inf;
);
Thank you a lot! it works
Post Reply