|
NAMEMath::Evol - Evolution search optimisationSYNOPSISuse Math::Evol; ($xbref,$smref,$fb,$lf) = evol(\@xb,\@sm,\&function,\&constrain,$tm); # or ($xbref, $smref) = select_evol(\@xb,\@sm,\&choose_best,\&constrain); # or $new_text = text_evol($text, \&choose_best_text, $nchoices ); DESCRIPTIONThis module implements the evolution search strategy. Derivatives of the objective function are not required. Constraints can be incorporated. The caller must supply initial values for the variables and for the initial step sizes.This evolution strategy is a random strategy, and as such is particularly robust and will cope well with large numbers of variables, or rugged objective funtions. Evol.pm works either automatically (evol) with an objective function to be minimised, or interactively (select_evol) with a (suitably patient) human who at each step will choose the better of two possibilities. Another subroutine (text_evol) allows the evolution of numeric parameters in a text file, the parameters to be varied being identified in the text by means of special comments. A script ps_evol which uses that is included for human-judgement-based fine-tuning of drawings in PostScript. Version 1.13 SUBROUTINES
STEP SIZESThe caller must supply initial values for the step sizes. Following the work of Rechenberg and of Schwefel, evol will adjust these step-sizes as it proceeds to give a success rate of about 0.2, but since the ratios between the step-sizes remain constant, it helps convergence to supply sensible values.A good rule of thumb is the expected distance of the value from its optimum divided by the square root of the number of variables. Larger step sizes increase the chance of discovering a global optimum rather than an inferior local optimum, at the cost of course of slower convergence. CALLER-SUPPLIED SUBROUTINES
CONVERGENCE CRITERIA$ec (>0.0) is the convergence test, absolute. The search is terminated if the distance between the best and worst values of the objective function within the last 25 trials is less than or equal to $ec. The absolute convergence test is suppressed if $ec is undefined.$ed (>0.0) is the convergence test, relative. The search is terminated if the difference between the best and worst values of the objective function within the last 25 trials is less than or equal to $ed multiplied by the absolute value of the objective function. The relative convergence test is suppressed if $ed is undefined. These interact with two other small numbers $ea and $eb, which are the minimum allowable step-sizes, absolute and relative respectively. These number are set within Math::Evol as follows: $ea = 0.00000000000001; # absolute stepsize $eb = 0.000000001; # relative stepsize $ec = 0.0000000000000001; # absolute error $ed = 0.00000000001; # relative error You can change those settings before invoking the evol subroutine, e.g.: $Math::Evol::ea = 0.00000000000099; # absolute stepsize $Math::Evol::eb = 0.000000042; # relative stepsize undef $Math::Evol::ec; # disable absolute-error-criterion $Math::Evol::ec = 0.0000000000000031; # absolute error $Math::Evol::ed = 0.00000000067; # relative error The most robust criterion is the maximum-cpu-time parameter $tm LUAIn the "lua/" subdirectory of the install directory there is Evol.lua, which is an exact translation of this Perl code into Lua. The function names and arguments are unchanged, except that text_evol is not yet implemented. Brief Synopsis:local M = require 'Evol' local function minimise(x) -- returns a number to be minimised local sum = 1.0 for k,v in pairs(x) do sum = sum + v * v end return sum end local function constrain(x) if x[1] > 1.0 then x[1] = 1.0 -- it's a greyscale value elseif x[1] < 0.0 then x[1] = 0.0 end return x end local function choose_best(arglist) local preference = 1; local i_arg for i_arg=1,#arglist do local x = arglist[i_arg] if that_suits_me() then preference = i_arg; break end end local continue = true or false return preference, continue end M.ed = 0.00000000067 -- relative error local x = {3.456, 1.234, -2.345, 4.567} -- starting values local sm = {.8, .4, .6, 1.2} -- starting step-sizes local tm = 5.0 -- max time in seconds -- and now... xb,sm,fb,lf = M.evol(xb, sm, minimise, constrain, tm) -- or xb,sm = M.select_evol(xb, sm, choose_best, constrain) -- not yet implemented : -- new_text = M.text_evol(text, choose_best_text, nchoices) AUTHORPeter J Billam, www.pjb.com.au/comp/contact.htmlCREDITSThe strategy of adjusting the step-size to give a success rate of 0.2 comes from the work of I. Rechenberg in his Optimisation of Technical Systems in Accordance with the Principles of Biological Evolution (Problemata Series, Vol. 15, Verlag Fromman-Holzboog, Stuttgart 1973).The code of evol is based on the Fortran version in Numerical Optimisation of Computer Models by Hans-Paul Schwefel, Wiley 1981, pp 104-117, 330-337, translated into english by M.W. Finnis from Numerische Optimierung von Computer-Modellen mittels der Evolutionsstrategie (Interdiscipliniary Systems Research, Vol. 26), Birkhaeuser Verlag, Basel 1977. The calling interface has been greatly Perlised, and the constraining of values has been much simplified. SEE ALSOThe deterministic optimistation strategies can offer faster convergence on smaller problems (say 50 or 60 variables or less) with fairly smooth functions; see John A.R. Williams CPAN module Math::Amoeba which implements the Simplex strategy of Nelder and Mead; another good algorithm is that of Davidon, Fletcher, Powell and Stewart, currently unimplemented in Perl, see Algorithm 46 and notes, in Comp J. 13, 1 (Feb 1970), pp 111-113; Comp J. 14, 1 (Feb 1971), p 106 and Comp J. 14, 2 (May 1971), pp 214-215. See also http://www.pjb.com.au/, perl(1).
Visit the GSP FreeBSD Man Page Interface. |