From: stevenj Date: Sun, 24 Aug 2008 20:08:20 +0000 (-0400) Subject: use recursive MMA as fallback in case of problems with dual solution X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=40135b276c318a2dcfce510e592bb6cdbd4dfb99;p=nlopt.git use recursive MMA as fallback in case of problems with dual solution darcs-hash:20080824200820-c8de0-9a6ae641efe8267ea62a60c77a5b5a421733770c.gz --- diff --git a/mma/mma.c b/mma/mma.c index 19b9f1b..aae87eb 100644 --- a/mma/mma.c +++ b/mma/mma.c @@ -200,11 +200,22 @@ nlopt_result mma_minimize(int n, nlopt_func f, void *f_data, /* solve dual problem */ dd.rho = rho; dd.count = 0; + dual_solution: reti = nlopt_minimize( dual_alg, m, dual_func, &dd, dual_lb, dual_ub, y, &min_dual, -HUGE_VAL, dual_tolrel,0., 0.,NULL, dual_maxeval, stop->maxtime - (nlopt_seconds() - stop->start)); + if (reti == NLOPT_FAILURE && dual_alg != NLOPT_LD_MMA) { + /* LBFGS etc. converge quickly but are sometimes + very finicky if there are any rounding errors in + the gradient, etcetera; if it fails, try again + with MMA called recursively for the dual */ + dual_alg = NLOPT_LD_MMA; + if (mma_verbose) + printf("MMA: switching to recursive MMA for dual\n"); + goto dual_solution; + } if (reti < 0 || reti == NLOPT_MAXTIME_REACHED) { ret = reti; goto done;