robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
constraint_component_base.hxx
Go to the documentation of this file.
1#ifndef ROBOTOC_CONSTRAINT_COMPONENT_BASE_HXX_
2#define ROBOTOC_CONSTRAINT_COMPONENT_BASE_HXX_
3
6
7#include <cassert>
8#include <stdexcept>
9
10
11namespace robotoc {
12
14 const ConstraintComponentData& data) const {
15 return pdipm::fractionToBoundarySlack(fraction_to_boundary_rule_, data);
16}
17
18
20 const ConstraintComponentData& data) const {
21 return pdipm::fractionToBoundaryDual(fraction_to_boundary_rule_, data);
22}
23
24
26 const double step_size) {
27 assert(step_size > 0);
28 data.slack.noalias() += step_size * data.dslack;
29}
30
31
33 const double step_size) {
34 assert(step_size > 0);
35 data.dual.noalias() += step_size * data.ddual;
36}
37
38
39template <typename Derived>
40inline std::shared_ptr<Derived> ConstraintComponentBase::as_shared_ptr() {
41 auto ptr = shared_from_this();
42 auto derived_ptr = std::dynamic_pointer_cast<Derived>(ptr);
43 if (derived_ptr == nullptr) {
44 throw std::runtime_error("[ConstraintComponentBase] runtime error: failed in down-casting!");
45 }
46 return derived_ptr;
47}
48
49
51 ConstraintComponentData& data) const {
53}
54
55
57 ConstraintComponentData& data, const int start, const int size) const {
58 pdipm::computeComplementarySlackness(barrier_, data, start, size);
59}
60
61
62template <int Size>
64 ConstraintComponentData& data, const int start) const {
65 pdipm::computeComplementarySlackness<Size>(barrier_, data, start);
66}
67
68
70 const double slack, const double dual) const {
71 return pdipm::computeComplementarySlackness(barrier_, slack, dual);
72}
73
74
78}
79
80
82 ConstraintComponentData& data, const int start, const int size) {
83 pdipm::computeCondensingCoeffcient(data, start, size);
84}
85
86
87template <int Size>
89 ConstraintComponentData& data, const int start) {
90 pdipm::computeCondensingCoeffcient<Size>(data, start);
91}
92
93
95 const double slack, const double dual, const double residual,
96 const double cmpl) {
97 return pdipm::computeCondensingCoeffcient(slack, dual, residual, cmpl);
98}
99
100
104}
105
106
108 ConstraintComponentData& data, const int start, const int size) {
109 pdipm::computeDualDirection(data, start, size);
110}
111
112
113template <int Size>
115 ConstraintComponentData& data, const int start) {
116 pdipm::computeDualDirection<Size>(data, start);
117}
118
119
121 const double slack, const double dual, const double dslack,
122 const double cmpl) {
123 return pdipm::computeDualDirection(slack, dual, dslack, cmpl);
124}
125
126
127template <typename VectorType>
129 const Eigen::MatrixBase<VectorType>& slack) const {
130 return pdipm::logBarrier(barrier_, slack);
131}
132
133} // namespace robotoc
134
135#endif // ROBOTOC_CONSTRAINT_COMPONENT_BASE_HXX_
static void updateDual(ConstraintComponentData &data, const double step_size)
Updates the dual variable according to the step size.
Definition: constraint_component_base.hxx:32
double logBarrier(const Eigen::MatrixBase< VectorType > &slack) const
Computes the log barrier function of the slack variable.
Definition: constraint_component_base.hxx:128
static void computeDualDirection(ConstraintComponentData &data)
Computes the direction of the dual variable from slack, primal residual, complementary slackness,...
Definition: constraint_component_base.hxx:101
void computeComplementarySlackness(ConstraintComponentData &data) const
Computes the residual in the complementarity slackness between the slack and dual variables.
Definition: constraint_component_base.hxx:50
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: constraint_component_base.hxx:40
double maxDualStepSize(const ConstraintComponentData &data) const
Computes and returns the maximum step size by applying fraction-to-boundary-rule to the direction of ...
Definition: constraint_component_base.hxx:19
static void updateSlack(ConstraintComponentData &data, const double step_size)
Updates the slack variable according to the step size.
Definition: constraint_component_base.hxx:25
static void computeCondensingCoeffcient(ConstraintComponentData &data)
Computes the coefficient of the condensing.
Definition: constraint_component_base.hxx:75
double maxSlackStepSize(const ConstraintComponentData &data) const
Computes and returns the maximum step size by applying fraction-to-boundary-rule to the direction of ...
Definition: constraint_component_base.hxx:13
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
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