Skip to content

Documentation Incorrect #1082

@tb6g16

Description

@tb6g16

I've noticed that in the explanation in the docs of the Nelder-Mead solver contains a couple of bugs, specifically the snippet of code to construct the initial simplexer for a Matlab like simplex:

function Optim.simplexer(A::MatlabSimplexer, initial_x::AbstractArray{T, N}) where {T, N}
    n = length(initial_x)
    initial_simplex = Array{T, N}[initial_x for i = 1:n+1]
    for j = 1:n
        initial_simplex[j+1][j] += initial_simplex[j+1][j] == zero(T) ? S.b * initial_simplex[j+1][j] : S.a
    end
    initial_simplex
end

I was going to submit a small pull request to fix this before I noticed that the fixes had already been implemented:

function Optim.simplexer(S::MatlabSimplexer, initial_x::AbstractArray{T, N}) where {T, N}
n = length(initial_x)
initial_simplex = Array{T, N}[copy(initial_x) for i = 1:n+1]
for j = 1:n
initial_simplex[j+1][j] += initial_simplex[j+1][j] != zero(T) ? S.b * initial_simplex[j+1][j] : S.a
end
initial_simplex
end

Presumably the docs using this example should be updated to the correct version.

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