chiark / gitweb /
fix #26
authorSteven G. Johnson <stevenj@alum.mit.edu>
Fri, 17 Apr 2015 02:47:43 +0000 (22:47 -0400)
committerSteven G. Johnson <stevenj@alum.mit.edu>
Fri, 17 Apr 2015 02:47:43 +0000 (22:47 -0400)
api/optimize.c

index 2087d8f69480b8e008e32eba45e2c2b1c65cfb17..0d679dc0ba6c1dd3678ed48fb3b259cc3d2248aa 100644 (file)
@@ -248,10 +248,15 @@ static void elimdim_expand(unsigned n, double *v,
 /* given opt, create a new opt with equal-constraint dimensions eliminated */
 static nlopt_opt elimdim_create(nlopt_opt opt)
 {
-     nlopt_opt opt0 = nlopt_copy(opt);
+     nlopt_opt opt0;
+     nlopt_munge munge_copy_save = opt->munge_on_copy;
      double *x, *grad = NULL;
      unsigned i;
      
+     opt->munge_on_copy = 0; /* hack: since this is an internal copy,
+                                we can leave it un-munged; see issue #26 */
+     opt0 = nlopt_copy(opt);
+     opt->munge_on_copy = munge_copy_save;
      if (!opt0) return NULL;
      x = (double *) malloc(sizeof(double) * opt->n);
      if (opt->n && !x) { nlopt_destroy(opt0); return NULL; }