invalid expression to quad expr multiplication
AnsweredI am trying to optimize a model, but it always result with an error of "invalid expression to quad expr multiplication", mentioning this line of code:
obj2= obj2 + (1 - z[k-1,i,c]) * z[k,i,c] * ((e[k,i] - Edod) / Ebat) + z[k-1,i,c] * (1 - z[k,i,c]) * ((Emax - e[k,i]) / Ebat)
I know that I cannot multiply 3 variables in Gurobi! But what to do in this case?
By the way, I tried to break the equation into multiple equations with 2 variables in each one of them, but the problem still available!
Any solution?
0
-
Official comment
This post is more than three 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 why not try our AI Gurobot?. -
You can resolve this by adding auxiliary variables, for instance, if you want
x * y * z
term in your objective, introduce auxiliary u variable and set u == x*y through a constraint, then you can use
u * z
as part of your objective expression.
Hope this helps.
0
Post is closed for comments.
Comments
2 comments