It seems that your constraint
@constraint(model, [i = 1:numtime], -60 * time60[i] <= Q[i] - 60)
forces time60[i]
to be 1 if Q[i] < 60
. Let’s say that Q[i]=40
. Then we have:
-60*time60[i]<=-20
If time60[i]
is zero, then we have 0<=-20
which is false, so time60[i]
must be one. Maybe this link would help: Conditional constraint if else in JuMP - #12 by odow? Your constraint could be something like:
for i in numtime
if Q[i] >= 0
@constraint(model,time60[i] == 1)
end
end
If you really want to play with reformulations, how about (not sure if this covers all the cases, so take with a pinch of salt):
@constraint(model, [i = 1:numtime], -60 * time60[i] <= 60 - Q[i] )
Now if Q[i]<=60
, then the right-hand side is non-negative and time60[i]
can be either zero or one. If Q[i]>60
the right-hand side is negative and time60[i]
must be one. We still need to make sure that for Q[i]<60
you get time60[i]=0
. We can redo the second constraint as:
@constraint(model, [i = 1:numtime], Q[i] -60>= -60 * (1-time60[i]))
Now, if Q[i]>=60
, the left-hand side is positive, so time60[i]
can be either zero or one. But if Q[i] <60
, then the left-hand side is negative. And for the constraint to be satisfied we need to push the right-hand side to its minimal value that can be attained only when time60[i]=0
.