From 7993645afd6cd040a160362fe9b6e0712152acba Mon Sep 17 00:00:00 2001 From: stevenj Date: Sat, 25 Aug 2007 00:09:43 -0400 Subject: [PATCH] support both randomized and deterministic versions of StoGO darcs-hash:20070825040943-c8de0-dae271fcbf9097b206b94be55369be426b286935.gz --- api/nlopt.c | 6 +++++- api/nlopt.h | 1 + api/nlopt_minimize.3 | 6 +++++- stogo/stogo.cc | 6 ++++-- stogo/stogo.h | 7 ++++++- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/api/nlopt.c b/api/nlopt.c index bf7ee9f..529c9eb 100644 --- a/api/nlopt.c +++ b/api/nlopt.c @@ -44,6 +44,7 @@ static const char nlopt_algorithm_names[NLOPT_NUM_ALGORITHMS][128] = { "DIRECT-L (global)", "Subplex (local)", "StoGO (global)", + "StoGO with randomized search (global)", "Low-storage BFGS (LBFGS) (local)" }; @@ -180,8 +181,11 @@ static nlopt_result nlopt_minimize_( break; case NLOPT_GLOBAL_STOGO: + case NLOPT_GLOBAL_STOGO_RANDOMIZED: if (!stogo_minimize(n, f, f_data, x, fmin, lb, ub, - maxeval, maxtime)) + maxeval, maxtime, + algorithm == NLOPT_GLOBAL_STOGO + ? 0 : 2*n)) return NLOPT_FAILURE; break; diff --git a/api/nlopt.h b/api/nlopt.h index abbe1a4..2188991 100644 --- a/api/nlopt.h +++ b/api/nlopt.h @@ -18,6 +18,7 @@ typedef enum { /* gradient-based algorithms */ NLOPT_GLOBAL_STOGO, + NLOPT_GLOBAL_STOGO_RANDOMIZED, NLOPT_LOCAL_LBFGS, NLOPT_NUM_ALGORITHMS /* not an algorithm, just the number of them */ diff --git a/api/nlopt_minimize.3 b/api/nlopt_minimize.3 index b8b59c0..312b658 100644 --- a/api/nlopt_minimize.3 +++ b/api/nlopt_minimize.3 @@ -201,8 +201,12 @@ as well as nonlinear constraints as described above). Global optimization using the StoGO algorithm by Madsen et al. StoGO exploits gradient information (which must be supplied by the objective) for its local searches, and performs the global search by a -stochastic branch-and-bound technique. Only bound-constrained optimization +branch-and-bound technique. Only bound-constrained optimization is supported. +.TP +.B NLOPT_GLOBAL_STOGO_RANDOMIZED +As above, but uses randomized starting points for the local searches +(which is sometimes better, often worse than the deterministic version). .TP .B NLOPT_LOCAL_LBFGS Local gradient-based optimization using the low-storage BFGS (L-BFGS) diff --git a/stogo/stogo.cc b/stogo/stogo.cc index 97b0db3..1390837 100644 --- a/stogo/stogo.cc +++ b/stogo/stogo.cc @@ -30,12 +30,14 @@ int stogo_minimize(int n, objective_func fgrad, void *data, double *x, double *fmin, const double *l, const double *u, - long int maxeval, double maxtime) + long int maxeval, double maxtime, + int nrandom) { GlobalParams params; // FIXME: WTF do these parameters mean? - params.det_pnts=2*n+1; params.rnd_pnts=0; + params.rnd_pnts=nrandom; + params.det_pnts=2*n+1 - nrandom; params.eps_cl=0.1; params.rshift=0.3; params.mu=1.0E-4; diff --git a/stogo/stogo.h b/stogo/stogo.h index 4ae727e..c5cd6d2 100644 --- a/stogo/stogo.h +++ b/stogo/stogo.h @@ -37,6 +37,10 @@ typedef double (*objective_func)(int n, const double *x, double *grad, maxtime: if nonzero, a maximum time (in seconds) + nrandom: number of randomized search points to use per box, + in addition to 2*n+1 deterministic search points + (0 for a deterministic algorithm). + Output: fmin: the minimum value of the objective function found @@ -51,7 +55,8 @@ int stogo_minimize(int n, objective_func fgrad, void *data, double *x, double *fmin, const double *l, const double *u, - long int maxeval, double maxtime); + long int maxeval, double maxtime, + int nrandom); extern int stogo_verbose; /* set to nonzero for verbose output */ -- 2.30.2