Multiplication of multiple variables
AnsweredI’m currently using Gurobi optimizer for a cost optimization, but encounter a very annoying problem.
I would like to add constraints in which I multiply three variables, all binary, but results in a QuadExpr() error. Is there any way to overcome this issue?
Kind regards
Michiel

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*x3For binary variables, this should just work out of the box. For nonbinary variables, this is only supported since Gurobi 9.0, and only if you set the "NonConvex" parameter to 2.
Regards,
Tobias
0 
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/enus/community/posts/360057684331invalidexpressiontoquadexprmultiplication yields a quite ugly solution with a lot of dummy vars. Isn't there a simpler solution?
Thanks in advance.
0 
Yes, unfortunately this is still the way to do it as of today.
0
Please sign in to leave a comment.
Comments
3 comments