chiark / gitweb /
added nlopt_munge_data to fix bug in C++ (and Python, and Guile) copy constructor
authorSteven G. Johnson <stevenj@alum.mit.edu>
Thu, 28 Mar 2013 15:27:33 +0000 (11:27 -0400)
committerSteven G. Johnson <stevenj@alum.mit.edu>
Thu, 28 Mar 2013 15:27:33 +0000 (11:27 -0400)
NEWS
api/nlopt.h
api/options.c

diff --git a/NEWS b/NEWS
index 8c0d188cd772addce5fc0f7a2842a6d68f94ac22..67f4e9c73f579f122b85427b8ada9e32539b09d0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+NLopt 2.4
+
+* New genetic algorithm ESCH, thanks to Carlos Henrique da Silva Santos.
+
+* Fix swig dir for VPATH builds, thanks to Sandro Vitenti for the bug report.
+
+* Bugfix in copy constructor for C++ and Python interfaces.
+
 NLopt 2.3.1 (16 September 2012)
 
 * Bug fix: COBLYA should return ROUNDOFF_LIMITED rather than XTOL_REACHED
index eecf231d4b9ec8066fac58fe89788d2655107087..beb7fa9280ec8a610ce886ccb5b2370362bc940c 100644 (file)
@@ -305,6 +305,9 @@ typedef void* (*nlopt_munge)(void *p);
 NLOPT_EXTERN(void) nlopt_set_munge(nlopt_opt opt,
                                  nlopt_munge munge_on_destroy,
                                  nlopt_munge munge_on_copy);
+typedef void* (*nlopt_munge2)(void *p, void *data);
+NLOPT_EXTERN(void) nlopt_munge_data(nlopt_opt opt,
+                                    nlopt_munge2 munge, void *data);
 
 /*************************** DEPRECATED API **************************/
 /* The new "object-oriented" API is preferred, since it allows us to
index 8b75c15b538c1b767a4535ba1f851aade34c8078..9bfb6eba123967d6a3e792d80b9abff90645568e 100644 (file)
@@ -738,4 +738,16 @@ void NLOPT_STDCALL nlopt_set_munge(nlopt_opt opt,
      }
 }
 
+void NLOPT_STDCALL nlopt_munge_data(nlopt_opt opt,
+                                    nlopt_munge2 munge, void *data) {
+     if (opt && munge) {
+          unsigned i;
+          opt->f_data = munge(opt->f_data, data);
+          for (i = 0; i < opt->m; ++i)
+               opt->fc[i].f_data = munge(opt->fc[i].f_data, data);
+          for (i = 0; i < opt->p; ++i)
+               opt->h[i].f_data = munge(opt->h[i].f_data, data);
+     }
+}
+
 /*************************************************************************/