pythonnonlinear-optimizationgekkomixed-integer-programming

Is there any benefit of choosing to formulate constraints in a way or another in GEKKO?


I have an MINLP problem and let's say the continuous variable Q can only be 0 when the binary variable z is 0. Two ways to formulate this would be:

m.Equation(Q*(1-z) == 0) (1)

or

m.Equation(Q < z*10000) (2)

whereby 10000 would be the upper bound to the continuous variable Q. Does (1) or (2) have any benefits over the other?

I've used (1) in my model for heat exchanger network synthesis and I got a good solution pretty quickly. Using (2) takes around 100x longer and it gives worse solution than the one given using (1).

From what I can see, the MINLP relaxation to (1) would still require z to be exactly 1 for Q to take on non-zero values. Does this have any effect on how APOPT solve the problem?


Solution

  • Q(1-z) = 0 is non-linear and non-convex while Q <= 10000z is linear (and convex). The last one is much better as long as the big-M constant is small.

    If you can't reduce the size of the big-M constant, consider using indicator constraints (using suitable modeling tools and solvers).