Hi, I am trying to maximize a very simple function in JuMP which I can solve analytically. I am getting an optimal solution which is different from what I should get. I was hoping someone could point me to my error.
They seems pretty similar to me? Ipopt uses tolerances, so you should expect some (small) differences between the analytic solution and the computed optimum.
You can get a better solution by turning off scaling:
But the underlying problem is that x^0.8 is only defined for x>=0 and this can cause problems when Ipopt attempts to evaluate a solution that is slightly negative (e.g., Q[1] = -1e-8).
(@v1.6) pkg> status JuMP
Status `C:\Users\juan\.julia\environments\v1.6\Project.toml`
[4076af6c] JuMP v0.21.10
(@v1.6) pkg> status Ipopt
Status `C:\Users\juan\.julia\environments\v1.6\Project.toml`
[b6b21f68] Ipopt v0.7.0
Actually, I have a much larger problem, and I do not know if this is a symptom. The solution in this optimization routine is interior (in terms that the constraint c1 is not binding at the optimum), however when I change the value of the constant C1 the value of the optimizer changes.
Edit: your analytical solution is correct, provided it satisfies the constraint (which of course should be checked).
Are you sure Ipopt converged properly? When I ran your example, it failed with “EXIT: Restoration Failed”.
This is unlikely to be relevant here, but you probably shouldn’t use 1.6.1 - the current stable release is 1.7.1, and even if for some reason you need to use 1.6, the latest patch release is 1.6.5