@@ -16,6 +16,7 @@ class swSQP{
1616 struct stage_statistics
1717 {
1818 double cost;
19+ double constraint_violation;
1920 };
2021
2122 struct statistics
@@ -28,6 +29,7 @@ class swSQP{
2829 std::vector<stage_statistics> stages_statistics;
2930 int iters;
3031 double cost;
32+ double constraint_violation;
3133 double alpha;
3234 int line_search_iters;
3335 bool line_search_accepted;
@@ -43,28 +45,34 @@ class swSQP{
4345 _oss<<" === swSQP Statistics ===" <<std::endl;
4446 _oss << " iter : " << iters << std::endl;
4547 _oss << " cost : " << cost << std::endl;
48+ _oss << " sum-constr-viol : " << constraint_violation << std::endl;
4649 _oss << " iter time : " << iter_time << std::endl;
4750 _oss << " total time : " << total_time << std::endl;
4851 _oss << " === LineSearch Statistics === " << std::endl;
4952 _oss << " accepted : " << line_search_accepted << std::endl;
5053 _oss << " alpha : " << alpha << std::endl;
5154 _oss << " ls iters : " << line_search_iters << std::endl;
52- // TODO constraint violation
5355
5456
5557 _oss << " === swSQP Stage Statistics ===" << std::endl;
56- // Header row
57- _oss << std::setw (15 ) << " Statistic" ;
58- for (size_t i = 0 ; i < stages_statistics.size (); ++i) {
59- _oss << std::setw (12 ) << (" Stage " + std::to_string (i));
60- }
61- _oss << std::endl;
6258
63- _oss << std::setw (15 ) << " cost" ;
64- for (const auto & s : stages_statistics) {
65- _oss << std::setw (12 ) << s.cost ;
59+ // Column headers
60+ _oss << std::setw (10 ) << " Stage"
61+ << std::setw (15 ) << " Cost"
62+ << std::setw (25 ) << " Constr-Viol"
63+ << std::endl;
64+
65+ // Print a separator line (optional)
66+ _oss << std::string (50 , ' -' ) << std::endl;
67+
68+ // Print one row per stage
69+ for (size_t i = 0 ; i < stages_statistics.size (); ++i) {
70+ const auto & s = stages_statistics[i];
71+ _oss << std::setw (10 ) << i
72+ << std::setw (15 ) << s.cost
73+ << std::setw (25 ) << s.constraint_violation
74+ << std::endl;
6675 }
67- _oss << std::endl;
6876
6977 return _oss;
7078 }
@@ -135,7 +143,6 @@ class swSQP{
135143
136144
137145 void computeDynamics (const unsigned int i, Eigen::MatrixXd& A, Eigen::MatrixXd& B, Eigen::VectorXd& b);
138- // void computeQuadraticApproximation(const unsigned int i, Eigen::MatrixXd& H, Eigen::VectorXd& g);
139146 void computeCost (const unsigned int i,
140147 Eigen::MatrixXd& Q, Eigen::VectorXd& q,
141148 Eigen::MatrixXd& R, Eigen::VectorXd& r,
@@ -145,6 +152,7 @@ class swSQP{
145152
146153
147154 void linearize (); // update linearization/quadritization matrices
155+ void update_statistics ();
148156 void step (double alpha); // step of the solver
149157 bool break_criteria (); // sqp solvers breaking criteria
150158
0 commit comments