sleipnirgroup-jormungandr 0.5.6.dev6__tar.gz → 0.5.6.dev7__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.
Files changed (124) hide show
  1. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/PKG-INFO +1 -1
  2. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/problem.hpp +45 -24
  3. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/interior_point.hpp +12 -10
  4. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/interior_point_matrix_callbacks.hpp +6 -0
  5. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/newton.hpp +6 -3
  6. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/newton_matrix_callbacks.hpp +6 -0
  7. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/sqp.hpp +6 -3
  8. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/sqp_matrix_callbacks.hpp +6 -0
  9. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/feasibility_restoration.hpp +19 -2
  10. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/kkt_error.hpp +113 -0
  11. sleipnirgroup_jormungandr-0.5.6.dev7/include/sleipnir/optimization/solver/util/problem_scaling.hpp +116 -0
  12. sleipnirgroup_jormungandr-0.5.6.dev7/include/sleipnir/optimization/solver/util/sparse_inf_norms.hpp +34 -0
  13. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/src/sleipnir/__init__.py +1 -1
  14. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/CMakeLists.txt +0 -0
  15. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/LICENSE.txt +0 -0
  16. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/README.md +0 -0
  17. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/SleipnirConfig.cmake.in +0 -0
  18. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/cmake/BuildTypes.cmake +0 -0
  19. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/cmake/CompilerFlags.cmake +0 -0
  20. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/cmake/Pybind11Mkdoc.cmake +0 -0
  21. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/cmake/SubdirList.cmake +0 -0
  22. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/cmake/arm-none-eabi.cmake +0 -0
  23. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/expression.hpp +0 -0
  24. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/expression_graph.hpp +0 -0
  25. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/expression_type.hpp +0 -0
  26. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/gradient.hpp +0 -0
  27. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/gradient_expression_graph.hpp +0 -0
  28. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/hessian.hpp +0 -0
  29. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/jacobian.hpp +0 -0
  30. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/sleipnir_base.hpp +0 -0
  31. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/slice.hpp +0 -0
  32. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/variable.hpp +0 -0
  33. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/variable_block.hpp +0 -0
  34. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/autodiff/variable_matrix.hpp +0 -0
  35. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/multistart.hpp +0 -0
  36. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/ocp/dynamics_type.hpp +0 -0
  37. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/ocp/timestep_method.hpp +0 -0
  38. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/ocp/transcription_method.hpp +0 -0
  39. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/ocp.hpp +0 -0
  40. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/exit_status.hpp +0 -0
  41. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/iteration_info.hpp +0 -0
  42. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/options.hpp +0 -0
  43. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/all_finite.hpp +0 -0
  44. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/append_as_triplets.hpp +0 -0
  45. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/bounds.hpp +0 -0
  46. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/dense_regularized_ldlt.hpp +0 -0
  47. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/filter.hpp +0 -0
  48. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/fraction_to_the_boundary_rule.hpp +0 -0
  49. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/inertia.hpp +0 -0
  50. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/is_locally_infeasible.hpp +0 -0
  51. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/lagrange_multiplier_estimate.hpp +0 -0
  52. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/regularized_ldlt.hpp +0 -0
  53. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/optimization/solver/util/sparse_regularized_ldlt.hpp +0 -0
  54. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/assert.hpp +0 -0
  55. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/concepts.hpp +0 -0
  56. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/empty.hpp +0 -0
  57. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/function_ref.hpp +0 -0
  58. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/intrusive_shared_ptr.hpp +0 -0
  59. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/pool.hpp +0 -0
  60. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/print.hpp +0 -0
  61. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/print_diagnostics.hpp +0 -0
  62. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/profiler.hpp +0 -0
  63. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/scope_exit.hpp +0 -0
  64. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/spy.hpp +0 -0
  65. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/include/sleipnir/util/symbol_exports.hpp +0 -0
  66. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/pyproject.toml +0 -0
  67. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/autodiff/bind_expression_type.cpp +0 -0
  68. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/autodiff/bind_gradient.cpp +0 -0
  69. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/autodiff/bind_hessian.cpp +0 -0
  70. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/autodiff/bind_jacobian.cpp +0 -0
  71. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/autodiff/bind_variable.cpp +0 -0
  72. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/autodiff/bind_variable_block.cpp +0 -0
  73. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/autodiff/bind_variable_matrix.cpp +0 -0
  74. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/binders.hpp +0 -0
  75. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/docstrings.hpp +0 -0
  76. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/for_each_type.hpp +0 -0
  77. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/main.cpp +0 -0
  78. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/optimization/bind_equality_constraints.cpp +0 -0
  79. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/optimization/bind_inequality_constraints.cpp +0 -0
  80. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/optimization/bind_ocp.cpp +0 -0
  81. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/optimization/bind_problem.cpp +0 -0
  82. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/optimization/ocp/bind_dynamics_type.cpp +0 -0
  83. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/optimization/ocp/bind_timestep_method.cpp +0 -0
  84. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/optimization/ocp/bind_transcription_method.cpp +0 -0
  85. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/optimization/solver/bind_exit_status.cpp +0 -0
  86. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/optimization/solver/bind_iteration_info.cpp +0 -0
  87. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/cpp/try_cast.hpp +0 -0
  88. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/src/sleipnir/autodiff/__init__.py +0 -0
  89. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/src/sleipnir/optimization/__init__.py +0 -0
  90. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/autodiff/gradient_test.py +0 -0
  91. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/autodiff/hessian_test.py +0 -0
  92. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/autodiff/jacobian_test.py +0 -0
  93. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/autodiff/variable_matrix_test.py +0 -0
  94. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/autodiff/variable_test.py +0 -0
  95. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/arm_on_elevator_problem_test.py +0 -0
  96. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/cart_pole_ocp_test.py +0 -0
  97. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/cart_pole_problem_test.py +0 -0
  98. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/cart_pole_util.py +0 -0
  99. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/constraints_test.py +0 -0
  100. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/decision_variable_test.py +0 -0
  101. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/differential_drive_ocp_test.py +0 -0
  102. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/differential_drive_problem_test.py +0 -0
  103. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/differential_drive_util.py +0 -0
  104. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/double_integrator_problem_test.py +0 -0
  105. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/flywheel_ocp_test.py +0 -0
  106. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/flywheel_problem_test.py +0 -0
  107. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/linear_problem_test.py +0 -0
  108. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/multistart_test.py +0 -0
  109. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/nonlinear_problem_test.py +0 -0
  110. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/problem_spy_test.py +0 -0
  111. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/quadratic_problem_test.py +0 -0
  112. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/rk4.py +0 -0
  113. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/solver/exit_status_test.py +0 -0
  114. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/python/test/optimization/trivial_problem_test.py +0 -0
  115. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/autodiff/gradient.cpp +0 -0
  116. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/autodiff/hessian.cpp +0 -0
  117. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/autodiff/jacobian.cpp +0 -0
  118. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/autodiff/variable_matrix.cpp +0 -0
  119. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/optimization/ocp.cpp +0 -0
  120. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/optimization/problem.cpp +0 -0
  121. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/optimization/solver/interior_point.cpp +0 -0
  122. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/optimization/solver/newton.cpp +0 -0
  123. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/optimization/solver/sqp.cpp +0 -0
  124. {sleipnirgroup_jormungandr-0.5.6.dev6 → sleipnirgroup_jormungandr-0.5.6.dev7}/src/util/pool.cpp +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sleipnirgroup-jormungandr
