Is there an upper bound for the variable in 'addGenConstrPow()' ?
AnsweredHi,
I am trying to add a general constraint into my model. However, it seems like there's an upper bound for the variable in 'addGenConstrPow()'.
Here is an example:
x = m.addVar(ub=5,lb=0,vtype=GRB.CONTINUOUS,name='x')
y = m.addVar(ub=GRB.INFINITY,lb=0,vtype=GRB.CONTINUOUS,name='y')
m.update()
m.setObjective(y, GRB.MAXIMIZE)
m.addGenConstrPow(x, y, 10)
m.optimize()
Optimal solution found (tolerance 1.00e-04)
Best objective 1.000000000000e+06, best bound 1.000000000000e+06, gap 0.0000%
1000000.0000000005
Apparently, the objective value should be y = 9765625 (5^10), but I got 1000000 as the 'objVal'. Besides, I also meet the same problem while implementing 'addGenConstrLog()' .
I am wondering if there is a misunderstanding or how can I deal with the limitation?
Thanks,
Lin
-
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 are correct, there is an upper limit placed on \(y\). According to the General Constraint documentation,
For some of the supported functions, modest values can lead to enormous values (and vice-versa). This can cause numerical issues when solving the resulting piecewise-linear MIP model. To avoid such issues, we limit the range of any x or y that participates in a function constraint to [-1e+6, 1e+6]. The parameter FuncMaxVal allows you to change these limits, but we recommend that you proceed with caution.
Therefore, you can simply change this value using the FuncMaxVal parameter. However, as the documentation notes, such large numbers can lead to numerical issues. You can learn more about numerical instability in the Guidelines for Numerical Issues.
0 -
I've changed the parameter successfully! Thanks for your help!
Best,
Lin
0
Post is closed for comments.
Comments
3 comments