changeset 9844:94a15827f127 octave-forge

ga: fix bad examples of objective functions
author slackydeb
date Sat, 24 Mar 2012 16:33:31 +0000
parents 4138881fd6c3
children 3b7136683b6f
files main/ga/inst/ga.m
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/main/ga/inst/ga.m	Sat Mar 24 16:33:14 2012 +0000
+++ b/main/ga/inst/ga.m	Sat Mar 24 16:33:31 2012 +0000
@@ -159,15 +159,17 @@
 %! 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 (@(x) x(1, 1) ** 2, nvars);
+%! x = ga (ff (nvars), nvars);
 %!test
 %! nvars = 2;
-%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2), nvars);
+%! x = ga (ff (nvars), nvars);
 %!test
 %! nvars = 3;
-%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2) + (x(:, 3) ** 2), nvars);
+%! x = ga (ff (nvars), nvars);
 
 ## flawless execution with any supported optimization parameter
 ## different from the default value