class Aitk::NelderMeadOptimizer
- Aitk::NelderMeadOptimizer
- Aitk::AbstractOptimizer
- Reference
- Object
Overview
Tries to find optimal parameters that result into maximum result of function. If you want to understand better how it works check this PDF.
Example: find a peak of the given pyaramid function.
optimizer = Aitk::NelderMeadOptimizer.new(2) do |params|
x,y = params
xc, yc = 30.0, -15.0
# pyramid function, with highest peak z=1, in x=30 and y=-15
1 - ((x-xc) + (y-yc)).abs - ((y-yc) - (x-xc)).abs
end
# Perform 100 iterations
optimizer.optimize(iterations: 100) # => [30.0, -15]
# Interrupt optimization using the callback, that is being called every 10 iterations:
optimizer.optimize(period: 10) do |optimizer|
# Stop, when best score is higher than 0.99
optimizer.score > 0.99
end
# => [29.999, -15.0022]
Interrupt, if 10 iterations, did not change score more than 0.01 :
optimizer.optimize(period: 10, min_change: 0.01) # => # [29.9999, -15.0002]
By default it tries to initialize solutions, that form simplex based a given range. For size=2, it would look like the following triangle (points represent the solutions):
^ y
|
* b
|
|
|
|
|
* - - - - - * - -> x
c a
a = [range.end, range.begin]
b = [range.begin, range.end]
c = [range.begin, range.begin]
Defined in:
aitk/optimization/nelder_mead_optimizer.crConstructors
Instance Method Summary
- #iterate
- #iterations : Int32
-
#score : Float64
Get current best score.
- #scores
-
#solution : Array(Float64)
Get current best solution.
- #vectors : Array(Aitk::Vector)
Instance methods inherited from class Aitk::AbstractOptimizer
iterate
iterate,
iterations : Int32
iterations,
optimize(iterations = nil, period = 1, min_change = nil)optimize(iterations : Nil | Int = nil, period = 1, min_change : Nil | Number = nil, &) : Array(Float64) optimize, score score, solution solution