From: <sla...@us...> - 2012-03-24 16:33:08
|
Revision: 10028 http://octave.svn.sourceforge.net/octave/?rev=10028&view=rev Author: slackydeb Date: 2012-03-24 16:33:02 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: test parallel and vectorized evaluation of finessfcn Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:32:50 UTC (rev 10027) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:33:02 UTC (rev 10028) @@ -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 ())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |