Skip to main content

Multiplication of multiple variables

Answered

Comments

3 comments

  • Tobias Achterberg
    Gurobi Staff Gurobi Staff

    Gurobi only supports products of pairs of variables, not triples. To overcome this issue, you need to introduce auxiliary variables and build the more complex expression using those. For example, in order to model

    y = x1*x2*x3

    you could write

    z12 = x1*x2
    y = z12*x3

    For binary variables, this should just work out of the box. For non-binary variables, this is only supported since Gurobi 9.0, and only if you set the "NonConvex" parameter to 2.

    Regards,

    Tobias

     

    0
  • Moritz Rettinger
    Gurobi-versary
    First Question
    First Comment

    Is this still the only way to model prod() constraints?

     

    e.g. a == x1*x2*x3? I'm looking for something like quicksum just for products.

     

    Trying the solution above combined with https://support.gurobi.com/hc/en-us/community/posts/360057684331-invalid-expression-to-quad-expr-multiplication yields a quite ugly solution with a lot of dummy vars. Isn't there a simpler solution?

     

    Thanks in advance.

    0
  • Richard Oberdieck
    Gurobi Staff Gurobi Staff

    Yes, unfortunately this is still the way to do it as of today.

    0

Please sign in to leave a comment.