proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
results.hpp
Go to the documentation of this file.
1
3#pragma once
4
7
8namespace proxsuite {
9namespace nlp {
10
12inline auto format_as(ConvergenceFlag fl) { return fmt::underlying(fl); }
13
20template <typename _Scalar> struct ResultsTpl {
21 using Scalar = _Scalar;
24 using VecBool = Eigen::Matrix<bool, Eigen::Dynamic, 1>;
25
27
30 VectorXs x_opt;
31 VectorXs data_lams_opt;
32 VectorOfRef lams_opt;
34 std::vector<VecBool> active_set;
41
43 std::size_t num_iters = 0;
44 std::size_t al_iters = 0;
47
48 ResultsTpl(const Problem &prob)
49 : x_opt(prob.manifold_->neutral()),
50 data_lams_opt(prob.getTotalConstraintDim()),
51 constraint_violations(prob.getNumConstraints()), num_iters(0), mu(0.),
52 rho(0.) {
54 constraint_violations.setZero();
55 active_set.reserve(prob.getNumConstraints());
56 for (std::size_t i = 0; i < prob.getNumConstraints(); i++) {
57 active_set.push_back(VecBool::Zero(prob.getConstraint(i).func().nr()));
58 }
59 }
60
61 friend std::ostream &operator<<(std::ostream &oss,
62 const ResultsTpl<Scalar> &self) {
63 oss << "Results {" << fmt::format("\n convergence: {},", self.converged)
64 << fmt::format("\n merit: {:.3e},", self.merit)
65 << fmt::format("\n value: {:.3e},", self.value)
66 << fmt::format("\n num_iters: {:d},", self.num_iters)
67 << fmt::format("\n mu: {:.3e},", self.mu)
68 << fmt::format("\n rho: {:.3e},", self.rho)
69 << fmt::format("\n dual_infeas: {:.3e},", self.dual_infeas)
70 << fmt::format("\n prim_infeas: {:.3e},", self.prim_infeas)
71 << fmt::format("\n cstr_values: {}",
72 self.constraint_violations.transpose());
73 for (std::size_t i = 0; i < self.active_set.size(); i++) {
74 oss << fmt::format("\n activeSet[{:d}]: {}", i,
75 self.active_set[i].transpose());
76 }
77 oss << "\n}";
78 return oss;
79 }
80};
81
82} // namespace nlp
83} // namespace proxsuite
84
85template <typename Scalar>
86struct fmt::formatter<::proxsuite::nlp::ResultsTpl<Scalar>>
87 : fmt::ostream_formatter {};
88
89#ifdef PROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION
90#include "proxsuite-nlp/results.txx"
91#endif
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:26
void allocateMultipliersOrResiduals(const ProblemTpl< Scalar > &prob, typename math_types< Scalar >::VectorXs &data, typename math_types< Scalar >::VectorOfRef &out)
Allocate a set of multipliers (or residuals) for a given problem instance.
auto format_as(ConvergenceFlag fl)
Definition results.hpp:12
Main package namespace.
Definition bcl-params.hpp:5
int nr() const
Get function codimension.
const FunctionType & func() const
std::size_t getNumConstraints() const
Get the number of constraint blocks.
const ConstraintObject & getConstraint(const std::size_t &i) const
Get a pointer to the -th constraint pointer.
Results struct, holding the returned data from the solver.
Definition results.hpp:20
std::size_t num_iters
Final solver parameters.
Definition results.hpp:43
Scalar dual_infeas
Dual infeasibility error.
Definition results.hpp:36
friend std::ostream & operator<<(std::ostream &oss, const ResultsTpl< Scalar > &self)
Definition results.hpp:61
Scalar prim_infeas
Primal infeasibility error.
Definition results.hpp:38
ResultsTpl(const Problem &prob)
Definition results.hpp:48
ConvergenceFlag converged
Definition results.hpp:26
Eigen::Matrix< bool, Eigen::Dynamic, 1 > VecBool
Definition results.hpp:24
std::vector< VecBool > active_set
Current active set of the algorithm.
Definition results.hpp:34
VectorXs constraint_violations
Violations for each constraint.
Definition results.hpp:40