robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
impact_constraint_component_base.hxx
Go to the documentation of this file.
1#ifndef ROBOTOC_IMPACT_CONSTRAINT_COMPONENT_BASE_HXX_
2#define ROBOTOC_IMPACT_CONSTRAINT_COMPONENT_BASE_HXX_
3
6
7#include <cassert>
8
9
10namespace robotoc {
11
13 const ConstraintComponentData& data) const {
14 return pdipm::fractionToBoundarySlack(fraction_to_boundary_rule_, data);
15}
16
17
19 const ConstraintComponentData& data) const {
20 return pdipm::fractionToBoundaryDual(fraction_to_boundary_rule_, data);
21}
22
23
25 ConstraintComponentData& data, const double step_size) {
26 assert(step_size > 0);
27 data.slack.noalias() += step_size * data.dslack;
28}
29
30
32 ConstraintComponentData& data, const double step_size) {
33 assert(step_size > 0);
34 data.dual.noalias() += step_size * data.ddual;
35}
36
37
38template <typename Derived>
39inline std::shared_ptr<Derived> ImpactConstraintComponentBase::as_shared_ptr() {
40 auto ptr = shared_from_this();
41 auto derived_ptr = std::dynamic_pointer_cast<Derived>(ptr);
42 if (derived_ptr == nullptr) {
43 throw std::runtime_error("[ImpactConstraintComponentBase] runtime error: failed in down-casting!");
44 }
45 return derived_ptr;
46}
47
48
50 ConstraintComponentData& data) const {
52}
53
54
56 ConstraintComponentData& data, const int start, const int size) const {
57 pdipm::computeComplementarySlackness(barrier_, data, start, size);
58}
59
60
61template <int Size>
63 ConstraintComponentData& data, const int start) const {
64 pdipm::computeComplementarySlackness<Size>(barrier_, data, start);
65}
66
67
69 const double slack, const double dual) const {
70 return pdipm::computeComplementarySlackness(barrier_, slack, dual);
71}
72
73
77}
78
79
81 ConstraintComponentData& data, const int start, const int size) {
82 pdipm::computeCondensingCoeffcient(data, start, size);
83}
84
85
86template <int Size>
88 ConstraintComponentData& data, const int start) {
89 pdipm::computeCondensingCoeffcient<Size>(data, start);
90}
91
92
94 const double slack, const double dual, const double residual,
95 const double cmpl) {
96 return pdipm::computeCondensingCoeffcient(slack, dual, residual, cmpl);
97}
98
99
103}
104
105
107 ConstraintComponentData& data, const int start, const int size) {
108 pdipm::computeDualDirection(data, start, size);
109}
110
111
112template <int Size>
114 ConstraintComponentData& data, const int start) {
115 pdipm::computeDualDirection<Size>(data, start);
116}
117
118
120 const double slack, const double dual, const double dslack,
121 const double cmpl) {
122 return (- (dual * dslack + cmpl) / slack);
123}
124
125
126template <typename VectorType>
128 const Eigen::MatrixBase<VectorType>& slack) const {
129 return pdipm::logBarrier(barrier_, slack);
130}
131
132} // namespace robotoc
133
134#endif // ROBOTOC_IMPACT_CONSTRAINT_COMPONENT_BASE_HXX_
Data used in constraint components. Composed by slack, dual (Lagrange multiplier),...
Definition: constraint_component_data.hpp:17
Eigen::VectorXd ddual
Newton direction of the dual. Size is ConstraintComponentData::dimc().
Definition: constraint_component_data.hpp:91
Eigen::VectorXd dslack
Newton direction of the slack. Size is ConstraintComponentData::dimc().
Definition: constraint_component_data.hpp:85
Eigen::VectorXd slack
Slack variable of the constraint. Size is ConstraintComponentData::dimc(). All elements must be posit...
Definition: constraint_component_data.hpp:61
Eigen::VectorXd dual
Dual variable (Lagrange multiplier) of the constraint. Size is ConstraintComponentData::dimc()....
Definition: constraint_component_data.hpp:67
static void computeDualDirection(ConstraintComponentData &data)
Computes the direction of the dual variable from slack, primal residual, complementarity slackness,...
Definition: impact_constraint_component_base.hxx:100
static void computeCondensingCoeffcient(ConstraintComponentData &data)
Computes the coefficient of the condensing.
Definition: impact_constraint_component_base.hxx:74
double maxSlackStepSize(const ConstraintComponentData &data) const
Computes and returns the maximum step size by applying fraction-to-boundary-rule to the direction of ...
Definition: impact_constraint_component_base.hxx:12
void computeComplementarySlackness(ConstraintComponentData &data) const
Computes the residual in the complementarity slackness between the slack and dual variables.
Definition: impact_constraint_component_base.hxx:49
double logBarrier(const Eigen::MatrixBase< VectorType > &slack) const
Computes the log barrier function of the slack variable.
Definition: impact_constraint_component_base.hxx:127
double maxDualStepSize(const ConstraintComponentData &data) const
Computes and returns the maximum step size by applying fraction-to-boundary-rule to the direction of ...
Definition: impact_constraint_component_base.hxx:18
static void updateSlack(ConstraintComponentData &data, const double step_size)
Updates the slack variable according to the step size.
Definition: impact_constraint_component_base.hxx:24
static void updateDual(ConstraintComponentData &data, const double step_size)
Updates the dual variable according to the step size.
Definition: impact_constraint_component_base.hxx:31
std::shared_ptr< Derived > as_shared_ptr()
Gets the shared ptr of this object as the specified type. If this fails in dynamic casting,...
Definition: impact_constraint_component_base.hxx:39
void computeCondensingCoeffcient(ConstraintComponentData &data)
Computes the coefficient of the condensing.
Definition: pdipm.hxx:66
void computeComplementarySlackness(const double barrier_param, ConstraintComponentData &data)
Computes the residual in the complementarity slackness between the slack and dual variables.
Definition: pdipm.hxx:27
void computeDualDirection(ConstraintComponentData &data)
Computes the direction of the dual variable from slack, primal residual, complementary slackness,...
Definition: pdipm.hxx:159
double fractionToBoundaryDual(const double fraction_rate, const ConstraintComponentData &data)
Applies the fraction-to-boundary-rule to the directions of the dual variables.
Definition: pdipm.hxx:112
double fractionToBoundarySlack(const double fraction_rate, const ConstraintComponentData &data)
Applies the fraction-to-boundary-rule to the directions of the slack variables.
Definition: pdipm.hxx:103
double logBarrier(const double barrier_param, const Eigen::MatrixBase< VectorType > &vec)
Computes the log barrier function.
Definition: pdipm.hxx:195
Definition: constraint_component_base.hpp:17