Dear all,
I have a binary decision variable, y(X,t) as follows:
sets
t /t1*t5/
X /X1*X2/ ;
binary variable
y(X,t);
As it can be seen, the variable y(X,t) can take 1 or 0 value for all X set. In other words:
y(X,t) can take as follows (an example):
X1 X2
t1 0 0
t2 1 0
t3 0 1
t4 1 1
t5 1 1
I want to define a variable, Y(t) ( for equation ):
such that if for any t,
sum(X,y(X,t)) > 1
Y(t) should be 1, else Y(t) should be 0.
Please note that, I do not want to have conditional-statement, because I cannot use it while writing equations. Also, there should be no dollar condition for variables.
Thanks
Do you want
sum(X,y(X,t)) > 1 (means 2 or more) or sum(X,y(X,t)) >= 1 (means one or more)?
If it is the latter, it is very easy (first of all do not rename both variables y. I will use y(x, t) and y1(t) in the following equations)
eq1(t)… y1(t) =l= sum(X,y(X,t))
eq2(x,t)… y(x,t) =l= y1(t);
eq1 ensures that if sum(x, y(x, t)) is 1 or more, y1(t) has to be 1. M is a big-M constant (not too big I would say it should be same as card(x) in your case).
eq2 ensures that if all y(x,t) are 0, y1(t) is 0.
Hope this helps.
Hi Atharv,
Thanks for your answer. Your answer is absolutely what I needed.
Yes, I wrote it by mistake (repeared Y), thanks that you have corrected it.
Meanwhile, before your answer was being posted , I thought the following :
y(t) =e= [{[sum(X,Y(X,t)) = 0 ] AND 0} AND 0 ]
Can you please see if it makes sense ?
Thanks alot for your answer !
No it does not make sense. “sum(X,Y(X,t)) = 0” is a condition that might keep changing during solve. This is no different than using $ values on variables. It is not allowed while defining equations.
Please use the constraints that I mentioned.
Yes. You are correct.
I tried with it. And indeed it is like using $ over variables.
Thanks for your advice. I have to use the condition , which you have provided.
Thanks alot again.