optimization module of multi dimensional function
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README
downhill-simplex.rb
stat.rb

README

optimium is a multidimensioal optimization package for Ruby and its
built-in class Proc.

Copyright (c) 2010 FUJITA Yuji <yuji@webmasters.gr.jp>
License: what Ruby is using

Currently optimium only uses Nelder-Mead method (aka downhill simplex
method) for its optimization algorithm.

Usage: make a Proc instance to compute the function of n independent
arguments (parameters). Then build an n-dimensional simplex as a set of
initial values and call method "dhsmplx" with the argument of the simplex.
The return value is the array of simplice representing the history
took to optimize the function with the first simplex as the starting
point and the last one as the optimized result.
The history is kept so as to make you can chek the process of optimization
via gnuplot or sort of such tools.

-- Here's a sample session --

include Math
proc=lambda{|a, b|sin(a)*cos(b)}
optimium=proc.dhsmplx([[0, 0], [1, 0], [0, 1]])

optimium[-1][0] would be [-1.59662085343529, -0.00122691377946672]
which means -PI/2 and 0.
The optimized function value can be obtained by
proc.call(*optimium[-1][0]) which will be -0.999665 or something,
meaning optimized to -1. Note the "*" in front of argument for parameter
expansion.

--

For more details, please see
http://fjt.webmasters.gr.jp/linux/yesterday/2009.09.19.html
although above article is written in Japanese.