Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebuild for nlopt 2.9 #112

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci_support/linux_64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ libboost_devel:
libode:
- 0.16.5
nlopt:
- '2.8'
- '2.9'
numpy:
- '1.22'
- '1.23'
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/linux_aarch64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ libboost_devel:
libode:
- 0.16.5
nlopt:
- '2.8'
- '2.9'
numpy:
- '1.22'
- '1.23'
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/linux_ppc64le_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ libboost_devel:
libode:
- 0.16.5
nlopt:
- '2.8'
- '2.9'
numpy:
- '1.22'
- '1.23'
Expand Down
8 changes: 8 additions & 0 deletions .ci_support/migrations/nlopt29.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__migrator:
build_number: 1
commit_message: Rebuild for nlopt 2.9
kind: version
migration_number: 1
migrator_ts: 1731419846.1841683
nlopt:
- '2.9'
2 changes: 1 addition & 1 deletion .ci_support/osx_64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ libode:
macos_machine:
- x86_64-apple-darwin13.4.0
nlopt:
- '2.8'
- '2.9'
numpy:
- '1.22'
- '1.23'
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/osx_arm64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ libode:
macos_machine:
- arm64-apple-darwin20.0.0
nlopt:
- '2.8'
- '2.9'
numpy:
- '1.22'
- '1.23'
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/win_64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ libboost_devel:
libode:
- 0.16.5
nlopt:
- '2.8'
- '2.9'
numpy:
- '1.22'
- '1.23'
Expand Down
4 changes: 2 additions & 2 deletions .scripts/run_win_build.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

139 changes: 139 additions & 0 deletions recipe/002-pr-1874.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
diff --git a/dart/optimizer/nlopt/CMakeLists.txt b/dart/optimizer/nlopt/CMakeLists.txt
index 27b93321d4be0..16130f44aca5b 100644
--- a/dart/optimizer/nlopt/CMakeLists.txt
+++ b/dart/optimizer/nlopt/CMakeLists.txt
@@ -2,6 +2,26 @@
dart_find_package(NLOPT)
dart_check_optional_package(NLOPT "dart-optimizer-nlopt" "nlopt" "2.4.1")

+if(NOT NLOPT_VERSION)
+ # If version is not found, we just assume 2.9.0
+ set(NLOPT_VERSION "2.9.0")
+endif()
+
+# Attempt to parse version components
+string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\1" NLOPT_MAJOR_VERSION "${NLOPT_VERSION}")
+string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\2" NLOPT_MINOR_VERSION "${NLOPT_VERSION}")
+string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\3" NLOPT_PATCH_VERSION "${NLOPT_VERSION}")
+
+# Check if parsing succeeded
+if(NOT (NLOPT_MAJOR_VERSION MATCHES "^[0-9]+$" AND
+ NLOPT_MINOR_VERSION MATCHES "^[0-9]+$" AND
+ NLOPT_PATCH_VERSION MATCHES "^[0-9]+$"))
+ message(WARNING "Failed to parse NLOPT_VERSION '${NLOPT_VERSION}'. Using default values (2, 9, 0) for version components.")
+ set(NLOPT_MAJOR_VERSION "2")
+ set(NLOPT_MINOR_VERSION "9")
+ set(NLOPT_PATCH_VERSION "0")
+endif()
+
# Search all header and source files
file(GLOB hdrs "*.hpp")
file(GLOB srcs "*.cpp")
@@ -13,6 +33,12 @@ set(component_name optimizer-nlopt)
# Add target
dart_add_library(${target_name} ${hdrs} ${srcs})
target_link_libraries(${target_name} PUBLIC dart NLOPT::nlopt)
+target_compile_definitions(${target_name}
+ PUBLIC
+ -DNLOPT_MAJOR_VERSION=${NLOPT_MAJOR_VERSION}
+ -DNLOPT_MINOR_VERSION=${NLOPT_MINOR_VERSION}
+ -DNLOPT_PATCH_VERSION=${NLOPT_PATCH_VERSION}
+)

