Hi, I’m trying to understand why the COBYLA algorithm doesn’t find the optimal value in the following MWE. By contrast, IPNewton does work. Am I violating some COBYLA assumption that I’m forgetting about? For the problem with non-binding constraints, uncomment the other definition for prob
and comment the current one; this gives similar behaviour.
using Random, Optimization, OptimizationMOI, OptimizationNLopt, OptimizationOptimJL, OptimizationPRIMA, DifferentiationInterface, Ipopt
Random.seed!(42)
function RunTest()
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = [0.5, 0.5]
_p = [1.0, 100.0]
f(x) = [x[1]^2 + x[2]^2, x[1] * x[2]]
cons(res, x, p) = (res .= f(x))
optprob = OptimizationFunction(rosenbrock, SecondOrder(AutoForwardDiff(), AutoForwardDiff()), cons = cons)
#prob = OptimizationProblem(optprob, x0, _p, lb = [0., 0.], ub = [1., 1.], lcons = [-1., -1.0], ucons = [2., 2.0])
prob = OptimizationProblem(optprob, x0, _p, lb = [0., 0.], ub = [1., 1.], lcons = [-1., -1.0], ucons = [0.8, 2.0])
opt_vec = [COBYLA(), IPNewton()]
opt_names = ["COBYLA", "IPNewton"]
for (opt, opt_name) in zip(opt_vec, opt_names)
sol = solve(prob, opt)
print("====\n$opt_name\n$sol")
end
end
RunTest()
I get for the problem with constraints:
====
COBYLA
retcode: Success
u: [1.58113883008419e-6, 4.743416490252569e-6]
Final objective value: 0.9999968399748375
====
IPNewton
retcode: Success
u: [0.7247018404470709, 0.5242206047577943]
Final objective value: 0.07588358475785834