Algorithm::SpiralSearch - Function Optimization of Two Parameters
use Algorithm::SpiralSearch;
my $LBx = 0; my $UBx = 1000; my $LBy = 0; my $UBy = 1000; my $iters = 50; my ($x, $y) = spiral_search($LBx, $UBx, $LBy, $UBy, $iters, \&f, 'MAX');
sub f { my ($p1, $p2) = @_; my $ret = simulator($p1, $p2, ...); return $ret; }
A spiral search is a method used to optimize a two-parameter, relatively,
well-behaved function. Boundary conditions, the maximum number of
iterations, a reference to a function, and an indicator to maximize or
minimize the function are passed to the spiral_search function.
spiral_search() returns the optimal point in the function passed to it.
It's an elegant optimization algorithm, but is not well-suited for most
applications. SETI uses the spiral search in hunting for strong radio
signals. Spiral search is most effective in situations where function
evaluations are expensive and where there's a small amount of random
noise within the search space. The algorithm is of order O(n).
spiral_search($LowerBound_x, $UpperBound_x, $LowerBound_y, $UpperBound_y, $iterations, \&function, $MAX_or_MIN)
Initiates the spiral search. The first four parameters define the search space plane. Spiral search is of order O(n), so the number of iterations defines how many refinements the algorithm should take into account. The greater the number of iterations, the more accurate the findings. The sixth parameter should be a reference to a function for which the parameters will be plugged into. This function should return only one value - a scalar output indicative of the accuracy of the inputs. The last input parameter should be either one of the two strings 'MAX' or 'MIN', each corresponding to how spiral_search will optimize its given function. spiral_search returns a pair of parameters that are approximately optimal with respect to the given function.
Sean Mostafavi, <seanm@undersea.net>
Copyright (C) 2006 by Sean Mostafavi
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.