3
- Version: 0.5.6.dev6
3
+ Version: 0.5.6.dev7
4
4
  Summary: Reverse mode autodiff library and NLP solver DSL
5
5
  License-Expression: BSD-3-Clause
6
6
  License-File: LICENSE.txt
@@ -30,6 +30,7 @@
30
30
  #include "sleipnir/optimization/solver/options.hpp"
31
31
  #include "sleipnir/optimization/solver/sqp.hpp"
32
32
  #include "sleipnir/optimization/solver/util/bounds.hpp"
33
+ #include "sleipnir/optimization/solver/util/problem_scaling.hpp"
33
34
  #include "sleipnir/util/empty.hpp"
34
35
  #include "sleipnir/util/print.hpp"
35
36
  #include "sleipnir/util/print_diagnostics.hpp"
@@ -375,20 +376,26 @@ class Problem {
375
376
  }
376
377
  #endif
377
378
 
379
+ // Automatically scale the cost. The problem scaling procedure is
380
+ // described in more detail in docs/algorithms.md#problem-scaling.
381
+ x_ad.set_value(x);
382
+ const ProblemScaling<Scalar> scaling{g.value()};
383
+
378
384
  NewtonMatrixCallbacks<Scalar> matrix_callbacks{
379
385
  num_decision_variables,
380
386
  [&](const DenseVector& x) -> Scalar {
381
387
  x_ad.set_value(x);
382
- return f.value();
388
+ return scaling.f * f.value();
383
389
  },
384
390
  [&](const DenseVector& x) -> SparseVector {
385
391
  x_ad.set_value(x);
386
- return g.value();
392
+ return scaling.f * g.value();
387
393
  },
388
394
  [&](const DenseVector& x) -> SparseMatrix {
389
395
  x_ad.set_value(x);
390
- return H.value();
391
- }};
396
+ return scaling.f * H.value();
397
+ },
398
+ scaling};
392
399
 
393
400
  // Invoke Newton solver
394
401
  status =
@@ -463,35 +470,42 @@ class Problem {
463
470
  }
464
471
  #endif
465
472
 
473
+ // Automatically scale the cost and constraints. The problem scaling
474
+ // procedure is described in more detail in
475
+ // docs/algorithms.md#problem-scaling.
476
+ x_ad.set_value(x);
477
+ const ProblemScaling<Scalar> scaling{g.value(), A_e.value()};
478
+
466
479
  SQPMatrixCallbacks<Scalar> matrix_callbacks{
467
480
  num_decision_variables,
468
481
  num_equality_constraints,
469
482
  [&](const DenseVector& x) -> Scalar {
470
483
  x_ad.set_value(x);
471
- return f.value();
484
+ return scaling.f * f.value();
472
485
  },
473
486
  [&](const DenseVector& x) -> SparseVector {
474
487
  x_ad.set_value(x);
475
- return g.value();
488
+ return scaling.f * g.value();
476
489
  },
477
490
  [&](const DenseVector& x, const DenseVector& y) -> SparseMatrix {
478
491
  x_ad.set_value(x);
479
- y_ad.set_value(y);
480
- return H_f.value() + H_c.value();
492
+ y_ad.set_value(scaling.c_e.cwiseProduct(y));
493
+ return scaling.f * H_f.value() + H_c.value();
481
494
  },
482
495
  [&](const DenseVector& x, const DenseVector& y) -> SparseMatrix {
483
496
  x_ad.set_value(x);
484
- y_ad.set_value(y);
497
+ y_ad.set_value(scaling.c_e.cwiseProduct(y));
485
498
  return H_c.value();
486
499
  },
487
500
  [&](const DenseVector& x) -> DenseVector {
488
501
  x_ad.set_value(x);
489
- return c_e_ad.value();
502
+ return scaling.c_e.cwiseProduct(c_e_ad.value());
490
503
  },
491
504
  [&](const DenseVector& x) -> SparseMatrix {
492
505
  x_ad.set_value(x);
493
- return A_e.value();
494
- }};
506
+ return scaling.c_e.asDiagonal() * A_e.value();
507
+ },
508
+ scaling};
495
509
 
496
510
  // Invoke SQP solver
497
511
  status = sqp<Scalar>(matrix_callbacks, iteration_callbacks, options, x);
@@ -595,48 +609,55 @@ class Problem {
595
609
  project_onto_bounds(x, bounds);
596
610
  #endif
597
611
 
612
+ // Automatically scale the cost and constraints. The problem scaling
613
+ // procedure is described in more detail in
614
+ // docs/algorithms.md#problem-scaling.
615
+ x_ad.set_value(x);
616
+ const ProblemScaling<Scalar> scaling{g.value(), A_e.value(), A_i.value()};
617
+
598
618
  InteriorPointMatrixCallbacks<Scalar> matrix_callbacks{
599
619
  num_decision_variables,
600
620
  num_equality_constraints,
601
621
  num_inequality_constraints,
602
622
  [&](const DenseVector& x) -> Scalar {
603
623
  x_ad.set_value(x);
604
- return f.value();
624
+ return scaling.f * f.value();
605
625
  },
606
626
  [&](const DenseVector& x) -> SparseVector {
607
627
  x_ad.set_value(x);
608
- return g.value();
628
+ return scaling.f * g.value();
609
629
  },
610
630
  [&](const DenseVector& x, const DenseVector& y,
611
631
  const DenseVector& z) -> SparseMatrix {
612
632
  x_ad.set_value(x);
613
- y_ad.set_value(y);
614
- z_ad.set_value(z);
615
- return H_f.value() + H_c.value();
633
+ y_ad.set_value(scaling.c_e.cwiseProduct(y));
634
+ z_ad.set_value(scaling.c_i.cwiseProduct(z));
635
+ return scaling.f * H_f.value() + H_c.value();
616
636
  },
617
637
  [&](const DenseVector& x, const DenseVector& y,
618
638
  const DenseVector& z) -> SparseMatrix {
619
639
  x_ad.set_value(x);
620
- y_ad.set_value(y);
621
- z_ad.set_value(z);
640
+ y_ad.set_value(scaling.c_e.cwiseProduct(y));
641
+ z_ad.set_value(scaling.c_i.cwiseProduct(z));
622
642
  return H_c.value();
623
643
  },
624
644
  [&](const DenseVector& x) -> DenseVector {
625
645
  x_ad.set_value(x);
626
- return c_e_ad.value();
646
+ return scaling.c_e.cwiseProduct(c_e_ad.value());
627
647
  },
628
648
  [&](const DenseVector& x) -> SparseMatrix {
629
649
  x_ad.set_value(x);
630
- return A_e.value();
650
+ return scaling.c_e.asDiagonal() * A_e.value();
631
651
  },
632
652
  [&](const DenseVector& x) -> DenseVector {
633
653
  x_ad.set_value(x);
634
- return c_i_ad.value();
654
+ return scaling.c_i.cwiseProduct(c_i_ad.value());
635
655
  },
636
656
  [&](const DenseVector& x) -> SparseMatrix {
637
657
  x_ad.set_value(x);
638
- return A_i.value();
639
- }};
658
+ return scaling.c_i.asDiagonal() * A_i.value();
659
+ },
660
+ scaling};
640
661
 
641
662
  // Invoke interior-point method solver
642
663
  status =
