changeset 9842:2ceac224d860 octave-forge

ga: test parallel and vectorized evaluation of finessfcn
author slackydeb
date Sat, 24 Mar 2012 16:33:02 +0000
parents 68a47b65f41b
children 4138881fd6c3
files main/ga/inst/ga.m
diffstat 1 files changed, 49 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/main/ga/inst/ga.m	Sat Mar 24 16:32:50 2012 +0000
+++ b/main/ga/inst/ga.m	Sat Mar 24 16:33:02 2012 +0000
@@ -257,14 +257,14 @@
 %!test # TODO: use non-default value
 %! options = gaoptimset ("TimeLimit", Inf);
 %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options);
-%!#xtest # TODO
-%!# options = gaoptimset ("UseParallel", "always");
-%!# 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
+## error with conflicting optimization parameters: population size et al.
 %!shared f, nvars
 %! f = @rastriginsfcn;
 %! nvars = 2;
@@ -290,6 +290,51 @@
 %!                           "InitialScores",     zeros (ip + 1, 1));
 %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_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);
+
 # TODO: structure/add tests below
 
 %!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ()));