5

JuMP provides a special syntax for creating indicator constraints.So, Which one is better, linearizing the indicator constraints and then write a code or using this feature?

In order to constrain the constraint x + y <= 2 to hold when z binary variable a is one:

@variable(model, x)
@variable(model, y)
@variable(model, z, Bin)
@constraint(model, z => {x + y <= 2})

Actually my question is which one is faster and more efficient, To linearize ourselves or to use code?

Python.py
  • 71
  • 3

1 Answers1

1

The answer is problem- and solver-dependent. You should try both approaches and time them to find out which is more efficient for your problem.

Some solvers (e.g., Gurobi) have special support for indicators, in which case it's probably faster to use the indicators directly. If you're using a solver that doesn't have special support for indicators, we convert the indicator constraint to a SOS-I constraint (https://jump.dev/MathOptInterface.jl/stable/submodules/Bridges/reference/#MathOptInterface.Bridges.Constraint.IndicatorSOS1Bridge).

The quality of a big-M type linearization will depend on using domain knowledge to select a good big-M. JuMP doesn't do big-M reformulations automatically.

Oscar Dowson
  • 2,395
  • 1
  • 5
  • 13
  • 2
    Sorry, I don't think "try it yourself and figure it out" is an effective StackOverflow answer. That doesn't really provide anything to future viewers (or the OP, for that matter). – Silvio Mayolo May 22 '21 at 01:28
  • 1
    The answer is "it depends" so encouraging people to try it out is exactly what they should do. – Oscar Dowson May 22 '21 at 03:38
  • 1
    I've edited the post to provide more detail. But the answer is still "it depends" and I encourage future readers to experiment with multiple formulations. Modeling in OR is an art, not a science. – Oscar Dowson May 25 '21 at 20:00