@@ -76,7 +76,7 @@ ExitStatus interior_point(
76
76
  DenseVector y = DenseVector::Zero(matrix_callbacks.num_equality_constraints);
77
77
  DenseVector z =
78
78
  DenseVector::Ones(matrix_callbacks.num_inequality_constraints);
79
- Scalar μ(0.1);
79
+ Scalar μ = Scalar(0.1) * matrix_callbacks.scaling.f;
80
80
 
81
81
  return interior_point(matrix_callbacks, iteration_callbacks, options, false,
82
82
  #ifdef SLEIPNIR_ENABLE_BOUND_PROJECTION
@@ -231,7 +231,8 @@ ExitStatus interior_point(
231
231
  [&](const DenseVector& x) -> SparseMatrix {
232
232
  ScopedProfiler prof{A_i_prof};
233
233
  return matrix_callbacks.A_i(x);
234
- }};
234
+ },
235
+ matrix_callbacks.scaling};
235
236
  #else
236
237
  const auto& matrices = matrix_callbacks;
237
238
  #endif
@@ -290,7 +291,8 @@ ExitStatus interior_point(
290
291
  int iterations = 0;
291
292
 
292
293
  // Barrier parameter minimum
293
- const Scalar μ_min = Scalar(options.tolerance) / Scalar(10);
294
+ const Scalar μ_min =
295
+ matrices.scaling.f * Scalar(options.tolerance) / Scalar(10);
294
296
 
295
297
  // Fraction-to-the-boundary rule scale factor minimum
296
298
  constexpr Scalar τ_min(0.99);
@@ -356,8 +358,8 @@ ExitStatus interior_point(
356
358
  int full_step_rejected_counter = 0;
357
359
 
358
360
  // Error
359
- Scalar E_0 = kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
360
- g, A_e, c_e, A_i, c_i, s, y, z, Scalar(0));
361
+ Scalar E_0 = unscaled_kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
362
+ matrices.scaling, g, A_e, c_e, A_i, c_i, s, y, z, Scalar(0));
361
363
 
362
364
  setup_prof.stop();
363
365
 
@@ -569,9 +571,9 @@ ExitStatus interior_point(
569
571
  step_acceptable ? IterationType::ACCEPTED_SOC
570
572
  : IterationType::REJECTED_SOC,
571
573
  soc_profiler.current_duration(),
572
- kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
573
- g, A_e, trial_c_e, A_i, trial_c_i, trial_s, trial_y,
574
- trial_z, Scalar(0)),
574
+ unscaled_kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
575
+ matrices.scaling, g, A_e, trial_c_e, A_i, trial_c_i,
576
+ trial_s, trial_y, trial_z, Scalar(0)),
575
577
  trial_f,
576
578
  trial_c_e.template lpNorm<1>() +
577
579
  (trial_c_i - trial_s).template lpNorm<1>(),
@@ -781,8 +783,8 @@ ExitStatus interior_point(
781
783
  H = matrices.H(x, y, z);
782
784
 
783
785
  // Update the error
784
- E_0 = kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
785
- g, A_e, c_e, A_i, c_i, s, y, z, Scalar(0));
786
+ E_0 = unscaled_kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
787
+ matrices.scaling, g, A_e, c_e, A_i, c_i, s, y, z, Scalar(0));
786
788
 
787
789
  // Update the barrier parameter if necessary
788
790
  if (E_0 > Scalar(options.tolerance)) {
@@ -7,6 +7,8 @@
7
7
  #include <Eigen/Core>
8
8
  #include <Eigen/SparseCore>
9
9
 
10
+ #include "sleipnir/optimization/solver/util/problem_scaling.hpp"
11
+
10
12
  namespace slp {
11
13
 
12
14
  /// Matrix callbacks for the interior-point method solver.
@@ -241,6 +243,10 @@ struct InteriorPointMatrixCallbacks {
241
243
  /// </tr>
242
244
  /// </table>
243
245
  std::function<SparseMatrix(const DenseVector& x)> A_i;
246
+
247
+ /// Automatic problem scaling factors. Used to scale the cost, constraints,
248
+ /// and tolerance inside the interior-point solver.
249
+ ProblemScaling<Scalar> scaling;
244
250
  };
245
251
 
246
252
  } // namespace slp
@@ -102,7 +102,8 @@ ExitStatus newton(
102
102
  [&](const DenseVector& x) -> SparseMatrix {
103
103
  ScopedProfiler prof{H_prof};
104
104
  return matrix_callbacks.H(x);
105
- }};
105
+ },
106
+ matrix_callbacks.scaling};
106
107
  #else
107
108
  const auto& matrices = matrix_callbacks;
108
109
  #endif
@@ -141,7 +142,8 @@ ExitStatus newton(
141
142
  constexpr Scalar α_min(1e-20);
142
143
 
143
144
  // Error
144
- Scalar E_0 = kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(g);
145
+ Scalar E_0 = unscaled_kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
146
+ matrices.scaling, g);
145
147
 
146
148
  setup_prof.stop();
147
149
 
@@ -255,7 +257,8 @@ ExitStatus newton(
255
257
  H = matrices.H(x);
256
258
 
257
259
  // Update the error
258
- E_0 = kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(g);
260
+ E_0 = unscaled_kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
261
+ matrices.scaling, g);
259
262
 
260
263
  inner_iter_profiler.stop();
261
264
 
@@ -7,6 +7,8 @@
7
7
  #include <Eigen/Core>
8
8
  #include <Eigen/SparseCore>
