16#include <Eigen/Eigenvalues> 18#include "pinocchio/eigen-common.hpp" 19#include "pinocchio/macros.hpp" 21#include "pinocchio/container/eigen-storage.hpp" 23#include "pinocchio/math.hpp" 25#include "pinocchio/tracy.hpp" 27#include "pinocchio/utils/check.hpp" 29#include "pinocchio/constraints.hpp" 31#include "pinocchio/algorithm/solvers/fwd.hpp" 32#include "pinocchio/algorithm/solvers/constraint-solver-base.hpp" 33#include "pinocchio/algorithm/solvers/constraint-solver-utils.hpp" 34#include "pinocchio/algorithm/solvers/anderson-acceleration.hpp" 44 template<
typename Scalar,
int Options>
45 struct ADMMSolverWorkspaceTpl;
47 template<
typename Scalar>
48 struct ADMMSpectralUpdateRuleTpl;
50 template<
typename Scalar>
51 struct ADMMLinearUpdateRuleTpl;
53 template<
typename Scalar>
54 struct ADMMOSQPUpdateRuleTpl;
57 template<
typename Scalar>
58 union ADMMUpdateRuleContainerTpl {
59 ADMMUpdateRuleContainerTpl()
61 ADMMSpectralUpdateRuleTpl<Scalar> spectral_rule;
62 ADMMOSQPUpdateRuleTpl<Scalar> osqp_rule;
63 ADMMLinearUpdateRuleTpl<Scalar> linear_rule;
101 template<
typename _Scalar,
int _Options>
104 typedef _Scalar Scalar;
105 static constexpr int Options = _Options;
119 template<
typename _Scalar,
int _Options>
122 typedef _Scalar Scalar;
123 static constexpr int Options = _Options;
126 typedef ConstraintSolverBase<Self> Base;
128 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options> VectorXs;
129 typedef Eigen::Ref<VectorXs> RefVectorXs;
130 typedef Eigen::Ref<const VectorXs> RefConstVectorXs;
131 typedef const Eigen::Ref<const VectorXs> ConstRefVectorXs;
132 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Options> MatrixXs;
135 typedef internal::ADMMSolverWorkspaceTpl<Scalar, Options> ADMMSolverWorkspace;
139 typedef internal::ADMMSpectralUpdateRuleTpl<Scalar> ADMMSpectralUpdateRule;
140 typedef internal::ADMMOSQPUpdateRuleTpl<Scalar> ADMMOSQPUpdateRule;
141 typedef internal::ADMMLinearUpdateRuleTpl<Scalar> ADMMLinearUpdateRule;
142 typedef internal::ADMMUpdateRuleContainerTpl<Scalar> ADMMUpdateRuleContainer;
145 using Base::timerStart;
146 using Base::timerStop;
174 typename DelassusDerived,
176 typename ConstraintModel,
177 typename ConstraintModelAllocator,
178 typename ConstraintData,
179 typename ConstraintDataAllocator>
181 DelassusOperatorBase<DelassusDerived> & delassus,
182 const Eigen::MatrixBase<VectorLike> & g,
183 const std::vector<ConstraintModel, ConstraintModelAllocator> & constraint_models,
184 const std::vector<ConstraintData, ConstraintDataAllocator> & constraint_datas,
185 const ADMMSolverSettings & settings,
186 ADMMSolverResult & result);
209 template<
typename DelassusDerived>
211 const DelassusOperatorBase<DelassusDerived> & delassus, ADMMSolverWorkspace & workspace);
215 typename DelassusDerived,
217 typename ConstraintModel,
218 typename ConstraintModelAllocator,
219 typename ConstraintData,
220 typename ConstraintDataAllocator>
222 DelassusOperatorBase<DelassusDerived> & delassus,
223 const Eigen::MatrixBase<VectorLike> & g,
224 const std::vector<ConstraintModel, ConstraintModelAllocator> & constraint_models,
225 const std::vector<ConstraintData, ConstraintDataAllocator> & constraint_datas,
226 const ADMMSolverSettings & settings,
227 const ADMMSolverResult & result,
228 ADMMSolverWorkspace & workspace);
231 template<
typename DelassusDerived>
233 const DelassusOperatorBase<DelassusDerived> & delassus,
234 const ADMMSolverSettings & settings,
235 const ADMMSolverResult & result,
236 ADMMSolverWorkspace & workspace);
239 template<
typename _Scalar>
242 typedef _Scalar Scalar;
247 template<
typename _Scalar>
250 typedef _Scalar Scalar;
252 typedef ConstraintSolverSettingsBase<Self> Base;
256 std::size_t max_iterations = 1000,
257 Scalar absolute_feasibility_tol = Scalar(1e-6),
258 Scalar relative_feasibility_tol = Scalar(1e-6),
259 Scalar absolute_complementarity_tol = Scalar(1e-6),
260 Scalar relative_complementarity_tol = Scalar(1e-6),
261 bool solve_ncp =
true,
262 bool measure_timings =
false,
263 bool stat_record =
false,
264 std::optional<Scalar>
rho_init = std::nullopt,
270 Scalar
tau = Scalar(0.5),
281 std::size_t
lanczos_size = std::numeric_limits<int>::max(),
286 absolute_feasibility_tol,
287 relative_feasibility_tol,
288 absolute_complementarity_tol,
289 relative_complementarity_tol,
316 void checkValidityImpl()
const 320 PINOCCHIO_CHECK_INPUT_ARGUMENT(
321 rho_init.value() > Scalar(0),
"rho_init should be none or > 0.");
323 PINOCCHIO_CHECK_INPUT_ARGUMENT(
mu_prox > Scalar(0),
"mu_prox should be > 0.");
324 PINOCCHIO_CHECK_INPUT_ARGUMENT(
325 tau_prox <= Scalar(1) &&
tau_prox > Scalar(0),
"tau_prox should lie in ]0,1].");
326 PINOCCHIO_CHECK_INPUT_ARGUMENT(
327 tau <= Scalar(1) &&
tau > Scalar(0),
"tau should lie in ]0,1].");
328 PINOCCHIO_CHECK_INPUT_ARGUMENT(
330 PINOCCHIO_CHECK_INPUT_ARGUMENT(
dual_momentum >= Scalar(0),
"dual_momentum should be >= 0.");
331 PINOCCHIO_CHECK_INPUT_ARGUMENT(
333 "rho_momentum should be in [0, 1].");
334 PINOCCHIO_CHECK_INPUT_ARGUMENT(
336 PINOCCHIO_CHECK_INPUT_ARGUMENT(
338 "rho_min and rho_max don't verify 0 <= rho_min <= rho_max");
345 using Base::max_iterations;
348 using Base::absolute_feasibility_tol;
351 using Base::relative_feasibility_tol;
354 using Base::absolute_complementarity_tol;
357 using Base::relative_complementarity_tol;
361 using Base::solve_ncp;
364 using Base::measure_timings;
367 using Base::stat_record;
449 template<
typename _Scalar,
int _Options>
452 typedef _Scalar Scalar;
453 static constexpr int Options = _Options;
460 template<
typename _Scalar,
int _Options>
463 typedef _Scalar Scalar;
464 static constexpr int Options = _Options;
466 typedef ConstraintSolverResultBase<Self> Base;
468 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options> VectorXs;
469 typedef internal::EigenStorageTpl<VectorXs> VectorXsStorage;
470 typedef Eigen::Ref<const VectorXs> RefConstVectorXs;
472 using Base::constraintSize;
473 using Base::setConstraintImpulseGuess;
474 using Base::setConstraintVelocityGuess;
483 ,
rho(std::numeric_limits<Scalar>::quiet_NaN())
485 ,
mu_prox(std::numeric_limits<Scalar>::quiet_NaN())
500 Base::operator=(other);
522 clearConstraintImpulseGuessImpl();
530 clearConstraintVelocityGuessImpl();
550 rho = std::numeric_limits<Scalar>::quiet_NaN();
552 mu_prox = std::numeric_limits<Scalar>::quiet_NaN();
555 x.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
556 y.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
557 z.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
558 desaxce.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
566 Eigen::Index np =
static_cast<Eigen::Index
>(
problem_size);
574 template<
typename VectorLike>
576 const Eigen::MatrixBase<VectorLike> & non_projected_primal_solution_)
const 578 auto & non_projected_primal_solution = non_projected_primal_solution_.const_cast_derived();
579 non_projected_primal_solution = x;
583 template<
typename VectorLike>
586 auto & primal_solution = primal_solution_.const_cast_derived();
592 template<
typename VectorLike>
595 auto & dual_solution = dual_solution_.const_cast_derived();
600 template<
typename VectorLike>
603 auto & desaxce_term = desaxce_term_.const_cast_derived();
604 desaxce_term = desaxce;
607 template<
typename VectorLike>
608 void setConstraintImpulseGuessImpl(
const Eigen::MatrixBase<VectorLike> & impulse_guess_in)
611 m_impulse_guess = impulse_guess_in;
615 void clearConstraintImpulseGuessImpl()
621 template<
typename VectorLike>
622 void setConstraintVelocityGuessImpl(
const Eigen::MatrixBase<VectorLike> & velocity_guess_in)
625 m_velocity_guess = velocity_guess_in;
629 void clearConstraintVelocityGuessImpl()
635 template<
typename VectorLike>
637 retrieveConstraintImpulsesImpl(
const Eigen::MatrixBase<VectorLike> & constraint_impulses_)
const 639 auto & constraint_impulses = constraint_impulses_.const_cast_derived();
640 constraint_impulses = y;
645 template<
typename VectorLike>
647 const Eigen::MatrixBase<VectorLike> & constraint_velocities_)
const 649 auto & constraint_velocities = constraint_velocities_.const_cast_derived();
650 constraint_velocities = z - desaxce;
654 using Base::iterations;
657 using Base::converged;
660 using Base::primal_feasibility;
663 using Base::dual_feasibility;
666 using Base::complementarity;
700 typename VectorXsStorage::RefMapType x =
x_storage.map();
704 typename VectorXsStorage::RefMapType y =
y_storage.map();
708 typename VectorXsStorage::RefMapType z =
z_storage.map();
724 template<
typename _Scalar>
727 typedef _Scalar Scalar;
732 template<
typename _Scalar>
735 typedef _Scalar Scalar;
737 typedef ConstraintSolverStatsBase<Self> Base;
750 : Base(max_iterations)
753 reserve(max_iterations);
756 void reserveImpl(std::size_t max_iterations)
758 rho.reserve(max_iterations);
759 mu_prox.reserve(max_iterations);
777 using Base::iterations;
780 using Base::primal_feasibility;
783 using Base::dual_feasibility;
786 using Base::dual_feasibility_ncp;
789 using Base::complementarity;
814 template<
typename _Scalar,
int _Options>
815 struct ADMMSolverWorkspaceTpl
817 typedef _Scalar Scalar;
818 static constexpr int Options = _Options;
819 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options> VectorXs;
820 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Options> MatrixXs;
821 typedef internal::EigenStorageTpl<VectorXs> VectorXsStorage;
822 typedef LanczosDecompositionTpl<MatrixXs> LanczosDecomposition;
823 typedef AndersonAccelerationTpl<Scalar> AndersonAcceleration;
826 ADMMSolverWorkspaceTpl(
827 std::size_t problem_size = 0,
828 std::size_t lanczos_size = 2,
829 std::size_t anderson_capacity = 0)
830 : problem_size(problem_size)
831 , lanczos_size(lanczos_size)
832 , anderson_capacity(anderson_capacity)
833 , delassus_decomposition_update_count(0)
834 , delassus_smallest_eigenvalue(std::nullopt)
835 , delassus_largest_eigenvalue(std::nullopt)
836 , rho(std::numeric_limits<Scalar>::quiet_NaN())
837 , spectral_rho_power(std::numeric_limits<Scalar>::quiet_NaN())
838 , mu_prox(std::numeric_limits<Scalar>::quiet_NaN())
839 , lanczos_decomposition(
840 static_cast<Eigen::Index
>(math::max(std::size_t(2), problem_size)),
841 static_cast<Eigen::Index
>(
842 math::max(std::size_t(2), math::min(problem_size, lanczos_size))))
843 , anderson_history(problem_size, anderson_capacity)
845 resize(problem_size, lanczos_size, anderson_capacity);
850 ADMMSolverWorkspaceTpl(
const ADMMSolverWorkspaceTpl & other)
851 : ADMMSolverWorkspaceTpl(0, 2, 0)
857 ADMMSolverWorkspaceTpl & operator=(
const ADMMSolverWorkspaceTpl & other)
861 problem_size = other.problem_size;
862 lanczos_size = other.lanczos_size;
863 anderson_capacity = other.anderson_capacity;
864 delassus_decomposition_update_count = other.delassus_decomposition_update_count;
865 delassus_smallest_eigenvalue = other.delassus_smallest_eigenvalue;
866 delassus_largest_eigenvalue = other.delassus_largest_eigenvalue;
868 spectral_rho_power = other.spectral_rho_power;
869 mu_prox = other.mu_prox;
870 lanczos_decomposition = other.lanczos_decomposition;
871 anderson_history = other.anderson_history;
876 x_storage = other.x_storage;
877 x_previous_storage = other.x_previous_storage;
878 x_anderson_storage = other.x_anderson_storage;
879 y_storage = other.y_storage;
880 y_previous_storage = other.y_previous_storage;
881 z_storage = other.z_storage;
882 z_previous_storage = other.z_previous_storage;
883 z_anderson_storage = other.z_anderson_storage;
884 desaxce_storage = other.desaxce_storage;
885 rhs_storage = other.rhs_storage;
886 tmp_storage = other.tmp_storage;
887 primal_feasibility_vector_storage = other.primal_feasibility_vector_storage;
888 anderson_primal_feasibility_vector_storage =
889 other.anderson_primal_feasibility_vector_storage;
890 dual_feasibility_vector_storage = other.dual_feasibility_vector_storage;
898 delassus_decomposition_update_count = 0;
899 delassus_smallest_eigenvalue.reset();
900 delassus_largest_eigenvalue.reset();
902 rho = std::numeric_limits<Scalar>::quiet_NaN();
903 spectral_rho_power = std::numeric_limits<Scalar>::quiet_NaN();
904 mu_prox = std::numeric_limits<Scalar>::quiet_NaN();
908 x.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
909 x_previous.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
910 x_anderson.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
911 y.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
912 y_previous.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
913 z.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
914 z_previous.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
915 z_anderson.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
916 desaxce.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
917 rhs.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
918 tmp.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
919 primal_feasibility_vector.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
920 anderson_primal_feasibility_vector.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
921 dual_feasibility_vector.setConstant(std::numeric_limits<Scalar>::quiet_NaN());
927 std::size_t problem_size_,
928 std::size_t lanczos_size_,
929 std::size_t anderson_capacity_)
931 problem_size = problem_size_;
932 lanczos_size = math::max(std::size_t(2), math::min(problem_size, lanczos_size_));
933 anderson_capacity = anderson_capacity_;
935 const Eigen::Index np =
static_cast<Eigen::Index
>(problem_size);
936 x_storage.resize(np);
937 x_anderson_storage.resize(np);
938 y_storage.resize(np);
939 x_previous_storage.resize(np);
940 y_previous_storage.resize(np);
941 z_storage.resize(np);
942 z_anderson_storage.resize(np);
943 z_previous_storage.resize(np);
944 desaxce_storage.resize(np);
945 rhs_storage.resize(np);
946 tmp_storage.resize(np);
947 primal_feasibility_vector_storage.resize(np);
948 anderson_primal_feasibility_vector_storage.resize(np);
949 dual_feasibility_vector_storage.resize(np);
952 const std::size_t lanczos_problem_size = math::max(std::size_t(2), problem_size);
954 lanczos_decomposition.size() !=
static_cast<Eigen::Index
>(lanczos_problem_size)
955 || lanczos_decomposition.decompositionSize() !=
static_cast<Eigen::Index
>(lanczos_size))
957 lanczos_decomposition = LanczosDecomposition(
958 static_cast<Eigen::Index
>(lanczos_problem_size),
959 static_cast<Eigen::Index
>(lanczos_size));
963 anderson_history.reserve(problem_size, anderson_capacity);
967 std::size_t problem_size;
970 std::size_t lanczos_size;
973 std::size_t anderson_capacity;
976 std::size_t delassus_decomposition_update_count;
980 std::optional<Scalar> delassus_smallest_eigenvalue;
984 std::optional<Scalar> delassus_largest_eigenvalue;
990 Scalar spectral_rho_power;
999 LanczosDecomposition lanczos_decomposition;
1002 AndersonAcceleration anderson_history;
1005 VectorXsStorage x_storage;
1006 typename VectorXsStorage::RefMapType x = x_storage.map();
1009 VectorXsStorage x_previous_storage;
1010 typename VectorXsStorage::RefMapType x_previous = x_previous_storage.map();
1013 VectorXsStorage x_anderson_storage;
1014 typename VectorXsStorage::RefMapType x_anderson = x_anderson_storage.map();
1017 VectorXsStorage y_storage;
1018 typename VectorXsStorage::RefMapType y = y_storage.map();
1021 VectorXsStorage y_previous_storage;
1022 typename VectorXsStorage::RefMapType y_previous = y_previous_storage.map();
1025 VectorXsStorage z_storage;
1026 typename VectorXsStorage::RefMapType z = z_storage.map();
1029 VectorXsStorage z_previous_storage;
1030 typename VectorXsStorage::RefMapType z_previous = z_previous_storage.map();
1033 VectorXsStorage z_anderson_storage;
1034 typename VectorXsStorage::RefMapType z_anderson = z_anderson_storage.map();
1037 VectorXsStorage desaxce_storage;
1038 typename VectorXsStorage::RefMapType desaxce = desaxce_storage.map();
1041 VectorXsStorage rhs_storage;
1042 typename VectorXsStorage::RefMapType rhs = rhs_storage.map();
1045 VectorXsStorage tmp_storage;
1046 typename VectorXsStorage::RefMapType tmp = tmp_storage.map();
1049 VectorXsStorage primal_feasibility_vector_storage;
1050 typename VectorXsStorage::RefMapType primal_feasibility_vector =
1051 primal_feasibility_vector_storage.map();
1054 VectorXsStorage anderson_primal_feasibility_vector_storage;
1055 typename VectorXsStorage::RefMapType anderson_primal_feasibility_vector =
1056 anderson_primal_feasibility_vector_storage.map();
1059 VectorXsStorage dual_feasibility_vector_storage;
1060 typename VectorXsStorage::RefMapType dual_feasibility_vector =
1061 dual_feasibility_vector_storage.map();
1066 template<
typename _Scalar>
1067 struct ADMMSpectralUpdateRuleTpl
1069 typedef _Scalar Scalar;
1072 ADMMSpectralUpdateRuleTpl(
1073 const Scalar ratio_primal_dual,
1076 const Scalar rho_power_factor)
1077 : ratio_primal_dual(ratio_primal_dual)
1078 , rho_increment(std::pow(L / m, rho_power_factor))
1080 PINOCCHIO_CHECK_INPUT_ARGUMENT(m > Scalar(0),
"m should be positive.");
1081 PINOCCHIO_CHECK_INPUT_ARGUMENT(L > m,
"L should be > m");
1085 void eval(
const Scalar primal_feasibility,
const Scalar dual_feasibility, Scalar & rho)
const 1087 if (primal_feasibility > ratio_primal_dual * dual_feasibility)
1089 rho *= rho_increment;
1093 else if (dual_feasibility > ratio_primal_dual * primal_feasibility)
1095 rho /= rho_increment;
1103 static inline Scalar computeRho(
const Scalar L,
const Scalar m,
const Scalar rho_power)
1105 const Scalar cond = L / m;
1106 const Scalar rho = math::sqrt(L * m) * math::pow(cond, rho_power);
1112 static inline Scalar computeRhoPower(
const Scalar L,
const Scalar m,
const Scalar rho)
1114 const Scalar cond = L / m;
1115 const Scalar sqrt_L_m = math::sqrt(L * m);
1116 const Scalar rho_power = math::log(rho / sqrt_L_m) / math::log(cond);
1121 Scalar ratio_primal_dual;
1125 Scalar rho_increment;
1130 template<
typename _Scalar>
1131 struct ADMMLinearUpdateRuleTpl
1133 typedef _Scalar Scalar;
1136 ADMMLinearUpdateRuleTpl(
1137 const Scalar ratio_primal_dual,
const Scalar increase_factor,
const Scalar decrease_factor)
1138 : ratio_primal_dual(ratio_primal_dual)
1139 , increase_factor(increase_factor)
1140 , decrease_factor(decrease_factor)
1142 PINOCCHIO_CHECK_INPUT_ARGUMENT(
1143 increase_factor > Scalar(1),
"increase_factor should be greater than one.");
1144 PINOCCHIO_CHECK_INPUT_ARGUMENT(
1145 decrease_factor > Scalar(1),
"decrease_factor should be greater than one.");
1150 ADMMLinearUpdateRuleTpl(
const Scalar ratio_primal_dual,
const Scalar factor)
1151 : ratio_primal_dual(ratio_primal_dual)
1152 , increase_factor(factor)
1153 , decrease_factor(factor)
1155 PINOCCHIO_CHECK_INPUT_ARGUMENT(factor > Scalar(1),
"factor should be greater than one.");
1159 void eval(
const Scalar primal_feasibility,
const Scalar dual_feasibility, Scalar & rho)
const 1161 if (primal_feasibility > ratio_primal_dual * dual_feasibility)
1163 rho *= increase_factor;
1165 else if (dual_feasibility > ratio_primal_dual * primal_feasibility)
1167 rho /= decrease_factor;
1172 Scalar ratio_primal_dual;
1175 Scalar increase_factor;
1178 Scalar decrease_factor;
1183 template<
typename _Scalar>
1184 struct ADMMOSQPUpdateRuleTpl
1186 typedef _Scalar Scalar;
1189 ADMMOSQPUpdateRuleTpl(
const Scalar ratio_primal_dual,
const Scalar eps_reg = 1e-8)
1190 : ratio_primal_dual(ratio_primal_dual)
1193 PINOCCHIO_CHECK_INPUT_ARGUMENT(
1194 ratio_primal_dual > Scalar(0),
"ratio_primal_dual should be positive.");
1195 PINOCCHIO_CHECK_INPUT_ARGUMENT(eps_reg > Scalar(0),
"eps_reg should be positive.");
1199 void eval(
const Scalar primal_feasibility,
const Scalar dual_feasibility, Scalar & rho)
const 1202 primal_feasibility > ratio_primal_dual * dual_feasibility
1203 || dual_feasibility > ratio_primal_dual * primal_feasibility)
1205 rho *= std::sqrt(primal_feasibility / (dual_feasibility + eps_reg));
1210 Scalar ratio_primal_dual;
1221#include "pinocchio/src/algorithm/solvers/admm-solver.hxx" Main pinocchio namespace.
ADMMProximalRule
ADMM proximal policy. MANUAL: mu_prox is constant and manually set. It is scaled by tau_prox AUTOMATI...
ADMMUpdateRule
ADMM rho update rule. SPECTRAL: if primal/dual ratio met, multiply rho by a spectral factor....
ADMMConstraintSolverTpl(std::size_t max_problem_size=0)
Default constructor.
static Scalar computeDelassusLargestEigenvalue(const DelassusOperatorBase< DelassusDerived > &delassus, ADMMSolverWorkspace &workspace)
Compute largest eigen value of delassus.
static void retrievePrimalDualGuess(DelassusOperatorBase< DelassusDerived > &delassus, const Eigen::MatrixBase< VectorLike > &g, const std::vector< ConstraintModel, ConstraintModelAllocator > &constraint_models, const std::vector< ConstraintData, ConstraintDataAllocator > &constraint_datas, const ADMMSolverSettings &settings, const ADMMSolverResult &result, ADMMSolverWorkspace &workspace)
Retrieve primal and/or dual guesses from settings and result's warmstarts.
static void retrieveRhoGuess(const DelassusOperatorBase< DelassusDerived > &delassus, const ADMMSolverSettings &settings, const ADMMSolverResult &result, ADMMSolverWorkspace &workspace)
Retrieve rho parameters guesses from settings and result's warmstarts.
bool isValid() const
Returns true if solver is in a valid state (it has solved a constraint problem). If so,...
ADMMSolverWorkspace m_workspace
Struct describing the solution of the ADMM constraint solver after calling the solve method....
void retrieveNonProjectedPrimalSolution(const Eigen::MatrixBase< VectorLike > &non_projected_primal_solution_) const
Retrieve non-projected primal solution.
VectorXsStorage x_storage
VectorXsStorage m_velocity_guess_storage
Storage for the optional velocity guess.
void resize(std::size_t problem_size_)
Resize the primal/dual/desaxce vectors of the solution.
ADMMSolverResultTpl(const ADMMSolverResultTpl &other)
Copy constructor.
std::optional< RefConstVectorXs > impulse_guess
void retrieveDualSolution(const Eigen::MatrixBase< VectorLike > &dual_solution_) const
Retrieve dual solution. At the optimum we have Gx + g + desaxce - z = 0.
std::size_t delassus_decomposition_update_count
void resetImpl()
Reset the results.
ADMMSolverResultTpl()
Default constructor.
Scalar spectral_rho_power
int constraintSizeImpl() const
VectorXsStorage z_storage
VectorXsStorage y_storage
std::optional< RefConstVectorXs > velocity_guess
ADMMSolverResultTpl & operator=(const ADMMSolverResultTpl &other)
Assignment operator.
VectorXsStorage desaxce_storage
void retrievePrimalSolution(const Eigen::MatrixBase< VectorLike > &primal_solution_) const
Retrieve primal solution.
void retrieveConstraintVelocitiesImpl(const Eigen::MatrixBase< VectorLike > &constraint_velocities_) const
void retrieveDesaxceTerm(const Eigen::MatrixBase< VectorLike > &desaxce_term_) const
Retrieve Desaxce term of solution.
VectorXsStorage m_impulse_guess_storage
Storage for the optional impulse guess.
Settings for the ADMM constraint solver loop.
std::size_t rho_min_update_frequency
std::optional< Scalar > rho_init
ADMMUpdateRule admm_update_rule
Scalar spectral_rho_power_init
bool warmstart_rho_with_previous_result
Scalar spectral_rho_power_factor
std::size_t anderson_capacity
std::size_t max_delassus_decomposition_updates
Scalar linear_update_rule_factor
ADMMSolverSettingsTpl(std::size_t max_iterations=1000, Scalar absolute_feasibility_tol=Scalar(1e-6), Scalar relative_feasibility_tol=Scalar(1e-6), Scalar absolute_complementarity_tol=Scalar(1e-6), Scalar relative_complementarity_tol=Scalar(1e-6), bool solve_ncp=true, bool measure_timings=false, bool stat_record=false, std::optional< Scalar > rho_init=std::nullopt, bool warmstart_rho_with_previous_result=false, ADMMUpdateRule admm_update_rule=ADMMUpdateRule::OSQP, ADMMProximalRule admm_proximal_rule=ADMMProximalRule::MANUAL, Scalar mu_prox=Scalar(1e-6), Scalar tau_prox=Scalar(1), Scalar tau=Scalar(0.5), Scalar ratio_primal_dual=Scalar(10), Scalar dual_momentum=Scalar(0), Scalar rho_update_ratio=Scalar(0), std::size_t rho_min_update_frequency=1, Scalar rho_momentum=Scalar(0), Scalar rho_min=Scalar(1e-6), Scalar rho_max=Scalar(1e6), Scalar spectral_rho_power_init=Scalar(0.2), Scalar spectral_rho_power_factor=Scalar(0.05), Scalar linear_update_rule_factor=Scalar(2), std::size_t lanczos_size=std::numeric_limits< int >::max(), std::size_t max_delassus_decomposition_updates=std::numeric_limits< int >::max(), std::size_t anderson_capacity=0)
Default constructor.
ADMMProximalRule admm_proximal_rule
Struct to track per iteration progress of ADMM constraint solver.
ADMMSolverStatsTpl(std::size_t max_iterations)
Constructor given a maximum iteration of the solver.
std::size_t delassus_decomposition_update_count
void resetImpl()
Reset stats.
std::vector< Scalar > mu_prox
History of mu_prox values.
std::vector< std::size_t > anderson_size
History of Anderson size.
std::vector< Scalar > linear_system_residual
History of linear system residual.
std::vector< Scalar > rho
History of rho values.
std::vector< Scalar > linear_system_consistency
History of linear system consistency.
ADMMSolverStatsTpl()
Default constructor.