From: <sla...@us...> - 2012-03-15 02:24:10
|
Revision: 9898 http://octave.svn.sourceforge.net/octave/?rev=9898&view=rev Author: slackydeb Date: 2012-03-15 02:24:02 +0000 (Thu, 15 Mar 2012) Log Message: ----------- ga: rename ga_{test,demo}.m to {test,demo}_ga.m Mimic the naming scheme of test_control.m from the control package, as there is no official best practice yet for exposing the unit test suite. References: http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/control/inst/test_control.m?revision=9663&view=markup http://sourceforge.net/mailarchive/message.php?msg_id=28977037 Added Paths: ----------- trunk/octave-forge/main/ga/inst/demo_ga.m trunk/octave-forge/main/ga/inst/test_ga.m Removed Paths: ------------- trunk/octave-forge/main/ga/inst/ga_demo.m trunk/octave-forge/main/ga/inst/ga_test.m Copied: trunk/octave-forge/main/ga/inst/demo_ga.m (from rev 9897, trunk/octave-forge/main/ga/inst/ga_demo.m) =================================================================== --- trunk/octave-forge/main/ga/inst/demo_ga.m (rev 0) +++ trunk/octave-forge/main/ga/inst/demo_ga.m 2012-03-15 02:24:02 UTC (rev 9898) @@ -0,0 +1,62 @@ +## Copyright (C) 2012 Luca Favatella <sla...@gm...> +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Script File} {} demo_ga +## Run a demo of the genetic algorithm package. The current +## implementation is only a placeholder. +## @end deftypefn + +## Author: Luca Favatella <sla...@gm...> +## Created: March 2012 +## Version: 0.0.3 + +demo ga_demo + + +%!demo +%! % TODO + + +## This code is a simple example of the usage of ga + # TODO: convert to demo +%!xtest assert (ga (@rastriginsfcn, 2), [0, 0], 1e-3) + + +## This code shows that ga optimizes also functions whose minimum is not +## in zero + # TODO: convert to demo +%!xtest +%! min = [-1, 2]; +%! assert (ga (struct ("fitnessfcn", @(x) rastriginsfcn (x - min), "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000, "PopInitRange", [-5; 5], "PopulationSize", 200))), min, 1e-5) + + +## This code shows that the "Vectorize" option usually speeds up execution + # TODO: convert to demo +%!test +%! +%! tic (); +%! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200))); +%! elapsed_time = toc (); +%! +%! tic (); +%! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200, "Vectorized", "on"))); +%! elapsed_time_with_vectorized = toc (); +%! +%! assert (elapsed_time > elapsed_time_with_vectorized); + +## The "UseParallel" option should speed up execution + # TODO: write demo (after implementing + # UseParallel) - low priority Deleted: trunk/octave-forge/main/ga/inst/ga_demo.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga_demo.m 2012-03-15 02:23:42 UTC (rev 9897) +++ trunk/octave-forge/main/ga/inst/ga_demo.m 2012-03-15 02:24:02 UTC (rev 9898) @@ -1,62 +0,0 @@ -## Copyright (C) 2012 Luca Favatella <sla...@gm...> -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Script File} {} ga_demo -## Run a demo of the genetic algorithm package. The current -## implementation is only a placeholder. -## @end deftypefn - -## Author: Luca Favatella <sla...@gm...> -## Created: March 2012 -## Version: 0.0.2 - -demo ga_demo - - -%!demo -%! % TODO - - -## This code is a simple example of the usage of ga - # TODO: convert to demo -%!xtest assert (ga (@rastriginsfcn, 2), [0, 0], 1e-3) - - -## This code shows that ga optimizes also functions whose minimum is not -## in zero - # TODO: convert to demo -%!xtest -%! min = [-1, 2]; -%! assert (ga (struct ("fitnessfcn", @(x) rastriginsfcn (x - min), "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000, "PopInitRange", [-5; 5], "PopulationSize", 200))), min, 1e-5) - - -## This code shows that the "Vectorize" option usually speeds up execution - # TODO: convert to demo -%!test -%! -%! tic (); -%! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200))); -%! elapsed_time = toc (); -%! -%! tic (); -%! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200, "Vectorized", "on"))); -%! elapsed_time_with_vectorized = toc (); -%! -%! assert (elapsed_time > elapsed_time_with_vectorized); - -## The "UseParallel" option should speed up execution - # TODO: write demo (after implementing - # UseParallel) - low priority Deleted: trunk/octave-forge/main/ga/inst/ga_test.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga_test.m 2012-03-15 02:23:42 UTC (rev 9897) +++ trunk/octave-forge/main/ga/inst/ga_test.m 2012-03-15 02:24:02 UTC (rev 9898) @@ -1,49 +0,0 @@ -## Copyright (C) 2012 Luca Favatella <sla...@gm...> -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Script File} {} ga_test -## Execute all available tests at once. -## @end deftypefn - -## Author: Luca Favatella <sla...@gm...> -## Created: March 2012 -## Version: 0.1.1 - -## Creation -test gacreationuniform - -## Fitness Scaling -test fitscalingrank - -## Selection -test selectionstochunif - -## Crossover -test crossoverscattered - -## Mutation -test mutationgaussian - -## Utility -test rastriginsfcn - -## Genetic Algorithm -test gaoptimset -test ga -## TODO: split performance tests - -## TODO: review all unit tests (DONE: rastriginsfcn) -## TODO: write missing unit tests, or write per-function TODOs Copied: trunk/octave-forge/main/ga/inst/test_ga.m (from rev 9897, trunk/octave-forge/main/ga/inst/ga_test.m) =================================================================== --- trunk/octave-forge/main/ga/inst/test_ga.m (rev 0) +++ trunk/octave-forge/main/ga/inst/test_ga.m 2012-03-15 02:24:02 UTC (rev 9898) @@ -0,0 +1,49 @@ +## Copyright (C) 2012 Luca Favatella <sla...@gm...> +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Script File} {} test_ga +## Execute all available tests at once. +## @end deftypefn + +## Author: Luca Favatella <sla...@gm...> +## Created: March 2012 +## Version: 0.2 + +## Creation +test gacreationuniform + +## Fitness Scaling +test fitscalingrank + +## Selection +test selectionstochunif + +## Crossover +test crossoverscattered + +## Mutation +test mutationgaussian + +## Utility +test rastriginsfcn + +## Genetic Algorithm +test gaoptimset +test ga +## TODO: split performance tests + +## TODO: review all unit tests (DONE: rastriginsfcn) +## TODO: write missing unit tests, or write per-function TODOs This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |