sleipnirgroup-jormungandr 0.5.6.dev4__tar.gz → 0.5.6.dev6__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.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/PKG-INFO +1 -1
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/interior_point.hpp +12 -2
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/newton.hpp +3 -1
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/sqp.hpp +6 -2
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/all_finite.hpp +4 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/append_as_triplets.hpp +4 -0
- sleipnirgroup_jormungandr-0.5.6.dev6/include/sleipnir/optimization/solver/util/dense_regularized_ldlt.hpp +186 -0
- sleipnirgroup_jormungandr-0.5.6.dev6/include/sleipnir/optimization/solver/util/regularized_ldlt.hpp +125 -0
- sleipnirgroup_jormungandr-0.5.6.dev4/include/sleipnir/optimization/solver/util/regularized_ldlt.hpp → sleipnirgroup_jormungandr-0.5.6.dev6/include/sleipnir/optimization/solver/util/sparse_regularized_ldlt.hpp +33 -74
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/src/sleipnir/__init__.py +1 -1
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/CMakeLists.txt +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/LICENSE.txt +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/README.md +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/SleipnirConfig.cmake.in +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/cmake/BuildTypes.cmake +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/cmake/CompilerFlags.cmake +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/cmake/Pybind11Mkdoc.cmake +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/cmake/SubdirList.cmake +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/cmake/arm-none-eabi.cmake +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/expression.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/expression_graph.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/expression_type.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/gradient.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/gradient_expression_graph.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/hessian.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/jacobian.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/sleipnir_base.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/slice.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/variable.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/variable_block.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/autodiff/variable_matrix.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/multistart.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/ocp/dynamics_type.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/ocp/timestep_method.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/ocp/transcription_method.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/ocp.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/problem.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/exit_status.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/interior_point_matrix_callbacks.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/iteration_info.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/newton_matrix_callbacks.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/options.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/sqp_matrix_callbacks.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/bounds.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/feasibility_restoration.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/filter.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/fraction_to_the_boundary_rule.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/inertia.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/is_locally_infeasible.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/kkt_error.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/optimization/solver/util/lagrange_multiplier_estimate.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/assert.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/concepts.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/empty.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/function_ref.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/intrusive_shared_ptr.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/pool.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/print.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/print_diagnostics.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/profiler.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/scope_exit.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/spy.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/include/sleipnir/util/symbol_exports.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/pyproject.toml +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/autodiff/bind_expression_type.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/autodiff/bind_gradient.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/autodiff/bind_hessian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/autodiff/bind_jacobian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/autodiff/bind_variable.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/autodiff/bind_variable_block.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/autodiff/bind_variable_matrix.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/binders.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/docstrings.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/for_each_type.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/main.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/optimization/bind_equality_constraints.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/optimization/bind_inequality_constraints.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/optimization/bind_ocp.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/optimization/bind_problem.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/optimization/ocp/bind_dynamics_type.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/optimization/ocp/bind_timestep_method.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/optimization/ocp/bind_transcription_method.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/optimization/solver/bind_exit_status.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/optimization/solver/bind_iteration_info.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/try_cast.hpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/src/sleipnir/autodiff/__init__.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/src/sleipnir/optimization/__init__.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/autodiff/gradient_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/autodiff/hessian_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/autodiff/jacobian_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/autodiff/variable_matrix_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/autodiff/variable_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/arm_on_elevator_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/cart_pole_ocp_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/cart_pole_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/cart_pole_util.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/constraints_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/decision_variable_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/differential_drive_ocp_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/differential_drive_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/differential_drive_util.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/double_integrator_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/flywheel_ocp_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/flywheel_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/linear_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/multistart_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/nonlinear_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/problem_spy_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/quadratic_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/rk4.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/solver/exit_status_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/test/optimization/trivial_problem_test.py +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/autodiff/gradient.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/autodiff/hessian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/autodiff/jacobian.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/autodiff/variable_matrix.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/optimization/ocp.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/optimization/problem.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/optimization/solver/interior_point.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/optimization/solver/newton.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/optimization/solver/sqp.cpp +0 -0
- {sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/util/pool.cpp +0 -0
|
@@ -333,10 +333,20 @@ ExitStatus interior_point(
|
|
|
333
333
|
// Kept outside the loop so its storage can be reused
|
|
334
334
|
gch::small_vector<Eigen::Triplet<Scalar>> triplets;
|
|
335
335
|
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
const int lhs_rows =
|
|
337
|
+
matrices.num_decision_variables + matrices.num_equality_constraints;
|
|
338
338
|
RegularizedLDLT<Scalar> solver{
|
|
339
|
+
// Use sparse solver if lower triangle fills < 25% of system
|
|
340
|
+
H.nonZeros() +
|
|
341
|
+
(A_i.transpose() * A_i)
|
|
342
|
+
.template triangularView<Eigen::Lower>()
|
|
343
|
+
.eval()
|
|
344
|
+
.nonZeros() +
|
|
345
|
+
A_e.nonZeros() <
|
|
346
|
+
0.25 * lhs_rows * lhs_rows,
|
|
339
347
|
matrices.num_decision_variables, matrices.num_equality_constraints,
|
|
348
|
+
// Constraint regularization is forced to zero in feasibility restoration
|
|
349
|
+
// because the equality constraint Jacobian cannot be rank-deficient
|
|
340
350
|
in_feasibility_restoration ? Scalar(0) : Scalar(1e-10)};
|
|
341
351
|
|
|
342
352
|
// Variables for determining when a step is acceptable
|
|
@@ -132,7 +132,9 @@ ExitStatus newton(
|
|
|
132
132
|
|
|
133
133
|
Filter<Scalar> filter;
|
|
134
134
|
|
|
135
|
-
RegularizedLDLT<Scalar> solver{
|
|
135
|
+
RegularizedLDLT<Scalar> solver{
|
|
136
|
+
// Use sparse solver if lower triangle fills < 25% of system
|
|
137
|
+
H.nonZeros() < 0.25 * H.size(), matrices.num_decision_variables, 0};
|
|
136
138
|
|
|
137
139
|
// Variables for determining when a step is acceptable
|
|
138
140
|
constexpr Scalar α_reduction_factor(0.5);
|
|
@@ -225,8 +225,12 @@ ExitStatus sqp(const SQPMatrixCallbacks<Scalar>& matrix_callbacks,
|
|
|
225
225
|
// Kept outside the loop so its storage can be reused
|
|
226
226
|
gch::small_vector<Eigen::Triplet<Scalar>> triplets;
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
const int lhs_rows =
|
|
229
|
+
matrices.num_decision_variables + matrices.num_equality_constraints;
|
|
230
|
+
RegularizedLDLT<Scalar> solver{
|
|
231
|
+
// Use sparse solver if lower triangle fills < 25% of system
|
|
232
|
+
H.nonZeros() + A_e.nonZeros() < 0.25 * lhs_rows * lhs_rows,
|
|
233
|
+
matrices.num_decision_variables, matrices.num_equality_constraints};
|
|
230
234
|
|
|
231
235
|
// Variables for determining when a step is acceptable
|
|
232
236
|
constexpr Scalar α_reduction_factor(0.5);
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
#include <Eigen/SparseCore>
|
|
8
8
|
|
|
9
|
+
namespace slp {
|
|
10
|
+
|
|
9
11
|
/// Returns true if elements of sparse matrix are all finite.
|
|
10
12
|
///
|
|
11
13
|
/// @param mat Sparse matrix.
|
|
@@ -24,3 +26,5 @@ bool all_finite(const Eigen::SparseCompressedBase<Derived>& mat) {
|
|
|
24
26
|
|
|
25
27
|
return true;
|
|
26
28
|
}
|
|
29
|
+
|
|
30
|
+
} // namespace slp
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
#include <Eigen/SparseCore>
|
|
8
8
|
#include <gch/small_vector.hpp>
|
|
9
9
|
|
|
10
|
+
namespace slp {
|
|
11
|
+
|
|
10
12
|
/// Appends sparse matrices to list of triplets at the given offset.
|
|
11
13
|
///
|
|
12
14
|
/// The triplets are appended in column-major order (e.g., first column of mat1,
|
|
@@ -58,3 +60,5 @@ void append_diagonal_as_triplets(
|
|
|
58
60
|
triplets.emplace_back(row_offset + row, col_offset + row, diag[row]);
|
|
59
61
|
}
|
|
60
62
|
}
|
|
63
|
+
|
|
64
|
+
} // namespace slp
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Copyright (c) Sleipnir contributors
|
|
2
|
+
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <Eigen/Cholesky>
|
|
6
|
+
#include <Eigen/Core>
|
|
7
|
+
|
|
8
|
+
#include "sleipnir/optimization/solver/util/inertia.hpp"
|
|
9
|
+
|
|
10
|
+
// See docs/algorithms.md#Works_cited for citation definitions
|
|
11
|
+
|
|
12
|
+
namespace slp {
|
|
13
|
+
|
|
14
|
+
/// Solves dense systems of linear equations using a regularized LDLT
|
|
15
|
+
/// factorization.
|
|
16
|
+
///
|
|
17
|
+
/// @tparam Scalar Scalar type.
|
|
18
|
+
template <typename Scalar>
|
|
19
|
+
class DenseRegularizedLDLT {
|
|
20
|
+
public:
|
|
21
|
+
/// Type alias for dense matrix.
|
|
22
|
+
using DenseMatrix = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>;
|
|
23
|
+
/// Type alias for dense vector.
|
|
24
|
+
using DenseVector = Eigen::Vector<Scalar, Eigen::Dynamic>;
|
|
25
|
+
|
|
26
|
+
/// Constructs a DenseRegularizedLDLT instance.
|
|
27
|
+
///
|
|
28
|
+
/// @param num_decision_variables The number of decision variables in the
|
|
29
|
+
/// system.
|
|
30
|
+
/// @param num_equality_constraints The number of equality constraints in the
|
|
31
|
+
/// system.
|
|
32
|
+
DenseRegularizedLDLT(int num_decision_variables, int num_equality_constraints)
|
|
33
|
+
: m_num_decision_variables{num_decision_variables},
|
|
34
|
+
m_num_equality_constraints{num_equality_constraints} {}
|
|
35
|
+
|
|
36
|
+
/// Constructs a DenseRegularizedLDLT instance.
|
|
37
|
+
///
|
|
38
|
+
/// @param num_decision_variables The number of decision variables in the
|
|
39
|
+
/// system.
|
|
40
|
+
/// @param num_equality_constraints The number of equality constraints in the
|
|
41
|
+
/// system.
|
|
42
|
+
/// @param γ_min The minimum constraint regularization.
|
|
43
|
+
DenseRegularizedLDLT(int num_decision_variables, int num_equality_constraints,
|
|
44
|
+
Scalar γ_min)
|
|
45
|
+
: m_num_decision_variables{num_decision_variables},
|
|
46
|
+
m_num_equality_constraints{num_equality_constraints},
|
|
47
|
+
m_γ_min{γ_min} {}
|
|
48
|
+
|
|
49
|
+
/// Reports whether previous computation was successful.
|
|
50
|
+
///
|
|
51
|
+
/// @return Whether previous computation was successful.
|
|
52
|
+
Eigen::ComputationInfo info() const { return m_info; }
|
|
53
|
+
|
|
54
|
+
/// Computes the regularized LDLT factorization of a matrix.
|
|
55
|
+
///
|
|
56
|
+
/// @param lhs Left-hand side of the system.
|
|
57
|
+
/// @return The factorization.
|
|
58
|
+
DenseRegularizedLDLT& compute(const DenseMatrix& lhs) {
|
|
59
|
+
// The regularization procedure is based on algorithm B.1 of [1]
|
|
60
|
+
|
|
61
|
+
m_info = m_solver.compute(lhs).info();
|
|
62
|
+
|
|
63
|
+
if (m_info == Eigen::Success) {
|
|
64
|
+
auto D = m_solver.vectorD();
|
|
65
|
+
|
|
66
|
+
// If the inertia is ideal and D from LDLT is sufficiently far from zero,
|
|
67
|
+
// don't regularize the system
|
|
68
|
+
if (Inertia{D} == ideal_inertia &&
|
|
69
|
+
(D.cwiseAbs().array() >= Scalar(1e-4)).all()) {
|
|
70
|
+
m_prev_δ = Scalar(0);
|
|
71
|
+
return *this;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Also regularize the Hessian. If the Hessian wasn't regularized in a
|
|
76
|
+
// previous run of compute(), start at small values of δ and γ. Otherwise,
|
|
77
|
+
// attempt a δ and γ half as big as the previous run so δ and γ can trend
|
|
78
|
+
// downwards over time.
|
|
79
|
+
Scalar δ = m_prev_δ == Scalar(0) ? Scalar(1e-4) : m_prev_δ / Scalar(2);
|
|
80
|
+
Scalar γ = m_γ_min;
|
|
81
|
+
|
|
82
|
+
while (true) {
|
|
83
|
+
m_info = m_solver.compute(lhs + regularization(δ, γ)).info();
|
|
84
|
+
|
|
85
|
+
if (m_info == Eigen::Success) {
|
|
86
|
+
Inertia inertia{m_solver.vectorD()};
|
|
87
|
+
|
|
88
|
+
if (inertia == ideal_inertia) {
|
|
89
|
+
// If the inertia is ideal, store δ and return
|
|
90
|
+
m_prev_δ = δ;
|
|
91
|
+
return *this;
|
|
92
|
+
} else if (inertia.zero > 0) {
|
|
93
|
+
// If there's zero eigenvalues, increase δ and γ by an order of
|
|
94
|
+
// magnitude and try again
|
|
95
|
+
δ *= Scalar(10);
|
|
96
|
+
γ *= Scalar(10);
|
|
97
|
+
} else if (inertia.negative > ideal_inertia.negative) {
|
|
98
|
+
// If there's too many negative eigenvalues, increase δ by an order of
|
|
99
|
+
// magnitude and try again
|
|
100
|
+
δ *= Scalar(10);
|
|
101
|
+
} else if (inertia.positive > ideal_inertia.positive) {
|
|
102
|
+
// If there's too many positive eigenvalues, increase γ by an order of
|
|
103
|
+
// magnitude and try again
|
|
104
|
+
γ = γ == Scalar(0) ? Scalar(1e-10) : γ * Scalar(10);
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
// If the decomposition failed, increase δ and γ by an order of
|
|
108
|
+
// magnitude and try again
|
|
109
|
+
δ *= Scalar(10);
|
|
110
|
+
γ *= Scalar(10);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// If the Hessian perturbation is too high, report failure. This can be
|
|
114
|
+
// caused by ill-conditioning.
|
|
115
|
+
if (δ > Scalar(1e20) || γ > Scalar(1e20)) {
|
|
116
|
+
m_info = Eigen::NumericalIssue;
|
|
117
|
+
return *this;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// Solves the system of equations using a regularized LDLT factorization.
|
|
123
|
+
///
|
|
124
|
+
/// @param rhs Right-hand side of the system.
|
|
125
|
+
/// @return The solution.
|
|
126
|
+
template <typename Rhs>
|
|
127
|
+
DenseVector solve(const Eigen::MatrixBase<Rhs>& rhs) const {
|
|
128
|
+
return m_solver.solve(rhs);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// Solves the system of equations using a regularized LDLT factorization.
|
|
132
|
+
///
|
|
133
|
+
/// @param rhs Right-hand side of the system.
|
|
134
|
+
/// @return The solution.
|
|
135
|
+
template <typename Rhs>
|
|
136
|
+
DenseVector solve(const Eigen::SparseMatrixBase<Rhs>& rhs) const {
|
|
137
|
+
return m_solver.solve(rhs.toDense());
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/// Returns the Hessian regularization factor.
|
|
141
|
+
///
|
|
142
|
+
/// @return Hessian regularization factor.
|
|
143
|
+
Scalar hessian_regularization() const { return m_prev_δ; }
|
|
144
|
+
|
|
145
|
+
private:
|
|
146
|
+
using Solver = Eigen::LDLT<DenseMatrix>;
|
|
147
|
+
|
|
148
|
+
Solver m_solver;
|
|
149
|
+
|
|
150
|
+
Eigen::ComputationInfo m_info = Eigen::Success;
|
|
151
|
+
|
|
152
|
+
/// The number of decision variables in the system.
|
|
153
|
+
int m_num_decision_variables = 0;
|
|
154
|
+
|
|
155
|
+
/// The number of equality constraints in the system.
|
|
156
|
+
int m_num_equality_constraints = 0;
|
|
157
|
+
|
|
158
|
+
/// The minimum constraint regularization.
|
|
159
|
+
Scalar m_γ_min{1e-10};
|
|
160
|
+
|
|
161
|
+
/// The ideal system inertia.
|
|
162
|
+
Inertia ideal_inertia{m_num_decision_variables, m_num_equality_constraints,
|
|
163
|
+
0};
|
|
164
|
+
|
|
165
|
+
/// The value of δ from the previous run of compute().
|
|
166
|
+
Scalar m_prev_δ{0};
|
|
167
|
+
|
|
168
|
+
/// Returns regularization matrix.
|
|
169
|
+
///
|
|
170
|
+
/// [δI 0]
|
|
171
|
+
/// [ 0 −γI]
|
|
172
|
+
///
|
|
173
|
+
/// @param δ The Hessian regularization factor.
|
|
174
|
+
/// @param γ The equality constraint Jacobian regularization factor.
|
|
175
|
+
/// @return Regularization matrix.
|
|
176
|
+
DenseMatrix regularization(Scalar δ, Scalar γ) const {
|
|
177
|
+
DenseVector vec{m_num_decision_variables + m_num_equality_constraints};
|
|
178
|
+
vec.segment(0, m_num_decision_variables).setConstant(δ);
|
|
179
|
+
vec.segment(m_num_decision_variables, m_num_equality_constraints)
|
|
180
|
+
.setConstant(-γ);
|
|
181
|
+
|
|
182
|
+
return vec.asDiagonal().toDenseMatrix();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
} // namespace slp
|
sleipnirgroup_jormungandr-0.5.6.dev6/include/sleipnir/optimization/solver/util/regularized_ldlt.hpp
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Copyright (c) Sleipnir contributors
|
|
2
|
+
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <Eigen/Core>
|
|
6
|
+
#include <Eigen/SparseCore>
|
|
7
|
+
|
|
8
|
+
#include "sleipnir/optimization/solver/util/dense_regularized_ldlt.hpp"
|
|
9
|
+
#include "sleipnir/optimization/solver/util/sparse_regularized_ldlt.hpp"
|
|
10
|
+
|
|
11
|
+
namespace slp {
|
|
12
|
+
|
|
13
|
+
/// Solves systems of linear equations using a regularized LDLT factorization.
|
|
14
|
+
///
|
|
15
|
+
/// @tparam Scalar Scalar type.
|
|
16
|
+
template <typename Scalar>
|
|
17
|
+
class RegularizedLDLT {
|
|
18
|
+
public:
|
|
19
|
+
/// Type alias for dense vector.
|
|
20
|
+
using DenseVector = Eigen::Vector<Scalar, Eigen::Dynamic>;
|
|
21
|
+
/// Type alias for sparse matrix.
|
|
22
|
+
using SparseMatrix = Eigen::SparseMatrix<Scalar>;
|
|
23
|
+
|
|
24
|
+
/// Constructs a RegularizedLDLT instance.
|
|
25
|
+
///
|
|
26
|
+
/// @param use_sparse_solver Whether to use sparse or dense solver.
|
|
27
|
+
/// @param num_decision_variables The number of decision variables in the
|
|
28
|
+
/// system.
|
|
29
|
+
/// @param num_equality_constraints The number of equality constraints in the
|
|
30
|
+
/// system.
|
|
31
|
+
RegularizedLDLT(bool use_sparse_solver, int num_decision_variables,
|
|
32
|
+
int num_equality_constraints)
|
|
33
|
+
: m_use_sparse_solver{use_sparse_solver},
|
|
34
|
+
m_sparse_solver{num_decision_variables, num_equality_constraints},
|
|
35
|
+
m_dense_solver{num_decision_variables, num_equality_constraints} {}
|
|
36
|
+
|
|
37
|
+
/// Constructs a RegularizedLDLT instance.
|
|
38
|
+
///
|
|
39
|
+
/// @param use_sparse_solver Whether to use sparse or dense solver.
|
|
40
|
+
/// @param num_decision_variables The number of decision variables in the
|
|
41
|
+
/// system.
|
|
42
|
+
/// @param num_equality_constraints The number of equality constraints in the
|
|
43
|
+
/// system.
|
|
44
|
+
/// @param γ_min The minimum constraint regularization.
|
|
45
|
+
RegularizedLDLT(bool use_sparse_solver, int num_decision_variables,
|
|
46
|
+
int num_equality_constraints, Scalar γ_min)
|
|
47
|
+
: m_use_sparse_solver{use_sparse_solver},
|
|
48
|
+
m_sparse_solver{num_decision_variables, num_equality_constraints,
|
|
49
|
+
γ_min},
|
|
50
|
+
m_dense_solver{num_decision_variables, num_equality_constraints,
|
|
51
|
+
γ_min} {}
|
|
52
|
+
|
|
53
|
+
/// Reports whether previous computation was successful.
|
|
54
|
+
///
|
|
55
|
+
/// @return Whether previous computation was successful.
|
|
56
|
+
Eigen::ComputationInfo info() const {
|
|
57
|
+
if (m_use_sparse_solver) {
|
|
58
|
+
return m_sparse_solver.info();
|
|
59
|
+
} else {
|
|
60
|
+
return m_dense_solver.info();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// Computes the regularized LDLT factorization of a matrix.
|
|
65
|
+
///
|
|
66
|
+
/// In sparse mode, the matrix's symbolic decomposition is reused in
|
|
67
|
+
/// subsequent calls, so subsequent calls must be given a matrix with the same
|
|
68
|
+
/// sparsity pattern.
|
|
69
|
+
///
|
|
70
|
+
/// @param lhs Left-hand side of the system.
|
|
71
|
+
/// @return The factorization.
|
|
72
|
+
RegularizedLDLT& compute(const SparseMatrix& lhs) {
|
|
73
|
+
if (m_use_sparse_solver) {
|
|
74
|
+
m_sparse_solver.compute(lhs);
|
|
75
|
+
} else {
|
|
76
|
+
m_dense_solver.compute(lhs);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return *this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// Solves the system of equations using a regularized LDLT factorization.
|
|
83
|
+
///
|
|
84
|
+
/// @param rhs Right-hand side of the system.
|
|
85
|
+
/// @return The solution.
|
|
86
|
+
template <typename Rhs>
|
|
87
|
+
DenseVector solve(const Eigen::MatrixBase<Rhs>& rhs) const {
|
|
88
|
+
if (m_use_sparse_solver) {
|
|
89
|
+
return m_sparse_solver.solve(rhs);
|
|
90
|
+
} else {
|
|
91
|
+
return m_dense_solver.solve(rhs);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// Solves the system of equations using a regularized LDLT factorization.
|
|
96
|
+
///
|
|
97
|
+
/// @param rhs Right-hand side of the system.
|
|
98
|
+
/// @return The solution.
|
|
99
|
+
template <typename Rhs>
|
|
100
|
+
DenseVector solve(const Eigen::SparseMatrixBase<Rhs>& rhs) const {
|
|
101
|
+
if (m_use_sparse_solver) {
|
|
102
|
+
return m_sparse_solver.solve(rhs);
|
|
103
|
+
} else {
|
|
104
|
+
return m_dense_solver.solve(rhs);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// Returns the Hessian regularization factor.
|
|
109
|
+
///
|
|
110
|
+
/// @return Hessian regularization factor.
|
|
111
|
+
Scalar hessian_regularization() const {
|
|
112
|
+
if (m_use_sparse_solver) {
|
|
113
|
+
return m_sparse_solver.hessian_regularization();
|
|
114
|
+
} else {
|
|
115
|
+
return m_dense_solver.hessian_regularization();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private:
|
|
120
|
+
bool m_use_sparse_solver;
|
|
121
|
+
SparseRegularizedLDLT<Scalar> m_sparse_solver;
|
|
122
|
+
DenseRegularizedLDLT<Scalar> m_dense_solver;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
} // namespace slp
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
#pragma once
|
|
4
4
|
|
|
5
|
-
#include <Eigen/Cholesky>
|
|
6
5
|
#include <Eigen/Core>
|
|
7
6
|
#include <Eigen/SparseCholesky>
|
|
8
7
|
#include <Eigen/SparseCore>
|
|
@@ -13,38 +12,38 @@
|
|
|
13
12
|
|
|
14
13
|
namespace slp {
|
|
15
14
|
|
|
16
|
-
/// Solves systems of linear equations using a regularized LDLT
|
|
15
|
+
/// Solves sparse systems of linear equations using a regularized LDLT
|
|
16
|
+
/// factorization.
|
|
17
17
|
///
|
|
18
18
|
/// @tparam Scalar Scalar type.
|
|
19
19
|
template <typename Scalar>
|
|
20
|
-
class
|
|
20
|
+
class SparseRegularizedLDLT {
|
|
21
21
|
public:
|
|
22
|
-
/// Type alias for dense matrix.
|
|
23
|
-
using DenseMatrix = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>;
|
|
24
22
|
/// Type alias for dense vector.
|
|
25
23
|
using DenseVector = Eigen::Vector<Scalar, Eigen::Dynamic>;
|
|
26
24
|
/// Type alias for sparse matrix.
|
|
27
25
|
using SparseMatrix = Eigen::SparseMatrix<Scalar>;
|
|
28
26
|
|
|
29
|
-
/// Constructs a
|
|
27
|
+
/// Constructs a SparseRegularizedLDLT instance.
|
|
30
28
|
///
|
|
31
29
|
/// @param num_decision_variables The number of decision variables in the
|
|
32
30
|
/// system.
|
|
33
31
|
/// @param num_equality_constraints The number of equality constraints in the
|
|
34
32
|
/// system.
|
|
35
|
-
|
|
33
|
+
SparseRegularizedLDLT(int num_decision_variables,
|
|
34
|
+
int num_equality_constraints)
|
|
36
35
|
: m_num_decision_variables{num_decision_variables},
|
|
37
36
|
m_num_equality_constraints{num_equality_constraints} {}
|
|
38
37
|
|
|
39
|
-
/// Constructs a
|
|
38
|
+
/// Constructs a SparseRegularizedLDLT instance.
|
|
40
39
|
///
|
|
41
40
|
/// @param num_decision_variables The number of decision variables in the
|
|
42
41
|
/// system.
|
|
43
42
|
/// @param num_equality_constraints The number of equality constraints in the
|
|
44
43
|
/// system.
|
|
45
44
|
/// @param γ_min The minimum constraint regularization.
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
SparseRegularizedLDLT(int num_decision_variables,
|
|
46
|
+
int num_equality_constraints, Scalar γ_min)
|
|
48
47
|
: m_num_decision_variables{num_decision_variables},
|
|
49
48
|
m_num_equality_constraints{num_equality_constraints},
|
|
50
49
|
m_γ_min{γ_min} {}
|
|
@@ -61,23 +60,23 @@ class RegularizedLDLT {
|
|
|
61
60
|
///
|
|
62
61
|
/// @param lhs Left-hand side of the system.
|
|
63
62
|
/// @return The factorization.
|
|
64
|
-
|
|
63
|
+
SparseRegularizedLDLT& compute(const SparseMatrix& lhs) {
|
|
65
64
|
// The regularization procedure is based on algorithm B.1 of [1]
|
|
66
65
|
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
|
|
66
|
+
// Regularization with zeros ensures the pattern analysis in the sparse
|
|
67
|
+
// solver is reused by all factorizations
|
|
68
|
+
SparseMatrix unregularized_lhs = lhs + regularization(Scalar(0), Scalar(0));
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
if (!m_analyzed_pattern) {
|
|
71
|
+
m_solver.analyzePattern(unregularized_lhs);
|
|
72
|
+
m_analyzed_pattern = true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
m_solver.factorize(unregularized_lhs);
|
|
76
|
+
m_info = m_solver.info();
|
|
77
77
|
|
|
78
78
|
if (m_info == Eigen::Success) {
|
|
79
|
-
auto D =
|
|
80
|
-
m_is_sparse ? m_sparse_solver.vectorD() : m_dense_solver.vectorD();
|
|
79
|
+
auto D = m_solver.vectorD();
|
|
81
80
|
|
|
82
81
|
// If the inertia is ideal and D from LDLT is sufficiently far from zero,
|
|
83
82
|
// don't regularize the system
|
|
@@ -96,25 +95,12 @@ class RegularizedLDLT {
|
|
|
96
95
|
Scalar γ = m_γ_min;
|
|
97
96
|
|
|
98
97
|
while (true) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// Regularize lhs by adding a multiple of the identity matrix
|
|
102
|
-
//
|
|
103
|
-
// lhs = [H + AᵢᵀΣAᵢ + δI Aₑᵀ]
|
|
104
|
-
// [ Aₑ −γI]
|
|
105
|
-
if (m_is_sparse) {
|
|
106
|
-
m_info = compute_sparse(lhs + regularization(δ, γ)).info();
|
|
107
|
-
if (m_info == Eigen::Success) {
|
|
108
|
-
inertia = Inertia{m_sparse_solver.vectorD()};
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
m_info = m_dense_solver.compute(lhs + regularization(δ, γ)).info();
|
|
112
|
-
if (m_info == Eigen::Success) {
|
|
113
|
-
inertia = Inertia{m_dense_solver.vectorD()};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
98
|
+
m_solver.factorize(lhs + regularization(δ, γ));
|
|
99
|
+
m_info = m_solver.info();
|
|
116
100
|
|
|
117
101
|
if (m_info == Eigen::Success) {
|
|
102
|
+
Inertia inertia{m_solver.vectorD()};
|
|
103
|
+
|
|
118
104
|
if (inertia == ideal_inertia) {
|
|
119
105
|
// If the inertia is ideal, store δ and return
|
|
120
106
|
m_prev_δ = δ;
|
|
@@ -155,11 +141,7 @@ class RegularizedLDLT {
|
|
|
155
141
|
/// @return The solution.
|
|
156
142
|
template <typename Rhs>
|
|
157
143
|
DenseVector solve(const Eigen::MatrixBase<Rhs>& rhs) const {
|
|
158
|
-
|
|
159
|
-
return m_sparse_solver.solve(rhs);
|
|
160
|
-
} else {
|
|
161
|
-
return m_dense_solver.solve(rhs);
|
|
162
|
-
}
|
|
144
|
+
return m_solver.solve(rhs);
|
|
163
145
|
}
|
|
164
146
|
|
|
165
147
|
/// Solves the system of equations using a regularized LDLT factorization.
|
|
@@ -168,11 +150,7 @@ class RegularizedLDLT {
|
|
|
168
150
|
/// @return The solution.
|
|
169
151
|
template <typename Rhs>
|
|
170
152
|
DenseVector solve(const Eigen::SparseMatrixBase<Rhs>& rhs) const {
|
|
171
|
-
|
|
172
|
-
return m_sparse_solver.solve(rhs);
|
|
173
|
-
} else {
|
|
174
|
-
return m_dense_solver.solve(rhs.toDense());
|
|
175
|
-
}
|
|
153
|
+
return m_solver.solve(rhs);
|
|
176
154
|
}
|
|
177
155
|
|
|
178
156
|
/// Returns the Hessian regularization factor.
|
|
@@ -181,12 +159,10 @@ class RegularizedLDLT {
|
|
|
181
159
|
Scalar hessian_regularization() const { return m_prev_δ; }
|
|
182
160
|
|
|
183
161
|
private:
|
|
184
|
-
using
|
|
185
|
-
using DenseSolver = Eigen::LDLT<DenseMatrix>;
|
|
162
|
+
using Solver = Eigen::SimplicialLDLT<SparseMatrix>;
|
|
186
163
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
bool m_is_sparse = true;
|
|
164
|
+
Solver m_solver;
|
|
165
|
+
bool m_analyzed_pattern = false;
|
|
190
166
|
|
|
191
167
|
Eigen::ComputationInfo m_info = Eigen::Success;
|
|
192
168
|
|
|
@@ -206,28 +182,11 @@ class RegularizedLDLT {
|
|
|
206
182
|
/// The value of δ from the previous run of compute().
|
|
207
183
|
Scalar m_prev_δ{0};
|
|
208
184
|
|
|
209
|
-
// Number of non-zeros in LHS.
|
|
210
|
-
int m_non_zeros = -1;
|
|
211
|
-
|
|
212
|
-
/// Computes factorization of a sparse matrix.
|
|
213
|
-
///
|
|
214
|
-
/// @param lhs Matrix to factorize.
|
|
215
|
-
/// @return The factorization.
|
|
216
|
-
SparseSolver& compute_sparse(const SparseMatrix& lhs) {
|
|
217
|
-
// Reanalize lhs's sparsity pattern if it changed
|
|
218
|
-
int non_zeros = lhs.nonZeros();
|
|
219
|
-
if (m_non_zeros != non_zeros) {
|
|
220
|
-
m_sparse_solver.analyzePattern(lhs);
|
|
221
|
-
m_non_zeros = non_zeros;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
m_sparse_solver.factorize(lhs);
|
|
225
|
-
|
|
226
|
-
return m_sparse_solver;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
185
|
/// Returns regularization matrix.
|
|
230
186
|
///
|
|
187
|
+
/// [δI 0]
|
|
188
|
+
/// [ 0 −γI]
|
|
189
|
+
///
|
|
231
190
|
/// @param δ The Hessian regularization factor.
|
|
232
191
|
/// @param γ The equality constraint Jacobian regularization factor.
|
|
233
192
|
/// @return Regularization matrix.
|
{sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/CMakeLists.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/cmake/BuildTypes.cmake
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/cmake/SubdirList.cmake
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/pyproject.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/binders.hpp
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/python/cpp/main.cpp
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sleipnirgroup_jormungandr-0.5.6.dev4 → sleipnirgroup_jormungandr-0.5.6.dev6}/src/util/pool.cpp
RENAMED
|
File without changes
|