diff -Nru octave-ga-0.9.8/debian/changelog octave-ga-0.10.0/debian/changelog --- octave-ga-0.9.8/debian/changelog 2011-04-15 22:00:26.000000000 +0000 +++ octave-ga-0.10.0/debian/changelog 2012-04-18 13:08:32.000000000 +0000 @@ -1,3 +1,23 @@ +octave-ga (0.10.0-1) unstable; urgency=low + + * Imported Upstream version 0.10.0 (Closes: #622929) + * debian/copyright: reflect upstream changes + * Drop obsolete Build-Depends/Depends on octave-{communications,miscellanous} + + -- Sébastien Villemot Wed, 18 Apr 2012 13:08:31 +0000 + +octave-ga (0.9.8-3) unstable; urgency=low + + [ Sébastien Villemot ] + * Imported Upstream version 0.9.8 + * Bump to debhelper compat level 9 + * Bump to Standards-Version 3.9.3, no changes needed + * Build-depend on octave-pkg-dev >= 1.0.1, to compile against Octave 3.6 + * Add Sébastien Villemot to Uploaders + * debian/copyright: upgrade to machine-readable format 1.0 + + -- Thomas Weber Sat, 31 Mar 2012 00:55:07 +0200 + octave-ga (0.9.8-2) unstable; urgency=low * Upload to unstable diff -Nru octave-ga-0.9.8/debian/compat octave-ga-0.10.0/debian/compat --- octave-ga-0.9.8/debian/compat 2011-04-15 14:27:38.000000000 +0000 +++ octave-ga-0.10.0/debian/compat 2012-03-27 18:55:57.000000000 +0000 @@ -1 +1 @@ -6 +9 diff -Nru octave-ga-0.9.8/debian/control octave-ga-0.10.0/debian/control --- octave-ga-0.9.8/debian/control 2011-04-15 20:43:43.000000000 +0000 +++ octave-ga-0.10.0/debian/control 2012-04-18 13:00:50.000000000 +0000 @@ -2,21 +2,21 @@ Section: math Priority: optional Maintainer: Debian Octave Group -Uploaders: Thomas Weber +Uploaders: Thomas Weber , + Sébastien Villemot DM-Upload-Allowed: yes -Build-Depends: debhelper (>= 6), cdbs, octave-pkg-dev (>= 0.7.0), -Build-Depends-Indep: octave-communications, octave-miscellaneous -Standards-Version: 3.9.1 +Build-Depends: debhelper (>= 9), cdbs, octave-pkg-dev (>= 1.0.1) +Standards-Version: 3.9.3 Homepage: http://octave.sourceforge.net/ga Vcs-Git: git://git.debian.org/git/pkg-octave/octave-ga.git Vcs-Browser: http://git.debian.org/?p=pkg-octave/octave-ga.git Package: octave-ga Architecture: all -Depends: ${misc:Depends}, ${octave:Depends}, octave-communications +Depends: ${misc:Depends}, ${octave:Depends} Description: genetic optimization code for Octave This package provides function to work with genetic algorithms in Octave, a - numerical computation software. It proveides the ga() function, which - works similarly to other optimization functions in Octave. + numerical computation software. It provides the ga() function, which works + similarly to other optimization functions in Octave. . This Octave add-on package is part of the Octave-Forge project. diff -Nru octave-ga-0.9.8/debian/copyright octave-ga-0.10.0/debian/copyright --- octave-ga-0.9.8/debian/copyright 2011-04-15 14:27:38.000000000 +0000 +++ octave-ga-0.10.0/debian/copyright 2012-04-18 13:01:31.000000000 +0000 @@ -1,22 +1,52 @@ -Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?rev=48 +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: ga package for Octave -Upstream-Maintainer: Luca Favatella -Upstream-Source: http://octave.sourceforge.net/ga/index.html +Upstream-Contact: Luca Favatella +Source: http://octave.sourceforge.net/ga/ + +Files: * +Copyright: 2008-2012 Luca Favatella +License: GPL-2+ Files: debian/* -Copyright: © 2008 Olafur Jens Sigurdsson +Copyright: 2008 Olafur Jens Sigurdsson + 2008-2009 Rafael Laboissiere + 2008-2012 Thomas Weber + 2012 Sébastien Villemot License: GPL-3+ -Files: inst/*.m -Copyright: © 2008 Luca Favatella -License: GPL-2+ - License: GPL-2+ + 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 . + . On Debian systems, the complete text of the GNU General Public License, version 2, can be found in the file `/usr/share/common-licenses/GPL-2'. License: GPL-3+ + 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 3 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 . + . On Debian systems, the complete text of the GNU General Public License, version 3, can be found in the file `/usr/share/common-licenses/GPL-3'. + diff -Nru octave-ga-0.9.8/debian/source.lintian-overrides octave-ga-0.10.0/debian/source.lintian-overrides --- octave-ga-0.9.8/debian/source.lintian-overrides 2011-04-15 14:27:38.000000000 +0000 +++ octave-ga-0.10.0/debian/source.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -octave-ga source: build-depends-without-arch-dep debhelper -octave-ga source: build-depends-without-arch-dep octave-pkg-dev diff -Nru octave-ga-0.9.8/debian/watch octave-ga-0.10.0/debian/watch --- octave-ga-0.9.8/debian/watch 2011-04-15 14:27:38.000000000 +0000 +++ octave-ga-0.10.0/debian/watch 2012-03-27 18:54:42.000000000 +0000 @@ -1,3 +1,2 @@ version=3 -http://octave.sourceforge.net/packages.php \ - http://downloads\.sourceforge\.net/octave/ga-([\d.]+)\.tar\.gz\?download +http://sf.net/octave/ga-(.+)\.tar\.gz diff -Nru octave-ga-0.9.8/DESCRIPTION octave-ga-0.10.0/DESCRIPTION --- octave-ga-0.9.8/DESCRIPTION 2010-06-24 21:49:50.000000000 +0000 +++ octave-ga-0.10.0/DESCRIPTION 2012-04-06 20:30:27.000000000 +0000 @@ -1,12 +1,12 @@ Name: ga -Version: 0.9.8 -Date: 2010-06-24 +Version: 0.10.0 +Date: 2012-04-06 Author: Luca Favatella Maintainer: Luca Favatella -Title: Genetic Algorithm and Direct Search +Title: Genetic Algorithm Description: Genetic optimization code Categories: Optimization -Depends: octave (>= 2.9.7), communications (>= 1.0.0) +Depends: octave (>= 3.4.0) Autoload: yes -License: GPL version 2 or later +License: GPLv2+ Url: http://octave.sf.net diff -Nru octave-ga-0.9.8/doc/EXAMPLES octave-ga-0.10.0/doc/EXAMPLES --- octave-ga-0.9.8/doc/EXAMPLES 2010-02-16 01:49:42.000000000 +0000 +++ octave-ga-0.10.0/doc/EXAMPLES 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -This file could be outdated or incomplete. Please refer to tests in ga.m. - -If you add in this file an example not coming from ga.m, please mark -it as "NOT COPIED FROM ga.m". - - - -######## - -min = [-1, 2]; -ga (struct ("fitnessfcn", @(x) rastriginsfcn (x - min), "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000, "PopInitRange", [-5; 5], "PopulationSize", 200))) - -######## - -ga (@(x) x ** 2, 1) - -######## - -ga (@(x) (x ** 2) - (cos (2 * pi * x)) + 1, 1) - -######## - -ga (@rastriginsfcn, 2) - -######## - -ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000))) - -######## - -ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "PopulationSize", 200))) - -######## - -ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ("EliteCount", 5, "FitnessLimit", 1e-7, "PopInitRange", [-2; 2], "PopulationSize", 200))) \ No newline at end of file diff -Nru octave-ga-0.9.8/doc/README octave-ga-0.10.0/doc/README --- octave-ga-0.9.8/doc/README 2009-05-11 23:25:32.000000000 +0000 +++ octave-ga-0.10.0/doc/README 2012-04-05 23:25:27.000000000 +0000 @@ -1,13 +1,17 @@ STATUS (BY EXAMPLES) -See tests of the ga function or the EXAMPLES file. +See tests of the ga function. TODO +create a demo +write a proper README linear constraints (needs mutationadaptfeasible and perhaps LMI) nonlinear constraints subpopulations and migrations bitstring support plot functions -more texinfo \ No newline at end of file +more texinfo +handle TODOs in the code +integer constraints diff -Nru octave-ga-0.9.8/INDEX octave-ga-0.10.0/INDEX --- octave-ga-0.9.8/INDEX 2008-08-14 15:06:51.000000000 +0000 +++ octave-ga-0.10.0/INDEX 2012-04-05 23:25:27.000000000 +0000 @@ -19,4 +19,7 @@ mutationgaussian Utility - rastriginsfcn \ No newline at end of file + rastriginsfcn + +Miscellaneous + test_ga diff -Nru octave-ga-0.9.8/inst/crossoverscattered.m octave-ga-0.10.0/inst/crossoverscattered.m --- octave-ga-0.9.8/inst/crossoverscattered.m 2009-04-09 20:43:29.000000000 +0000 +++ octave-ga-0.10.0/inst/crossoverscattered.m 2012-04-05 23:25:27.000000000 +0000 @@ -1,4 +1,4 @@ -## Copyright (C) 2008, 2009 Luca Favatella +## Copyright (C) 2008, 2009, 2011 Luca Favatella ## ## 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 @@ -14,7 +14,7 @@ ## along with this program; If not, see . ## Author: Luca Favatella -## Version: 6.3.2 +## Version: 7.0 function xoverKids = crossoverscattered (parents, options, nvars, FitnessFcn, unused, @@ -31,7 +31,19 @@ thisPopulation(parents(1, 1:n_children), 1:nvars); p2(1:n_children, 1:nvars) = \ thisPopulation(parents(1, n_children + (1:n_children)), 1:nvars); - b(1:n_children, 1:nvars) = randint (n_children, nvars); + b(1:n_children, 1:nvars) = randi (1, n_children, nvars); ## TODO: test randi xoverKids(1:n_children, 1:nvars) = \ b .* p1 + (ones (n_children, nvars) - b) .* p2; -endfunction \ No newline at end of file +endfunction + + +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO diff -Nru octave-ga-0.9.8/inst/fitscalingrank.m octave-ga-0.10.0/inst/fitscalingrank.m --- octave-ga-0.9.8/inst/fitscalingrank.m 2009-04-09 21:41:22.000000000 +0000 +++ octave-ga-0.10.0/inst/fitscalingrank.m 2012-04-05 23:25:27.000000000 +0000 @@ -29,6 +29,17 @@ endfunction +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO + %!shared scores, nParents, expectation %! scores = rand (20, 1); %! nParents = 32; diff -Nru octave-ga-0.9.8/inst/gacreationuniform.m octave-ga-0.10.0/inst/gacreationuniform.m --- octave-ga-0.9.8/inst/gacreationuniform.m 2008-08-16 18:14:17.000000000 +0000 +++ octave-ga-0.10.0/inst/gacreationuniform.m 2012-04-05 23:25:27.000000000 +0000 @@ -50,4 +50,16 @@ ((ones (options.PopulationSize, 1) * (UB - LB)) .* \ rand (options.PopulationSize, GenomeLength)) + \ (ones (options.PopulationSize, 1) * LB); -endfunction \ No newline at end of file +endfunction + + +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO diff -Nru octave-ga-0.9.8/inst/ga.m octave-ga-0.10.0/inst/ga.m --- octave-ga-0.9.8/inst/ga.m 2010-02-16 02:56:32.000000000 +0000 +++ octave-ga-0.10.0/inst/ga.m 2012-04-05 23:25:27.000000000 +0000 @@ -1,4 +1,4 @@ -## Copyright (C) 2008, 2010 Luca Favatella +## Copyright (C) 2008, 2010, 2012 Luca Favatella ## ## 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 @@ -71,7 +71,7 @@ ## @end deftypefn ## Author: Luca Favatella -## Version: 5.21.1 +## Version: 6.0.1 function [x fval exitflag output population scores] = \ ga (fitnessfcn_or_problem, @@ -115,71 +115,258 @@ endfunction -## nvars == 2 and min != zeros (1, nvars) - -%!# TODO: get this test working with tol = 1e-6 -%!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) - - -## nvars == 1 and min == zeros (1, nvars) - -%!test assert (ga (@(x) x ** 2, 1), 0, 1e-3) - -%!test assert (ga (@(x) (x ** 2) - (cos (2 * pi * x)) + 1, 1), 0, 1e-3) - - -## nvars == 2 and min == zeros (1, nvars) - -%!xtest assert (ga (@rastriginsfcn, 2), [0, 0], 1e-3) - -%!# TODO: get this test working with tol = 1e-6 -%!xtest assert (ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 1000))), zeros (1, 2), 1e-4) - -%!# TODO: get this test working with tol = 1e-6 -%!xtest assert (ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "PopulationSize", 200))), zeros (1, 2), 1e-4) - - -## nvars == 4 and min == zeros (1, nvars) - -%!# TODO: get this test working with tol = 1e-3 -%!xtest assert (ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ("EliteCount", 5, "FitnessLimit", 1e-7, "PopInitRange", [-2; 2], "PopulationSize", 200))), zeros (1, 4), 1e-2) - - -## InitialPopulation and InitialScores options - -%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "PopulationSize", 3))); - -%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialScores", [0; 0; 0]))); - -%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("InitialPopulation", [0, 0; 0, 0], "InitialScores", [0; 0; 0]))); - -%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0]))); - -%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "InitialPopulation", [0, 0; 0, 0; 0, 0; 0, 0], "InitialScores", [0; 0; 0; 0]))); - - -## Vectorized and UseParallel options - -%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Vectorized", "bad value"))); - -%!error ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("UseParallel", "bad value"))); - -%!test ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "Vectorized", "on"))); - -%!xtest ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "UseParallel", "always"))); - -%!test ## Vectorized option speeds up execution +## number of input arguments +%!shared f, nvars +%! f = @rastriginsfcn; +%! nvars = 2; +%!error x = ga () +%!error x = ga (f) +%!error x = ga (f, nvars, []) +%!error x = ga (f, nvars, [], [], []) +%!error x = ga (f, nvars, [], [], [], [], []) +%!error x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []], gaoptimset (), []) + +## number of output arguments +# TODO + +## type of arguments +%!function f = ff (nvars) +%! f = @(x) sum (x(:, 1:nvars) .** 2, 2); +%!error x = ga (ff (3), 2); +# TODO +# TODO: test that each field in the user-specified "problem" structure is checked + + +## flawless execution with right arguments +%!shared f, nvars +%! f = @rastriginsfcn; +%! nvars = 2; +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!test x = ga (f, nvars); +%!test x = ga (f, nvars, [], []); +%!test x = ga (f, nvars, ones (3, nvars), ones (3, 1)); +%!test x = ga (f, nvars, [], [], [], []); +%!test x = ga (f, nvars, [], [], ones (4, nvars), ones (4, 1)); +%!test x = ga (f, nvars, [], [], [], [], [], []); +%!test x = ga (f, nvars, [], [], [], [], - Inf (1, nvars), Inf (1, nvars)); +%!test x = ga (f, nvars, [], [], [], [], - ones (1, nvars), ones (1, nvars)); +%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []]); +%!test x = ga (f, nvars, [], [], [], [], [], [], @nonlcon); +%!test x = ga (f, nvars, [], [], [], [], [], [], @(x) [[], []], gaoptimset ()); +%!test # TODO: convert to error after implementing private ga-specific createOptimProblem. All fields in the user-specified structure should be checked +%! problem = struct ("fitnessfcn", @rastriginsfcn, +%! "nvars", 2, +%! "options", gaoptimset ()); +%! x = ga (problem); + +## flawless execution with any nvars +%!function f = ff (nvars) +%! f = @(x) sum (x(:, 1:nvars) .** 2, 2); +%!test +%! nvars = 1; +%! x = ga (ff (nvars), nvars); +%!test +%! nvars = 2; +%! x = ga (ff (nvars), nvars); +%!test +%! nvars = 3; +%! x = ga (ff (nvars), nvars); + +## flawless execution with any supported optimization parameter +## different from the default value +%!shared f, nvars, default_options +%! f = @rastriginsfcn; +%! nvars = 2; +%! default_options = gaoptimset (); +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!test +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, default_options); +%!test # TODO: use non-default value +%! options = gaoptimset ("CreationFcn", @gacreationuniform); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # TODO: use non-default value +%! options = gaoptimset ("CrossoverFcn", @crossoverscattered); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("CrossoverFraction", rand); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! ps = getfield (default_options, "PopulationSize"); +%! options = gaoptimset ("EliteCount", randi ([0, ps])); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("FitnessLimit", 1e-7); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # TODO: use non-default value +%! options = gaoptimset ("FitnessScalingFcn", @fitscalingrank); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! g = getfield (default_options, "Generations"); +%! options = gaoptimset ("Generations", g + 1); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! ps = getfield (default_options, "PopulationSize"); +%! ## Initial population can be partial +%! options_w_full_ip = \ +%! gaoptimset ("InitialPopulation", rand (ps, nvars)); +%! partial_ip = randi ([0, ps - 1]); +%! options_w_partial_ip = \ +%! gaoptimset ("InitialPopulation", rand (partial_ip, nvars)); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options_w_full_ip); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options_w_partial_ip); +%!test +%! ps = getfield (default_options, "PopulationSize"); +%! ## Initial scores needs initial population %! -%! tic (); -%! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200))); -%! elapsed_time = toc (); +%! options_w_full_ip_full_is = \ +%! gaoptimset ("InitialPopulation", rand (ps, nvars), +%! "InitialScores", rand (ps, 1 )); +%! partial_ip = randi ([2, ps - 1]); +%! options_w_partial_ip_full_is = \ +%! gaoptimset ("InitialPopulation", rand (partial_ip, nvars), +%! "InitialScores", rand (partial_ip, 1 )); %! -%! tic (); -%! ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("Generations", 10, "PopulationSize", 200, "Vectorized", "on"))); -%! elapsed_time_with_vectorized = toc (); +%! ## Initial scores can be partial +%! partial_is_when_full_ip = randi ([1, ps - 1]); +%! partial_is_when_partial_ip = randi ([1, partial_ip - 1]); +%! options_w_full_ip_partial_is = \ +%! gaoptimset ("InitialPopulation", rand (ps, nvars), +%! "InitialScores", rand (partial_is_when_full_ip, 1 )); +%! options_w_partial_ip_partial_is = \ +%! gaoptimset ("InitialPopulation", rand (partial_ip, nvars), +%! "InitialScores", rand (partial_is_when_partial_ip, 1 )); %! -%! assert (elapsed_time > elapsed_time_with_vectorized); - - #TODO: test that UseParallel speeds up execution \ No newline at end of file +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, +%! options_w_full_ip_full_is); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, +%! options_w_partial_ip_full_is); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, +%! options_w_full_ip_partial_is); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, +%! options_w_partial_ip_partial_is); +%!test # TODO: use non-default value +%! options = gaoptimset ("MutationFcn", {@mutationgaussian, 1, 1}); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("PopInitRange", [-2; 2]); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("PopulationSize", 200); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # TODO: use non-default value +%! options = gaoptimset ("SelectionFcn", @selectionstochunif); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # TODO: use non-default value +%! options = gaoptimset ("TimeLimit", Inf); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!error # TODO: this should become test +%! options = gaoptimset ("UseParallel", "always"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test +%! options = gaoptimset ("Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); + + +## error with conflicting optimization parameters: population size et al. +%!shared f, nvars +%! f = @rastriginsfcn; +%! nvars = 2; +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!error # Elite count cannot be greater than the population size +%! ps = 3; +%! bad_options = gaoptimset ("PopulationSize", ps, +%! "EliteCount", ps + 1); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error # The number of individuals in the initial population cannot be greater of the population size +%! ps = 3; +%! bad_options = gaoptimset ("PopulationSize", ps, +%! "InitialPopulation", zeros (ps + 1, nvars)); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error # Initial scores cannot be specified without specifying the initial population too +%! bad_options = gaoptimset ("InitialScores", zeros (3, 1)); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error # The number of initial scores specified cannot be greater of the number of individuals in the initial population +%! ip = 3; +%! bad_options = gaoptimset ("InitialPopulation", zeros (ip, nvars), +%! "InitialScores", zeros (ip + 1, 1)); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); + +## error with vectorized evaluation of objective function. Vectorized +## objective functions are better because can be evaluated both as +## serial and vectorized. +%!shared nvars +%! nvars = 2; +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!function f = ff (nvars) +%! f = @(x) sum (x(:, 1:nvars) .** 2, 2); +%!function f_not_vectorized = ff_not_vectorized (nvars) +%! f_not_vectorized = @(x) sum (x(1:nvars) .** 2); +%!test # A non-vectorized objective function works when no vectorization is required +%! f = ff_not_vectorized (nvars); +%! options = gaoptimset ("Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!error # A non-vectorized objective function does not work when vectorization is required +%! f = ff_not_vectorized (nvars); +%! options = gaoptimset ("Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # A vectorized objective function works when no vectorization is required +%! f = ff (nvars); +%! options = gaoptimset ("Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # A vectorized objective function works when vectorization is required +%! f = ff (nvars); +%! options = gaoptimset ("Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); + +## error with conflicting optimization parameters: parallel and +## vectorized evaluation of objective function +%!shared f, nvars +%! f = @rastriginsfcn; +%! nvars = 2; +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!test +%! options = gaoptimset ("UseParallel", "never", +%! "Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!error # TODO: this should become test +%! options = gaoptimset ("UseParallel", "always", +%! "Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!error +%! bad_options = gaoptimset ("UseParallel", "garbage", +%! "Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!test +%! options = gaoptimset ("UseParallel", "never", +%! "Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!warning +%! bad_options = gaoptimset ("UseParallel", "always", +%! "Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!warning +%! bad_options = gaoptimset ("UseParallel", "garbage", +%! "Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error +%! bad_options = gaoptimset ("UseParallel", "never", +%! "Vectorized", "garbage"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error +%! bad_options = gaoptimset ("UseParallel", "always", +%! "Vectorized", "garbage"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error +%! bad_options = gaoptimset ("UseParallel", "garbage", +%! "Vectorized", "garbage"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); diff -Nru octave-ga-0.9.8/inst/gaoptimset.m octave-ga-0.10.0/inst/gaoptimset.m --- octave-ga-0.9.8/inst/gaoptimset.m 2010-06-11 01:15:49.000000000 +0000 +++ octave-ga-0.10.0/inst/gaoptimset.m 2012-04-05 23:25:27.000000000 +0000 @@ -21,7 +21,8 @@ ## @strong{Inputs} ## @table @var ## @item param -## Parameter to set. Unspecified parameters are set to their default values; specifying no parameters is allowed. +## Parameter to set. Unspecified parameters are set to their default +## values; specifying no parameters is allowed. ## @item value ## Value of @var{param}. ## @end table @@ -60,7 +61,7 @@ ## @end deftypefn ## Author: Luca Favatella -## Version: 4.4.6 +## Version: 4.4.7 function options = gaoptimset (varargin) if ((nargout != 1) || @@ -86,17 +87,35 @@ endfunction +## number of input arguments +%!error options = gaoptimset ("odd number of arguments") +%!error options = gaoptimset ("Generations", 123, "odd number of arguments") + +## number of output arguments %!error gaoptimset ("Generations", 123) %!error [a, b] = gaoptimset ("Generations", 123) -%!error gaoptimset ("odd number of arguments") -%!error gaoptimset ("Generations", 123, "odd number of arguments") +## type of arguments +# TODO +%!#error options = gaoptimset ("Vectorized", "bad value") # TODO: fix +%!#error options = gaoptimset ("UseParallel", "bad value") # TODO: fix +# TODO: structure/add tests below %!assert (getfield (gaoptimset ("Generations", 123), "Generations"), 123) %!test -%! options = gaoptimset ("EliteCount", 1, "FitnessLimit", 1e-7, "Generations", 1000, "PopInitRange", [-5; 5], "PopulationSize", 200); +%! options = gaoptimset ("EliteCount", 1, +%! "FitnessLimit", 1e-7, +%! "Generations", 1000, +%! "PopInitRange", [-5; 5], +%! "PopulationSize", 200); %! %! ## "CrossoverFraction" is not specified, so gaoptimset should put the default value: testing this too -%! assert ([(getfield (options, "CrossoverFraction")); (getfield (options, "EliteCount")); (getfield (options, "FitnessLimit")); (getfield (options, "Generations")); (getfield (options, "PopInitRange")); (getfield (options, "PopulationSize"))], [0.8; 1; 1e-7; 1000; [-5; 5]; 200]) \ No newline at end of file +%! assert ([(getfield (options, "CrossoverFraction")); +%! (getfield (options, "EliteCount")); +%! (getfield (options, "FitnessLimit")); +%! (getfield (options, "Generations")); +%! (getfield (options, "PopInitRange")); +%! (getfield (options, "PopulationSize"))], +%! [0.8; 1; 1e-7; 1000; [-5; 5]; 200]) diff -Nru octave-ga-0.9.8/inst/__ga_scores__.m octave-ga-0.10.0/inst/__ga_scores__.m --- octave-ga-0.9.8/inst/__ga_scores__.m 2010-02-16 02:33:56.000000000 +0000 +++ octave-ga-0.10.0/inst/__ga_scores__.m 2012-04-05 23:25:27.000000000 +0000 @@ -14,32 +14,35 @@ ## along with this program; If not, see . ## Author: Luca Favatella -## Version: 5.5 +## Version: 5.7 function Scores = __ga_scores__ (problem, Population) - if (strcmp (problem.options.Vectorized, "on")) ## using vectorized evaluation - if (strcmp (problem.options.UseParallel, "always")) - warning ("'Vectorized' option is 'on': ignoring 'UseParallel' \ - option, even if it is 'always'"); - endif - Scores = problem.fitnessfcn (Population); - else ## not using vectorized evaluation - if (! strcmp (problem.options.Vectorized, "off")) + [nrP ncP] = size (Population); + switch problem.options.Vectorized + case "on" ## using vectorized evaluation + switch problem.options.UseParallel + case "always" + warning ("'Vectorized' option is 'on': ignoring 'UseParallel' option, even if it is 'always'"); + case "never" + ## Nothing. + otherwise + warning ("'Vectorized' option is 'on': ignoring invalid 'UseParallel' option value (it should be 'always' or 'never')"); + endswitch + Scores = (problem.fitnessfcn (Population))(1:nrP, 1); + case "off" ## not using vectorized evaluation + switch problem.options.UseParallel + case "always" ## using parallel evaluation + error ("TODO: implement parallel evaluation of objective function"); + case "never" ## using serial evaluation (i.e. loop) + tmp = zeros (nrP, 1); + for index = 1:nrP + tmp(index, 1) = problem.fitnessfcn (Population(index, 1:ncP)); + endfor + Scores = tmp(1:nrP, 1); + otherwise + error ("'UseParallel' option must be 'always' or 'never'"); + endswitch + otherwise error ("'Vectorized' option must be 'on' or 'off'"); - endif - if (strcmp (problem.options.UseParallel, "always")) ## using parallel evaluation - error ("TODO: implement parallel evaluation of objective \ - function"); ## TODO - else ## using serial evaluation (i.e. loop) - if (! strcmp (problem.options.UseParallel, "never")) - error ("'UseParallel' option must be 'always' or 'never'"); - endif - [nrP ncP] = size (Population); - tmp = zeros (nrP, 1); - for index = 1:nrP - tmp(index, 1) = problem.fitnessfcn (Population(index, 1:ncP)); - endfor - Scores = tmp(1:nrP, 1); - endif - endif -endfunction \ No newline at end of file + endswitch +endfunction diff -Nru octave-ga-0.9.8/inst/mutationgaussian.m octave-ga-0.10.0/inst/mutationgaussian.m --- octave-ga-0.9.8/inst/mutationgaussian.m 2008-08-16 18:14:17.000000000 +0000 +++ octave-ga-0.10.0/inst/mutationgaussian.m 2012-04-05 23:25:27.000000000 +0000 @@ -45,4 +45,16 @@ mutationChildren(1:nc_parents, 1:nvars) = \ thisPopulation(parents(1, 1:nc_parents), 1:nvars) + \ expanded_current_std .* randn (nc_parents, nvars); -endfunction \ No newline at end of file +endfunction + + +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO diff -Nru octave-ga-0.9.8/inst/rastriginsfcn.m octave-ga-0.10.0/inst/rastriginsfcn.m --- octave-ga-0.9.8/inst/rastriginsfcn.m 2010-06-11 00:59:26.000000000 +0000 +++ octave-ga-0.10.0/inst/rastriginsfcn.m 2012-04-05 23:25:27.000000000 +0000 @@ -1,4 +1,4 @@ -## Copyright (C) 2008, 2009, 2010 Luca Favatella +## Copyright (C) 2008, 2009, 2010, 2012 Luca Favatella ## ## 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 @@ -14,15 +14,16 @@ ## along with this program; If not, see . ## -*- texinfo -*- -## @deftypefn{Function File} {} rastriginsfcn (@var{x}) +## @deftypefn{Function File} {@var{y} =} rastriginsfcn (@var{x}) ## Rastrigin's function. ## @end deftypefn ## Author: Luca Favatella -## Version: 1.4 +## Version: 2.0 function retval = rastriginsfcn (x) - if (nargout != 1) + if ((nargout != 1) || + (nargin != 1) || (columns (x) != 2)) print_usage (); else x1 = x(:, 1); @@ -33,8 +34,17 @@ endfunction -%!error rastriginsfcn () -%!error rastriginsfcn ([0, 0], "other argument") +## number of input arguments +%!error y = rastriginsfcn () +%!error y = rastriginsfcn ([0, 0], "other argument") + +## number of output arguments +%!error [y1, y2] = rastriginsfcn ([0, 0]) + +## type of arguments +%!error y = rastriginsfcn ([0; 0]) +%!error y = rastriginsfcn (zeros (2, 3)) # TODO: document size of x %!assert (rastriginsfcn ([0, 0]), 0) -%!assert (rastriginsfcn ([0, 0; 0, 0]), [0; 0]) \ No newline at end of file +%!assert (rastriginsfcn ([0, 0; 0, 0]), [0; 0]) +%!assert (rastriginsfcn (zeros (3, 2)), [0; 0; 0]) diff -Nru octave-ga-0.9.8/inst/selectionstochunif.m octave-ga-0.10.0/inst/selectionstochunif.m --- octave-ga-0.9.8/inst/selectionstochunif.m 2008-08-14 15:06:51.000000000 +0000 +++ octave-ga-0.10.0/inst/selectionstochunif.m 2012-04-05 23:25:27.000000000 +0000 @@ -31,4 +31,16 @@ endwhile parents(1, index_steps) = index_line; endfor -endfunction \ No newline at end of file +endfunction + + +## number of input arguments +# TODO + +## number of output arguments +# TODO + +## type of arguments +# TODO + +# TODO diff -Nru octave-ga-0.9.8/inst/test_ga.m octave-ga-0.10.0/inst/test_ga.m --- octave-ga-0.9.8/inst/test_ga.m 1970-01-01 00:00:00.000000000 +0000 +++ octave-ga-0.10.0/inst/test_ga.m 2012-04-05 23:25:27.000000000 +0000 @@ -0,0 +1,49 @@ +## Copyright (C) 2012 Luca Favatella +## +## 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 . + +## -*- texinfo -*- +## @deftypefn{Script File} {} test_ga +## Execute all available tests at once. +## @end deftypefn + +## Author: Luca Favatella +## Created: March 2012 +## Version: 0.3 + +## 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 + +## Private functions +test __ga_initial_population__ +test __ga_problem_update_state_at_each_generation__ diff -Nru octave-ga-0.9.8/NEWS octave-ga-0.10.0/NEWS --- octave-ga-0.9.8/NEWS 1970-01-01 00:00:00.000000000 +0000 +++ octave-ga-0.10.0/NEWS 2012-04-05 23:25:27.000000000 +0000 @@ -0,0 +1,18 @@ +Summary of important user-visible changes for releases of the ga package + +=============================================================================== +ga-0.10.0 Release Date: 2012-04-06 Release Manager: Luca Favatella +=============================================================================== + +** Remove dependency on the "communications" package and require + Octave version 3.4.0 (or better). The "communications" package was + used only for its "randint" function; now the "randi" function, + introduced in Octave 3.4.0, is used instead. + +** Reorganize the unit test suite. All available tests can be + executed by running "test_ga". Fix bug #3287917 (Debian bug + #622929). + +** Rename the package from "Genetic Algorithm and Direct Search" to + "Genetic Algorithm" as only the Genetic Algorithm is implemented. + Direct Search will not be implemented in the foreseeable future.