From: <sla...@us...> - 2008-08-03 14:59:31
|
Revision: 5208 http://octave.svn.sourceforge.net/octave/?rev=5208&view=rev Author: slackydeb Date: 2008-08-03 14:59:41 +0000 (Sun, 03 Aug 2008) Log Message: ----------- moved the definition of a common function to test ga algorithms in a script file; modified ga.m to take advantage of it Modified Paths: -------------- trunk/octave-forge/main/ga/INDEX trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/INDEX =================================================================== --- trunk/octave-forge/main/ga/INDEX 2008-07-30 12:38:05 UTC (rev 5207) +++ trunk/octave-forge/main/ga/INDEX 2008-08-03 14:59:41 UTC (rev 5208) @@ -9,4 +9,5 @@ crossoversinglepoint gacreationuniform mutationsinglepoint - selectionroulette + rastriginsfcn + selectionroulette \ No newline at end of file Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2008-07-30 12:38:05 UTC (rev 5207) +++ trunk/octave-forge/main/ga/inst/ga.m 2008-08-03 14:59:41 UTC (rev 5208) @@ -44,7 +44,7 @@ ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 3.3 +## Version: 3.4 function x = ga (varargin) if ((nargout > 1) || (length (varargin) < 1) || (length (varargin) > 3)) @@ -67,6 +67,8 @@ endif endfunction +%!assert (ga (@rastriginsfcn, 2), [0, 0], 1e-6) + %!function retval = test_4_variabili (x) %! retval = 0; %! retval += 20 + (x(1) ** 2) + (x(2) ** 2) - 10 * (cos (2 * pi * x(1)) + cos (2 * pi * x(2))); @@ -82,11 +84,6 @@ %!assert (ga (@test_rastriginsfcn_traslato, 2, gaoptimset ('FitnessLimit', 0.001, 'PopInitRange', [-2; 2], 'PopulationSize', 100)), [1, 0], sqrt(0.001)) -%!function retval = test_rastriginsfcn (x) -%! retval = 20 + (x(1) ** 2) + (x(2) ** 2) - 10 * (cos (2 * pi * x(1)) + cos (2 * pi * x(2))); - -%!assert (ga (@test_rastriginsfcn, 2), [0, 0], 1e-6) - %!function retval = test_f_con_inf_minimi_locali (x) %! retval = (x ** 2) - (cos (2 * pi * x)) + 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |