Suppose I have two real variables: X & Y and two binary variables x & y.
I want to add the following constraint pyomo:
when X>0 x--->1 else x-->0
when Y>0 y--->1 else y-->0
and x+y==1
My approach was cons1: x>=X cons2: y>=Y cons3: x+y==1
but the above doesn't seem to work and the values of x and y are random.
Your first two conditions require big M constraints. You can try something like
M_x * x >= X
, M_y * y >= Y
, and x + y == 1
where M_x and M_y are be constants that you set to values that doesn't unnecessarily bound X and Y. These constraints won't restrict the values of X and Y to 1 and will make x = 1 when X > 0 and y = 1 when Y > 0.