Mercurial > forge
changeset 9822:c63f213bad31 octave-forge
ga: test number of nvars in ga
author | slackydeb |
---|---|
date | Fri, 23 Mar 2012 01:57:33 +0000 |
parents | c869fff01da2 |
children | 8323245498b5 |
files | main/ga/inst/ga.m |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/main/ga/inst/ga.m Thu Mar 22 22:38:34 2012 +0000 +++ b/main/ga/inst/ga.m Fri Mar 23 01:57:33 2012 +0000 @@ -157,6 +157,17 @@ %! "options", gaoptimset ()); %! x = ga (problem); +## number of nvars +%!test +%! nvars = 1; +%! x = ga (@(x) x(1, 1) ** 2, nvars); +%!test +%! nvars = 2; +%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2), nvars); +%!test +%! nvars = 3; +%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2) + (x(:, 3) ** 2), nvars); + # TODO: structure/add tests below %!test x = ga (struct ("fitnessfcn", @rastriginsfcn, "nvars", 2, "options", gaoptimset ("FitnessLimit", 1e-7, "Generations", 200)));