JuliaNLSolvers / Optim.jl

Optimization functions for Julia
Other
1.12k stars 217 forks source link

Documentation Incorrect #1082

Closed tb6g16 closed 6 months ago

tb6g16 commented 7 months ago

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:

https://github.com/JuliaNLSolvers/Optim.jl/blob/78ab1f4859c09ec73640829d26b3825c02b7ac95/docs/src/algo/nelder_mead.md?plain=1#L82-L89

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

pkofod commented 6 months ago

It seems like the docs are not running for some reason.. Thanks for noticing.

pkofod commented 6 months ago

Thanks to @asinghvi17 it is now correctly updated :)