chiark / gitweb /
add NLOPT_G_MLSL variants that require local_opt to be specified
authorstevenj <stevenj@alum.mit.edu>
Tue, 15 Jun 2010 22:25:04 +0000 (18:25 -0400)
committerstevenj <stevenj@alum.mit.edu>
Tue, 15 Jun 2010 22:25:04 +0000 (18:25 -0400)
darcs-hash:20100615222504-c8de0-5f416d50c5d8431fe641785cc1458a78178b13db.gz

api/Makefile.am
api/general.c
api/nlopt.3
api/nlopt.h
api/optimize.c
octave/Makefile.am
octave/NLOPT_G_MLSL.m [new file with mode: 0644]
octave/NLOPT_G_MLSL_LDS.m [new file with mode: 0644]
octave/mkconstants.sh
swig/Makefile.am

index 7a9f0274ea5d2db0b92af41a968e76154702ca4f..4f169f7e2f75cbbdef6abe0ca9205e18e0984724 100644 (file)
@@ -15,10 +15,10 @@ if MAINTAINER_MODE
 
 nlopt.f: nlopt.h
        rm -f $@
-       (i=0; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG' $(srcdir)/nlopt.h | tr -d ' =0,' | while read n; do echo "      integer $$n"; echo "      parameter ($$n=$$i)"; i=`expr $$i + 1`; done; tail -n +`grep -n enum $(srcdir)/nlopt.h |cut -d: -f1 |tail -n 1` $(srcdir)/nlopt.h  | grep NLOPT | egrep -v 'EXTERN|DEPRECATED|MINF_MAX' | cut -d, -f1 | tr -d ' ' | perl -pe 's/([A-Za-z0-9_]+)=([-+0-9]+)/      integer \1\n      parameter (\1=\2)/') > $@
+       (i=0; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL' $(srcdir)/nlopt.h | tr -d ' =0,' | while read n; do echo "      integer $$n"; echo "      parameter ($$n=$$i)"; i=`expr $$i + 1`; done; tail -n +`grep -n enum $(srcdir)/nlopt.h |cut -d: -f1 |tail -n 1` $(srcdir)/nlopt.h  | grep NLOPT | egrep -v 'EXTERN|DEPRECATED|MINF_MAX' | cut -d, -f1 | tr -d ' ' | perl -pe 's/([A-Za-z0-9_]+)=([-+0-9]+)/      integer \1\n      parameter (\1=\2)/') > $@
 
 nlopt.hpp: nlopt.h nlopt-in.hpp
        rm -f $@
-       (n=`grep -n GEN_ENUMS_HERE nlopt-in.hpp | cut -d: -f1`; head -n $$n $(srcdir)/nlopt-in.hpp;  echo "  enum algorithm {"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_NUM_ALGORITHMS' $(srcdir)/nlopt.h | sed 's/NLOPT_//g'; echo "  };"; echo "  enum result {"; egrep 'NLOPT_[A-Z_]* =' $(srcdir)/nlopt.h | egrep -v 'NLOPT_[LG][DN]' | sed 's/NLOPT_//g'; echo "  };"; tail -n +$$n $(srcdir)/nlopt-in.hpp) > $@
+       (n=`grep -n GEN_ENUMS_HERE nlopt-in.hpp | cut -d: -f1`; head -n $$n $(srcdir)/nlopt-in.hpp;  echo "  enum algorithm {"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL|NLOPT_NUM_ALGORITHMS' $(srcdir)/nlopt.h | sed 's/NLOPT_//g'; echo "  };"; echo "  enum result {"; egrep 'NLOPT_[A-Z_]* =' $(srcdir)/nlopt.h | egrep -v 'NLOPT_[LG][DN]' | sed 's/NLOPT_//g'; echo "  };"; tail -n +$$n $(srcdir)/nlopt-in.hpp) > $@
 
 endif
index b217a8959c8574b41ebdda0468c36b7377e798ef..e892bd997d8ae6f545099451bd64b619ea14bb51 100644 (file)
@@ -93,6 +93,8 @@ static const char nlopt_algorithm_names[NLOPT_NUM_ALGORITHMS][256] = {
      "ISRES evolutionary constrained optimization (global, no-derivative)",
      "Augmented Lagrangian method (needs sub-algorithm)",
      "Augmented Lagrangian method for equality constraints (needs sub-algorithm)",
+     "Multi-level single-linkage (MLSL), random (global, needs sub-algorithm)",
+     "Multi-level single-linkage (MLSL), quasi-random (global, needs sub-algorithm)",
 };
 
 const char *nlopt_algorithm_name(nlopt_algorithm a)
index 3f5eaaf39806db247c177b2f40117c7abe73f173..ec547387714f1904a54240f21121e17559694f84 100644 (file)
@@ -422,21 +422,17 @@ Global (G) derivative-free (N) optimization using a genetic algorithm
 handle nonlinear inequality and equality constraints as suggested by
 Runarsson and Yao.
 .TP
-\fBNLOPT_GD_MLSL_LDS\fR, \fBNLOPT_GN_MLSL_LDS\fR
-Global (G) derivative-based (D) or derivative-free (N) optimization
-using the multi-level single-linkage (MLSL) algorithm with a
-low-discrepancy sequence (LDS).  This algorithm executes a quasi-random
-(LDS) sequence of local searches, with a clustering heuristic to
-avoid multiple local searches for the same local optimum.  The local
-search uses the derivative/nonderivative algorithm set by
-.I nlopt_set_local_optimizer
-(currently defaulting to
-.I NLOPT_LD_MMA
-and
-.I NLOPT_LN_COBYLA
-for derivative/nonderivative searches, respectively).  There are also
-two other variants, \fBNLOPT_GD_MLSL\fR and \fBNLOPT_GN_MLSL\fR, which use
-pseudo-random numbers (instead of an LDS) as in the original MLSL algorithm.
+\fBNLOPT_G_MLSL_LDS\fR, \fBNLOPT_G_MLSL\fR 
+Global (G) optimization using the multi-level single-linkage (MLSL)
+algorithm with a low-discrepancy sequence (LDS) or pseudorandom
+numbers, respectively.  This algorithm executes a low-discrepancy
+or pseudorandom sequence of local searches, with a clustering
+heuristic to avoid multiple local searches for the same local optimum.
+The local search algorithm must be specified, along with termination
+criteria/tolerances for the local searches, by
+\fInlopt_set_local_optimizer\fR.  (This subsidiary algorithm can be
+with or without derivatives, and determines whether the objective
+function needs gradients.)
 .TP
 .B NLOPT_LD_MMA
 Local (L) gradient-based (D) optimization using the method of moving
index bfa8e41290c8d2cd25317b6b7e7d15839123a6ee..41e3991854fa0d73b65a7b36c8ead7267533aef2 100644 (file)
@@ -125,9 +125,12 @@ typedef enum {
 
      NLOPT_GN_ISRES,
 
-     /* not with older AUGLAG constants for backwards compatibility */
+     /* new variants that require local_optimizer to be set,
+       not with older constants for backwards compatibility */
      NLOPT_AUGLAG,
      NLOPT_AUGLAG_EQ,
+     NLOPT_G_MLSL,
+     NLOPT_G_MLSL_LDS,
 
      NLOPT_NUM_ALGORITHMS /* not an algorithm, just the number of them */
 } nlopt_algorithm;
index 11951eb1764bda72286c1740ccdd15f5c37c4b5b..a298964b19751d4a322b933e178ab87e9d2e7836 100644 (file)
@@ -348,6 +348,8 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf)
              return crs_minimize(ni, f, f_data, lb, ub, x, minf, &stop, 
                                  (int) POP(0), 0);
 
+        case NLOPT_G_MLSL:
+        case NLOPT_G_MLSL_LDS:
         case NLOPT_GN_MLSL:
         case NLOPT_GD_MLSL:
         case NLOPT_GN_MLSL_LDS:
@@ -355,6 +357,9 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf)
              if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS;
              nlopt_opt local_opt = opt->local_opt;
              nlopt_result ret;
+             if (!local_opt && (algorithm == NLOPT_G_MLSL 
+                                || algorithm == NLOPT_G_MLSL_LDS))
+                  return NLOPT_INVALID_ARGS;
              if (!local_opt) { /* default */
                   nlopt_algorithm local_alg = (algorithm == NLOPT_GN_MLSL ||
                                                algorithm == NLOPT_GN_MLSL_LDS)
@@ -386,7 +391,8 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf)
              opt->force_stop_child = local_opt;
              ret = mlsl_minimize(ni, f, f_data, lb, ub, x, minf, &stop,
                                  local_opt, (int) POP(0),
-                                 algorithm >= NLOPT_GN_MLSL_LDS);
+                                 algorithm >= NLOPT_GN_MLSL_LDS &&
+                                 algorithm != NLOPT_G_MLSL);
              opt->force_stop_child = NULL;
              if (!opt->local_opt) nlopt_destroy(local_opt);
              return ret;
index 36840774bc840a7f4cf58d9301b0881cf1a57894..821fe65d84daf75d444d21d7f35e9b5cf622969e 100644 (file)
@@ -1,6 +1,6 @@
 AM_CPPFLAGS = -I$(top_srcdir)/api -I$(top_srcdir)/util
 
-MFILES = NLOPT_GN_DIRECT.m NLOPT_GN_DIRECT_L.m NLOPT_GN_DIRECT_L_RAND.m NLOPT_GN_DIRECT_NOS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WTON_PRECOND_RESTART.m NLOPT_GN_CRS2_LM.m NLOPT_GN_MLSL.m NLOPT_GD_MLSL.m NLOPT_GN_MLSL_LDS.m NLOPT_GD_MLSL_LDS.m NLOPT_LD_MMA.m NLOPT_LN_COBYLA.m NLOPT_LN_NEWUOA.m NLOPT_LN_NEWUOA_BOUND.m NLOPT_LN_NELDERMEAD.m NLOPT_LN_SBPLX.m NLOPT_LN_AUGLAG.m NLOPT_LD_AUGLAG.m NLOPT_LN_AUGLAG_EQ.m NLOPT_LD_AUGLAG_EQ.m NLOPT_LN_BOBYQA.m NLOPT_GN_ISRES.m NLOPT_AUGLAG.m NLOPT_AUGLAG_EQ.m NLOPT_G_MLSL.m NLOPT_G_MLSL_LDS.m 
 
 #######################################################################
 # dummy C program to fool automake into making sure that CPPFLAGS etc.
diff --git a/octave/NLOPT_G_MLSL.m b/octave/NLOPT_G_MLSL.m
new file mode 100644 (file)
index 0000000..f0c0abc
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_G_MLSL: Multi-level single-linkage (MLSL), random (global, needs sub-algorithm)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_G_MLSL
+  val = 38;
diff --git a/octave/NLOPT_G_MLSL_LDS.m b/octave/NLOPT_G_MLSL_LDS.m
new file mode 100644 (file)
index 0000000..254023e
--- /dev/null
@@ -0,0 +1,5 @@
+% NLOPT_G_MLSL_LDS: Multi-level single-linkage (MLSL), quasi-random (global, needs sub-algorithm)
+%
+% See nlopt_minimize for more information.
+function val = NLOPT_G_MLSL_LDS
+  val = 39;
index 45ac91da0e8843d6f1522bd3da858d8474e45fa2..b27234aa92e4c1dae3b9d451c03bcc95cf6fb985 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh 
 
-names=`egrep 'NLOPT_[LG][ND]|NLOPT_AUGLAG' ../api/nlopt.h |sed 's/ //g' |tr = , |cut -d, -f1`
+names=`egrep 'NLOPT_[LG][ND]|NLOPT_AUGLAG|NLOPT_G_MLSL' ../api/nlopt.h |sed 's/ //g' |tr = , |cut -d, -f1`
 i=0
 
 gcc -I../util -I.. -E ../api/general.c | perl -pe 's/^ *\n//' > foo.c
index 04bde58729ba5a25ca59326eb3ee44748b054b92..2434d71e9e911e5616607cb84ab1f1c4d7cb106c 100644 (file)
@@ -51,6 +51,6 @@ nlopt-python.cpp nlopt.py: $(SWIG_SRC) nlopt-python.i numpy.i $(HDR)
        swig -I$(top_builddir)/api -outdir $(builddir) -c++ -python -o $@ nlopt.i
 
 nlopt-enum-renames.i: $(top_srcdir)/api/nlopt.h
-       (echo "// AUTOMATICALLY GENERATED -- DO NOT EDIT"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_NUM_ALGORITHMS' $(top_srcdir)/api/nlopt.h | sed 's/NLOPT_//g' |tr -d ' ' |tr '/' ',' |tr '=' ',' |cut -d, -f1 |while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done; egrep 'NLOPT_[A-Z_]* =' $(top_srcdir)/api/nlopt.h | egrep -v 'NLOPT_[LG][DN]|NLOPT_AUGLAG' | sed 's/NLOPT_//g' |tr -d ' ' |cut -d'=' -f1 | while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done) > $@
+       (echo "// AUTOMATICALLY GENERATED -- DO NOT EDIT"; egrep 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL|NLOPT_NUM_ALGORITHMS' $(top_srcdir)/api/nlopt.h | sed 's/NLOPT_//g' |tr -d ' ' |tr '/' ',' |tr '=' ',' |cut -d, -f1 |while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done; egrep 'NLOPT_[A-Z_]* =' $(top_srcdir)/api/nlopt.h | egrep -v 'NLOPT_[LG][DN]|NLOPT_AUGLAG|NLOPT_G_MLSL' | sed 's/NLOPT_//g' |tr -d ' ' |cut -d'=' -f1 | while read name; do echo "%rename(NLOPT_$$name) nlopt::$$name;"; done) > $@
 
 endif