robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
constraints_data.hxx
Go to the documentation of this file.
1#ifndef ROBOTOC_CONSTRAINTS_DATA_HXX_
2#define ROBOTOC_CONSTRAINTS_DATA_HXX_
3
5
6
7namespace robotoc {
8
9inline double ConstraintsData::KKTError() const {
10 double err = 0.0;
12 for (const auto& data : position_level_data) {
13 err += data.KKTError();
14 }
15 }
17 for (const auto& data : velocity_level_data) {
18 err += data.KKTError();
19 }
20 }
22 for (const auto& data : acceleration_level_data) {
23 err += data.KKTError();
24 }
25 }
26 if (isImpactLevelValid()) {
27 for (const auto& data : impact_level_data) {
28 err += data.KKTError();
29 }
30 }
31 return err;
32}
33
34
35inline double ConstraintsData::logBarrier() const {
36 double lb = 0.0;
38 for (const auto& data : position_level_data) {
39 lb += data.log_barrier;
40 }
41 }
43 for (const auto& data : velocity_level_data) {
44 lb += data.log_barrier;
45 }
46 }
48 for (const auto& data : acceleration_level_data) {
49 lb += data.log_barrier;
50 }
51 }
52 if (isImpactLevelValid()) {
53 for (const auto& data : impact_level_data) {
54 lb += data.log_barrier;
55 }
56 }
57 return lb;
58}
59
60
61template <int p>
63 double feasibility = 0.0;
65 for (const auto& data : position_level_data) {
66 feasibility += data.template primalFeasibility<p>();
67 }
68 }
70 for (const auto& data : velocity_level_data) {
71 feasibility += data.template primalFeasibility<p>();
72 }
73 }
75 for (const auto& data : acceleration_level_data) {
76 feasibility += data.template primalFeasibility<p>();
77 }
78 }
79 if (isImpactLevelValid()) {
80 for (const auto& data : impact_level_data) {
81 feasibility += data.template primalFeasibility<p>();
82 }
83 }
84 return feasibility;
85}
86
87
88template <int p>
89inline double ConstraintsData::dualFeasibility() const {
90 double feasibility = 0.0;
92 for (const auto& data : position_level_data) {
93 feasibility += data.template dualFeasibility<p>();
94 }
95 }
97 for (const auto& data : velocity_level_data) {
98 feasibility += data.template dualFeasibility<p>();
99 }
100 }
102 for (const auto& data : acceleration_level_data) {
103 feasibility += data.template dualFeasibility<p>();
104 }
105 }
106 if (isImpactLevelValid()) {
107 for (const auto& data : impact_level_data) {
108 feasibility += data.template dualFeasibility<p>();
109 }
110 }
111 return feasibility;
112}
113
114} // namespace robotoc
115
116#endif // ROBOTOC_CONSTRAINTS_DATA_XXH
bool isPositionLevelValid() const
Checks wheather the position-level constraints are valid or not.
Definition: constraints_data.hpp:65
double primalFeasibility() const
Returns the lp norm of the primal feasibility, i.e., the constraint violation. Default norm is l1-nor...
Definition: constraints_data.hxx:62
std::vector< ConstraintComponentData > acceleration_level_data
The collection of the acceleration-level constraints data.
Definition: constraints_data.hpp:142
bool isVelocityLevelValid() const
Checks wheather the velocity-level constraints are valid or not.
Definition: constraints_data.hpp:73
bool isAccelerationLevelValid() const
Checks wheather the acceleration-level constraints are valid or not.
Definition: constraints_data.hpp:82
std::vector< ConstraintComponentData > velocity_level_data
The collection of the velocity-level constraints data.
Definition: constraints_data.hpp:137
bool isImpactLevelValid() const
Checks wheather the impact-level constraints are valid or not.
Definition: constraints_data.hpp:90
double KKTError() const
Returns the sum of the squared norm of the KKT error (primal residual and complementary slackness) of...
Definition: constraints_data.hxx:9
double dualFeasibility() const
Returns the lp norm of the dual feasibility. Default norm is l1-norm. You can also specify l-infty no...
Definition: constraints_data.hxx:89
double logBarrier() const
Returns the sum of the log-barrier of the slack variables of all the constraints.
Definition: constraints_data.hxx:35
std::vector< ConstraintComponentData > impact_level_data
The collection of the impact-level constraints data.
Definition: constraints_data.hpp:147
std::vector< ConstraintComponentData > position_level_data
The collection of the position-level constraints data.
Definition: constraints_data.hpp:132
Definition: constraint_component_base.hpp:17