Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package nlopt for openSUSE:Factory checked in at 2021-12-12 00:57:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/nlopt (Old) and /work/SRC/openSUSE:Factory/.nlopt.new.2520 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "nlopt" Sun Dec 12 00:57:50 2021 rev:16 rq:939962 version:2.7.1 Changes: -------- --- /work/SRC/openSUSE:Factory/nlopt/nlopt.changes 2020-12-02 13:59:21.305872817 +0100 +++ /work/SRC/openSUSE:Factory/.nlopt.new.2520/nlopt.changes 2021-12-12 00:58:08.866606554 +0100 @@ -1,0 +2,8 @@ +Tue Dec 7 23:03:09 UTC 2021 - Atri Bhattacharya <[email protected]> + +- Update to version 2.7.1: + * Various minor bugfixes (gh#stevengj/nlopt#268, + gh#stevengj/nlopt#409, gh#stevengj/nlopt#420) + * Build improvements (support Octave 6.x, Guile 3.x, Cmake 3.2). + +------------------------------------------------------------------- Old: ---- nlopt-2.7.0.tar.gz New: ---- nlopt-2.7.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ nlopt.spec ++++++ --- /var/tmp/diff_new_pack.1utR7k/_old 2021-12-12 00:58:09.298606850 +0100 +++ /var/tmp/diff_new_pack.1utR7k/_new 2021-12-12 00:58:09.298606850 +0100 @@ -1,7 +1,7 @@ # # spec file for package nlopt # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: nlopt -Version: 2.7.0 +Version: 2.7.1 Release: 0 Summary: A library for nonlinear optimization License: LGPL-2.0-only ++++++ nlopt-2.7.0.tar.gz -> nlopt-2.7.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/.github/workflows/build.yml new/nlopt-2.7.1/.github/workflows/build.yml --- old/nlopt-2.7.0/.github/workflows/build.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/nlopt-2.7.1/.github/workflows/build.yml 2021-12-03 19:38:01.000000000 +0100 @@ -0,0 +1,44 @@ +name: Build +on: [push, pull_request] +jobs: + linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build + run: | + sudo apt-get install python3-dev python3-numpy guile-2.0-dev liboctave-dev cmake gfortran g++-mingw-w64-x86-64 gfortran-mingw-w64-x86-64 + pip install mkdocs python-markdown-math --user + PATH=$PATH:~/.local/bin mkdocs build + mkdir build && pushd build + cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-std=c89 -pedantic -D_POSIX_C_SOURCE=200809L -Wall -Wextra -Werror' -DCMAKE_CXX_FLAGS='-Wall -Wextra' .. + make install -j2 && ctest -j2 --output-on-failure + rm -rf * ~/.local + cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake .. + make install -j2 + + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Build + run: | + brew upgrade && brew install swig octave + mkdir build && pushd build + cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_FORTRAN=OFF -DNLOPT_GUILE=OFF .. + make install -j3 && ctest --output-on-failure + + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Build + shell: cmd + run: | + pip install numpy + cmake -DCMAKE_INSTALL_PREFIX=%cd:\=/%/install . + cmake --build . --config Release --target install + xcopy %cd%\install\bin\nlopt.dll %cd%\src\swig + xcopy %cd%\install\Lib\site-packages\_nlopt.pyd %cd%\src\swig + dir /p %cd%\src\swig + ctest -C Release --output-on-failure --timeout 100 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/.travis.yml new/nlopt-2.7.1/.travis.yml --- old/nlopt-2.7.0/.travis.yml 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,38 +0,0 @@ -language: cpp -sudo: false - -matrix: - include: - - os: linux - addons: - apt: - packages: - - swig - - python-dev - - python-numpy - - guile-2.0-dev - - liboctave-dev - - cmake - - gfortran - - binutils-mingw-w64-x86-64 - - g++-mingw-w64-x86-64 - - gfortran-mingw-w64-x86-64 - - script: - - pip install mkdocs python-markdown-math --user - - PATH=$PATH:~/.local/bin mkdocs build - - mkdir build && pushd build - - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-std=c89 -pedantic -D_POSIX_C_SOURCE=200112L -Wall -Wextra -Werror' -DCMAKE_CXX_FLAGS='-Wall -Wextra' .. - - make install -j2 && ctest -j2 --output-on-failure - - rm -rf * ~/.local - - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake .. - - make install -j2 - - - os: osx - install: - - brew update - - brew install swig octave guile || echo "nope" - script: - - mkdir build && pushd build - - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DPYTHON_EXECUTABLE=/usr/bin/python -DNLOPT_FORTRAN=ON .. - - make install && ctest --output-on-failure diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/CMakeLists.txt new/nlopt-2.7.1/CMakeLists.txt --- old/nlopt-2.7.0/CMakeLists.txt 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/CMakeLists.txt 2021-12-03 19:38:01.000000000 +0100 @@ -12,7 +12,7 @@ # Benoit Scherrer, 2010 CRL, Harvard Medical School # Copyright (c) 2008-2009 Children's Hospital Boston #============================================================================== -cmake_minimum_required (VERSION 2.8.11) +cmake_minimum_required (VERSION 3.2) if (NOT DEFINED CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") @@ -24,7 +24,7 @@ # version set (NLOPT_MAJOR_VERSION "2") set (NLOPT_MINOR_VERSION "7") -set (NLOPT_BUGFIX_VERSION "0") +set (NLOPT_BUGFIX_VERSION "1") set (NLOPT_VERSION_STRING ${NLOPT_MAJOR_VERSION}.${NLOPT_MINOR_VERSION}.${NLOPT_BUGFIX_VERSION}) message (STATUS "NLopt version ${NLOPT_VERSION_STRING}") @@ -32,7 +32,7 @@ # (it indicates ABI compatibility), but they are typically incremented together. set(SO_MAJOR 0) set(SO_MINOR 11) -set(SO_PATCH 0) +set(SO_PATCH 1) #============================================================================== list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) @@ -98,18 +98,10 @@ #============================================================================== # COMPILATION CHECKINGS and CONFIGURATION GENERATION #============================================================================== -check_include_file (dlfcn.h HAVE_DLFCN_H) check_include_file (getopt.h HAVE_GETOPT_H) check_include_file (unistd.h HAVE_UNISTD_H) -check_include_file (string.h HAVE_STRING_H) -check_include_file (strings.h HAVE_STRINGS_H) -check_include_file (inttypes.h HAVE_INTTYPES_H) -check_include_file (memory.h HAVE_MEMORY_H) -check_include_file (stdlib.h HAVE_STDLIB_H) check_include_file (stdint.h HAVE_STDINT_H) check_include_file (time.h HAVE_TIME_H) -check_include_file (sys/types.h HAVE_SYS_TYPES_H) -check_include_file (sys/stat.h HAVE_SYS_STAT_H) check_include_file (sys/time.h HAVE_SYS_TIME_H) if (HAVE_TIME_H AND HAVE_SYS_TIME_H) set (TIME_WITH_SYS_TIME TRUE) @@ -297,7 +289,7 @@ ARCHIVE DESTINATION ${RELATIVE_INSTALL_LIB_DIR} ) -if (MSVC AND BUILD_SHARED_LIBS AND NOT CMAKE_VERSION VERSION_LESS 3.1) +if (MSVC AND BUILD_SHARED_LIBS) install (FILES $<TARGET_PDB_FILE:${nlopt_lib}> DESTINATION ${RELATIVE_INSTALL_BIN_DIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT Debug) endif () @@ -309,16 +301,12 @@ find_package (NumPy) endif () -if (NOT DEFINED INSTALL_PYTHON_DIR AND PYTHONINTERP_FOUND) - execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE ) - - get_filename_component (_ABS_PYTHON_MODULE_PATH "${_ABS_PYTHON_MODULE_PATH}" ABSOLUTE) - file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} "${_ABS_PYTHON_MODULE_PATH}") - - set (INSTALL_PYTHON_DIR "${_REL_PYTHON_MODULE_PATH}") - +if (NOT DEFINED INSTALL_PYTHON_DIR) + if (WIN32) + set (INSTALL_PYTHON_DIR Lib/site-packages) + else () + set (INSTALL_PYTHON_DIR ${INSTALL_LIB_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages) + endif () endif () if (NLOPT_GUILE) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/NEWS.md new/nlopt-2.7.1/NEWS.md --- old/nlopt-2.7.0/NEWS.md 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/NEWS.md 2021-12-03 19:38:01.000000000 +0100 @@ -1,5 +1,12 @@ # NLopt Release Notes +## NLopt 2.7.1 + +3 December 2021 + +* Various minor bugfixes ([#268], [#409], [#420]) and build + improvements (support Octave 6.x, Guile 3.x, Cmake 3.2). + ## NLopt 2.7 18 November 2020 @@ -438,7 +445,7 @@ * Initial public release. -<!--- generated by julia/doc/NEWS-update.jl: --> +<!--- generated by script similar to julia/doc/NEWS-update.jl: --> [#12]: https://github.com/stevengj/nlopt/issues/12 [#13]: https://github.com/stevengj/nlopt/issues/13 [#21]: https://github.com/stevengj/nlopt/issues/21 @@ -455,12 +462,15 @@ [#257]: https://github.com/stevengj/nlopt/issues/257 [#258]: https://github.com/stevengj/nlopt/issues/258 [#261]: https://github.com/stevengj/nlopt/issues/261 +[#268]: https://github.com/stevengj/nlopt/issues/268 [#278]: https://github.com/stevengj/nlopt/issues/278 [#303]: https://github.com/stevengj/nlopt/issues/303 [#308]: https://github.com/stevengj/nlopt/issues/308 [#314]: https://github.com/stevengj/nlopt/issues/314 [#317]: https://github.com/stevengj/nlopt/issues/317 [#319]: https://github.com/stevengj/nlopt/issues/319 -[#319]: https://github.com/stevengj/nlopt/issues/355 -[#319]: https://github.com/stevengj/nlopt/issues/361 -[#319]: https://github.com/stevengj/nlopt/issues/365 +[#355]: https://github.com/stevengj/nlopt/issues/355 +[#361]: https://github.com/stevengj/nlopt/issues/361 +[#365]: https://github.com/stevengj/nlopt/issues/365 +[#409]: https://github.com/stevengj/nlopt/issues/409 +[#420]: https://github.com/stevengj/nlopt/issues/420 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/README.md new/nlopt-2.7.1/README.md --- old/nlopt-2.7.0/README.md 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/README.md 2021-12-03 19:38:01.000000000 +0100 @@ -1,6 +1,5 @@ [](http://nlopt.readthedocs.io/en/latest/) -[](https://travis-ci.org/stevengj/nlopt) -[](https://ci.appveyor.com/project/StevenGJohnson/nlopt) +[](https://github.com/stevengj/nlopt/actions/workflows/build.yml) NLopt is a library for nonlinear local and global optimization, for functions with and without gradient information. It is designed as @@ -14,7 +13,7 @@ NLopt is compiled and installed with the [CMake](https://cmake.org/) build system (see `CMakeLists.txt` file for available options): - git clone git://github.com/stevengj/nlopt + git clone https://github.com/stevengj/nlopt.git cd nlopt mkdir build cd build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/TODO new/nlopt-2.7.1/TODO --- old/nlopt-2.7.0/TODO 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/TODO 2021-12-03 19:38:01.000000000 +0100 @@ -9,3 +9,5 @@ own BFGS. Wrappers for GNU R, Java, Perl, Ocaml, C#, ... + +Updates from Jones, D.R., Martins, J.R.R.A., (2021) "The DIRECT algorithm: 25 years Later." J Glob Optim 79, 521???566. \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/appveyor.yml new/nlopt-2.7.1/appveyor.yml --- old/nlopt-2.7.0/appveyor.yml 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/appveyor.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,23 +0,0 @@ -version: 1.0.{build} -os: Visual Studio 2015 -clone_folder: C:\projects\nlopt -test: off -configuration: - - Release -branches: - only: - - master -environment: - matrix: - - CMAKE_PLATFORM: "Visual Studio 10 2010" - - CMAKE_PLATFORM: "Visual Studio 14 2015" - - CMAKE_PLATFORM: "Visual Studio 14 2015 Win64" -install: - - cinstall: python - #- choco install swig -build_script: - - echo Running cmake... - - cd c:\projects\nlopt - - cmake -G "%CMAKE_PLATFORM%" -DCMAKE_INSTALL_PREFIX="C:\projects\nlopt\install" . - - cmake --build . --config %Configuration% --target install - - ctest -C %Configuration% --output-on-failure --timeout 100 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/cmake/FindGuile.cmake new/nlopt-2.7.1/cmake/FindGuile.cmake --- old/nlopt-2.7.0/cmake/FindGuile.cmake 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/cmake/FindGuile.cmake 2021-12-03 19:38:01.000000000 +0100 @@ -18,6 +18,7 @@ # Macports for OSX puts things in /opt/local find_path (GUILE_INCLUDE_DIR libguile.h PATH_SUFFIXES + guile/3.0 guile/2.2 guile/2.0 guile/1.8 @@ -27,7 +28,7 @@ ) # Look for the library -find_library (GUILE_LIBRARY NAMES guile-2.2 guile-2.0 guile +find_library (GUILE_LIBRARY NAMES guile-3.0 guile-2.2 guile-2.0 guile HINTS /opt/local/lib ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/cmake/NLoptConfig.cmake.in new/nlopt-2.7.1/cmake/NLoptConfig.cmake.in --- old/nlopt-2.7.0/cmake/NLoptConfig.cmake.in 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/cmake/NLoptConfig.cmake.in 2021-12-03 19:38:01.000000000 +0100 @@ -1,9 +1,4 @@ -# defined since 2.8.3 -if (CMAKE_VERSION VERSION_LESS 2.8.3) - get_filename_component (CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -endif () - # Tell the user project where to find our headers and libraries set (NLOPT_VERSION "@NLOPT_VERSION_STRING@") @@ -23,6 +18,3 @@ # These are IMPORTED targets created by NLOPTLibraryDepends.cmake set (NLOPT_LIBRARIES "@NLOPT_LIBRARIES@") -if (CMAKE_VERSION VERSION_LESS 2.8.3) - set (CMAKE_CURRENT_LIST_DIR) -endif () diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/cmake/TargetLinkLibrariesWithDynamicLookup.cmake new/nlopt-2.7.1/cmake/TargetLinkLibrariesWithDynamicLookup.cmake --- old/nlopt-2.7.0/cmake/TargetLinkLibrariesWithDynamicLookup.cmake 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/cmake/TargetLinkLibrariesWithDynamicLookup.cmake 2021-12-03 19:38:01.000000000 +0100 @@ -58,7 +58,7 @@ int foo(void) {return bar()+1;} ") - if(APPLE AND ${CMAKE_VERSION} VERSION_GREATER 2.8.11) + if(APPLE) set( _rpath_arg "-DCMAKE_MACOSX_RPATH='${CMAKE_MACOSX_RPATH}'" ) else() set( _rpath_arg ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/cmake/generate-cpp.cmake new/nlopt-2.7.1/cmake/generate-cpp.cmake --- old/nlopt-2.7.0/cmake/generate-cpp.cmake 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/cmake/generate-cpp.cmake 2021-12-03 19:38:01.000000000 +0100 @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.11) +cmake_minimum_required (VERSION 3.2) # generate nlopt.hpp from nlopt-in.hpp file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/nlopt.hpp "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/cmake/generate-fortran.cmake new/nlopt-2.7.1/cmake/generate-fortran.cmake --- old/nlopt-2.7.0/cmake/generate-fortran.cmake 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/cmake/generate-fortran.cmake 2021-12-03 19:38:01.000000000 +0100 @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.11) +cmake_minimum_required (VERSION 3.2) # generate nlopt.f from nlopt.h enums file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/nlopt.f "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/doc/docs/NLopt_Algorithms.md new/nlopt-2.7.1/doc/docs/NLopt_Algorithms.md --- old/nlopt-2.7.0/doc/docs/NLopt_Algorithms.md 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/doc/docs/NLopt_Algorithms.md 2021-12-03 19:38:01.000000000 +0100 @@ -107,7 +107,7 @@ This is an algorithm adapted from the code downloaded from -- [StoGO global optimization library](http://www2.imm.dtu.dk/~km/GlobOpt/opt.html) (link broken as of Nov. 2009, and the software seems absent from the [author's web site](http://www2.imm.dtu.dk/~km/)) +- [StoGO global optimization library](http://www.imm.dtu.dk/projects/scicomp/GlobOpt/opt.html) by Madsen et al. StoGO is a global optimization algorithm that works by systematically dividing the search space (which must be bound-constrained) into smaller hyper-rectangles via a branch-and-bound technique, and searching them by a gradient-based local-search algorithm (a BFGS variant), optionally including some randomness (hence the "Sto", which stands for "stochastic" I believe). @@ -316,7 +316,7 @@ * `inner_maxeval`: If ??? 0, gives maximum number of "inner" iterations of the algorithm where it tries to ensure that its approximatations are "conservative"; defaults to `0` (no limit). It can be useful to specify a finite number (e.g. `5` or `10`) for this parameter if inaccuracies in your gradient or objective function are preventing the algorithm from making progress. * `dual_algorithm` (defaults to `NLOPT_LD_MMA`), `dual_ftol_rel` (defaults to `1e-14`), `dual_ftol_abs` (defaults to `0`), `dual_xtol_rel` (defaults to `0`), `dual_xtol_abs` (defaults to `0`), `dual_maxeval` (defaults to `100000`): These specify how the algorithm internally solves the "dual" optimization problem for its approximate objective. Because this subsidiary solve requires no evaluations of the user's objective function, it is typically fast enough that we can solve it to high precision without worrying too much about the details. Howeve,r in high-dimensional problems you may notice that MMA/CCSA is taking a long time between optimization steps, in which case you may want to increase `dual_ftol_rel` or make other changes. If these parameters are not specified, NLopt takes them from the [subsidiary-optimizer algorithm](NLopt_Reference#localsubsidiary-optimization-algorithm) if that has been specified, and otherwise uses the defaults indicated here. -* `verbosity`: If ??? 0, causes the algorithm to print internal status information on each iteration. +* `verbosity`: If > 0, causes the algorithm to print internal status information on each iteration. ### SLSQP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/doc/docs/NLopt_Introduction.md new/nlopt-2.7.1/doc/docs/NLopt_Introduction.md --- old/nlopt-2.7.0/doc/docs/NLopt_Introduction.md 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/doc/docs/NLopt_Introduction.md 2021-12-03 19:38:01.000000000 +0100 @@ -80,7 +80,7 @@ In *principle*, each equality constraint can be expressed by two inequality constraints $h_i(\mathbf{x}) \leq 0$ and $-h_i(\mathbf{x}) \leq 0$, so you might think that any code that can handle inequality constraints can automatically handle equality constraints. In practice, this is not true???if you try to express an equality constraint as a pair of nonlinear inequality constraints, some algorithms will fail to converge. -Equality constraints sometimes require special handling because they reduce the *dimensionality* of the feasible region, and not just its size as for an inequality constraint. Only some of the NLopt algorithms (AUGLAG, COBYLA, and ISRES) currently support nonlinear equality constraints. +Equality constraints sometimes require special handling because they reduce the *dimensionality* of the feasible region, and not just its size as for an inequality constraint. Only some of the NLopt algorithms (AUGLAG, SLSQP, COBYLA, and ISRES) currently support nonlinear equality constraints. #### Elimination diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/nlopt_config.h.in new/nlopt-2.7.1/nlopt_config.h.in --- old/nlopt-2.7.0/nlopt_config.h.in 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/nlopt_config.h.in 2021-12-03 19:38:01.000000000 +0100 @@ -28,9 +28,6 @@ /* Define if the copysign function/macro is available. */ #cmakedefine HAVE_COPYSIGN -/* Define to 1 if you have the <dlfcn.h> header file. */ -#cmakedefine HAVE_DLFCN_H - /* Define if the fpclassify() function/macro is available. */ #cmakedefine HAVE_FPCLASSIFY @@ -49,9 +46,6 @@ /* Define to 1 if you have the `gettimeofday' function. */ #cmakedefine HAVE_GETTIMEOFDAY -/* Define to 1 if you have the <inttypes.h> header file. */ -#cmakedefine HAVE_INTTYPES_H - /* Define if the isinf() function/macro is available. */ #cmakedefine HAVE_ISINF @@ -61,30 +55,12 @@ /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM -/* Define to 1 if you have the <memory.h> header file. */ -#cmakedefine HAVE_MEMORY_H - /* Define to 1 if you have the `qsort_r' function. */ #cmakedefine HAVE_QSORT_R /* Define to 1 if you have the <stdint.h> header file. */ #cmakedefine HAVE_STDINT_H -/* Define to 1 if you have the <stdlib.h> header file. */ -#cmakedefine HAVE_STDLIB_H - -/* Define to 1 if you have the <strings.h> header file. */ -#cmakedefine HAVE_STRINGS_H - -/* Define to 1 if you have the <string.h> header file. */ -#cmakedefine HAVE_STRING_H - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#cmakedefine HAVE_SYS_STAT_H - -/* Define to 1 if you have the <sys/types.h> header file. */ -#cmakedefine HAVE_SYS_TYPES_H - /* Define to 1 if you have the <sys/types.h> header file. */ #cmakedefine HAVE_SYS_TIME_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/ags/ags.cc new/nlopt-2.7.1/src/algs/ags/ags.cc --- old/nlopt-2.7.0/src/algs/ags/ags.cc 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/ags/ags.cc 2021-12-03 19:38:01.000000000 +0100 @@ -53,7 +53,7 @@ params.evolventDensity = evolvent_density; params.epsR = eps_res; params.stopVal = stop->minf_max; - params.refineSolution = (bool)ags_refine_loc; + params.refineSolution = static_cast<bool>(ags_refine_loc); ags::NLPSolver solver; solver.SetParameters(params); @@ -94,12 +94,12 @@ for (size_t i = 0; i < holderConstEstimations.size() - 1; i++) std::cout << "Estimation of Holder constant of function # " << i << ": " << holderConstEstimations[i] << "\n"; std::cout << "Estimation of Holder constant of objective: " << holderConstEstimations.back() << "\n"; - if (optPoint.idx != (int)m) + if (optPoint.idx != static_cast<int>(m)) std::cout << "Feasible point not found" << "\n"; std::cout << std::string(40, '-') << std::endl; } - if ((int)m == optPoint.idx) + if (static_cast<int>(m) == optPoint.idx) { memcpy(x, optPoint.y, n*sizeof(x[0])); *minf = optPoint.g[optPoint.idx]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/ags/evolvent.cc new/nlopt-2.7.1/src/algs/ags/evolvent.cc --- old/nlopt-2.7.0/src/algs/ags/evolvent.cc 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/ags/evolvent.cc 2021-12-03 19:38:01.000000000 +0100 @@ -112,7 +112,7 @@ } else { d = d*nexp; - is = (int)d; + is = static_cast<int>(d); d = d - is; } i = is; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/ags/solver.cc new/nlopt-2.7.1/src/algs/ags/solver.cc --- old/nlopt-2.7.0/src/algs/ags/solver.cc 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/ags/solver.cc 2021-12-03 19:38:01.000000000 +0100 @@ -191,7 +191,7 @@ for (size_t i = 1; i <= mParameters.numPoints; i++) { - mNextPoints[i - 1] = Trial((double)i / (mParameters.numPoints + 1)); + mNextPoints[i - 1] = Trial(static_cast<double>(i) / (mParameters.numPoints + 1)); mEvolvent.GetImage(mNextPoints[i - 1].x, mNextPoints[i - 1].y); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/bobyqa/bobyqa.c new/nlopt-2.7.1/src/algs/bobyqa/bobyqa.c --- old/nlopt-2.7.0/src/algs/bobyqa/bobyqa.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/bobyqa/bobyqa.c 2021-12-03 19:38:01.000000000 +0100 @@ -3123,9 +3123,11 @@ /* SGJ, 2009: compute rhoend from NLopt stop info */ rhoend = stop->xtol_rel * (rhobeg); - for (j = 0; j < n; ++j) - if (rhoend < stop->xtol_abs[j] / fabs(s[j])) - rhoend = stop->xtol_abs[j] / fabs(s[j]); + if (stop->xtol_abs) { + for (j = 0; j < n; ++j) + if (rhoend < stop->xtol_abs[j] / fabs(s[j])) + rhoend = stop->xtol_abs[j] / fabs(s[j]); + } /* This subroutine seeks the least value of a function of many variables, */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/cdirect/cdirect.c new/nlopt-2.7.1/src/algs/cdirect/cdirect.c --- old/nlopt-2.7.0/src/algs/cdirect/cdirect.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/cdirect/cdirect.c 2021-12-03 19:38:01.000000000 +0100 @@ -383,7 +383,7 @@ { int i; for (i = 0; i < p->n; ++i) - if (w[i] > p->stop->xtol_abs[i] && + if (w[i] > (p->stop->xtol_abs ? p->stop->xtol_abs[i] : 0) && w[i] > (p->ub[i] - p->lb[i]) * p->stop->xtol_rel) return 0; return 1; @@ -575,21 +575,24 @@ { cdirect_uf_data d; nlopt_result ret; - const double *xtol_abs_save; + const double *xtol_abs_save = NULL; int i; d.f = f; d.f_data = f_data; d.lb = lb; d.ub = ub; - d.x = (double *) malloc(sizeof(double) * n*4); + d.x = (double *) malloc(sizeof(double) * n * (stop->xtol_abs ? 4 : 3)); if (!d.x) return NLOPT_OUT_OF_MEMORY; for (i = 0; i < n; ++i) { x[i] = (x[i] - lb[i]) / (ub[i] - lb[i]); d.x[n+i] = 0; d.x[2*n+i] = 1; - d.x[3*n+i] = stop->xtol_abs[i] / (ub[i] - lb[i]); } - xtol_abs_save = stop->xtol_abs; - stop->xtol_abs = d.x + 3*n; + if (stop->xtol_abs) { + for (i = 0; i < n; ++i) + d.x[3*n+i] = stop->xtol_abs[i] / (ub[i] - lb[i]); + xtol_abs_save = stop->xtol_abs; + stop->xtol_abs = d.x + 3*n; + } ret = cdirect_unscaled(n, cdirect_uf, &d, d.x+n, d.x+2*n, x, minf, stop, magic_eps, which_alg); stop->xtol_abs = xtol_abs_save; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/cdirect/hybrid.c new/nlopt-2.7.1/src/algs/cdirect/hybrid.c --- old/nlopt-2.7.0/src/algs/cdirect/hybrid.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/cdirect/hybrid.c 2021-12-03 19:38:01.000000000 +0100 @@ -152,7 +152,7 @@ /* check xtol */ for (i = 0; i < n; ++i) if (w[i] > p->stop->xtol_rel * (ub[i] - lb[i]) - && w[i] > p->stop->xtol_abs[i]) + && w[i] > (p->stop->xtol_abs ? p->stop->xtol_abs[i] : 0)) break; if (i == n) return NLOPT_XTOL_REACHED; @@ -316,21 +316,24 @@ { cdirect_uf_data d; nlopt_result ret; - const double *xtol_abs_save; + const double *xtol_abs_save = NULL; int i; d.f = f; d.f_data = f_data; d.lb = lb; d.ub = ub; - d.x = (double *) malloc(sizeof(double) * n*4); + d.x = (double *) malloc(sizeof(double) * n * (stop->xtol_abs ? 4 : 3)); if (!d.x) return NLOPT_OUT_OF_MEMORY; for (i = 0; i < n; ++i) { x[i] = (x[i] - lb[i]) / (ub[i] - lb[i]); d.x[n+i] = 0; d.x[2*n+i] = 1; - d.x[3*n+i] = stop->xtol_abs[i] / (ub[i] - lb[i]); } - xtol_abs_save = stop->xtol_abs; - stop->xtol_abs = d.x + 3*n; + if (stop->xtol_abs) { + for (i = 0; i < n; ++i) + d.x[3*n+i] = stop->xtol_abs[i] / (ub[i] - lb[i]); + xtol_abs_save = stop->xtol_abs; + stop->xtol_abs = d.x + 3*n; + } ret = cdirect_hybrid_unscaled(n, cdirect_uf, &d, d.x+n, d.x+2*n, x, minf, stop, local_alg, local_maxeval, randomized_div); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/cobyla/cobyla.c new/nlopt-2.7.1/src/algs/cobyla/cobyla.c --- old/nlopt-2.7.0/src/algs/cobyla/cobyla.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/cobyla/cobyla.c 2021-12-03 19:38:01.000000000 +0100 @@ -219,9 +219,10 @@ /* SGJ, 2008: compute rhoend from NLopt stop info */ rhobeg = fabs(dx[0] / s.scale[0]); rhoend = stop->xtol_rel * (rhobeg); - for (j = 0; j < n; ++j) - if (rhoend < stop->xtol_abs[j] / fabs(s.scale[j])) - rhoend = stop->xtol_abs[j] / fabs(s.scale[j]); + if (stop->xtol_abs) + for (j = 0; j < n; ++j) + if (rhoend < stop->xtol_abs[j] / fabs(s.scale[j])) + rhoend = stop->xtol_abs[j] / fabs(s.scale[j]); /* each equality constraint gives two inequality constraints */ m = nlopt_count_constraints(m, fc) + 2 * nlopt_count_constraints(p, h); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/neldermead/sbplx.c new/nlopt-2.7.1/src/algs/neldermead/sbplx.c --- old/nlopt-2.7.0/src/algs/neldermead/sbplx.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/neldermead/sbplx.c 2021-12-03 19:38:01.000000000 +0100 @@ -195,7 +195,7 @@ the step size is too large (in early iterations), the inner Nelder-Mead may not make much progress */ for (j = 0; j < n; ++j) - if (fabs(xstep[j]) * psi > stop->xtol_abs[j] + if (fabs(xstep[j]) * psi > (stop->xtol_abs ? stop->xtol_abs[j] : 0) && fabs(xstep[j]) * psi > stop->xtol_rel * fabs(x[j])) break; if (j == n) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/newuoa/newuoa.c new/nlopt-2.7.1/src/algs/newuoa/newuoa.c --- old/nlopt-2.7.0/src/algs/newuoa/newuoa.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/newuoa/newuoa.c 2021-12-03 19:38:01.000000000 +0100 @@ -1626,9 +1626,10 @@ /* SGJ, 2008: compute rhoend from NLopt stop info */ rhoend = stop->xtol_rel * (*rhobeg); - for (j = 0; j < *n; ++j) - if (rhoend < stop->xtol_abs[j]) - rhoend = stop->xtol_abs[j]; + if (stop->xtol_abs) + for (j = 0; j < *n; ++j) + if (rhoend < stop->xtol_abs[j]) + rhoend = stop->xtol_abs[j]; /* The arguments N, NPT, X, RHOBEG, RHOEND, IPRINT and MAXFUN are identical */ /* to the corresponding arguments in SUBROUTINE NEWUOA. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/praxis/praxis.c new/nlopt-2.7.1/src/algs/praxis/praxis.c --- old/nlopt-2.7.0/src/algs/praxis/praxis.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/praxis/praxis.c 2021-12-03 19:38:01.000000000 +0100 @@ -189,7 +189,8 @@ t_old = small + t0; else { t_old = 0; - for (i__ = 0; i__ < n; ++i__) + if (stop->xtol_abs) + for (i__ = 0; i__ < n; ++i__) if (stop->xtol_abs[i__] > t_old) t_old = stop->xtol_abs[i__]; t_old += small; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/slsqp/slsqp.c new/nlopt-2.7.1/src/algs/slsqp/slsqp.c --- old/nlopt-2.7.0/src/algs/slsqp/slsqp.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/slsqp/slsqp.c 2021-12-03 19:38:01.000000000 +0100 @@ -76,7 +76,7 @@ static double ddot_sl__(int *n_, double *dx, int incx, double *dy, int incy) { int n = *n_, i; - long double sum = 0; + double sum = 0; if (n <= 0) return 0; for (i = 0; i < n; ++i) sum += dx[i*incx] * dy[i*incy]; return (double) sum; @@ -87,7 +87,7 @@ { int i, n = *n_; double xmax = 0, scale; - long double sum = 0; + double sum = 0; for (i = 0; i < n; ++i) { double xabs = fabs(dx[incx*i]); if (xmax < xabs) xmax = xabs; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/stogo/stogo.cc new/nlopt-2.7.1/src/algs/stogo/stogo.cc --- old/nlopt-2.7.0/src/algs/stogo/stogo.cc 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/stogo/stogo.cc 2021-12-03 19:38:01.000000000 +0100 @@ -18,9 +18,9 @@ switch (which) { case GRADIENT_ONLY: case OBJECTIVE_AND_GRADIENT: - return my_func((unsigned) xy.GetLength(), xy.raw_data_const(), grad.raw_data(), my_data); + return my_func(static_cast<unsigned>(xy.GetLength()), xy.raw_data_const(), grad.raw_data(), my_data); case OBJECTIVE_ONLY: - return my_func((unsigned) xy.GetLength(), xy.raw_data_const(), NULL, my_data); + return my_func(static_cast<unsigned>(xy.GetLength()), xy.raw_data_const(), NULL, my_data); } return 0.0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/algs/stogo/tools.cc new/nlopt-2.7.1/src/algs/stogo/tools.cc --- old/nlopt-2.7.0/src/algs/stogo/tools.cc 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/algs/stogo/tools.cc 2021-12-03 19:38:01.000000000 +0100 @@ -192,7 +192,7 @@ center=0; dispers=0; for ( itr = TList.begin(); itr != TList.end(); ++itr ) axpy(1.0, (*itr).xvals, center); - scal((double)(1.0/ns),center); + scal((1.0/ns),center); // Compute the relative deviations for ( itr = TList.begin(); itr != TList.end(); ++itr ) { @@ -201,7 +201,7 @@ dispers(k)=dispers(k)+pow(center(k)-x(k),2.0); } } - scal((double)(1.0/ns),dispers); + scal((1.0/ns),dispers); // i=arg max(disp) tmp=dispers(0);i=0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/api/general.c new/nlopt-2.7.1/src/api/general.c --- old/nlopt-2.7.0/src/api/general.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/api/general.c 2021-12-03 19:38:01.000000000 +0100 @@ -185,9 +185,8 @@ case NLOPT_XTOL_REACHED: return "XTOL_REACHED"; case NLOPT_MAXEVAL_REACHED: return "MAXEVAL_REACHED"; case NLOPT_MAXTIME_REACHED: return "MAXTIME_REACHED"; - case NLOPT_NUM_RESULTS: return NULL; + default: return NULL; } - return NULL; } @@ -196,9 +195,10 @@ int i; if (name == NULL) return -1; - for (i = 0; i < NLOPT_NUM_RESULTS; ++i) - { - if (strcmp(name, nlopt_result_to_string(i)) == 0) + /* Check all valid negative (failure) and positive (success) result codes */ + for (i = NLOPT_NUM_FAILURES + 1; i < NLOPT_NUM_RESULTS; ++i) { + const char *name_i = nlopt_result_to_string(i); + if (name_i != NULL && strcmp(name, name_i) == 0) return i; } return -1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/api/nlopt.h new/nlopt-2.7.1/src/api/nlopt.h --- old/nlopt-2.7.0/src/api/nlopt.h 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/api/nlopt.h 2021-12-03 19:38:01.000000000 +0100 @@ -165,13 +165,14 @@ NLOPT_OUT_OF_MEMORY = -3, NLOPT_ROUNDOFF_LIMITED = -4, NLOPT_FORCED_STOP = -5, + NLOPT_NUM_FAILURES = -6, /* not a result, just the number of possible failures */ NLOPT_SUCCESS = 1, /* generic success code */ NLOPT_STOPVAL_REACHED = 2, NLOPT_FTOL_REACHED = 3, NLOPT_XTOL_REACHED = 4, NLOPT_MAXEVAL_REACHED = 5, NLOPT_MAXTIME_REACHED = 6, - NLOPT_NUM_RESULTS /* not a result, just the number of them */ + NLOPT_NUM_RESULTS /* not a result, just the number of possible successes */ } nlopt_result; /* nlopt_result enum <-> string conversion */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/api/optimize.c new/nlopt-2.7.1/src/api/optimize.c --- old/nlopt-2.7.0/src/api/optimize.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/api/optimize.c 2021-12-03 19:38:01.000000000 +0100 @@ -622,7 +622,7 @@ } if (opt->dx) nlopt_set_initial_step(local_opt, opt->dx); - for (i = 0; i < n && stop.xtol_abs[i] > 0; ++i); + for (i = 0; i < n && stop.xtol_abs && stop.xtol_abs[i] > 0; ++i); if (local_opt->ftol_rel <= 0 && local_opt->ftol_abs <= 0 && local_opt->xtol_rel <= 0 && i < n) { /* it is not sensible to call MLSL without *some* nonzero tolerance for the local search */ @@ -863,6 +863,8 @@ ret = nlopt_optimize_(elim_opt, x, opt_f); if (elim_opt != opt) { + opt->numevals = elim_opt->numevals; + opt->errmsg = elim_opt->errmsg; elim_opt->errmsg = NULL; elimdim_destroy(elim_opt); elimdim_expand(opt->n, x, opt->lb, opt->ub); opt->force_stop_child = NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/api/options.c new/nlopt-2.7.1/src/api/options.c --- old/nlopt-2.7.0/src/api/options.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/api/options.c 2021-12-03 19:38:01.000000000 +0100 @@ -116,12 +116,8 @@ opt->ub = (double *) calloc(n, sizeof(double)); if (!opt->ub) goto oom; - opt->xtol_abs = (double *) calloc(n, sizeof(double)); - if (!opt->xtol_abs) - goto oom; nlopt_set_lower_bounds1(opt, -HUGE_VAL); nlopt_set_upper_bounds1(opt, +HUGE_VAL); - nlopt_set_xtol_abs1(opt, 0.0); } } @@ -163,9 +159,11 @@ nopt->ub = (double *) malloc(sizeof(double) * (opt->n)); if (!opt->ub) goto oom; - nopt->xtol_abs = (double *) malloc(sizeof(double) * (opt->n)); - if (!opt->xtol_abs) - goto oom; + if (opt->xtol_abs) { + nopt->xtol_abs = (double *) malloc(sizeof(double) * (opt->n)); + if (!opt->xtol_abs) + goto oom; + } if (opt->x_weights) { nopt->x_weights = (double *) malloc(sizeof(double) * (opt->n)); if (!opt->x_weights) @@ -175,7 +173,9 @@ memcpy(nopt->lb, opt->lb, sizeof(double) * (opt->n)); memcpy(nopt->ub, opt->ub, sizeof(double) * (opt->n)); - memcpy(nopt->xtol_abs, opt->xtol_abs, sizeof(double) * (opt->n)); + if (opt->xtol_abs) { + memcpy(nopt->xtol_abs, opt->xtol_abs, sizeof(double) * (opt->n)); + } } if (opt->m) { @@ -691,6 +691,10 @@ { if (opt) { nlopt_unset_errmsg(opt); + if (!opt->xtol_abs && opt->n > 0) { + opt->xtol_abs = (double *) calloc(opt->n, sizeof(double)); + if (!opt->xtol_abs) return NLOPT_OUT_OF_MEMORY; + } memcpy(opt->xtol_abs, xtol_abs, opt->n * sizeof(double)); return NLOPT_SUCCESS; } @@ -702,6 +706,10 @@ if (opt) { unsigned i; nlopt_unset_errmsg(opt); + if (!opt->xtol_abs && opt->n > 0) { + opt->xtol_abs = (double *) calloc(opt->n, sizeof(double)); + if (!opt->xtol_abs) return NLOPT_OUT_OF_MEMORY; + } for (i = 0; i < opt->n; ++i) opt->xtol_abs[i] = xtol_abs; return NLOPT_SUCCESS; @@ -713,7 +721,13 @@ { nlopt_unset_errmsg(opt); if (opt && (opt->n == 0 || xtol_abs)) { - memcpy(xtol_abs, opt->xtol_abs, opt->n * sizeof(double)); + if (opt->xtol_abs) { + memcpy(xtol_abs, opt->xtol_abs, sizeof(double) * (opt->n)); + } else { + unsigned i; + for (i = 0; i < opt->n; ++i) + xtol_abs[i] = 0; + } return NLOPT_SUCCESS; } return NLOPT_INVALID_ARGS; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/octave/nlopt_optimize-oct.cc new/nlopt-2.7.1/src/octave/nlopt_optimize-oct.cc --- old/nlopt-2.7.0/src/octave/nlopt_optimize-oct.cc 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/octave/nlopt_optimize-oct.cc 2021-12-03 19:38:01.000000000 +0100 @@ -80,7 +80,7 @@ } typedef struct { - octave_function *f; + octave_value f; int neval, verbose; nlopt_opt opt; } user_function_data; @@ -89,7 +89,7 @@ double *gradient, /* NULL if not needed */ void *data_) { - user_function_data *data = (user_function_data *) data_; + user_function_data *data = static_cast<user_function_data *>(data_); octave_value_list args(1, 0); Matrix xm(1,n); for (unsigned i = 0; i < n; ++i) @@ -99,7 +99,7 @@ #if OCTAVE_MAJOR_VERSION > 4 || (OCTAVE_MAJOR_VERSION == 4 && OCTAVE_MINOR_VERSION > 2) = octave::feval(data->f, args, gradient ? 2 : 1); #else - = data->f->do_multi_index_op(gradient ? 2 : 1, args); + = data->f.do_multi_index_op(gradient ? 2 : 1, args); #endif if (res.length() < (gradient ? 2 : 1)) err_user_supplied_eval("nlopt_optimize"); @@ -131,7 +131,7 @@ double *gradient, /* NULL if not needed */ void *data_) { - octave_function *f = (octave_function *) data_; + octave_value* f = static_cast<octave_value*>(data_); octave_value_list args(1, 0); Matrix xm(1,n); for (unsigned i = 0; i < n; ++i) @@ -139,7 +139,7 @@ args(0) = xm; octave_value_list res #if OCTAVE_MAJOR_VERSION > 4 || (OCTAVE_MAJOR_VERSION == 4 && OCTAVE_MINOR_VERSION > 2) - = octave::feval(f, args, gradient ? 2 : 1); + = octave::feval(*f, args, gradient ? 2 : 1); #else = f->do_multi_index_op(gradient ? 2 : 1, args); #endif @@ -265,23 +265,25 @@ CHECK(opts.contents("min_objective").numel() == 1 && (opts.contents("min_objective"))(0).is_function_handle(), "opt.min_objective must be a function"); - d.f = (opts.contents("min_objective"))(0).function_value(); + d.f = (opts.contents("min_objective"))(0); nlopt_set_min_objective(opt, user_function, &d); } else if (opts.contains("max_objective")) { CHECK(opts.contents("max_objective").numel() == 1 && (opts.contents("max_objective"))(0).is_function_handle(), "opt.max_objective must be a function"); - d.f = (opts.contents("max_objective"))(0).function_value(); + d.f = (opts.contents("max_objective"))(0); nlopt_set_max_objective(opt, user_function, &d); } else { CHECK(0,"either opt.min_objective or opt.max_objective must exist"); } + Cell fc, h; + if (opts.contains("fc") && opts.contents("fc").numel() == 1) { CHECK((opts.contents("fc"))(0).iscell(), "opt.fc must be cell array"); - Cell fc = (opts.contents("fc"))(0).cell_value(); + fc = (opts.contents("fc"))(0).cell_value(); Matrix zeros(1, fc.numel(), 0.0); Matrix fc_tol = struct_val_default(opts, "fc_tol", zeros); CHECK(fc_tol.numel() == fc.numel(), @@ -290,7 +292,7 @@ CHECK(fc(i).is_function() || fc(i).is_function_handle(), "opt.fc must be a cell array of function handles"); CHECK(nlopt_add_inequality_constraint(opt, user_function1, - fc(i).function_value(), + &fc(i), fc_tol(i)) > 0, "nlopt error adding inequality constraint"); } @@ -298,7 +300,7 @@ if (opts.contains("h") && opts.contents("h").numel() == 1) { CHECK((opts.contents("h"))(0).iscell(), "opt.h must be cell array"); - Cell h = (opts.contents("h"))(0).cell_value(); + h = (opts.contents("h"))(0).cell_value(); Matrix zeros(1, h.numel(), 0.0); Matrix h_tol = struct_val_default(opts, "h_tol", zeros); CHECK(h_tol.numel() == h.numel(), @@ -307,7 +309,7 @@ CHECK(h(i).is_function() || h(i).is_function_handle(), "opt.h must be a cell array of function handles"); CHECK(nlopt_add_equality_constraint(opt, user_function1, - h(i).function_value(), + &h(i), h_tol(i)) > 0, "nlopt error adding equality constraint"); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/src/util/stop.c new/nlopt-2.7.1/src/util/stop.c --- old/nlopt-2.7.0/src/util/stop.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/src/util/stop.c 2021-12-03 19:38:01.000000000 +0100 @@ -100,6 +100,7 @@ unsigned i; if (diff_norm(s->n, x, oldx, s->x_weights, NULL, NULL) < s->xtol_rel * vector_norm(s->n, x, s->x_weights, NULL, NULL)) return 1; + if (!s->xtol_abs) return 0; for (i = 0; i < s->n; ++i) if (fabs(x[i] - oldx[i]) >= s->xtol_abs[i]) return 0; @@ -111,6 +112,7 @@ unsigned i; if (vector_norm(s->n, dx, s->x_weights, NULL, NULL) < s->xtol_rel * vector_norm(s->n, x, s->x_weights, NULL, NULL)) return 1; + if (!s->xtol_abs) return 0; for (i = 0; i < s->n; ++i) if (fabs(dx[i]) >= s->xtol_abs[i]) return 0; @@ -124,6 +126,7 @@ unsigned i; if (diff_norm(s->n, xs, oldxs, s->x_weights, scale_min, scale_max) < s->xtol_rel * vector_norm(s->n, xs, s->x_weights, scale_min, scale_max)) return 1; + if (!s->xtol_abs) return 0; for (i = 0; i < s->n; ++i) if (fabs(sc(xs[i], scale_min[i], scale_max[i]) - sc(oldxs[i], scale_min[i], scale_max[i])) >= s->xtol_abs[i]) return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/test/t_tutorial.cxx new/nlopt-2.7.1/test/t_tutorial.cxx --- old/nlopt-2.7.0/test/t_tutorial.cxx 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/test/t_tutorial.cxx 2021-12-03 19:38:01.000000000 +0100 @@ -5,8 +5,9 @@ #include <iomanip> #include <nlopt.hpp> -double myvfunc(const std::vector<double> &x, std::vector<double> &grad, void *my_func_data) +double myvfunc(const std::vector<double> &x, std::vector<double> &grad, void *data) { + (void)data; if (!grad.empty()) { grad[0] = 0.0; grad[1] = 0.5 / sqrt(x[1]); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nlopt-2.7.0/test/testopt.c new/nlopt-2.7.1/test/testopt.c --- old/nlopt-2.7.0/test/testopt.c 2020-11-19 03:21:56.000000000 +0100 +++ new/nlopt-2.7.1/test/testopt.c 2021-12-03 19:38:01.000000000 +0100 @@ -321,7 +321,7 @@ feenableexcept(FE_INVALID); #endif - while ((c = getopt(argc, argv, "hLvCc0:r:a:o:i:e:t:x:X:f:F:m:b:")) != -1) + while ((c = getopt(argc, argv, "hLvVCc0:r:a:o:i:e:t:x:X:f:F:m:b:")) != -1) switch (c) { case 'h': usage(stdout); @@ -333,6 +333,12 @@ case 'v': testfuncs_verbose = 1; break; + case 'V': { + int major, minor, patch; + nlopt_version(&major, &minor, &patch); + printf("NLopt version %d.%d.%d\n", major, minor, patch); + return EXIT_SUCCESS; + } case 'C': force_constraints = 1; break;
