sleipnirgroup-jormungandr 0.6.7.dev149__tar.gz → 0.6.7.dev167__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/CMakeLists.txt +13 -6
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/PKG-INFO +1 -1
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/autodiff/expression_functions.hpp +76 -49
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/autodiff/gradient.hpp +15 -15
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/autodiff/hessian.hpp +26 -27
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/autodiff/jacobian.hpp +30 -33
- sleipnirgroup_jormungandr-0.6.7.dev149/include/sleipnir/autodiff/variable_matrix.hpp → sleipnirgroup_jormungandr-0.6.7.dev167/include/sleipnir/autodiff/matrix.hpp +202 -217
- sleipnirgroup_jormungandr-0.6.7.dev149/include/sleipnir/autodiff/variable.hpp → sleipnirgroup_jormungandr-0.6.7.dev167/include/sleipnir/autodiff/real.hpp +312 -278
- sleipnirgroup_jormungandr-0.6.7.dev149/include/sleipnir/autodiff/variable_block.hpp → sleipnirgroup_jormungandr-0.6.7.dev167/include/sleipnir/autodiff/submatrix.hpp +101 -105
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/ocp.hpp +48 -51
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/problem.hpp +42 -80
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/ipm.hpp +80 -106
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/newton.hpp +7 -11
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/sqp.hpp +63 -54
- sleipnirgroup_jormungandr-0.6.7.dev167/include/sleipnir/optimization/solver/util/barrier_parameter.hpp +49 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/bounds.hpp +3 -3
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/feasibility_restoration.hpp +25 -25
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/filter.hpp +23 -15
- sleipnirgroup_jormungandr-0.6.7.dev167/include/sleipnir/optimization/solver/util/first_derivatives.hpp +52 -0
- sleipnirgroup_jormungandr-0.6.7.dev167/include/sleipnir/optimization/solver/util/function_values.hpp +56 -0
- sleipnirgroup_jormungandr-0.6.7.dev167/include/sleipnir/optimization/solver/util/iterates.hpp +40 -0
- sleipnirgroup_jormungandr-0.6.7.dev167/include/sleipnir/optimization/solver/util/kkt_error.hpp +340 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/kkt_system.hpp +1 -163
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/problem_scaling.hpp +9 -6
- sleipnirgroup_jormungandr-0.6.7.dev167/include/sleipnir/optimization/solver/util/step.hpp +172 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/empty.hpp +2 -2
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/pyproject.toml +1 -1
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/autodiff/bind_gradient.cpp +4 -4
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/autodiff/bind_hessian.cpp +4 -4
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/autodiff/bind_jacobian.cpp +7 -7
- sleipnirgroup_jormungandr-0.6.7.dev149/python/cpp/autodiff/bind_variable_matrix.cpp → sleipnirgroup_jormungandr-0.6.7.dev167/python/cpp/autodiff/bind_matrix.cpp +165 -183
- sleipnirgroup_jormungandr-0.6.7.dev149/python/cpp/autodiff/bind_variable.cpp → sleipnirgroup_jormungandr-0.6.7.dev167/python/cpp/autodiff/bind_real.cpp +44 -36
- sleipnirgroup_jormungandr-0.6.7.dev149/python/cpp/autodiff/bind_variable_block.cpp → sleipnirgroup_jormungandr-0.6.7.dev167/python/cpp/autodiff/bind_submatrix.cpp +134 -151
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/binders.hpp +6 -8
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/docstrings.hpp +1170 -1150
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/main.cpp +22 -28
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/optimization/bind_equality_constraints.cpp +1 -1
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/optimization/bind_inequality_constraints.cpp +1 -1
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/optimization/bind_ocp.cpp +20 -21
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/optimization/bind_problem.cpp +3 -6
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/postprocess_stubs.py +31 -35
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/src/sleipnir/__init__.py +1 -1
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/autodiff/gradient_test.py +61 -29
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/autodiff/hessian_test.py +32 -32
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/autodiff/jacobian_test.py +12 -12
- sleipnirgroup_jormungandr-0.6.7.dev149/python/test/autodiff/variable_matrix_test.py → sleipnirgroup_jormungandr-0.6.7.dev167/python/test/autodiff/matrix_test.py +56 -60
- sleipnirgroup_jormungandr-0.6.7.dev149/python/test/autodiff/variable_test.py → sleipnirgroup_jormungandr-0.6.7.dev167/python/test/autodiff/real_test.py +13 -13
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/cart_pole_ocp_test.py +2 -2
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/cart_pole_util.py +10 -12
- sleipnirgroup_jormungandr-0.6.7.dev167/python/test/optimization/constraints_test.py +166 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/differential_drive_util.py +4 -4
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/flywheel_ocp_test.py +4 -4
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/problem_variable_test.py +0 -22
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/rk4.py +10 -7
- sleipnirgroup_jormungandr-0.6.7.dev167/src/autodiff/matrix.cpp +10 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/src/optimization/solver/ipm.cpp +2 -3
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/src/optimization/solver/sqp.cpp +2 -2
- sleipnirgroup_jormungandr-0.6.7.dev149/include/sleipnir/optimization/solver/util/kkt_error.hpp +0 -293
- sleipnirgroup_jormungandr-0.6.7.dev149/python/test/optimization/constraints_test.py +0 -158
- sleipnirgroup_jormungandr-0.6.7.dev149/src/autodiff/variable_matrix.cpp +0 -11
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/LICENSE.txt +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/README.md +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/SleipnirConfig.cmake.in +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/cmake/BuildTypes.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/cmake/CompilerFlags.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/cmake/Pybind11Mkdoc.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/cmake/Pybind11MkdocPostprocess.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/cmake/SubdirList.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/cmake/aarch64-linux-gnu.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/cmake/arm-none-eabi.cmake +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/autodiff/expression.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/autodiff/expression_graph.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/autodiff/expression_type.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/autodiff/sleipnir_base.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/autodiff/slice.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/multistart.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/ocp/dynamics_type.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/ocp/timestep_method.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/ocp/transcription_method.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/control_flow.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/exit_status.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/ipm_matrix_callbacks.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/iteration_info.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/newton_matrix_callbacks.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/options.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/sqp_matrix_callbacks.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/all_finite.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/append_as_triplets.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/constraint_violation.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/dense_kkt_solver.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/feasibility_restoration_cycle_detector.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/fraction_to_the_boundary_rule.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/kkt_solver.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/regularization_limits.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/ruiz_equilibration.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/sparse_inf_norms.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/sparse_kkt_solver.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/optimization/solver/util/time_trace.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/assert.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/concepts.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/force_inline.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/function_ref.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/intrusive_shared_ptr.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/pool.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/print.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/print_diagnostics.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/scope_exit.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/spy.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/symbol_exports.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/include/sleipnir/util/time_tracer.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/.clang-tidy +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/arity.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/autodiff/bind_expression_type.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/for_each_type.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/optimization/ocp/bind_dynamics_type.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/optimization/ocp/bind_timestep_method.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/optimization/ocp/bind_transcription_method.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/optimization/solver/bind_exit_status.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/optimization/solver/bind_iteration_info.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/slice_tuple.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/text_wrap.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/cpp/try_cast.hpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/src/sleipnir/autodiff/__init__.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/src/sleipnir/optimization/__init__.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/arm_on_elevator_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/cart_pole_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/differential_drive_ocp_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/differential_drive_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/double_integrator_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/flywheel_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/flywheel_util.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/linear_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/multistart_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/nonlinear_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/problem_spy_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/quadratic_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/solver/exit_status_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/tolerance.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/python/test/optimization/trivial_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/src/autodiff/gradient.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/src/autodiff/hessian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/src/autodiff/jacobian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/src/optimization/ocp.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/src/optimization/problem.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/src/optimization/solver/newton.cpp +0 -0
- {sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/src/util/pool.cpp +0 -0
{sleipnirgroup_jormungandr-0.6.7.dev149 → sleipnirgroup_jormungandr-0.6.7.dev167}/CMakeLists.txt
RENAMED
|
@@ -44,6 +44,11 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
|
|
|
44
44
|
option(SLEIPNIR_BUILD_BENCHMARKS "Build CasADi and Sleipnir benchmarks" OFF)
|
|
45
45
|
option(SLEIPNIR_BUILD_EXAMPLES "Build examples" OFF)
|
|
46
46
|
option(SLEIPNIR_BUILD_PYTHON "Build Python module" OFF)
|
|
47
|
+
option(
|
|
48
|
+
SLEIPNIR_GENERATE_DOCSTRINGS
|
|
49
|
+
"Regenerate the Python module's docstrings from the C++ headers with pybind11_mkdoc"
|
|
50
|
+
ON
|
|
51
|
+
)
|
|
47
52
|
option(
|
|
48
53
|
SLEIPNIR_DISABLE_DIAGNOSTICS
|
|
49
54
|
"Disable diagnostics support at compile-time"
|
|
@@ -558,9 +563,9 @@ if(SLEIPNIR_BUILD_PYTHON)
|
|
|
558
563
|
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/autodiff/gradient.hpp
|
|
559
564
|
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/autodiff/hessian.hpp
|
|
560
565
|
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/autodiff/jacobian.hpp
|
|
561
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/autodiff/
|
|
562
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/autodiff/
|
|
563
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/autodiff/
|
|
566
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/autodiff/real.hpp
|
|
567
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/autodiff/submatrix.hpp
|
|
568
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/autodiff/matrix.hpp
|
|
564
569
|
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/optimization/ocp.hpp
|
|
565
570
|
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/optimization/ocp/dynamics_type.hpp
|
|
566
571
|
${CMAKE_CURRENT_SOURCE_DIR}/include/sleipnir/optimization/ocp/timestep_method.hpp
|
|
@@ -572,7 +577,9 @@ if(SLEIPNIR_BUILD_PYTHON)
|
|
|
572
577
|
)
|
|
573
578
|
|
|
574
579
|
# Generate docs for the Python module
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
580
|
+
if(SLEIPNIR_GENERATE_DOCSTRINGS)
|
|
581
|
+
include(Pybind11Mkdoc)
|
|
582
|
+
pybind11_mkdoc(_sleipnir "${sleipnir_headers}")
|
|
583
|
+
add_dependencies(_sleipnir _sleipnir_docstrings)
|
|
584
|
+
endif()
|
|
578
585
|
endif()
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
#pragma once
|
|
4
4
|
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
|
|
5
7
|
#include <algorithm>
|
|
6
8
|
#include <array>
|
|
7
9
|
#include <cmath>
|
|
8
10
|
#include <concepts>
|
|
9
11
|
#include <numbers>
|
|
10
12
|
#include <string_view>
|
|
11
|
-
#include <type_traits>
|
|
12
13
|
#include <utility>
|
|
13
14
|
|
|
14
15
|
#include "sleipnir/autodiff/expression.hpp"
|
|
@@ -461,71 +462,97 @@ ExpressionPtr<Scalar> hypot(const ExpressionPtr<Scalar>& x,
|
|
|
461
462
|
return fold_or_make<Hypot3Expression, Scalar>(x, y, z);
|
|
462
463
|
}
|
|
463
464
|
|
|
465
|
+
/// The condition if_else() checks on its argument c.
|
|
466
|
+
enum class IfElseCondition : uint8_t {
|
|
467
|
+
/// c = 0.
|
|
468
|
+
ZERO,
|
|
469
|
+
/// c ≥ 0.
|
|
470
|
+
NONNEGATIVE,
|
|
471
|
+
/// c > 0.
|
|
472
|
+
POSITIVE
|
|
473
|
+
};
|
|
474
|
+
|
|
464
475
|
/// Derived expression type for if_else().
|
|
465
476
|
///
|
|
466
|
-
/// Returns t if
|
|
477
|
+
/// Returns t if c satisfies the condition, otherwise f.
|
|
467
478
|
///
|
|
468
479
|
/// @tparam Scalar Scalar type.
|
|
469
480
|
/// @tparam Type Expression type.
|
|
470
481
|
template <typename Scalar, ExpressionType Type>
|
|
471
482
|
struct IfElseExpression final
|
|
472
|
-
: NonLeafExpression<IfElseExpression, Scalar, Type,
|
|
483
|
+
: NonLeafExpression<IfElseExpression, Scalar, Type, 3> {
|
|
473
484
|
/// The expression's name.
|
|
474
485
|
static constexpr std::string_view NAME = "if-else";
|
|
475
486
|
|
|
476
|
-
///
|
|
477
|
-
|
|
487
|
+
/// The condition checked on c.
|
|
488
|
+
IfElseCondition cond;
|
|
478
489
|
|
|
479
490
|
/// Constructs an if-else expression.
|
|
480
491
|
///
|
|
481
|
-
/// @param cond
|
|
482
|
-
/// @param
|
|
483
|
-
/// @param
|
|
484
|
-
/// @param
|
|
485
|
-
|
|
486
|
-
constexpr IfElseExpression(bool (*cond)(Scalar a, Scalar b),
|
|
487
|
-
ExpressionPtr<Scalar> a, ExpressionPtr<Scalar> b,
|
|
492
|
+
/// @param cond The condition checked on c.
|
|
493
|
+
/// @param c The condition's argument.
|
|
494
|
+
/// @param t Value selected when c satisfies the condition.
|
|
495
|
+
/// @param f Value selected when c violates the condition.
|
|
496
|
+
constexpr IfElseExpression(IfElseCondition cond, ExpressionPtr<Scalar> c,
|
|
488
497
|
ExpressionPtr<Scalar> t, ExpressionPtr<Scalar> f)
|
|
489
|
-
: IfElseExpression::NonLeafExpression{std::move(
|
|
490
|
-
std::move(
|
|
498
|
+
: IfElseExpression::NonLeafExpression{std::move(c), std::move(t),
|
|
499
|
+
std::move(f)},
|
|
491
500
|
cond{cond} {}
|
|
492
501
|
|
|
493
|
-
|
|
494
|
-
|
|
502
|
+
/// Returns true if c satisfies the condition.
|
|
503
|
+
///
|
|
504
|
+
/// @param cond The condition checked on c.
|
|
505
|
+
/// @param c The condition's argument.
|
|
506
|
+
/// @return True if c satisfies the condition.
|
|
507
|
+
static bool satisfied(IfElseCondition cond, Scalar c) {
|
|
508
|
+
using enum IfElseCondition;
|
|
509
|
+
|
|
510
|
+
switch (cond) {
|
|
511
|
+
case ZERO:
|
|
512
|
+
return c == Scalar(0);
|
|
513
|
+
case NONNEGATIVE:
|
|
514
|
+
return c >= Scalar(0);
|
|
515
|
+
case POSITIVE:
|
|
516
|
+
return c > Scalar(0);
|
|
517
|
+
default:
|
|
518
|
+
std::unreachable();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
Scalar eval(Scalar c, Scalar t, Scalar f) const {
|
|
523
|
+
return satisfied(cond, c) ? t : f;
|
|
495
524
|
}
|
|
496
525
|
|
|
497
526
|
template <typename Value>
|
|
498
|
-
void eval_grad(std::array<Value,
|
|
499
|
-
const Value&
|
|
500
|
-
[[maybe_unused]] const Value& t,
|
|
527
|
+
void eval_grad(std::array<Value, 3>& g, [[maybe_unused]] const Value& val,
|
|
528
|
+
const Value& c, [[maybe_unused]] const Value& t,
|
|
501
529
|
[[maybe_unused]] const Value& f) const {
|
|
502
|
-
//
|
|
530
|
+
// c has zero gradient
|
|
503
531
|
if constexpr (std::same_as<Value, Scalar>) {
|
|
504
|
-
bool
|
|
505
|
-
g[
|
|
506
|
-
g[
|
|
532
|
+
bool s = satisfied(cond, c);
|
|
533
|
+
g[1] = s ? Scalar(1) : Scalar(0);
|
|
534
|
+
g[2] = s ? Scalar(0) : Scalar(1);
|
|
507
535
|
} else {
|
|
508
536
|
auto zero = constant_ptr(Scalar(0));
|
|
509
537
|
auto one = constant_ptr(Scalar(1));
|
|
510
|
-
g[
|
|
511
|
-
g[
|
|
538
|
+
g[1] = if_else(cond, c, one, zero);
|
|
539
|
+
g[2] = if_else(cond, c, zero, one);
|
|
512
540
|
}
|
|
513
541
|
}
|
|
514
542
|
};
|
|
515
543
|
|
|
516
|
-
/// Returns t if
|
|
544
|
+
/// Returns t if c satisfies the condition, otherwise f.
|
|
517
545
|
///
|
|
518
546
|
/// @tparam Scalar Scalar type.
|
|
519
|
-
/// @param cond
|
|
520
|
-
/// @param
|
|
521
|
-
/// @param
|
|
522
|
-
/// @param
|
|
523
|
-
/// @param f Value selected when cond(a, b) is false.
|
|
547
|
+
/// @param cond The condition checked on c.
|
|
548
|
+
/// @param c The condition's argument.
|
|
549
|
+
/// @param t Value selected when c satisfies the condition.
|
|
550
|
+
/// @param f Value selected when c violates the condition.
|
|
524
551
|
template <typename Scalar>
|
|
525
|
-
ExpressionPtr<Scalar> if_else(
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
552
|
+
ExpressionPtr<Scalar> if_else(IfElseCondition cond,
|
|
553
|
+
const ExpressionPtr<Scalar>& c,
|
|
554
|
+
const ExpressionPtr<Scalar>& t,
|
|
555
|
+
const ExpressionPtr<Scalar>& f) {
|
|
529
556
|
using enum ExpressionType;
|
|
530
557
|
|
|
531
558
|
// Prune expression
|
|
@@ -539,17 +566,17 @@ ExpressionPtr<Scalar> if_else(
|
|
|
539
566
|
}
|
|
540
567
|
|
|
541
568
|
// Evaluate constant condition
|
|
542
|
-
if (
|
|
543
|
-
return cond
|
|
569
|
+
if (c->type() == CONSTANT) {
|
|
570
|
+
return IfElseExpression<Scalar, NONLINEAR>::satisfied(cond, c->val) ? t : f;
|
|
544
571
|
}
|
|
545
572
|
|
|
546
|
-
if (
|
|
547
|
-
|
|
548
|
-
return make_expression_ptr<IfElseExpression<Scalar, PARAMETER>>(cond,
|
|
549
|
-
|
|
573
|
+
if (c->type() <= PARAMETER && t->type() <= PARAMETER &&
|
|
574
|
+
f->type() <= PARAMETER) {
|
|
575
|
+
return make_expression_ptr<IfElseExpression<Scalar, PARAMETER>>(cond, c, t,
|
|
576
|
+
f);
|
|
550
577
|
} else {
|
|
551
|
-
return make_expression_ptr<IfElseExpression<Scalar, NONLINEAR>>(cond,
|
|
552
|
-
|
|
578
|
+
return make_expression_ptr<IfElseExpression<Scalar, NONLINEAR>>(cond, c, t,
|
|
579
|
+
f);
|
|
553
580
|
}
|
|
554
581
|
}
|
|
555
582
|
|
|
@@ -647,9 +674,9 @@ struct MaxExpression final : NonLeafExpression<MaxExpression, Scalar, Type, 2> {
|
|
|
647
674
|
} else {
|
|
648
675
|
auto zero = constant_ptr(Scalar(0));
|
|
649
676
|
auto one = constant_ptr(Scalar(1));
|
|
650
|
-
auto
|
|
651
|
-
g[0] = if_else(
|
|
652
|
-
g[1] = if_else(
|
|
677
|
+
auto c = a - b;
|
|
678
|
+
g[0] = if_else(IfElseCondition::NONNEGATIVE, c, one, zero);
|
|
679
|
+
g[1] = if_else(IfElseCondition::NONNEGATIVE, c, zero, one);
|
|
653
680
|
}
|
|
654
681
|
}
|
|
655
682
|
};
|
|
@@ -694,9 +721,9 @@ struct MinExpression final : NonLeafExpression<MinExpression, Scalar, Type, 2> {
|
|
|
694
721
|
} else {
|
|
695
722
|
auto zero = constant_ptr(Scalar(0));
|
|
696
723
|
auto one = constant_ptr(Scalar(1));
|
|
697
|
-
auto
|
|
698
|
-
g[0] = if_else(
|
|
699
|
-
g[1] = if_else(
|
|
724
|
+
auto c = b - a;
|
|
725
|
+
g[0] = if_else(IfElseCondition::NONNEGATIVE, c, one, zero);
|
|
726
|
+
g[1] = if_else(IfElseCondition::NONNEGATIVE, c, zero, one);
|
|
700
727
|
}
|
|
701
728
|
}
|
|
702
729
|
};
|
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
#include <Eigen/SparseCore>
|
|
9
9
|
|
|
10
10
|
#include "sleipnir/autodiff/jacobian.hpp"
|
|
11
|
-
#include "sleipnir/autodiff/
|
|
12
|
-
#include "sleipnir/autodiff/
|
|
11
|
+
#include "sleipnir/autodiff/matrix.hpp"
|
|
12
|
+
#include "sleipnir/autodiff/real.hpp"
|
|
13
13
|
#include "sleipnir/util/concepts.hpp"
|
|
14
14
|
#include "sleipnir/util/symbol_exports.hpp"
|
|
15
15
|
|
|
16
16
|
namespace slp {
|
|
17
17
|
|
|
18
|
-
/// This class calculates the gradient of
|
|
19
|
-
/// variables.
|
|
18
|
+
/// This class calculates the gradient of an expression with respect to a vector
|
|
19
|
+
/// of variables.
|
|
20
20
|
///
|
|
21
|
-
/// The gradient is only recomputed if the
|
|
22
|
-
///
|
|
21
|
+
/// The gradient is only recomputed if the expression is quadratic or higher
|
|
22
|
+
/// order.
|
|
23
23
|
///
|
|
24
24
|
/// @tparam Scalar Scalar type.
|
|
25
25
|
template <typename Scalar>
|
|
@@ -27,26 +27,26 @@ class Gradient {
|
|
|
27
27
|
public:
|
|
28
28
|
/// Constructs a Gradient object.
|
|
29
29
|
///
|
|
30
|
-
/// @param
|
|
30
|
+
/// @param expression Expression of which to compute the gradient.
|
|
31
31
|
/// @param wrt Variable with respect to which to compute the gradient.
|
|
32
|
-
Gradient(
|
|
33
|
-
: m_jacobian{std::move(
|
|
32
|
+
Gradient(Real<Scalar> expression, Real<Scalar> wrt)
|
|
33
|
+
: m_jacobian{std::move(expression), std::move(wrt)} {}
|
|
34
34
|
|
|
35
35
|
/// Constructs a Gradient object.
|
|
36
36
|
///
|
|
37
|
-
/// @param
|
|
37
|
+
/// @param expression Expression of which to compute the gradient.
|
|
38
38
|
/// @param wrt Vector of variables with respect to which to compute the
|
|
39
39
|
/// gradient.
|
|
40
|
-
Gradient(
|
|
41
|
-
: m_jacobian{
|
|
40
|
+
Gradient(Real<Scalar> expression, SleipnirMatrixLike<Scalar> auto wrt)
|
|
41
|
+
: m_jacobian{Matrix{std::move(expression)}, std::move(wrt)} {}
|
|
42
42
|
|
|
43
|
-
/// Returns the gradient as a
|
|
43
|
+
/// Returns the gradient as a Matrix.
|
|
44
44
|
///
|
|
45
45
|
/// This is useful when constructing optimization problems with derivatives in
|
|
46
46
|
/// them.
|
|
47
47
|
///
|
|
48
|
-
/// @return The gradient as a
|
|
49
|
-
|
|
48
|
+
/// @return The gradient as a Matrix.
|
|
49
|
+
Matrix<Scalar> get() const { return m_jacobian.get().T(); }
|
|
50
50
|
|
|
51
51
|
/// Evaluates the gradient at wrt's value.
|
|
52
52
|
///
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
#include "sleipnir/autodiff/expression.hpp"
|
|
13
13
|
#include "sleipnir/autodiff/expression_graph.hpp"
|
|
14
|
-
#include "sleipnir/autodiff/
|
|
15
|
-
#include "sleipnir/autodiff/
|
|
14
|
+
#include "sleipnir/autodiff/matrix.hpp"
|
|
15
|
+
#include "sleipnir/autodiff/real.hpp"
|
|
16
16
|
#include "sleipnir/util/assert.hpp"
|
|
17
17
|
#include "sleipnir/util/concepts.hpp"
|
|
18
18
|
#include "sleipnir/util/empty.hpp"
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
|
|
21
21
|
namespace slp {
|
|
22
22
|
|
|
23
|
-
/// This class calculates the Hessian of
|
|
24
|
-
/// variables.
|
|
23
|
+
/// This class calculates the Hessian of an expression with respect to a vector
|
|
24
|
+
/// of variables.
|
|
25
25
|
///
|
|
26
26
|
/// The gradient tree is cached so subsequent Hessian calculations are faster,
|
|
27
|
-
/// and the Hessian is only recomputed if the
|
|
28
|
-
///
|
|
27
|
+
/// and the Hessian is only recomputed if the expression is nonlinear or its
|
|
28
|
+
/// quadratic coefficients depend on parameters.
|
|
29
29
|
///
|
|
30
30
|
/// @tparam Scalar Scalar type.
|
|
31
31
|
/// @tparam UpLo Which part of the Hessian to compute (Lower or Lower | Upper).
|
|
@@ -36,24 +36,24 @@ class Hessian {
|
|
|
36
36
|
public:
|
|
37
37
|
/// Constructs a Hessian object.
|
|
38
38
|
///
|
|
39
|
-
/// @param
|
|
39
|
+
/// @param expression Expression of which to compute the Hessian.
|
|
40
40
|
/// @param wrt Variable with respect to which to compute the Hessian.
|
|
41
|
-
Hessian(
|
|
42
|
-
: Hessian{std::move(
|
|
41
|
+
Hessian(Real<Scalar> expression, Real<Scalar> wrt)
|
|
42
|
+
: Hessian{std::move(expression), Matrix<Scalar>{std::move(wrt)}} {}
|
|
43
43
|
|
|
44
44
|
/// Constructs a Hessian object.
|
|
45
45
|
///
|
|
46
|
-
/// @param
|
|
46
|
+
/// @param expression Expression of which to compute the Hessian.
|
|
47
47
|
/// @param wrt Vector of variables with respect to which to compute the
|
|
48
48
|
/// Hessian.
|
|
49
|
-
Hessian(
|
|
50
|
-
:
|
|
51
|
-
detail::topological_sort(
|
|
49
|
+
Hessian(Real<Scalar> expression, SleipnirMatrixLike<Scalar> auto wrt)
|
|
50
|
+
: m_expressions{detail::gradient_tree(
|
|
51
|
+
detail::topological_sort(expression.expr), wrt)},
|
|
52
52
|
m_wrt{std::move(wrt)} {
|
|
53
53
|
slp_assert(m_wrt.cols() == 1);
|
|
54
54
|
|
|
55
|
-
for (auto&
|
|
56
|
-
m_top_lists.emplace_back(detail::topological_sort(
|
|
55
|
+
for (auto& expression : m_expressions) {
|
|
56
|
+
m_top_lists.emplace_back(detail::topological_sort(expression.expr));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// Initialize column each expression's adjoint occupies in the Jacobian
|
|
@@ -76,8 +76,8 @@ class Hessian {
|
|
|
76
76
|
node.expr->scratch = -1;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
for (int row = 0; row <
|
|
80
|
-
if (
|
|
79
|
+
for (int row = 0; row < m_expressions.rows(); ++row) {
|
|
80
|
+
if (m_expressions[row].expr == nullptr) {
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -100,23 +100,22 @@ class Hessian {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
/// Returns the Hessian as a
|
|
103
|
+
/// Returns the Hessian as a Matrix.
|
|
104
104
|
///
|
|
105
105
|
/// This is useful when constructing optimization problems with derivatives in
|
|
106
106
|
/// them.
|
|
107
107
|
///
|
|
108
|
-
/// @return The Hessian as a
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
m_wrt.rows()};
|
|
108
|
+
/// @return The Hessian as a Matrix.
|
|
109
|
+
Matrix<Scalar> get() const {
|
|
110
|
+
Matrix<Scalar> result{detail::empty, m_expressions.rows(), m_wrt.rows()};
|
|
112
111
|
|
|
113
|
-
for (int row = 0; row <
|
|
112
|
+
for (int row = 0; row < m_expressions.rows(); ++row) {
|
|
114
113
|
auto grad = detail::gradient_tree(m_top_lists[row], m_wrt);
|
|
115
114
|
for (int col = 0; col < m_wrt.rows(); ++col) {
|
|
116
115
|
if (grad[col].expr != nullptr) {
|
|
117
116
|
result[row, col] = std::move(grad[col]);
|
|
118
117
|
} else {
|
|
119
|
-
result[row, col] =
|
|
118
|
+
result[row, col] = Real{Scalar(0)};
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
}
|
|
@@ -155,8 +154,8 @@ class Hessian {
|
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
private:
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
Matrix<Scalar> m_expressions;
|
|
158
|
+
Matrix<Scalar> m_wrt;
|
|
160
159
|
|
|
161
160
|
/// List of topologically sorted graphs from parent to child, one for each row
|
|
162
161
|
gch::small_vector<detail::ExpressionGraph<Scalar>> m_top_lists;
|
|
@@ -166,7 +165,7 @@ class Hessian {
|
|
|
166
165
|
gch::small_vector<std::pair<int, detail::Expression<Scalar>*>>>
|
|
167
166
|
m_output_lists;
|
|
168
167
|
|
|
169
|
-
Eigen::SparseMatrix<Scalar> m_H{
|
|
168
|
+
Eigen::SparseMatrix<Scalar> m_H{m_expressions.rows(), m_wrt.rows()};
|
|
170
169
|
|
|
171
170
|
// Cached triplets for gradients of linear rows
|
|
172
171
|
gch::small_vector<Eigen::Triplet<Scalar>> m_cached_triplets;
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
#include "sleipnir/autodiff/expression.hpp"
|
|
12
12
|
#include "sleipnir/autodiff/expression_graph.hpp"
|
|
13
|
-
#include "sleipnir/autodiff/
|
|
14
|
-
#include "sleipnir/autodiff/
|
|
13
|
+
#include "sleipnir/autodiff/matrix.hpp"
|
|
14
|
+
#include "sleipnir/autodiff/real.hpp"
|
|
15
15
|
#include "sleipnir/util/assert.hpp"
|
|
16
16
|
#include "sleipnir/util/concepts.hpp"
|
|
17
17
|
#include "sleipnir/util/empty.hpp"
|
|
@@ -19,12 +19,11 @@
|
|
|
19
19
|
|
|
20
20
|
namespace slp {
|
|
21
21
|
|
|
22
|
-
/// This class calculates the Jacobian of a vector of
|
|
23
|
-
/// a vector of variables.
|
|
22
|
+
/// This class calculates the Jacobian of a vector of expressions with respect
|
|
23
|
+
/// to a vector of variables.
|
|
24
24
|
///
|
|
25
|
-
/// The Jacobian is only recomputed if the
|
|
26
|
-
///
|
|
27
|
-
/// parameters.
|
|
25
|
+
/// The Jacobian is only recomputed if the expression is quadratic or higher
|
|
26
|
+
/// order, or if it's linear with coefficients that depend on parameters.
|
|
28
27
|
///
|
|
29
28
|
/// @tparam Scalar Scalar type.
|
|
30
29
|
template <typename Scalar>
|
|
@@ -32,33 +31,32 @@ class Jacobian {
|
|
|
32
31
|
public:
|
|
33
32
|
/// Constructs a Jacobian object.
|
|
34
33
|
///
|
|
35
|
-
/// @param
|
|
34
|
+
/// @param expression Expression of which to compute the Jacobian.
|
|
36
35
|
/// @param wrt Variable with respect to which to compute the Jacobian.
|
|
37
|
-
Jacobian(
|
|
38
|
-
: Jacobian{
|
|
39
|
-
|
|
36
|
+
Jacobian(Real<Scalar> expression, Real<Scalar> wrt)
|
|
37
|
+
: Jacobian{Matrix<Scalar>{std::move(expression)},
|
|
38
|
+
Matrix<Scalar>{std::move(wrt)}} {}
|
|
40
39
|
|
|
41
40
|
/// Constructs a Jacobian object.
|
|
42
41
|
///
|
|
43
|
-
/// @param
|
|
42
|
+
/// @param expression Expression of which to compute the Jacobian.
|
|
44
43
|
/// @param wrt Vector of variables with respect to which to compute the
|
|
45
44
|
/// Jacobian.
|
|
46
|
-
Jacobian(
|
|
47
|
-
: Jacobian{
|
|
45
|
+
Jacobian(Real<Scalar> expression, SleipnirMatrixLike<Scalar> auto wrt)
|
|
46
|
+
: Jacobian{Matrix<Scalar>{std::move(expression)}, std::move(wrt)} {}
|
|
48
47
|
|
|
49
48
|
/// Constructs a Jacobian object.
|
|
50
49
|
///
|
|
51
|
-
/// @param
|
|
50
|
+
/// @param expressions Vector of expressions of which to compute the Jacobian.
|
|
52
51
|
/// @param wrt Vector of variables with respect to which to compute the
|
|
53
52
|
/// Jacobian.
|
|
54
|
-
Jacobian(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
slp_assert(m_variables.cols() == 1);
|
|
53
|
+
Jacobian(Matrix<Scalar> expressions, SleipnirMatrixLike<Scalar> auto wrt)
|
|
54
|
+
: m_expressions{std::move(expressions)}, m_wrt{std::move(wrt)} {
|
|
55
|
+
slp_assert(m_expressions.cols() == 1);
|
|
58
56
|
slp_assert(m_wrt.cols() == 1);
|
|
59
57
|
|
|
60
|
-
for (auto&
|
|
61
|
-
m_top_lists.emplace_back(detail::topological_sort(
|
|
58
|
+
for (auto& expression : m_expressions) {
|
|
59
|
+
m_top_lists.emplace_back(detail::topological_sort(expression.expr));
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
// Initialize column each expression's adjoint occupies in the Jacobian
|
|
@@ -81,8 +79,8 @@ class Jacobian {
|
|
|
81
79
|
node.expr->scratch = -1;
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
for (int row = 0; row <
|
|
85
|
-
if (
|
|
82
|
+
for (int row = 0; row < m_expressions.rows(); ++row) {
|
|
83
|
+
if (m_expressions[row].expr == nullptr) {
|
|
86
84
|
continue;
|
|
87
85
|
}
|
|
88
86
|
|
|
@@ -102,23 +100,22 @@ class Jacobian {
|
|
|
102
100
|
}
|
|
103
101
|
}
|
|
104
102
|
|
|
105
|
-
/// Returns the Jacobian as a
|
|
103
|
+
/// Returns the Jacobian as a Matrix.
|
|
106
104
|
///
|
|
107
105
|
/// This is useful when constructing optimization problems with derivatives in
|
|
108
106
|
/// them.
|
|
109
107
|
///
|
|
110
|
-
/// @return The Jacobian as a
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
m_wrt.rows()};
|
|
108
|
+
/// @return The Jacobian as a Matrix.
|
|
109
|
+
Matrix<Scalar> get() const {
|
|
110
|
+
Matrix<Scalar> result{detail::empty, m_expressions.rows(), m_wrt.rows()};
|
|
114
111
|
|
|
115
|
-
for (int row = 0; row <
|
|
112
|
+
for (int row = 0; row < m_expressions.rows(); ++row) {
|
|
116
113
|
auto grad = detail::gradient_tree(m_top_lists[row], m_wrt);
|
|
117
114
|
for (int col = 0; col < m_wrt.rows(); ++col) {
|
|
118
115
|
if (grad[col].expr != nullptr) {
|
|
119
116
|
result[row, col] = std::move(grad[col]);
|
|
120
117
|
} else {
|
|
121
|
-
result[row, col] =
|
|
118
|
+
result[row, col] = Real{Scalar(0)};
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
121
|
}
|
|
@@ -154,8 +151,8 @@ class Jacobian {
|
|
|
154
151
|
}
|
|
155
152
|
|
|
156
153
|
private:
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
Matrix<Scalar> m_expressions;
|
|
155
|
+
Matrix<Scalar> m_wrt;
|
|
159
156
|
|
|
160
157
|
/// List of topologically sorted graphs from parent to child, one for each row
|
|
161
158
|
gch::small_vector<detail::ExpressionGraph<Scalar>> m_top_lists;
|
|
@@ -165,7 +162,7 @@ class Jacobian {
|
|
|
165
162
|
gch::small_vector<std::pair<int, detail::Expression<Scalar>*>>>
|
|
166
163
|
m_output_lists;
|
|
167
164
|
|
|
168
|
-
Eigen::SparseMatrix<Scalar> m_J{
|
|
165
|
+
Eigen::SparseMatrix<Scalar> m_J{m_expressions.rows(), m_wrt.rows()};
|
|
169
166
|
|
|
170
167
|
/// Cached triplets for gradients of linear rows
|
|
171
168
|
gch::small_vector<Eigen::Triplet<Scalar>> m_cached_triplets;
|