Fixing binary variable

Hi!
I am currently working on a model that is quite lengthy. But in simple words, i want to fix a binary variable (nijt) as soon as other binary varibale (Vijt) becomes one. I tried to implement it as

if(sum((i,j), V.L(i,j,t) =1),
n.fx(i,j,t)$(n.L(i,j,t) = 1) = 1;
);

But it didn’t worked. Can anybody suggest me what to do?
Thanks in advance.

It is unclear why fixing a binary variable is needed.
A constraint such as n(i, j, t) =g= V(i, j, t) can ensure that when V(i, j, t) is 1, n(i, j, t) is 1.

Hi!

Thanks for your kind suggestion.

Actually, n(i,j,t) binary varibale is associated with retrofitting cost. Once retrofitting is done, it will remain over there for the rest of the time (for which i want to fix n(i,j,t)). Whereas, V(i,j,t) is binary variable for operation. If plant is operational then V(i,j,t) should be 1 otherwise zero.

I think the constraint “n(i,j,t) =g= V(i,j,t)” cannot perform it.

Is it correct to rephrase your question that if V(i,j,t1) is 1, then for all t >= t1, n(i, j, t) is 1?

  • I haven’t tested it myself but the logic is as follows.

if any V(i, j, t1) for t1<= t is 1, n(i, j, t1) is 1.

create a variable u(i, j, t) that will store if any v(i, j, t1) for t1<=t is 1. This can be done as follows.
for ord(t) not equal to 1.
u(i, j, t) =g= v(i, j, t);
u(i, j, t) =g= v(i, j, t-1);
u(i, j, t) =l= v(i, j, t) + v(i, j, t-1);

for ord(t) equal to 1.
u(i, j, t) =e= v(i, j, t);

Now we can use u(i, j, t) to define n(i, j, t)
we need the following constraint.

  1.    con1(i, j, t).. n(i, j, t) =g= 1 - M*(1 - u(i, j, t));
    
  2.    con2(i, j, t).. n(i, j, t) =l= M*u(i, j, t);
    

first constraint is needed to make sure if u(i, j, t) is 1 n(i, j, t) is 1. Second constraint is needed to ensure that if u(i, j, t) is 0 then n(i,j,t1) is 0.

Thanks for your time.

Sorry to bother you but it is not working.

I have made edits to my previous answer.

Thank you so much. Now it is working perfectly fine.

I need a bit more favor from you. My scenario is now changed a little bit.
Since retrofitting cost cash flow occurs only once. It means I want n(i,j,t) to be equal to 1 only once and the time when for any power plant ‘i’, V(i,j,t) becomes 1 for the first time.

You can use u(i, j, t) slightly differently to define n(i, j, t) for this case
we need the following constraint.

  1. con1(i, j, t)… n(i, j, t) =g= 1 - (2 - u(i, j, t) - V(i, j, t));
  2. con2(i, j, t)… n(i, j, t) =l= u(i, j, t);
  3. con3(i, j, t)… n(i, j, t) =l= V(i, j, t);
    first constraint is needed to make sure if n(i, j, t) is 1 only when u(i, j, t) and u(i, j, t) both are 1. Second and third constraint ensure that if any of V(i, j, t) or u(i, j, t) is 0 then n(i,j,t) is 0.