using GalacticOptim, Optim
function tmp(x,p)
return (x[1]-2)^2
end
prob = OptimizationProblem(tmp,[4.],lb=[3],ub=[6])
res = solve(prob,SimulatedAnnealing())
the result is correct 1.9982228757130818. However, I set a lower bound =3, so would expect it to step here. How do I get the lower bound to work?
Similarily, for:
using GalacticOptim, Optim
function tmp(x,p)
return -(x[1]-2)^2
end
prob = OptimizationProblem(tmp,[4.],lb=[3],ub=[6])
res = solve(prob,SimulatedAnnealing())
I would expect to just hit the upper bound, but I get the answer 400.7172021819915.
using GalacticOptim, Optim
function tmp(x,p)
return (x[1]-2)^2
end
fun = OptimizationFunction(tmp, GalacticOptim.AutoForwardDiff())
prob = OptimizationProblem(fun,[4.],lb=[3],ub=[6])
res = solve(prob,Fminbox())
println(res)
using GalacticOptim, Optim
function tmp(x,p)
return -(x[1]-2)^2
end
fun = OptimizationFunction(tmp, GalacticOptim.AutoForwardDiff())
prob = OptimizationProblem(fun,[4.],lb=[3],ub=[6])
res = solve(prob,Fminbox())
println(res)
returns
retcode: Default
u: [3.0000000013333334]
Final objective value: 1.0000000026666669
retcode: Default
u: [5.999999999666667]
Final objective value: -15.999999997333333
I found out about the bounds at OptimizationProblem · GalacticOptim.jl, but you might be right and those not applying to the SimulatedAnnealing algorithm.
I have a problem where derivatives don’t make sense, so I figured I was limited to that one and NelderMead (https://galacticoptim.sciml.ai/stable/local_optimizers/local_derivative_free/), which I ran into other problems with (it errors at the HPC I have access to, I’ve asked the HPC people for help with interpreting the error message the HPC yielded).
There is a bounded simulated annealing algorithm in Optim.jl called SAMIN. An example of how to call it would be opt = Optim.optimize(obj, lb, ub, θ, SAMIN())
where ib, ub and θ are all vectors.