]> gitweb.michael.orlitzky.com - octave.git/blob - optimization/test_functions/extended_rosenbrock1.m
Replace ##-style comments with %-style comments in all non-test code.
[octave.git] / optimization / test_functions / extended_rosenbrock1.m
1 function f = extended_rosenbrock1(x)
2 %
3 % The extended Rosenbrock function. See Dennis & Schnabel, Appendix
4 % B, problem #1.
5 %
6 % This function has a minimum at x=(1,1,...,1) with f(x) == 0. The
7 % suggested starting point is x0=(-1.2, 1,-1.2, 1,...,-1.2, 1).
8 % Since the number of arguments is variable, we take a vector
9 % instead of its individual components.
10 %
11 n = length(x);
12
13 if (odd(n))
14 % 'm' below must be an integer.
15 f = NA;
16 return;
17 end
18
19 m = n / 2;
20 f = 0;
21
22 % The extended Rosenbrock is simply a sum of Rosenbrock
23 % applications.
24 for k = [ 1 : m ]
25 y1 = x(2*k - 1);
26 y2 = x(2*k);
27 f_k = rosenbrock(y1, y2);
28 f = f + f_k;
29 end
30 end