Skip to content
代码片段 群组 项目
该项目从 https://github.com/stevengj/nlopt.git 镜像。 拉取镜像更新于
  1. 3月 14, 2025
  2. 3月 03, 2025
  3. 2月 25, 2025
    • Kevin Kofler's avatar
      slsqp: check ptot>n, not p>n · f61115ad
      Kevin Kofler 创作于
      src/algs/slsqp/slsqp.c (src/algs/slsqp/slsqp.c): Fix the check for more
      equality constraints than variables (introduced by PR #593 to fix #592)
      so that vector constraints (mconstraints) are correctly counted: the
      count to consider here is ptot (the total number of scalar equality
      constraints), not p (the number of equality constraints that may be
      vector constraints).
      f61115ad
  4. 2月 24, 2025
  5. 2月 20, 2025
  6. 2月 18, 2025
  7. 2月 12, 2025
  8. 2月 05, 2025
  9. 2月 04, 2025
  10. 1月 27, 2025
  11. 1月 23, 2025
    • Julien Schueller's avatar
      Update NEWS · ebf4ce6d
      Julien Schueller 创作于
      ebf4ce6d
    • Julien Schueller's avatar
      CMake: Add Python SABI option · d8895c04
      Julien Schueller 创作于
      d8895c04
    • Kevin Kofler's avatar
      C++: Allow disabling exceptions in opt::optimize · 7d870603
      Kevin Kofler 创作于
      * C++: Allow disabling exceptions in opt::optimize.
      
      Call opt.set_exceptions_enabled(false) before opt.optimize to avoid
      throwing an exception. The caller is then responsible for checking the
      returned result or opt.last_result(). The advantage is that, for the
      SWIG-friendly overload, the returned best point (which can be quite good
      in, e.g., the roundoff_limited case) is not lost (but then the caller
      MUST check opt.last_result() to know whether anything has gone wrong).
      The default is exceptions_enabled=true, so by default, nothing changes.
      
      src/api/nlopt-in.hpp (opt::exceptions_enabled): New private member
      variable.
      (opt::opt (all overloads)): Initialize it (default it to true, copy it
      in the copy constructor).
      (opt::operator=): Copy it.
      (opt::optimize): Only call mythrow if exceptions_enabled.
      (get_exceptions_enabled): New public inline getter.
      (set_exceptions_enabled): New public inline setter.
      
      * Document set_exceptions_enabled and get_exceptions_enabled
      
      doc/docs/NLopt_C-plus-plus_Reference.md,
      doc/docs/NLopt_Guile_Reference.md,
      doc/docs/NLopt_Python_Reference.md (Performing the optimization): Add
      "by default" wording to the claim that `optimize()` throws an exception
      for negative return codes. (The sentence already links to the
      "Exceptions" section that has the details.)
      (Exceptions): Document nlopt::opt::set_exceptions_enabled and
      nlopt::opt::get_exceptions_enabled, and adapt the remainder of the
      section to mention their impact where appropriate.
      
      * Java: Document setExceptionsEnabled and getExceptionsEnabled
      
      doc/docs/NLopt_Java_Reference.md (Performing the optimization): Add
      "by default" wording to the claim that `optimize()` throws an exception
      for negative return codes. (The sentence already links to the
      "Exceptions" section that has the details.)
      (Exceptions): Document nlopt.Opt.setExceptionsEnabled and
      nlopt.Opt.getExceptionsEnabled, and adapt the remainder of the section
      to mention their impact where appropriate.
      
      * Testing: Add test for set_exceptions_enabled
      
      test/t_java.java: Tests exception handling. This tests a test case known
      to fail (t_bounded.cxx on LD_SLSQP) with set_exceptions_enabled set to
      true if the argument is 1, false if the argument is 0, and verifies that
      the exception is thrown resp. not thrown, as expected.
      
      test/CMakeLists.txt: Add the C++ test t_except with the instances 1
      (true = exceptions enabled) and 0 (false = exceptions disabled). Both
      instances pass.
      7d870603
    • Kevin Kofler's avatar
      Add Java binding using the existing SWIG infrastructure · c87f91c5
      Kevin Kofler 创作于
      CMakeLists.txt: Add NLOPT_JAVA option. If set, check for C++, JNI, and
      Java (>= 1.5, because of varargs and enums).
      
      src/swig/nlopt-java.i: New SWIG input file (not standalone, but to be
      included into nlopt.i). Contains the Java-specific declarations.
      
      src/swig/nlopt.i: Add syntax highlighting declaration for KatePart-based
      editors. Call the module NLopt instead of nlopt for SWIGJAVA, because in
      Java, this is the name of the globals class (not the package, which is
      set separately on the SWIG command line), so it should be in CamelCase.
      Instantiate vector<double> as DoubleVector instead of nlopt_doublevector
      for SWIGJAVA, because everything is in an nlopt package in Java, so the
      nlopt_ part is redundant, and because it should be in CamelCase. Ignore
      nlopt_get_initial_step because at least for Java, SWIG wants to generate
      a binding for it, using SWIGTYPE_p_* types that cannot be practically
      used. (It is in-place just like nlopt::opt::get_initial_step, which is
      already ignored.) Rename nlopt::opt::get_initial_step_ to the
      lowerCamelCase getInitialStep instead of get_initial_step. For SWIGJAVA,
      %include nlopt-java.i.
      
      src/swig/CMakeLists.txt: Set UseSWIG_MODULE_VERSION to 2 so that UseSWIG
      cleans up old generated source files before running SWIG, useful for
      Java. (In particular, it prevents obsolete .java files from old .i file
      versions, which might not even compile anymore, from being included in
      the Java compilation and the JAR.) Update the path handling for the
      Python and Guile bindings accordingly. If JNI, Java, and SWIG were
      found, generate the Java binding with SWIG, and compile the JNI library
      with the C++ compiler and the Java JAR with the Java compiler. For the
      Guile binding, set and unset CMAKE_SWIG_FLAGS instead of using
      set_source_files_properties on nlopt.i, because nlopt.i is shared for
      all bindings, so setting the property on the source file does not help
      preventing breaking other target language bindings (such as Java). Also
      replace the deprecated swig_link_libraries with target_link_libraries.
      
      src/swig/glob_java.cmake: New helper script whose main purpose is to
      invoke the CMake file(GLOB ...) command at the correct stage of the
      build process, after the SWIG run, not when CMake is run on the main
      CMakeLists.txt, because the latter happens before anything at all is
      built. The script is invoked through cmake -P by an add_custom_command
      in CMakeLists.txt, whose dependencies order it to the correct spot of
      the build. This is the only portable way to automatically determine
      which *.java files SWIG has generated from the *.i files. The result
      is written to java_sources.txt, which is dynamically read by the add_jar
      command thanks to the @ indirection. In addition, it also does a
      replacement in DoubleVector.java, changing double[] initialElements to
      double... initialElements (introduced in Java 1.5), which needs to
      happen at the same stage of the build, so that initial elements can be
      passed directly to new DoubleVector without extra new double[]{
      boilerplate.
      
      test/t_java.java: New test. Java port of t_tutorial.cxx/t_python.py.
      
      test/CMakeLists.txt: If JNI, Java >= 1.8, and SWIG were found, run the
      t_java test program with the algorithms 23 (MMA), 24 (COBYLA), 30
      (augmented Lagrangian), and 39 (SLSQP). All 4 tests pass. (Java < 1.8
      should be supported by the binding itself, but not by the test.) Update
      the PYINSTALLCHECK_ENVIRONMENT settings for the src/swig/CMakeLists.txt
      changes, so that the Python tests keep passing. Update the
      GUILE_LOAD_PATH settings for the src/swig/CMakeLists.txt changes, so
      that the Guile tests keep passing.
      
      This code is mostly unrelated to the old unmaintained nlopt4j binding
      (https://github.com/dibyendumajumdar/nlopt4j), which used handwritten
      JNI code. Instead, it reuses the existing SWIG binding infrastructure,
      adding Java as a supported language to that. Only the code in the
      func_java and mfunc_java wrappers is loosely inspired by the nlopt4j
      code. The rest of the code in this binding relies mostly on SWIG
      features and uses very little handwritten JNI code, so nlopt4j was not
      useful as a reference for it. This binding is also
      backwards-incompatible with nlopt4j due to differing naming conventions.
      
      Note that this binding maps the C++ class and method names identically
      to Java. As a result, it does not use idiomatic Java case conventions,
      but uses snake_case for both class and method names instead of the usual
      UpperCamelCase for class names and lowerCamelCase for method names in
      Java. The C++ namespace nlopt is mapped to the Java package nlopt.
      
      doc/docs/NLopt_Java_Reference.md: New file, based on
      NLopt_Python_Reference.md and NLopt_Guile_Reference.md, adapted to the
      Java syntax.
      
      doc/docs/NLopt_Tutorial.md: Add example in Java.
      
      doc/docs/index.md: Mention Java, linking to NLopt_Java_Reference.md.
      
      README.md: Add Java. (The link will become valid after the commit makes
      it into master and the documentation on readthedocs is regenerated.)
      c87f91c5
  12. 12月 31, 2024
    • Jeremy Nimmer's avatar
      Remove unncessary <iostream> includes (#582) · 9128062c
      Jeremy Nimmer 创作于
      Including iostream means introducing the static (global) constructors
      and destructors for std::cin, std::cerr, and std::cout. That extra
      init and fini code is undesirable when those streams are not actually
      used.
      9128062c
  13. 12月 21, 2024
  14. 12月 16, 2024
  15. 12月 15, 2024
  16. 12月 04, 2024
  17. 12月 03, 2024
  18. 11月 25, 2024
  19. 11月 14, 2024
  20. 11月 12, 2024
  21. 11月 11, 2024
  22. 11月 10, 2024