chiark / gitweb /
C++, STOGO, and nocedal fixes
authorstevenj <stevenj@alum.mit.edu>
Mon, 14 Jun 2010 18:21:29 +0000 (14:21 -0400)
committerstevenj <stevenj@alum.mit.edu>
Mon, 14 Jun 2010 18:21:29 +0000 (14:21 -0400)
darcs-hash:20100614182129-c8de0-4877a5f93a8e37ad69984339f01830c9bb35a7d2.gz

api/f77api.c
api/general.c
api/nlopt-internal.h
api/optimize.c
stogo/local.cc
stogo/stogo.cc
stogo/stogo.h

index da709aeb7689f95c0085b48103d4df9a281fe8e1..15cf50f9f5d234afccd86b65e3467cad9deafdca 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 
 #include "nlopt.h"
 
index 5d300ea19ee44e313540502f7d9dcd99563c1bb0..9e43228b4ca3a18770347caef52e0bb1f31dd20e 100644 (file)
@@ -23,8 +23,7 @@
 #include <math.h>
 #include <float.h>
 
-#include "nlopt.h"
-#include "nlopt-util.h"
+#include "nlopt-internal.h"
 
 /*************************************************************************/
 
@@ -128,11 +127,11 @@ void nlopt_srand(unsigned long seed) {
      nlopt_init_genrand(seed);
 }
 
-void nlopt_srand_time() {
+void nlopt_srand_time(void) {
      nlopt_srand(nlopt_time_seed() + my_gettid() * 314159);
 }
 
-void nlopt_srand_time_default() {
+void nlopt_srand_time_default(void) {
      if (!nlopt_srand_called) nlopt_srand_time();
 }
 
index fc43db3b411ff7546a287556333f1d1e73202061..e8a80ffb13a59ba6e6d676fd6ed24d82341a1d72 100644 (file)
@@ -72,7 +72,7 @@ struct nlopt_opt_s {
 };
 
 /*********************************************************************/
-void nlopt_srand_time_default(void); /* init the rand. seed only if unset */
+extern void nlopt_srand_time_default(void); /* init the rand. seed only if unset */
 
 /*********************************************************************/
 /* global defaults set by deprecated API: */
index 0f35707fe2685668617d7ea52b7f997d80711546..50e5fa7d5458a47c9f203a76d20dbe8049468d74 100644 (file)
@@ -303,7 +303,7 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf)
                   nbd[i] = linf && uinf ? 0 : (uinf ? 1 : (linf ? 3 : 2));
              }
              iret = lbfgsb_minimize(ni, f, f_data, x, nbd, lb, ub,
-                                    MIN(ni, 5), 0.0, stop.ftol_rel, 
+                                    ni < 5 ? ni : 5, 0.0, stop.ftol_rel, 
                                     stop.xtol_abs[0] > 0 ? stop.xtol_abs[0]
                                     : stop.xtol_rel,
                                     stop.maxeval);
index ccf58029a72fb84f7cdb2b2433fd821f34b413ee..89802b62f10fec5c463b8b6ddc71486e67c5fd86 100644 (file)
@@ -82,7 +82,7 @@ int local(Trial &T, TBox &box, TBox &domain, double eps_cl, double *mgr,
      return LS_Old ;
    } 
 
-#ifdef NLOPT_H
+#if 0
 
   if (axis != -1) {
     cout << "NLopt code only works with axis == -1, exiting...\n" ;
index 69a4f8d32427fe8b7814e8e1c803bdc9b2999c19..146a9bc9b087dd6b703b2aa51f0431da970b2242 100644 (file)
@@ -18,9 +18,9 @@ public:
     switch (which) {
     case GRADIENT_ONLY:
     case OBJECTIVE_AND_GRADIENT:
-      return my_func(xy.GetLength(), xy.raw_data_const(), grad.raw_data(), my_data);
+      return my_func((unsigned) xy.GetLength(), xy.raw_data_const(), grad.raw_data(), my_data);
     case OBJECTIVE_ONLY:
-      return my_func(xy.GetLength(), xy.raw_data_const(), NULL, my_data);
+      return my_func((unsigned) xy.GetLength(), xy.raw_data_const(), NULL, my_data);
     }
     return 0.0;
   }
index 7ca57f30618ecc0b6451c96973dea7cb4fce54e2..211f3d840156694afe1d7f5c66fe0e1793f28b39 100644 (file)
@@ -10,7 +10,7 @@
 extern "C" {
 #endif
 
-typedef double (*objective_func)(int n, const double *x, double *grad,
+typedef double (*objective_func)(unsigned n, const double *x, double *grad,
                                 void *data);
 
 /* search for the global minimum of the function fgrad(n, x, grad, data)