Skip to content

Particle swarm getting stuck in local minima on corner of optimisation domain #996

@xtalax

Description

@xtalax

I have been trying to use Optimization.jl with Optim.jl to perform global optimization with ParticleSwarm(), with MethodOfLines.jl generating the data for the loss, and running the forward problem.

I have run in to an issue where the solver gets locked in to only evaluating the upper bound of all parameters, after a few iterations.

Is this the right place for this issue?

My code is somewhat difficult to produce an MWE from, so I thought to ask if this is a known issue before gutting it for debugging fodder.

My optimization setup:

...

LOSS = []                              # Loss accumulator
PARS = []                              # parameters accumulator
using Plots
cb = function (θ, l) #callback function to observe training
    append!(LOSS, l)
    append!(PARS, [θ])
    println("loss = ", l, "; θ = ", θ)
    false
end

println("Generate OptimizationFunction...")
@time opf = OptimizationFunction(loss, Optimization.AutoZygote())

println("Generate OptimizationProblem...")
@time opprob = OptimizationProblem(opf, initp)

_ = loss([1.0,1.0], [])

println("Optimizing...")
@time result = Optimization.solve(opprob, OptimizationOptimJL.ParticleSwarm(lower = [0.0, 20.0], upper = [1.0, 100.0], n_particles=100), maxiters=500, callback=cb)

The output of the run so far:

Optimizing...
loss = 18.22959044129359; θ = [1.0, 30.0]
loss = 11.263023755822093; θ = [0.9909603966537504, 99.77047480421588]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
loss = 9.926057679334475; θ = [1.0, 100.0]
...

Should I post full code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions