robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
constraint_component_data.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_CONSTRAINT_COMPONENT_DATA_HPP_
2#define ROBOTOC_CONSTRAINT_COMPONENT_DATA_HPP_
3
4#include <vector>
5
6#include "Eigen/Core"
7
8
9namespace robotoc {
10
18public:
25 ConstraintComponentData(const int dimc, const double barrier_param);
26
31
36
41
46
51
55 ConstraintComponentData& operator=(ConstraintComponentData&&) noexcept = default;
56
61 Eigen::VectorXd slack;
62
67 Eigen::VectorXd dual;
68
73 Eigen::VectorXd residual;
74
79 Eigen::VectorXd cmpl;
80
85 Eigen::VectorXd dslack;
86
91 Eigen::VectorXd ddual;
92
97 Eigen::VectorXd cond;
98
103
108 std::vector<Eigen::VectorXd> r;
109
114 std::vector<Eigen::MatrixXd> J;
115
122 double KKTError() const {
123 return (residual.squaredNorm() + cmpl.squaredNorm());
124 }
125
133 template <int p=1>
134 double primalFeasibility() const {
135 return residual.template lpNorm<p>();
136 }
137
145 template <int p=1>
146 double dualFeasibility() const {
147 return cmpl.template lpNorm<p>();
148 }
149
154 void resize(const int dimc);
155
160 int dimc() const {
161 return dimc_;
162 }
163
170
176 bool isApprox(const ConstraintComponentData& other) const;
177
178private:
179 int dimc_;
180
181};
182
183} // namespace robotoc
184
185#endif // ROBOTOC_CONSTRAINT_COMPONENT_DATA_HPP_
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
double primalFeasibility() const
Returns the lp norm of the primal feasibility, i.e., the constraint violation. Default norm is l1-nor...
Definition: constraint_component_data.hpp:134
double dualFeasibility() const
Returns the lp norm of the dual feasibility. Default norm is l1-norm. You can also specify l-infty no...
Definition: constraint_component_data.hpp:146
std::vector< Eigen::VectorXd > r
std vector of Eigen::VectorXd used to store residual temporaly. Only be allocated in ConstraintCompon...
Definition: constraint_component_data.hpp:108
Eigen::VectorXd residual
Primal residual of the constraint. Size is ConstraintComponentData::dimc().
Definition: constraint_component_data.hpp:73
bool checkDimensionalConsistency() const
Check whether dimensions of slack, dual, residual, cmpl, dslack, ddual are ConstraintComponentData::d...
ConstraintComponentData(const int dimc, const double barrier_param)
Constructor.
void resize(const int dimc)
Resizes the constraint.
ConstraintComponentData(const ConstraintComponentData &)=default
Default copy constructor.
int dimc() const
Dimension of the constraint.
Definition: constraint_component_data.hpp:160
ConstraintComponentData()
Default constructor.
Eigen::VectorXd dslack
Newton direction of the slack. Size is ConstraintComponentData::dimc().
Definition: constraint_component_data.hpp:85
~ConstraintComponentData()=default
Default destructor.
Eigen::VectorXd cond
Used in condensing of slack and dual. Size is ConstraintComponentData::dimc().
Definition: constraint_component_data.hpp:97
Eigen::VectorXd cmpl
Residual in the complementary slackness between slack and dual. Size is ConstraintComponentData::dimc...
Definition: constraint_component_data.hpp:79
ConstraintComponentData & operator=(const ConstraintComponentData &)=default
Default copy operator.
std::vector< Eigen::MatrixXd > J
std vector of Eigen::MatrixXd used to store Jacobian temporaly. Only be allocated in ConstraintCompon...
Definition: constraint_component_data.hpp:114
Eigen::VectorXd slack
Slack variable of the constraint. Size is ConstraintComponentData::dimc(). All elements must be posit...
Definition: constraint_component_data.hpp:61
ConstraintComponentData(ConstraintComponentData &&) noexcept=default
Default move constructor.
bool isApprox(const ConstraintComponentData &other) const
Checks the equivalence of two ConstraintComponentData.
double log_barrier
Value of the log berrier function of the slack variable.
Definition: constraint_component_data.hpp:102
double KKTError() const
Returns the squared norm of the KKT reisdual, that is, the sum of the squared norm of the primal resi...
Definition: constraint_component_data.hpp:122
Eigen::VectorXd dual
Dual variable (Lagrange multiplier) of the constraint. Size is ConstraintComponentData::dimc()....
Definition: constraint_component_data.hpp:67
Definition: constraint_component_base.hpp:17