chiark / gitweb /
added mma_verbose flag for debugging
authorstevenj <stevenj@alum.mit.edu>
Tue, 5 Aug 2008 01:59:45 +0000 (21:59 -0400)
committerstevenj <stevenj@alum.mit.edu>
Tue, 5 Aug 2008 01:59:45 +0000 (21:59 -0400)
darcs-hash:20080805015945-c8de0-6bd5b05be22520ce8c26cb1fa50019fc9d99d98f.gz

mma/mma.c
mma/mma.h

index fa2ae42d5a9bfdc63f3668893b8a706d7c057755..891d83dd1df7a77e79a56e55892dfb35dd8a7465 100644 (file)
--- a/mma/mma.c
+++ b/mma/mma.c
@@ -1,9 +1,12 @@
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
+#include <stdio.h>
 
 #include "mma.h"
 
+int mma_verbose = 0; /* > 0 for verbose output */
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -81,6 +84,8 @@ nlopt_result mma_minimize(int n, nlopt_func f, void *f_data,
 
               if (gcur >= fcur) break;
               rho = MIN(10*rho, 1.1 * (rho + (fcur - gcur) / w));
+              if (mma_verbose)
+                   printf("MMA inner iteration: rho -> %g\n", rho);
          }
 
          if (nlopt_stop_ftol(stop, fcur, fprev))
@@ -91,6 +96,8 @@ nlopt_result mma_minimize(int n, nlopt_func f, void *f_data,
               
          /* update rho and sigma for iteration k+1 */
          rho = MAX(0.1 * rho, MMA_RHOMIN);
+         if (mma_verbose)
+              printf("MMA outer iteration: rho -> %g\n", rho);
          if (k > 1)
               for (j = 0; j < n; ++j) {
                    double dx2 = (xcur[j]-xprev[j]) * (xprev[j]-xprevprev[j]);
index d492de84a55bf1a10bd709d7dfe212332936dcc8..b2d18d24ee313978e9c9f52a1e5159943ba46113 100644 (file)
--- a/mma/mma.h
+++ b/mma/mma.h
@@ -9,6 +9,8 @@ extern "C"
 {
 #endif /* __cplusplus */
 
+extern int mma_verbose;
+
 nlopt_result mma_minimize(int n, nlopt_func f, void *f_data,
                          const double *lb, const double *ub, /* bounds */
                          double *x, /* in: initial guess, out: minimizer */