Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParticleSwarm does not respect Optim.Options(iterations=x) #836

Closed
NightMachinery opened this issue Jul 21, 2020 · 1 comment
Closed

ParticleSwarm does not respect Optim.Options(iterations=x) #836

NightMachinery opened this issue Jul 21, 2020 · 1 comment

Comments

@NightMachinery
Copy link

julia> Optim.Options(iterations=10)
                x_abstol = 0.0
                x_reltol = 0.0
                f_abstol = 0.0
                f_reltol = 0.0
                g_abstol = 1.0e-8
                g_reltol = 1.0e-8
          outer_x_abstol = 0.0
          outer_x_reltol = 0.0
          outer_f_abstol = 0.0
          outer_f_reltol = 0.0
          outer_g_abstol = 1.0e-8
          outer_g_reltol = 1.0e-8
           f_calls_limit = 0
           g_calls_limit = 0
           h_calls_limit = 0
       allow_f_increases = false
 allow_outer_f_increases = false
        successive_f_tol = 1
              iterations = 10
        outer_iterations = 1000
             store_trace = false
           trace_simplex = false
              show_trace = false
          extended_trace = false
              show_every = 1
                callback = nothing
              time_limit = NaN


julia> result = optimize(x-> f(x[1],x[2]), [0.0,0.0], ParticleSwarm())
 * Status: failure (reached maximum number of iterations) (line search failed)

 * Candidate solution
    Minimizer: [5.00e+00, -1.00e+00]
    Minimum:   -9.116548e+01

 * Found with
    Algorithm:     Particle Swarm
    Initial Point: [0.00e+00, 0.00e+00]

 * Convergence measures
    |x - x'|               = NaN ≰ 0.0e+00
    |x - x'|/|x'|          = NaN ≰ 0.0e+00
    |f(x) - f(x')|         = NaN ≰ 0.0e+00
    |f(x) - f(x')|/|f(x')| = NaN ≰ 0.0e+00
    |g(x)|                 = NaN ≰ 1.0e-08

 * Work counters
    Seconds run:   28  (vs limit Inf)
    Iterations:    1000
    f(x) calls:    4001
    ∇f(x) calls:   0

julia> Optim.Options(outer_iterations=12)
                x_abstol = 0.0
                x_reltol = 0.0
                f_abstol = 0.0
                f_reltol = 0.0
                g_abstol = 1.0e-8
                g_reltol = 1.0e-8
          outer_x_abstol = 0.0
          outer_x_reltol = 0.0
          outer_f_abstol = 0.0
          outer_f_reltol = 0.0
          outer_g_abstol = 1.0e-8
          outer_g_reltol = 1.0e-8
           f_calls_limit = 0
           g_calls_limit = 0
           h_calls_limit = 0
       allow_f_increases = false
 allow_outer_f_increases = false
        successive_f_tol = 1
              iterations = 1000
        outer_iterations = 12
             store_trace = false
           trace_simplex = false
              show_trace = false
          extended_trace = false
              show_every = 1
                callback = nothing
              time_limit = NaN


julia> result = optimize(x-> f(x[1],x[2]), [0.0,0.0], ParticleSwarm())
 * Status: failure (reached maximum number of iterations) (line search failed)

 * Candidate solution
    Minimizer: [4.99e+00, -9.97e-01]
    Minimum:   -9.114673e+01

 * Found with
    Algorithm:     Particle Swarm
    Initial Point: [0.00e+00, 0.00e+00]

 * Convergence measures
    |x - x'|               = NaN ≰ 0.0e+00
    |x - x'|/|x'|          = NaN ≰ 0.0e+00
    |f(x) - f(x')|         = NaN ≰ 0.0e+00
    |f(x) - f(x')|/|f(x')| = NaN ≰ 0.0e+00
    |g(x)|                 = NaN ≰ 1.0e-08

 * Work counters
    Seconds run:   30  (vs limit Inf)
    Iterations:    1000
    f(x) calls:    4001
    ∇f(x) calls:   0
@NightMachinery
Copy link
Author

My usage was incorrect. This is the correct syntax:

optimize(slow, zeros(2), NelderMead(), Optim.Options(time_limit = 3.0))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant