chiark / gitweb /
fix #12
authorSteven G. Johnson <stevenj@mit.edu>
Tue, 18 Feb 2014 16:51:04 +0000 (11:51 -0500)
committerSteven G. Johnson <stevenj@mit.edu>
Tue, 18 Feb 2014 16:51:04 +0000 (11:51 -0500)
CMakeLists.txt [new file with mode: 0644]
config.cmake.h.in [new file with mode: 0644]
esch/esch.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5e667b5
--- /dev/null
@@ -0,0 +1,153 @@
+PROJECT(NLOPT)\r
+\r
+#==============================================================================\r
+# NLOPT CMake file\r
+# \r
+# NLopt is a free/open-source library for nonlinear optimization, providing \r
+# a common interface for a number of different free optimization routines \r
+# available online as well as original implementations of various other \r
+# algorithms\r
+# WEBSITE: http://ab-initio.mit.edu/wiki/index.php/NLopt \r
+# AUTHOR: Steven G. Johnson\r
+#\r
+# This CMakeLists.txt file was created to compile NLOPT with the CMAKE utility.\r
+# Benoit Scherrer, 2010 CRL, Harvard Medical School\r
+# Copyright (c) 2008-2009 Children's Hospital Boston \r
+#==============================================================================\r
+\r
+\r
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)\r
+INCLUDE(CheckIncludeFiles)\r
+INCLUDE(CheckFunctionExists)\r
+INCLUDE(CheckTypeSize)\r
+\r
+\r
+#==============================================================================\r
+# COMPILATION CHECKINGS and CONFIGURATION GENERATION\r
+#==============================================================================\r
+CHECK_INCLUDE_FILES( unistd.h HAVE_UNISTD_H)\r
+CHECK_INCLUDE_FILES( string.h HAVE_STRING_H)\r
+CHECK_INCLUDE_FILES( strings.h HAVE_STRINGS_H)\r
+CHECK_INCLUDE_FILES( sys/stat.h HAVE_SYS_STAT_H)\r
+CHECK_INCLUDE_FILES( inttypes.h HAVE_INTTYPES_H)\r
+CHECK_INCLUDE_FILES( memory.h HAVE_MEMORY_H)\r
+CHECK_INCLUDE_FILES( stdlib.h HAVE_STDLIB_H)\r
+CHECK_INCLUDE_FILES( stdint.h HAVE_STDINT_H)\r
+\r
+CHECK_INCLUDE_FILES( sys/types.h HAVE_SYS_TYPES_H)\r
+CHECK_INCLUDE_FILES( sys/types.h HAVE_SYS_TYPES_H)\r
+CHECK_INCLUDE_FILES( sys/types.h HAVE_SYS_TYPES_H)\r
+\r
+CHECK_FUNCTION_EXISTS( isinf HAVE_ISINF)\r
+CHECK_FUNCTION_EXISTS( isinf HAVE_ISNAN)\r
+CHECK_FUNCTION_EXISTS( gettimeofday HAVE_GETTIMEOFDAY)\r
+CHECK_FUNCTION_EXISTS( qsort_r HAVE_QSORT_R)\r
+CHECK_FUNCTION_EXISTS( time HAVE_TIME)\r
+CHECK_FUNCTION_EXISTS( copysign HAVE_COPYSIGN)\r
+\r
+CHECK_TYPE_SIZE(uint32_t    UINT32_T)\r
+IF(NOT HAVE_UINT32_T)\r
+  IF(MSVC)\r
+    SET(uint32_t "unsigned int")\r
+    SET(SIZEOF_UNSIGNED_INT 4)\r
+  ENDIF(MSVC)\r
+ENDIF(NOT HAVE_UINT32_T)\r
+\r
+#==============================================================================\r
+# LOOK FOR THE VERSION NUMBER IN configure.ac\r
+#==============================================================================\r
+\r
+FILE( READ configure.ac CONFIG_AUTOMAKE )\r
+\r
+STRING( REGEX MATCH "AC_INIT\\(nlopt, ([0-9]+\\.[0-9]+\\.?[0-9]*)" NLOPT_AUTOMAKE_LINE_VERSION "${CONFIG_AUTOMAKE}") \r
+\r
+#---------------------------------\r
+# If version matches 'X.X.X'\r
+#---------------------------------\r
+IF(${NLOPT_AUTOMAKE_LINE_VERSION} MATCHES ".*[0-9]+\\.[0-9]+\\.[0-9]+")\r
+    STRING( REGEX REPLACE ".*([0-9]+)\\.[0-9]+\\.[0-9]*.*" "\\1" NLOPT_MAJOR_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") \r
+    STRING( REGEX REPLACE ".*[0-9]+\\.([0-9]+)\\.[0-9]*.*" "\\1" NLOPT_MINOR_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") \r
+    STRING( REGEX REPLACE ".*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" NLOPT_BUGFIX_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") \r
+#---------------------------------\r
+# Else (consider that version matches 'X.X')\r
+#---------------------------------\r
+ELSE(${NLOPT_AUTOMAKE_LINE_VERSION} MATCHES ".*[0-9]+\\.[0-9]+\\.[0-9]+")\r
+    STRING( REGEX REPLACE ".*([0-9]+)\\.[0-9]+.*" "\\1" NLOPT_MAJOR_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") \r
+    STRING( REGEX REPLACE ".*[0-9]+\\.([0-9]+).*" "\\1" NLOPT_MINOR_VERSION "${NLOPT_AUTOMAKE_LINE_VERSION}") \r
+    SET (NLOPT_BUGFIX_VERSION "0")\r
+ENDIF(${NLOPT_AUTOMAKE_LINE_VERSION} MATCHES ".*[0-9]+\\.[0-9]+\\.[0-9]+")\r
+\r
+MESSAGE(STATUS "NLOPT: Version number ${NLOPT_MAJOR_VERSION}.${NLOPT_MINOR_VERSION}.${NLOPT_BUGFIX_VERSION} found in configure.ac" )\r
+\r
+\r
+#==============================================================================\r
+# CREATE config.h\r
+#==============================================================================\r
+\r
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h IMMEDIATE )\r
+\r
+\r
+#==============================================================================\r
+# INCLUDE DIRECTORIES\r
+#==============================================================================\r
+SET(${INCLUDE_DIRECTORIES} "")\r
+INCLUDE_DIRECTORIES (\r
+       ${CMAKE_CURRENT_SOURCE_DIR}\r
+        ${CMAKE_CURRENT_BINARY_DIR}\r
+       stogo \r
+       util \r
+       direct \r
+       cdirect \r
+       praxis \r
+       luksan \r
+       crs \r
+       mlsl \r
+       mma \r
+       cobyla \r
+       newuoa \r
+       neldermead \r
+       auglag \r
+       bobyqa \r
+       isres \r
+       slsqp\r
+        esch\r
+       api   )\r
+\r
+\r
+#==============================================================================\r
+# nlopt LIBRARY TARGET (SHARED OR STATIC)\r
+#==============================================================================\r
+\r
+SET ( NLOPT_SOURCES   \r
+       direct/DIRect.c direct/direct_wrap.c direct/DIRserial.c direct/DIRsubrout.c direct/direct-internal.h direct/direct.h\r
+       cdirect/cdirect.c cdirect/hybrid.c cdirect/cdirect.h\r
+       praxis/praxis.c praxis/praxis.h\r
+       luksan/plis.c luksan/plip.c luksan/pnet.c luksan/mssubs.c luksan/pssubs.c luksan/luksan.h\r
+       crs/crs.c crs/crs.h\r
+       mlsl/mlsl.c mlsl/mlsl.h\r
+       mma/mma.c mma/mma.h mma/ccsa_quadratic.c\r
+       cobyla/cobyla.c cobyla/cobyla.h\r
+       newuoa/newuoa.c newuoa/newuoa.h \r
+       neldermead/nldrmd.c neldermead/neldermead.h neldermead/sbplx.c   \r
+       auglag/auglag.c auglag/auglag.h\r
+       bobyqa/bobyqa.c bobyqa/bobyqa.h\r
+       isres/isres.c isres/isres.h \r
+       slsqp/slsqp.c slsqp/slsqp.h \r
+       esch/esch.c esch/esch.h\r
+       api/general.c api/options.c api/optimize.c api/deprecated.c api/nlopt-internal.h api/nlopt.h api/f77api.c api/f77funcs.h api/f77funcs_.h api/nlopt.hpp api/nlopt-in.hpp\r
+       util/mt19937ar.c util/sobolseq.c util/soboldata.h util/timer.c util/stop.c util/nlopt-util.h util/redblack.c util/redblack.h util/qsort_r.c util/rescale.c \r
+       stogo/global.cc stogo/linalg.cc stogo/local.cc stogo/stogo.cc stogo/tools.cc stogo/global.h stogo/linalg.h stogo/local.h stogo/stogo_config.h stogo/stogo.h stogo/tools.h \r
+        )\r
+\r
+OPTION(NLOPT_BUILD_SHARED "Build NLOPT as a shared library" OFF )\r
+\r
+IF(NLOPT_BUILD_SHARED)\r
+  ADD_DEFINITIONS(-DNLOPT_DLL)\r
+  ADD_DEFINITIONS(-DNLOPT_DLL_EXPORT )\r
+  ADD_LIBRARY (nlopt SHARED ${NLOPT_SOURCES} )\r
+ELSE(NLOPT_BUILD_SHARED)\r
+  ADD_LIBRARY (nlopt STATIC ${NLOPT_SOURCES} )\r
+ENDIF(NLOPT_BUILD_SHARED)\r
+\r
+\r
+\r
diff --git a/config.cmake.h.in b/config.cmake.h.in
new file mode 100644 (file)
index 0000000..0dce2db
--- /dev/null
@@ -0,0 +1,159 @@
+/*==============================================================================\r
+# NLOPT CMake configuration file\r
+# \r
+# NLopt is a free/open-source library for nonlinear optimization, providing \r
+# a common interface for a number of different free optimization routines \r
+# available online as well as original implementations of various other \r
+# algorithms\r
+# WEBSITE: http://ab-initio.mit.edu/wiki/index.php/NLopt \r
+# AUTHOR: Steven G. Johnson\r
+#\r
+# This config.cmake.h.in file was created to compile NLOPT with the CMAKE utility.\r
+# Benoit Scherrer, 2010 CRL, Harvard Medical School\r
+# Copyright (c) 2008-2009 Children's Hospital Boston \r
+#\r
+# Minor changes to the source was applied to make possible the compilation with\r
+# Cmake under Linux/Win32\r
+#============================================================================*/\r
+\r
+/* Bugfix version number. */\r
+#define BUGFIX_VERSION @NLOPT_BUGFIX_VERSION@\r
+\r
+/* Define to enable extra debugging code. */\r
+#undef DEBUG\r
+\r
+/* Define to 1 if you have the `BSDgettimeofday' function. */\r
+#undef HAVE_BSDGETTIMEOFDAY\r
+\r
+/* Define to 1 if you have the <dlfcn.h> header file. */\r
+#undef HAVE_DLFCN_H\r
+\r
+/* Define to 1 if you have the <getopt.h> header file. */\r
+#undef HAVE_GETOPT_H\r
+\r
+/* Define to 1 if you have the `getpid' function. */\r
+#undef HAVE_GETPID\r
+\r
+/* Define if syscall(SYS_gettid) available. */\r
+#undef HAVE_GETTID_SYSCALL\r
+\r
+/* Define to 1 if you have the `gettimeofday' function. */\r
+#cmakedefine HAVE_GETTIMEOFDAY\r
+\r
+/* Define if the copysign function/macro is available. */\r
+#cmakedefine HAVE_COPYSIGN\r
+\r
+/* Define to 1 if you have the <inttypes.h> header file. */\r
+#cmakedefine HAVE_INTTYPES_H\r
+\r
+/* Define if the isinf() function/macro is available. */\r
+#cmakedefine HAVE_ISINF\r
+\r
+/* Define if the isnan() function/macro is available. */\r
+#cmakedefine HAVE_ISNAN\r
+\r
+/* Define to 1 if you have the `m' library (-lm). */\r
+#undef HAVE_LIBM\r
+\r
+/* Define to 1 if you have the <memory.h> header file. */\r
+#cmakedefine HAVE_MEMORY_H\r
+\r
+/* Define to 1 if you have the `qsort_r' function. */\r
+#cmakedefine HAVE_QSORT_R\r
+\r
+/* Define to 1 if you have the <stdint.h> header file. */\r
+#cmakedefine HAVE_STDINT_H\r
+\r
+/* Define to 1 if you have the <stdlib.h> header file. */\r
+#cmakedefine HAVE_STDLIB_H\r
+\r
+/* Define to 1 if you have the <strings.h> header file. */\r
+#cmakedefine HAVE_STRINGS_H\r
+\r
+/* Define to 1 if you have the <string.h> header file. */\r
+#cmakedefine HAVE_STRING_H\r
+\r
+/* Define to 1 if you have the <sys/stat.h> header file. */\r
+#cmakedefine HAVE_SYS_STAT_H\r
+\r
+/* Define to 1 if you have the <sys/types.h> header file. */\r
+#cmakedefine HAVE_SYS_TYPES_H\r
+\r
+/* Define to 1 if you have the `time' function. */\r
+#cmakedefine HAVE_TIME\r
+\r
+/* Define to 1 if the system has the type `uint32_t'. */\r
+#cmakedefine HAVE_UINT32_T\r
+\r
+/* Define to 1 if you have the <unistd.h> header file. */\r
+#cmakedefine HAVE_UNISTD_H\r
+\r
+/* Define to the sub-directory in which libtool stores uninstalled libraries.\r
+   */\r
+#undef LT_OBJDIR\r
+\r
+/* Major version number. */\r
+#define MAJOR_VERSION @NLOPT_MAJOR_VERSION@\r
+\r
+/* Minor version number. */\r
+#define MINOR_VERSION @NLOPT_MINOR_VERSION@\r
+\r
+/* Name of package */\r
+#undef PACKAGE\r
+\r
+/* Define to the address where bug reports for this package should be sent. */\r
+#undef PACKAGE_BUGREPORT\r
+\r
+/* Define to the full name of this package. */\r
+#undef PACKAGE_NAME\r
+\r
+/* Define to the full name and version of this package. */\r
+#undef PACKAGE_STRING\r
+\r
+/* Define to the one symbol short name of this package. */\r
+#undef PACKAGE_TARNAME\r
+\r
+/* Define to the home page for this package. */\r
+#undef PACKAGE_URL\r
+\r
+/* Define to the version of this package. */\r
+#undef PACKAGE_VERSION\r
+\r
+/* replacement for broken HUGE_VAL macro, if needed */\r
+#undef REPLACEMENT_HUGE_VAL\r
+\r
+/* The size of `unsigned int', as computed by sizeof. */\r
+#define SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@\r
+\r
+/* The size of `unsigned long', as computed by sizeof. */\r
+#undef SIZEOF_UNSIGNED_LONG\r
+\r
+/* Define to 1 if you have the ANSI C header files. */\r
+#undef STDC_HEADERS\r
+\r
+/* Define to C thread-local keyword, or to nothing if this is not supported in\r
+   your compiler. */\r
+#define THREADLOCAL\r
+\r
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */\r
+#undef TIME_WITH_SYS_TIME\r
+\r
+/* Version number of package */\r
+#undef VERSION\r
+\r
+/* Define if compiled including C++-based routines */\r
+#undef WITH_CXX\r
+\r
+/* Define if we have the non-free Nocedal LBFGS code */\r
+#undef WITH_NOCEDAL\r
+\r
+/* Define to empty if `const' does not conform to ANSI C. */\r
+#undef const\r
+\r
+/* Define to `__inline__' or `__inline' if that's what the C compiler\r
+   calls it, or to nothing if 'inline' is not supported under any name.  */\r
+#ifndef __cplusplus\r
+#undef inline\r
+#endif\r
+\r
+\r
index cc4952d637ea1ca1c10ceb9151412a4e7670972e..e2c01d745a461d30ca89889a724f2b089807226a 100644 (file)
@@ -32,18 +32,18 @@ static double randcauchy(const double params[7]) {
      double valor;
      double min = params[1], max = params[2], mi = params[3],
          t = params[4], band = params[5];
-     limit_inf = mi - (band/2);
-     limit_sup = mi + (band/2);
+     limit_inf = mi - (band*0.5);
+     limit_sup = mi + (band*0.5);
      do {
          na_unif = nlopt_urand(0,1); // ran2(0,1);
-         cauchy_mit = t*tan((na_unif-(1/2))*M_PI) + mi;
+         cauchy_mit = t*tan((na_unif-0.5)*3.14159265358979323846) + mi;
      } while ( (cauchy_mit<limit_inf) || (cauchy_mit>limit_sup) );   
      
      if (cauchy_mit < 0)
          cauchy_mit = -cauchy_mit;
      else
-         cauchy_mit = cauchy_mit + (band/2);
-     valor  = (cauchy_mit*100/band)/100;
+         cauchy_mit = cauchy_mit + (band*0.5);
+     valor  = cauchy_mit/band;
      valor = min+(max-min)*valor;   
      return valor;  
 }
@@ -57,7 +57,7 @@ typedef struct IndividualStructure {
 } Individual; 
 
 static int CompareIndividuals(void *unused, const void *a_, const void *b_) {
-     (void) unused;
+     // (void) unused;
      const Individual *a = (const Individual *) a_;
      const Individual *b = (const Individual *) b_;
      return a->fitness < b->fitness ? -1 : (a->fitness > b->fitness ? +1 : 0);