Skip to content

Commit

Permalink
Deprecate NelderMead better.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkofod committed Aug 13, 2016
1 parent 32d6b37 commit 7b0207c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/deprecate.jl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@deprecate NelderMead(a::Real, g::Real, b::Real) NelderMead(parameters = FixedParameters(a, g, b, 0.5))
@deprecate NelderMead(a::Real, g::Real, b::Real) NelderMead(initial_simplex = AffineSimplexer(), parameters = FixedParameters(a, g, b, 0.5))
19 changes: 18 additions & 1 deletion src/nelder_mead.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,24 @@ immutable NelderMead{Ts <: Simplexer, Tp <: NMParameters} <: Optimizer
parameters::Tp
end

NelderMead(; initial_simplex = AffineSimplexer(), parameters = AdaptiveParameters()) = NelderMead(initial_simplex, parameters)

function NelderMead(; kwargs...)
KW = Dict(kwargs)
if any(haskey(KW, k) for k in (:a,:g,:b))
a, g, b = 1.0, 2.0, 0.5
haskey(KW, :a) && (a = KW[:a])
haskey(KW, :g) && (g = KW[:g])
haskey(KW, :b) && (b = KW[:b])
return NelderMead(a, g, b)
elseif any(haskey(KW, k) for k in (:initial_simplex, :parameters))
initial_simplex, parameters = AffineSimplexer(), AdaptiveParameters()
haskey(KW, :initial_simplex) && (initial_simplex = KW[:initial_simplex])
haskey(KW, :parameters) && (parameters = KW[:parameters])
return NelderMead(initial_simplex, parameters)
else
return NelderMead(AffineSimplexer(), AdaptiveParameters())
end
end

# centroid except h-th vertex
function centroid!{T}(c::Array{T}, simplex, h=0)
Expand Down

0 comments on commit 7b0207c

Please sign in to comment.