Syntactical Question about optimize

Hi, someone not knowing much about optimization here…

Why does this code searching for the minimum of the two-dimensional paraboloid

optimize(x->x[1]^2+x[2]^2,[1.0, 1.0])

work without given algorithm whilst this one-dimensional equivalent


only works with specified algorithm

optimize(x->x[1]^2,[1.0], BFGS())

(message says that NelderMead does not work with one variable)

Further, this version without vectors


does not work at all for syntactical reasons, seemingly:

ERROR: MethodError: no method matching optimize(::getfield(Main, Symbol("##13#14")), ::Float64)

but the bound version in (-1.0,1.0) works fine (and is much more precise)


I stumbled across this because I want to optimize a one-dimensional function from a given starting point, not an interval

Check out the docs for valid syntax The question about NelderMead is arguably a user experience bug. NelderMead is the default solver for vector inputs when only the objective function is given but it needs at least 2 variables, which probably means that there should be another fallback for the one variable vector case. You can open an issue about this on Github to get some more attention from the package authors.

1 Like

Edit: I misunderstood


So this syntax is just unsupported?

No it is not supported AFAIK, but maybe it should be. You can open an issue.