Usage of variables
AnsweredHi, I have a trouble with decision variables I defined. I want to use decision variables in some mathematical context but ı get the error of "must be real number, not gurobipy.LinExpr" . The code is like that
p=[]
for i in range(5):
p.append(exp((P[i]-u[i])/(0.4))
u[i]'s are decision variables, How can I solve this problem?
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?. -
Hi İrem,
Gurobi currently does not support nonlinear expressions other than bilinear multiplication and square terms. This means that you cannot construct a term \(\exp(x)\) where \(x\) is an optimization variable.
You can use a piecewise-linear approximation to model the \(\exp\) function. For more information, please refer to the documentation of the addGenConstrXxx functions and the documentation of general constraints.
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments