I’m having some trouble with the function “log” in an optimization problem.
I create a variable, and then the following constraint:
@NLconstraint(ModelName, log(x) <=100), I use Ipopt to solve it (a feasible problema) and it gives me x=0 (it is infeasible I think), but then I put this constraint: @NL(ModelName, x <= exp(100)) and now it returns a feasible solution. This is a simpler version of my issue…
The thing is…I strongly need to use “Log” in some constraints and the objective function of the optimization problem.How can I solve this?
IPOPT is not a feasible method. The first thing it does is add slack variables to turn your constraint into an equality: log(x) + s = 100 with s ≥ 0. IPOPT only ensures that s > 0 during the iterations, but the equality constraint is only guaranteed to be satisfied in the limit. The problem you have is that your constraint function isn’t defined everywhere, and IPOPT is likely to venture outside of its domain. If you have access to KNITRO, it has a “feasible” option to ensure that nonlinear inequality constraints remain strictly satisfied. If you don’t have access to KNITRO, your best bet is to rework your model.