I am currently trying to solve a simple unit commitment problem in the form of MILP. And this model relates to some binary variables to indicate the condition of different generators.

While I was modelling, I built a constraint like: ‘y_gsd(t-1) =e= y_g(t-1) - y_g(t)’ . In this constraint, y_gsd, y_g are binary variables and t is a index set of time step. I just want to know what would happen, if y_g(t-1) = 0 and y_g(t) = 1, which will cause y_gsd(t-1) = -1.

The physical logic of this constraint might be wrong. But I still want to know how GAMS will handle y_gsd(t-1) in this case. Which a negative value is assigned to a binary variable.

If I rephrase your question, you ask what happens if you have

x =e= y - z

for x, y, z binary.

It’s important to know that this is not an assignment statement: it’s an equality constraint. It behaves exactly as if you write

z =e= y - x or
x - y + z =e= 0

So if y is zero and z is 1, there is no way to satisfy the equality constraint and the bound on the variable. Usually, both GAMS and the solvers will respect the simple bounds on the variables, so x will take a feasible value and y and/or z will be adjusted in the solver to satisfy the constraint.

Thank you for your reply! Would you mind elaborating little bit about this bound violation? (Or please recommend if there is related documents for reference)

Because so far I think solver or GAMS itself will tightly respect the bound. So for cases need big-M disjunctive formulation, I will try to push a positive variable a to negative, (e.g. a =l= 5 - M*y, y is binary) and I think the solver will consider a = 0 when y = 1.

After your explanation, it seems like solvers have their own way to deal with this situation. Could you share more insight about this topic? Thank you!

It seems fair to assume that M >> 5, so if y = 1, this equation infeasible. So the solver could just fix y to 0.

In general, I think of the feasible set in mathematical terms: for a vector x, the feasible set is all values of x s.t. L <= x <= U, Ax <= b or similar. If you think in this way, you don’t need to be concerned with how the solver chooses one of those values as the optimum: that is the solver’s job, not the modeler’s.

Of course, as a modeler, you want to model in a way that helps the solver, so it can help to understand how a solver works. Sometimes a solver can make deductions about the feasible set based on a constraint. For example, x + y = 1 with x, y free is nice. A solver can replace x with 1-y everywhere, removing x from the model. In your case, you had

You asked what would happen if y - z is -1. Such a point is infeasible, so the solver would never return it as the optimum (or even a feaslble) point. The techniques solvers use to do so efficiently is much more than I can describe here, but in this case a solver could look at the constraint and introduce a new constraint