Invalid argument to QuadExpr multiplication
Answered

I get the error at objective function. The cosole output is:
File ~\Desktop\Optimization code.py:51 in TSP
md.setObjective(quicksum(ux[j]*w[0]*z[j]*( tf[0]+tv[0]) for j in range(m)) + quicksum(uy[j]*w[1]*z[j]*(tv[1]+tf[1]) for j in range(m)) +
File src\gurobipy\gurobi.pxi:3631 in gurobipy.quicksum
File ~\Desktop\Optimization code.py:51 in <genexpr>
md.setObjective(quicksum(ux[j]*w[0]*z[j]*( tf[0]+tv[0]) for j in range(m)) + quicksum(uy[j]*w[1]*z[j]*(tv[1]+tf[1]) for j in range(m)) +
File src\gurobipy\quadexpr.pxi:523 in gurobipy.QuadExpr.__mul__
File src\gurobipy\quadexpr.pxi:245 in gurobipy.QuadExpr._mul
GurobiError: Invalid argument to QuadExpr multiplication
Can you help me with the problem?
-
Official comment
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Fatih,
Although Gurobi does not directly support constraints containing more general multilinear terms, they can be modeled using a series of bilinear constraints. In your case, you must extend your model by auxiliary variables, to express your objective function using bilinear terms only. Please have a look at this article explaining the concept.For further reference, a similar question was asked in these two community posts:
https://support.gurobi.com/hc/en-us/community/posts/360056771292-Invalid-argument-to-QuadExpr-multiplication-Error-
https://support.gurobi.com/hc/en-us/community/posts/360076716571-Invalid-argument-to-QuadExpr-multiplication
Best regards,
Lennart0
Post is closed for comments.
Comments
2 comments