9
9
 
10
+ #include "sleipnir/optimization/solver/util/problem_scaling.hpp"
11
+
10
12
  namespace slp {
11
13
 
12
14
  /// Matrix callbacks for the Newton's method solver.
@@ -90,6 +92,10 @@ struct NewtonMatrixCallbacks {
90
92
  /// </tr>
91
93
  /// </table>
92
94
  std::function<SparseMatrix(const DenseVector& x)> H;
95
+
96
+ /// Automatic problem scaling factors. Used to scale the cost and tolerance
97
+ /// inside the Newton solver.
98
+ ProblemScaling<Scalar> scaling;
93
99
  };
94
100
 
95
101
  } // namespace slp
@@ -175,7 +175,8 @@ ExitStatus sqp(const SQPMatrixCallbacks<Scalar>& matrix_callbacks,
175
175
  [&](const DenseVector& x) -> SparseMatrix {
176
176
  ScopedProfiler prof{A_e_prof};
177
177
  return matrix_callbacks.A_e(x);
178
- }};
178
+ },
179
+ matrix_callbacks.scaling};
179
180
  #else
180
181
  const auto& matrices = matrix_callbacks;
181
182
  #endif
@@ -239,7 +240,8 @@ ExitStatus sqp(const SQPMatrixCallbacks<Scalar>& matrix_callbacks,
239
240
  int full_step_rejected_counter = 0;
240
241
 
241
242
  // Error
242
- Scalar E_0 = kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(g, A_e, c_e, y);
243
+ Scalar E_0 = unscaled_kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
244
+ matrices.scaling, g, A_e, c_e, y);
243
245
 
244
246
  setup_prof.stop();
245
247
 
@@ -555,7 +557,8 @@ ExitStatus sqp(const SQPMatrixCallbacks<Scalar>& matrix_callbacks,
555
557
  H = matrices.H(x, y);
556
558
 
557
559
  // Update the error
558
- E_0 = kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(g, A_e, c_e, y);
560
+ E_0 = unscaled_kkt_error<Scalar, KKTErrorType::INF_NORM_SCALED>(
561
+ matrices.scaling, g, A_e, c_e, y);
559
562
 
560
563
  inner_iter_profiler.stop();
561
564
 
@@ -7,6 +7,8 @@
7
7
  #include <Eigen/Core>
8
8
  #include <Eigen/SparseCore>
9
9
 
10
+ #include "sleipnir/optimization/solver/util/problem_scaling.hpp"
11
+
10
12
  namespace slp {
11
13
 
12
14
  /// Matrix callbacks for the Sequential Quadratic Programming (SQP) solver.
@@ -175,6 +177,10 @@ struct SQPMatrixCallbacks {
175
177
  /// </tr>
176
178
  /// </table>
177
179
  std::function<SparseMatrix(const DenseVector& x)> A_e;
180
+
181
+ /// Automatic problem scaling factors. Used to scale the cost, constraints,
182
+ /// and tolerance inside the SQP solver.
183
+ ProblemScaling<Scalar> scaling;
178
184
  };
179
185
 
180
186
  } // namespace slp
@@ -169,6 +169,12 @@ ExitStatus feasibility_restoration(
169
169
 
170
170
  Scalar fr_μ = std::max(μ, c_e.template lpNorm<Eigen::Infinity>());
171
171
 
172
+ // Inherit the parent problem's scaling for the constraints, and use no
173
+ // scaling for the cost function since it has changed. The new rows introduced
174
+ // are not scaled.
175
+ const ProblemScaling<Scalar> fr_scaling{Scalar(1), matrices.scaling.c_e,
176
+ DenseVector::Ones(2 * num_eq)};
177
+
172
178
  InteriorPointMatrixCallbacks<Scalar> fr_matrix_callbacks{
173
179
  static_cast<int>(fr_x.rows()),
174
180
  static_cast<int>(fr_y.rows()),
@@ -287,7 +293,8 @@ ExitStatus feasibility_restoration(
287
293
  SparseMatrix A_i_p{2 * num_eq, x_p.rows()};
288
294
  A_i_p.setFromSortedTriplets(triplets.begin(), triplets.end());
289
295
  return A_i_p;
290
- }};
296
+ },
297
+ fr_scaling};
291
298
 
292
299
  auto status = interior_point<Scalar>(fr_matrix_callbacks, iteration_callbacks,
293
300
  options, true,
@@ -401,6 +408,15 @@ ExitStatus feasibility_restoration(
401
408
  Scalar fr_μ = std::max({μ, c_e.template lpNorm<Eigen::Infinity>(),
402
409
  (c_i - s).template lpNorm<Eigen::Infinity>()});
403
410
 
411
+ // Inherit the parent problem's scaling for the constraints, and use no
412
+ // scaling for the cost function since it has changed. The new rows introduced
413
+ // are not scaled.
414
+ DenseVector fr_d_c_i{c_i.rows() + 2 * num_eq + 2 * num_ineq};
415
+ fr_d_c_i << matrices.scaling.c_i,
416
+ DenseVector::Ones(2 * num_eq + 2 * num_ineq);
417
+ const ProblemScaling<Scalar> fr_scaling{Scalar(1), matrices.scaling.c_e,
418
+ fr_d_c_i};
419
+
404
420
  InteriorPointMatrixCallbacks<Scalar> fr_matrix_callbacks{
405
421
  static_cast<int>(fr_x.rows()),
406
422
  static_cast<int>(fr_y.rows()),
@@ -562,7 +578,8 @@ ExitStatus feasibility_restoration(
562
578
  SparseMatrix A_i_p{2 * num_eq + 3 * num_ineq, x_p.rows()};
563
579
  A_i_p.setFromSortedTriplets(triplets.begin(), triplets.end());
564
580
  return A_i_p;
565
- }};
581
+ },
582
+ fr_scaling};
566
583
 
567
584
  auto status = interior_point<Scalar>(fr_matrix_callbacks, iteration_callbacks,
568
585
  options, true,
@@ -7,6 +7,8 @@
7
7
  #include <Eigen/Core>
8
8
  #include <Eigen/SparseCore>
9
9
 
10
+ #include "sleipnir/optimization/solver/util/problem_scaling.hpp"
11
+
10
12
  // See docs/algorithms.md#Works_cited for citation definitions
11
13
 
12
14
  namespace slp {
@@ -149,4 +151,115 @@ Scalar kkt_error(const Eigen::Vector<Scalar, Eigen::Dynamic>& g,
149
151
  }
150
152
  }
151
153
 
154
+ /// Returns the unscaled KKT error for Newton's method.
155
+ ///
156
+ /// @tparam Scalar Scalar type.
157
+ /// @tparam T The type of KKT error to compute.
158
+ /// @param scaling The problem scaling factors.
159
+ /// @param g Gradient of the scaled cost function d_f·∇f.
160
+ template <typename Scalar, KKTErrorType T>
161
+ Scalar unscaled_kkt_error(const ProblemScaling<Scalar>& scaling,
162
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& g) {
163
+ using DenseVector = Eigen::Vector<Scalar, Eigen::Dynamic>;
164
+
165
+ if (scaling.is_identity()) {
166
+ return kkt_error<Scalar, T>(g);
167
+ }
168
+
169
+ const DenseVector g_unscaled = (Scalar(1) / scaling.f) * g;
170
+
171
+ return kkt_error<Scalar, T>(g_unscaled);
172
+ }
173
+
174
+ /// Returns the unscaled KKT error for Sequential Quadratic Programming.
175
+ ///
176
+ /// @tparam Scalar Scalar type.
177
+ /// @tparam T The type of KKT error to compute.
178
+ /// @param scaling The problem scaling factors.
179
+ /// @param g Gradient of the scaled cost function d_f·∇f.
180
+ /// @param A_e The problem's scaled equality constraint Jacobian D_cₑ·Aₑ(x)
181
+ /// evaluated at the current iterate.
182
+ /// @param c_e The problem's scaled equality constraints D_cₑ·cₑ(x) evaluated
183
+ /// at the current iterate.
184
+ /// @param y Scaled equality constraint dual variables.
185
+ template <typename Scalar, KKTErrorType T>
186
+ Scalar unscaled_kkt_error(const ProblemScaling<Scalar>& scaling,
187
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& g,
188
+ const Eigen::SparseMatrix<Scalar>& A_e,
189
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& c_e,
190
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& y) {
191
+ using DenseVector = Eigen::Vector<Scalar, Eigen::Dynamic>;
192
+ using SparseMatrix = Eigen::SparseMatrix<Scalar>;
193
+
194
+ if (scaling.is_identity()) {
195
+ return kkt_error<Scalar, T>(g, A_e, c_e, y);
196
+ }
197
+
198
+ const Scalar inv_d_f = Scalar(1) / scaling.f;
199
+ const DenseVector inv_d_c_e = scaling.c_e.cwiseInverse();
200
+
201
+ const DenseVector g_unscaled = inv_d_f * g;
202
+ const SparseMatrix A_e_unscaled = inv_d_c_e.asDiagonal() * A_e;
203
+ const DenseVector c_e_unscaled = inv_d_c_e.cwiseProduct(c_e);
204
+ const DenseVector y_unscaled = scaling.c_e.cwiseProduct(y) * inv_d_f;
205
+
206
+ return kkt_error<Scalar, T>(g_unscaled, A_e_unscaled, c_e_unscaled,
207
+ y_unscaled);
208
+ }
209
+
210
+ /// Returns the unscaled KKT error for the interior-point method.
211
+ ///
212
+ /// @tparam Scalar Scalar type.
213
+ /// @tparam T The type of KKT error to compute.
214
+ /// @param scaling The problem scaling factors.
215
+ /// @param g Gradient of the scaled cost function d_f·∇f.
216
+ /// @param A_e The problem's scaled equality constraint Jacobian D_cₑ·Aₑ(x)
217
+ /// evaluated at the current iterate.
218
+ /// @param c_e The problem's scaled equality constraints D_cₑ·cₑ(x) evaluated at
219
+ /// the current iterate.
220
+ /// @param A_i The problem's scaled inequality constraint Jacobian D_cᵢ·Aᵢ(x)
221
+ /// evaluated at the current iterate.
222
+ /// @param c_i The problem's scaled inequality constraints D_cᵢ·cᵢ(x) evaluated
223
+ /// at the current iterate.
224
+ /// @param s Scaled inequality constraint slack variables.
225
+ /// @param y Scaled equality constraint dual variables.
226
+ /// @param z Scaled inequality constraint dual variables.
227
+ /// @param μ Scaled barrier parameter.
228
+ template <typename Scalar, KKTErrorType T>
229
+ Scalar unscaled_kkt_error(const ProblemScaling<Scalar>& scaling,
230
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& g,
231
+ const Eigen::SparseMatrix<Scalar>& A_e,
232
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& c_e,
233
+ const Eigen::SparseMatrix<Scalar>& A_i,
234
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& c_i,
235
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& s,
236
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& y,
237
+ const Eigen::Vector<Scalar, Eigen::Dynamic>& z,
238
+ Scalar μ) {
239
+ using DenseVector = Eigen::Vector<Scalar, Eigen::Dynamic>;
240
+ using SparseMatrix = Eigen::SparseMatrix<Scalar>;
241
+
242
+ if (scaling.is_identity()) {
243
+ return kkt_error<Scalar, T>(g, A_e, c_e, A_i, c_i, s, y, z, μ);
244
+ }
245
+
246
+ const Scalar inv_d_f = Scalar(1) / scaling.f;
247
+ const DenseVector inv_d_c_e = scaling.c_e.cwiseInverse();
248
+ const DenseVector inv_d_c_i = scaling.c_i.cwiseInverse();
249
+
250
+ const DenseVector g_unscaled = inv_d_f * g;
251
+ const SparseMatrix A_e_unscaled = inv_d_c_e.asDiagonal() * A_e;
252
+ const DenseVector c_e_unscaled = inv_d_c_e.cwiseProduct(c_e);
253
+ const SparseMatrix A_i_unscaled = inv_d_c_i.asDiagonal() * A_i;
254
+ const DenseVector c_i_unscaled = inv_d_c_i.cwiseProduct(c_i);
255
+ const DenseVector s_unscaled = inv_d_c_i.cwiseProduct(s);
256
+ const DenseVector y_unscaled = scaling.c_e.cwiseProduct(y) * inv_d_f;
257
+ const DenseVector z_unscaled = scaling.c_i.cwiseProduct(z) * inv_d_f;
258
+ const Scalar μ_unscaled = inv_d_f * μ;
259
+
260
+ return kkt_error<Scalar, T>(g_unscaled, A_e_unscaled, c_e_unscaled,
261
+ A_i_unscaled, c_i_unscaled, s_unscaled,
262
+ y_unscaled, z_unscaled, μ_unscaled);
263
+ }
264
+
152
265
  } // namespace slp
@@ -0,0 +1,116 @@
1
+ // Copyright (c) Sleipnir contributors
2
+
3
+ #pragma once
4
+
5
+ #include <algorithm>
6
+
7
+ #include <Eigen/Core>
8
+ #include <Eigen/SparseCore>
9
+
10
+ #include "sleipnir/optimization/solver/util/sparse_inf_norms.hpp"
11
+
12
+ // See docs/algorithms.md#Works_cited for citation definitions
13
+
14
+ namespace slp {
15
+
16
+ /// Automatic problem scaling factors.
17
+ ///
18
+ /// @tparam Scalar Scalar type.
19
+ template <typename Scalar>
20
+ struct ProblemScaling {
21
+ /// Type alias for dense vector.
22
+ using DenseVector = Eigen::Vector<Scalar, Eigen::Dynamic>;
23
+ /// Type alias for sparse matrix.
24
+ using SparseMatrix = Eigen::SparseMatrix<Scalar>;
25
+ /// Type alias for sparse vector.
26
+ using SparseVector = Eigen::SparseVector<Scalar>;
27
+
28
+ /// Cost scaling factor d_f.
29
+ Scalar f = Scalar(1);
30
+
31
+ /// Equality constraint scaling factors d_cₑ.
32
+ DenseVector c_e;
33
+
34
+ /// Inequality constraint scaling factors d_cᵢ.
35
+ DenseVector c_i;
36
+
37
+ /// Constructs identity problem scaling.
38
+ ProblemScaling() = default;
39
+
40
+ /// Constructs problem scaling from explicit factors.
41
+ ///
42
+ /// @param f Cost scaling factor d_f.
43
+ /// @param c_e Equality constraint scaling factors d_cₑ.
44
+ /// @param c_i Inequality constraint scaling factors d_cᵢ.
45
+ ProblemScaling(Scalar f, const DenseVector& c_e, const DenseVector& c_i)
46
+ : f{f}, c_e{c_e}, c_i{c_i} {}
47
+
48
+ /// Computes Newton problem scaling.
49
+ ///
50
+ /// Scales the cost so the largest gradient component at the starting point
51
+ /// is at most gₘₐₓ:
52
+ ///
53
+ /// d_f = min(1, gₘₐₓ / ‖∇f(x₀)‖_∞)
54
+ ///
55
+ /// See §3.8 Automatic Scaling of the Problem Statement in [2].
56
+ ///
57
+ /// @param g Cost gradient ∇f, evaluated at the starting point.
58
+ explicit ProblemScaling(const DenseVector& g) {
59
+ constexpr Scalar g_max(100);
60
+
61
+ f = std::min(Scalar(1), g_max / g.template lpNorm<Eigen::Infinity>());
62
+ }
63
+
64
+ /// Computes SQP problem scaling.
65
+ ///
66
+ /// Scales the cost and each equality constraint so the largest gradient
67
+ /// component at the starting point is at most gₘₐₓ:
68
+ ///
69
+ /// d_f = min(1, gₘₐₓ / ‖∇f(x₀)‖_∞)
70
+ /// d_cₑ[j] = min(1, gₘₐₓ / ‖∇cₑⱼ(x₀)‖_∞)
71
+ ///
72
+ /// See §3.8 Automatic Scaling of the Problem Statement in [2].
73
+ ///
74
+ /// @param g Cost gradient ∇f, evaluated at the starting point.
75
+ /// @param A_e Equality constraint Jacobian Aₑ, evaluated at the starting
76
+ /// point.
77
+ ProblemScaling(const DenseVector& g, const SparseMatrix& A_e) {
78
+ constexpr Scalar g_max(100);
79
+
80
+ f = std::min(Scalar(1), g_max / g.template lpNorm<Eigen::Infinity>());
81
+ c_e = (g_max / sparse_inf_norms(A_e).array()).min(Scalar(1)).matrix();
82
+ }
83
+
84
+ /// Computes interior-point problem scaling.
85
+ ///
86
+ /// Scales the cost and each constraint so the largest gradient
87
+ /// component at the starting point is at most gₘₐₓ:
88
+ ///
89
+ /// d_f = min(1, gₘₐₓ / ‖∇f(x₀)‖_∞)
90
+ /// d_c[j] = min(1, gₘₐₓ / ‖∇cⱼ(x₀)‖_∞)
91
+ ///
92
+ /// See §3.8 Automatic Scaling of the Problem Statement in [2].
93
+ ///
94
+ /// @param g Cost gradient ∇f, evaluated at the starting point.
95
+ /// @param A_e Equality constraint Jacobian Aₑ, evaluated at the starting
96
+ /// point.
97
+ /// @param A_i Inequality constraint Jacobian Aᵢ, evaluated at the starting
98
+ /// point.
99
+ ProblemScaling(const DenseVector& g, const SparseMatrix& A_e,
100
+ const SparseMatrix& A_i) {
101
+ constexpr Scalar g_max(100);
102
+
103
+ f = std::min(Scalar(1), g_max / g.template lpNorm<Eigen::Infinity>());
104
+ c_e = (g_max / sparse_inf_norms(A_e).array()).min(Scalar(1)).matrix();
105
+ c_i = (g_max / sparse_inf_norms(A_i).array()).min(Scalar(1)).matrix();
106
+ }
107
+
108
+ /// Whether the problem scaling is identity.
109
+ ///
110
+ /// @return True if the problem scaling is identity.
111
+ bool is_identity() const {
112
+ return f == Scalar(1) && c_e.size() == 0 && c_i.size() == 0;
113
+ }
114
+ };
115
+
116
+ } // namespace slp
@@ -0,0 +1,34 @@
1
+ // Copyright (c) Sleipnir contributors
2
+
3
+ #pragma once
4
+
5
+ #include <algorithm>
6
+
7
+ #include <Eigen/Core>
8
+ #include <Eigen/SparseCore>
9
+
10
+ namespace slp {
11
+
12
+ /// Computes the row-wise infinity norm of a sparse matrix.
13
+ ///
14
+ /// @param mat Sparse matrix.
15
+ /// @return A dense vector where each element is the infinity norm of the
16
+ /// corresponding row of the sparse matrix.
17
+ template <typename Derived>
18
+ auto sparse_inf_norms(const Eigen::SparseCompressedBase<Derived>& mat)
19
+ -> Eigen::Vector<typename Derived::Scalar, Eigen::Dynamic> {
20
+ using Scalar = typename Derived::Scalar;
21
+ using DenseVector = Eigen::Vector<Scalar, Eigen::Dynamic>;
22
+
23
+ DenseVector norms = DenseVector::Zero(mat.rows());
24
+ for (int k = 0; k < mat.outerSize(); ++k) {
25
+ for (typename Derived::InnerIterator it{mat, k}; it; ++it) {
26
+ using std::abs;
27
+ norms[it.row()] = std::max(norms[it.row()], abs(it.value()));
28
+ }
29
+ }
30
+
31
+ return norms;
32
+ }
33
+
34
+ } // namespace slp
@@ -2,4 +2,4 @@
2
2
 
3
3
  from ._sleipnir import *
4
4
 
5
- __version__ = "0.5.6.dev6"
5
+ __version__ = "0.5.6.dev7"