]> gitweb.michael.orlitzky.com - octave.git/blobdiff - optimization/test_functions/extended_powell1.m
Add extended_powell functions and their tests.
[octave.git] / optimization / test_functions / extended_powell1.m
diff --git a/optimization/test_functions/extended_powell1.m b/optimization/test_functions/extended_powell1.m
new file mode 100644 (file)
index 0000000..2b1da25
--- /dev/null
@@ -0,0 +1,33 @@
+function f = extended_powell1(x)
+  ##
+  ## The extended Powell function. See Dennis & Schnabel, Appendix B,
+  ## problem #2.
+  ##
+  ## This function has a minimum at x=(0,0,...,0) with f(x) == 0. The
+  ## suggested starting point is x0=(3, -1, 0, 1,..., 3, -1, 0, 1).
+  ## Since the number of arguments is variable, we take a vector
+  ## instead of its individual components.
+  ##
+  n = length(x);
+
+  if (odd(n))
+    ## 'm' below must be an integer.
+    f = NA;
+    return;
+  end
+
+  m = n / 4;
+  f = 0;
+
+  % The extended Powell is simply a sum of Powell
+  % applications.
+  for k = [ 1 : m ]
+    y1 = x(4*k - 3);
+    y2 = x(4*k - 2);
+    y3 = x(4*k - 1);
+    y4 = x(4*k);
+
+    f_k = powell(y1,y2,y3,y4);
+    f = f + f_k;
+  end
+end