Julia: Optimize a function with multiple bounded argument, without using JuMP or something like that?

Viewed 122

thank you for your consideration!

I am a novice of Julia and I am trying to solve multi-variable bounded constraint optimization problem.

I find a code for non-bounded multi-variable optimization example - Julia: Minimise a function with multiple arguments (BFGS)

fmin(x, a) = (1.0 - x[1])^a + 100.0 * (x[2] - x[1]^2)^(a)
r = optimize(x->fmin(x, 2), zeros(2), BFGS())
ddd = r.minimizer
dddd = r.minimum

If possible, how can I include bound "2<x[1]<5" and "4<x[2]<10" into the suggested example above?

of, is there any similar way to do so?

(If the bound does not work, you can apply any other bound as a practice.)

Thank you again!

Have a great day!

1 Answers

This would work

lower = [2.0, 4.0]
upper = [5.0, 10.0]
initial_x = [3.0, 6.0]
results = Optim.optimize(x->fmin(x, 2.0), lower, upper, initial_x, Fminbox(BFGS()))
results.minimizer
Related