chiark / gitweb /
added simple convex test function
authorstevenj <stevenj@alum.mit.edu>
Sat, 25 Aug 2007 17:34:59 +0000 (13:34 -0400)
committerstevenj <stevenj@alum.mit.edu>
Sat, 25 Aug 2007 17:34:59 +0000 (13:34 -0400)
darcs-hash:20070825173459-c8de0-c8c1a7b35e0a485dbc9dd535fd18fdab7cef9d00.gz

test/testfuncs.c
test/testfuncs.h

index fbfbbbcbbb032a71fa64c6d675666ce507523236..5e29d92f873c7973ff974fb630abc1fa205758a7 100644 (file)
@@ -270,6 +270,24 @@ static const double sixhumpcamel_lb[2] = {-5,-5};
 static const double sixhumpcamel_ub[2] = {5,5};
 static const double sixhumpcamel_xmin[2] = {0.08984, -0.71266};
 
+/****************************************************************************/
+static double convexcosh_f(int n, const double *x, double *grad, void *data)
+{
+     int i;
+     double f = 1;
+     UNUSED(data);
+     for (i = 0; i < n; ++i)
+         f *= cosh((x[i] - i) * (i+1));
+     if (grad)
+         for (i = 0; i < n; ++i)
+              grad[i] = f * tanh((x[i] - i) * (i+1)) * (i+1);
+     RETURN(f);
+}
+
+static const double convexcosh_lb[10] = {-1,0,0,0,0,0,0,0,0,0};
+static const double convexcosh_ub[10] = {2,3,6,7,8,10,11,13,14,16};
+static const double convexcosh_xmin[10] = {0,1,2,3,4,5,6,7,8,9};
+
 /****************************************************************************/
 /****************************************************************************/
 
@@ -318,5 +336,8 @@ const testfunc testfuncs[NTESTFUNCS] = {
        0.0, "Griewank function" },
      { sixhumpcamel_f, NULL, 1, 2,
        sixhumpcamel_lb, sixhumpcamel_ub, sixhumpcamel_xmin,
-       -1.03163, "Six-hump camel back function" }
+       -1.03163, "Six-hump camel back function" },
+     { convexcosh_f, NULL, 1, 10,
+       convexcosh_lb, convexcosh_ub, convexcosh_xmin,
+       1.0, "Convex product of cosh functions" }
 };
index 15af0aac7e9ea16d02eea25f28b33dce409682af..b8256e31541a2963c7d26010f17d4a11ba880a11 100644 (file)
@@ -18,7 +18,7 @@ typedef struct {
      const char *name;
 } testfunc;
 
-#define NTESTFUNCS 15
+#define NTESTFUNCS 16
 extern const testfunc testfuncs[NTESTFUNCS];
 
 extern int testfuncs_verbose;