optimization module of multi dimensional function
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


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


For more details, please see
although above article is written in Japanese.