From: stevenj Date: Tue, 5 Aug 2008 01:59:45 +0000 (-0400) Subject: added mma_verbose flag for debugging X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b05302581126f7834e369d1a0478a6997f3b7c4e;p=nlopt.git added mma_verbose flag for debugging darcs-hash:20080805015945-c8de0-6bd5b05be22520ce8c26cb1fa50019fc9d99d98f.gz --- diff --git a/mma/mma.c b/mma/mma.c index fa2ae42..891d83d 100644 --- a/mma/mma.c +++ b/mma/mma.c @@ -1,9 +1,12 @@ #include #include #include +#include #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]); diff --git a/mma/mma.h b/mma/mma.h index d492de8..b2d18d2 100644 --- 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 */