I’m solving a MINLP problem. In my case, there is an objective function max(sum(time60[time_slice])) indicating the number of time slices in which the expression Q[time_slice] is greater than 60. That is to say:
Q[i] >=60 ==> time60[i] = 1, else time60[i] = 0

Q is between [0, 100]

I have tried to formulate the problem as below, but according to the optimal point, it fails, the result cannot satisfy the formulation I want. I always got time60 = 1, even though Q <60

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:

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.

The reformulations is usually something like this, where M is a large upper bound on x - 60:

M = 1_000
model = Model()
@variable(model, x)
@variable(model, z, Bin)
@constraint(model, x - 60 <= M * z)
# if x > 60, then x - 60 > 0, so z must be 1
# if x < 60, then x - 60 < 0, so z might be 0 or 1
@constraint(model, 60 - x <= M * (1 - z))
# if x > 60, then 60 - x < 0, so (1 - z) might be 0 or 1
# if x < 60, then 60 - x > 0, so (1 - z) must be 0