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

Initial step size documentation incorrect #79

Closed
keatonmill opened this issue May 30, 2017 · 1 comment
Closed

Initial step size documentation incorrect #79

keatonmill opened this issue May 30, 2017 · 1 comment

Comments

@keatonmill
Copy link

keatonmill commented May 30, 2017

The "Initial Step Size" section of the documentation (https://github.com/JuliaOpt/NLopt.jl#initial-step-size) does not match the actual functions exposed by the package, here:

https://github.com/JuliaOpt/NLopt.jl/blob/master/src/NLopt.jl#L382

function initial_step(o::Opt, x::Vector{Cdouble}, dx::Vector{Cdouble})
    if length(x) != ndims(o) || length(dx) != ndims(o)
        throw(BoundsError())
    end
    chkn(ccall((:nlopt_get_initial_step,libnlopt),
               Cenum, (_Opt, Ptr{Cdouble}, Ptr{Cdouble}), o, x, dx))
    dx
end
initial_step{T<:Real}(o::Opt, x::AbstractVector{T}) =
    initial_step(o, copy!(Array(Cdouble,length(x)), x),
                 Array(Cdouble, ndims(o)))
@odow
Copy link
Member

odow commented Jan 25, 2023

Initial step size

Just as in the C
API
,
you can set the initial step sizes for derivative-free
optimization algorithms via the opt.initial_step property:

opt.initial_step = dx

Here, dx is an array of the (nonzero) initial steps for each
dimension, or a single number if you wish to use the same initial
steps for all dimensions. initial_step(opt::Opt, x::AbstractVector) returns the initial step that will be used for a
starting guess of x in optimize(opt,x).

Docs make sense to me:

julia> using NLopt

julia> opt = Opt(:LN_COBYLA, 2)
Opt(LN_COBYLA, 2)

julia> opt.initial_step = 0.1
0.1

julia> initial_step(opt, [1.0, 2.0])
2-element Vector{Float64}:
 0.1
 0.1

julia> opt.initial_step = [0.2, 0.3]
2-element Vector{Float64}:
 0.2
 0.3

julia> initial_step(opt, [1.0, 2.0])
2-element Vector{Float64}:
 0.2
 0.3

Closing as stale, and because the README is correct.

@odow odow closed this as completed Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants