Conditions on a binary variable

Problems with modeling
Post Reply
LorenzaFab
User
User
Posts: 1
Joined: 6 months ago

Conditions on a binary variable

Post by LorenzaFab »

Hi,

I need help on how to write conditions on a binary variable.

Considering:
y(i,t) = 1 if activity i is in progress at time t, 0 otherwise
x(i,t) = 1 if activity i starts at time t, 0 otherwise
d(i) = processing time of activity i

I should write the condition "When x(i,t*) = 1, activity i starts at time point t*. So the activity i is in process, y(i,t) = 1, between time point t* and t* + d (i) (not including t* + di)", meaning what:

y(i,t) = 1 with t in [t| t* <= t < t*+d(i), x(i,t*)=1]
y(i,t) = 0 with t in [t| t<t* or t>= t*+d(i), x(i,t*)=1]

Thanks to anyone who can help me!
Fred
Posts: 373
Joined: 7 years ago

Re: Conditions on a binary variable

Post by Fred »

Hi,

Assuming that each activitys stars exacly once, the following should do he trick.

Code: Select all

alias(t,tt);    
startOnce(i)..       sum(t, x(i,t)) =e= 1;
forceActive(i,t)..   sum(tt$[ord(t)<=ord(tt) and ord(tt)<=ord(t)+d(i)-1], y(i,tt)) =g= x(i,t)*d(i);      
forceInactive(i,t).. y(i,t) =l= sum(tt$[ord(t)-d(i)+1<=ord(tt) and ord(tt)<= ord(t)], x(i,tt));   
If x(i,t)=1, equation forceActive(i,t) pushes y to 1 for d(i) consecutive time steps starting at t.

Equation forceInactive(i,t) checks for every (i,t) whether activity i has started in one of the periods [t-d(i)+1 , t] and if not, it forces y(i,t) to zero.

I hope this helps

Fred
Post Reply