From f3e97a8e134ca0ab4f79c77ee66b7cdd05fee61d Mon Sep 17 00:00:00 2001 From: stevenj Date: Mon, 14 Jun 2010 16:26:11 -0400 Subject: [PATCH] NLOPT_AUGLAG, no LN/LD, which requires local-opt algorithm to be specified; remove "convergence" tests for no progress towards feasibility in auglag, which seem to cause incorrect termination .... darcs-hash:20100614202611-c8de0-2ee921f6892ca3d1824974367eba310ec6d21612.gz --- api/general.c | 2 ++ api/nlopt.h | 2 ++ api/optimize.c | 8 +++++++- api/options.c | 4 +++- auglag/auglag.c | 19 ++++++++----------- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/api/general.c b/api/general.c index 9e43228..02d370d 100644 --- a/api/general.c +++ b/api/general.c @@ -85,6 +85,8 @@ static const char nlopt_algorithm_names[NLOPT_NUM_ALGORITHMS][256] = { "Bound-constrained optimization via NEWUOA-based quadratic models (local, no-derivative)", "Nelder-Mead simplex algorithm (local, no-derivative)", "Sbplx variant of Nelder-Mead (re-implementation of Rowan's Subplex) (local, no-derivative)", + "Augmented Lagrangian method (needs sub-algorithm)", + "Augmented Lagrangian method for equality constraints (needs sub-algorithm)", "Augmented Lagrangian method (local, no-derivative)", "Augmented Lagrangian method (local, derivative)", "Augmented Lagrangian method for equality constraints (local, no-derivative)", diff --git a/api/nlopt.h b/api/nlopt.h index c785743..bc1dde3 100644 --- a/api/nlopt.h +++ b/api/nlopt.h @@ -116,6 +116,8 @@ typedef enum { NLOPT_LN_NELDERMEAD, NLOPT_LN_SBPLX, + NLOPT_AUGLAG, + NLOPT_AUGLAG_EQ, NLOPT_LN_AUGLAG, NLOPT_LD_AUGLAG, NLOPT_LN_AUGLAG_EQ, diff --git a/api/optimize.c b/api/optimize.c index 50e5fa7..3235b96 100644 --- a/api/optimize.c +++ b/api/optimize.c @@ -463,12 +463,17 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) return ret; } + case NLOPT_AUGLAG: + case NLOPT_AUGLAG_EQ: case NLOPT_LN_AUGLAG: case NLOPT_LN_AUGLAG_EQ: case NLOPT_LD_AUGLAG: case NLOPT_LD_AUGLAG_EQ: { nlopt_opt local_opt = opt->local_opt; nlopt_result ret; + if ((algorithm == NLOPT_AUGLAG || algorithm == NLOPT_AUGLAG_EQ) + && !local_opt) + return NLOPT_INVALID_ARGS; if (!local_opt) { /* default */ local_opt = nlopt_create( algorithm == NLOPT_LN_AUGLAG || @@ -489,7 +494,8 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) opt->p, opt->h, lb, ub, x, minf, &stop, local_opt, - algorithm == NLOPT_LN_AUGLAG_EQ + algorithm == NLOPT_AUGLAG_EQ + || algorithm == NLOPT_LN_AUGLAG_EQ || algorithm == NLOPT_LD_AUGLAG_EQ); opt->force_stop_child = NULL; if (!opt->local_opt) nlopt_destroy(local_opt); diff --git a/api/options.c b/api/options.c index 1f592d1..5b80810 100644 --- a/api/options.c +++ b/api/options.c @@ -271,7 +271,9 @@ nlopt_result nlopt_get_upper_bounds(nlopt_opt opt, double *ub) /*************************************************************************/ -#define AUGLAG_ALG(a) ((a) == NLOPT_LN_AUGLAG || \ +#define AUGLAG_ALG(a) ((a) == NLOPT_AUGLAG || \ + (a) == NLOPT_AUGLAG_EQ || \ + (a) == NLOPT_LN_AUGLAG || \ (a) == NLOPT_LN_AUGLAG_EQ || \ (a) == NLOPT_LD_AUGLAG || \ (a) == NLOPT_LD_AUGLAG_EQ) diff --git a/auglag/auglag.c b/auglag/auglag.c index 69d257e..14203bd 100644 --- a/auglag/auglag.c +++ b/auglag/auglag.c @@ -72,6 +72,7 @@ nlopt_result auglag_minimize(int n, nlopt_func f, void *f_data, double ICM = HUGE_VAL, minf_penalty = HUGE_VAL, penalty; double *xcur = NULL, fcur; int i, feasible, minf_feasible = 0; + int auglag_iters = 0; /* magic parameters from Birgin & Martinez */ const double tau = 0.5, gam = 10; @@ -181,18 +182,21 @@ nlopt_result auglag_minimize(int n, nlopt_func f, void *f_data, if (ICM > tau * prev_ICM) { d.rho *= gam; } + + auglag_iters++; if (auglag_verbose) { - printf("auglag: ICM=%g, rho=%g\nauglag lambda=", ICM, d.rho); + printf("auglag %d: ICM=%g (%sfeasible), rho=%g\nauglag lambda=", + auglag_iters, ICM, feasible ? "" : "not ", d.rho); for (i = 0; i < d.p; ++i) printf(" %g", d.lambda[i]); - printf("\nauglag mu = "); + printf("\nauglag %d: mu = ", auglag_iters); for (i = 0; i < d.m; ++i) printf(" %g", d.mu[i]); printf("\n"); } if ((feasible && (!minf_feasible || penalty < minf_penalty - || fcur <= *minf)) || - (!minf_feasible && penalty <= minf_penalty)) { + || fcur < *minf)) || + (!minf_feasible && penalty < minf_penalty)) { ret = NLOPT_SUCCESS; if (feasible) { if (fcur < stop->minf_max) @@ -202,13 +206,6 @@ nlopt_result auglag_minimize(int n, nlopt_func f, void *f_data, else if (nlopt_stop_x(stop, xcur, x)) ret = NLOPT_XTOL_REACHED; } - else { /* check if no progress towards feasibility */ - if (nlopt_stop_ftol(stop, fcur, *minf) - && nlopt_stop_ftol(stop, penalty, minf_penalty)) - ret = NLOPT_FTOL_REACHED; - else if (nlopt_stop_x(stop, xcur, x)) - ret = NLOPT_XTOL_REACHED; - } *minf = fcur; minf_penalty = penalty; minf_feasible = feasible; -- 2.30.2