When minimizing a function, I'm trying to prevent one value from exceeding another value in the used vector.
For example, this code optimizes init_x
:
using Optim
f(x) = (1.0-x[1])^2+100.0*(-x[2]^2)^2
init_x = [0.0,0.0]
res = Optim.minimizer(Optim.optimize(f, init_x))
which returns:
2-element Vector{Float64}:
0.9999860561511018
-0.0006072923701139431
How would I prevent the first value of res
(0.9999860561511018) from exceeding the second value of res
(-0.0006072923701139431) during optimization?
like using a constraint where res[1]
< res[2]