From: <sla...@us...> - 2012-03-21 18:58:49
|
Revision: 9995 http://octave.svn.sourceforge.net/octave/?rev=9995&view=rev Author: slackydeb Date: 2012-03-21 18:58:42 +0000 (Wed, 21 Mar 2012) Log Message: ----------- ga: move demo_ga to devel/ Added Paths: ----------- trunk/octave-forge/main/ga/devel/demo_ga.m Removed Paths: ------------- trunk/octave-forge/main/ga/inst/demo_ga.m Copied: trunk/octave-forge/main/ga/devel/demo_ga.m (from rev 9974, trunk/octave-forge/main/ga/inst/demo_ga.m) =================================================================== --- trunk/octave-forge/main/ga/devel/demo_ga.m (rev 0) +++ trunk/octave-forge/main/ga/devel/demo_ga.m 2012-03-21 18:58:42 UTC (rev 9995) @@ -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.4 + +demo demo_ga + + +%!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/demo_ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/demo_ga.m 2012-03-21 16:35:49 UTC (rev 9994) +++ trunk/octave-forge/main/ga/inst/demo_ga.m 2012-03-21 18:58:42 UTC (rev 9995) @@ -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} {} 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.4 - -demo demo_ga - - -%!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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |