There may be a bug for "addGenConstrLog"
AnsweredI establish a model that contain constrains:
model.addGenConstrLog(X[i], Y[i])
model.addConstrs((X[i]==Cost_Non[i]-(Cost_Tra[i]+C_e[i]) for i in range(N_i) ),"con_X")
model.addConstrs(Cost_Non[i]-(Cost_Tra[i]+C_e[i])>=0 for i in range(N_i) )
There is a GurobiError: 'lower bound of x variable is less than zero for LOG function' if X[i] is free.
I confuse that, X[i]>=0 according to the constrain "model.addConstrs(Cost_Non[i]-(Cost_Tra[i]+C_e[i])>=0 for i in range(N_i) )".
Why this error occurs? What is the principle of solution method for "addGenConstrLog"?
-
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?. -
The logarithm function only takes positive arguments. Hence the x-variable may not be negative here.
0 -
Thanks for your answer.
Although x is free, I have a constrait
model.addConstrs(Cost_Non[i]-(Cost_Tra[i]+C_e[i])>=0 for i in range(N_i) )
to satisfy x>=0. However, it doesn't work on "x". I'm confused on it.
0 -
Hi,
The check whether the variable \(x\) in \(\log(x)\) is \(\geq 0\) is done before the presolving step. Thus, it is required to explicitly set the lower bound of the \(x\) variable to 0. Moreover, it is a good modelling style to provide all bounds they are known.
Best regards,
Jaromił0
Post is closed for comments.
Comments
4 comments