# Component
add_component(${PROJECT_NAME} ${component_name})
diff --git a/dart/optimizer/nlopt/NloptSolver.cpp b/dart/optimizer/nlopt/NloptSolver.cpp
index 5e8d2dbce9b4c..0adb336fcda68 100644
--- a/dart/optimizer/nlopt/NloptSolver.cpp
+++ b/dart/optimizer/nlopt/NloptSolver.cpp
@@ -257,7 +257,9 @@ nlopt::algorithm NloptSolver::convertAlgorithm(NloptSolver::Algorithm algorithm)
NLOPTSOLVER_ALGORITHM_DART_TO_NLOPT(GN_ORIG_DIRECT_L)
NLOPTSOLVER_ALGORITHM_DART_TO_NLOPT(GD_STOGO)
NLOPTSOLVER_ALGORITHM_DART_TO_NLOPT(GD_STOGO_RAND)
+#if !NLOPT_VERSION_GE(2, 9, 0)
NLOPTSOLVER_ALGORITHM_DART_TO_NLOPT(LD_LBFGS_NOCEDAL)
+#endif
NLOPTSOLVER_ALGORITHM_DART_TO_NLOPT(LD_LBFGS)
NLOPTSOLVER_ALGORITHM_DART_TO_NLOPT(LN_PRAXIS)
NLOPTSOLVER_ALGORITHM_DART_TO_NLOPT(LD_VAR1)
@@ -311,7 +313,9 @@ NloptSolver::Algorithm NloptSolver::convertAlgorithm(nlopt::algorithm algorithm)
NLOPTSOLVER_ALGORITHM_NLOPT_TO_DART(GN_ORIG_DIRECT_L)
NLOPTSOLVER_ALGORITHM_NLOPT_TO_DART(GD_STOGO)
NLOPTSOLVER_ALGORITHM_NLOPT_TO_DART(GD_STOGO_RAND)
+#if !NLOPT_VERSION_GE(2, 9, 0)
NLOPTSOLVER_ALGORITHM_NLOPT_TO_DART(LD_LBFGS_NOCEDAL)
+#endif
NLOPTSOLVER_ALGORITHM_NLOPT_TO_DART(LD_LBFGS)
NLOPTSOLVER_ALGORITHM_NLOPT_TO_DART(LN_PRAXIS)
NLOPTSOLVER_ALGORITHM_NLOPT_TO_DART(LD_VAR1)
diff --git a/dart/optimizer/nlopt/NloptSolver.hpp b/dart/optimizer/nlopt/NloptSolver.hpp
index f8f2f9279f72e..29145f9e2e462 100644
--- a/dart/optimizer/nlopt/NloptSolver.hpp
+++ b/dart/optimizer/nlopt/NloptSolver.hpp
@@ -39,12 +39,18 @@

#include <nlopt.hpp>

+#define NLOPT_VERSION_GE(x, y, z) \
+ ((NLOPT_MAJOR_VERSION > (x)) \
+ || (NLOPT_MAJOR_VERSION == (x) && NLOPT_MINOR_VERSION > (y)) \
+ || (NLOPT_MAJOR_VERSION == (x) && NLOPT_MINOR_VERSION == (y) \
+ && NLOPT_PATCH_VERSION >= (z)))
+
namespace dart {
namespace optimizer {

class Problem;

-/// NloptSolver is a nonlinear programming solver that provides many unlerlying
+/// NloptSolver is a nonlinear programming solver that provides many underlying
/// algorithms through nlopt (an third-party library:
/// https://nlopt.readthedocs.io/).
///
@@ -73,7 +79,9 @@ class NloptSolver : public Solver
GN_ORIG_DIRECT_L,
GD_STOGO,
GD_STOGO_RAND,
+#if !NLOPT_VERSION_GE(2, 9, 0)
LD_LBFGS_NOCEDAL,
+#endif
LD_LBFGS,
LN_PRAXIS,
LD_VAR1,
diff --git a/pixi.toml b/pixi.toml
index 67bf879e15c20..35385c314d445 100644
--- a/pixi.toml
+++ b/pixi.toml
@@ -52,8 +52,9 @@ config = { cmd = """
-G Ninja \
-S . \
-B build \
- -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
+ -DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DDART_VERBOSE=ON \
-DDART_USE_SYSTEM_IMGUI=ON
""" }
@@ -192,6 +193,7 @@ config = { cmd = """
-B build \
-G 'Visual Studio 17 2022' \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
+ -DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
-DDART_VERBOSE=ON \
-DDART_MSVC_DEFAULT_OPTIONS=ON \
-DBUILD_SHARED_LIBS=OFF \
diff --git a/python/dartpy/optimizer/NloptSolver.cpp b/python/dartpy/optimizer/NloptSolver.cpp
index fba30c57af4b6..9a0d72a8b5f78 100644
--- a/python/dartpy/optimizer/NloptSolver.cpp
+++ b/python/dartpy/optimizer/NloptSolver.cpp
@@ -123,7 +123,9 @@ void NloptSolver(py::module& m)
DARTPY_DEFINE_ALGORITHM(GN_ORIG_DIRECT_L)
DARTPY_DEFINE_ALGORITHM(GD_STOGO)
DARTPY_DEFINE_ALGORITHM(GD_STOGO_RAND)
+#if !NLOPT_VERSION_GE(2, 9, 0)
DARTPY_DEFINE_ALGORITHM(LD_LBFGS_NOCEDAL)
+#endif
DARTPY_DEFINE_ALGORITHM(LD_LBFGS)
DARTPY_DEFINE_ALGORITHM(LN_PRAXIS)
DARTPY_DEFINE_ALGORITHM(LD_VAR1)
4 changes: 3 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ source:
- remove-opencl.patch
# https://github.com/dartsim/dart/pull/1872
- 001-pr-1872.patch
# https://github.com/dartsim/dart/pull/1874
- 002-pr-1874.patch

build:
number: 10
number: 11

outputs:
- name: dartsim-cpp
Expand Down
Loading