aligator  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
workspace.hpp
Go to the documentation of this file.
1
4#pragma once
5
9
10#include <proxsuite-nlp/modelling/constraints.hpp>
11
12namespace aligator {
13
14template <typename Scalar>
16 std::vector<xyz::polymorphic<ConstraintSetTpl<Scalar>>> components;
17 for (size_t i = 0; i < constraints.size(); i++) {
18 components.push_back(constraints.sets[i]);
19 }
20 return proxsuite::nlp::ConstraintSetProductTpl<Scalar>{components,
21 constraints.dims()};
22}
23
28template <typename Scalar> struct WorkspaceTpl : WorkspaceBaseTpl<Scalar> {
32 using VecBool = Eigen::Matrix<bool, Eigen::Dynamic, 1>;
34 using ConstraintSetProduct = proxsuite::nlp::ConstraintSetProductTpl<Scalar>;
35 using BlkJacobianType = BlkMatrix<MatrixXs, -1, 2>; // jacobians
37
38 using Base::dyn_slacks;
39 using Base::nsteps;
41
43 gar::LQRProblemTpl<Scalar> lqr_problem; //< Linear-quadratic subproblem
44
47 std::vector<VectorXs> Lxs; //< State gradients
48 std::vector<VectorXs> Lus; //< Control gradients
49 std::vector<VectorXs> Lvs; //< Path multiplier gradients
50 std::vector<VectorXs> Lds; //< Costate gradients
52
55 using Base::trial_us;
56 using Base::trial_xs;
57 std::vector<VectorXs> trial_vs;
58 std::vector<VectorXs> trial_lams;
60
63 std::vector<VectorXs> lams_plus;
64 std::vector<VectorXs> lams_pdal;
65 std::vector<VectorXs> vs_plus;
66 std::vector<VectorXs> vs_pdal;
68
70 std::vector<VectorXs> shifted_constraints;
71 std::vector<VectorXs> cstr_lx_corr;
72 std::vector<VectorXs> cstr_lu_corr;
74 std::vector<BlkJacobianType> cstr_proj_jacs;
76 std::vector<VecBool> active_constraints;
78 std::vector<ConstraintSetProduct> cstr_product_sets;
79
82 std::vector<VectorXs> dxs;
83 std::vector<VectorXs> dus;
84 std::vector<VectorXs> dvs;
85 std::vector<VectorXs> dlams;
87
90 std::vector<VectorXs> prev_xs;
91 std::vector<VectorXs> prev_us;
92 std::vector<VectorXs> prev_vs;
93 std::vector<VectorXs> prev_lams;
95
101 std::vector<VectorXs> stage_infeasibilities;
107 Scalar inner_criterion = 0.;
108
111
112 WorkspaceTpl(const WorkspaceTpl &) = delete;
114
117
119 shared_ptr<StageDataTpl<Scalar>> data);
120
121 template <typename T>
122 friend std::ostream &operator<<(std::ostream &oss,
123 const WorkspaceTpl<T> &self);
124};
125
126template <typename Scalar>
127std::ostream &operator<<(std::ostream &oss, const WorkspaceTpl<Scalar> &self) {
128 oss << "Workspace {" << fmt::format("\n nsteps: {:d}", self.nsteps)
129 << fmt::format("\n n_multipliers: {:d}", self.lams_pdal.size());
130 oss << "\n}";
131 return oss;
132}
133
134} // namespace aligator
135
136template <typename Scalar>
137struct fmt::formatter<aligator::WorkspaceTpl<Scalar>> : fmt::ostream_formatter {
138};
139
140#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
141#include "./workspace.txx"
142#endif
Block matrix class, with a fixed-size number of row and column blocks.
Main package namespace.
std::ostream & operator<<(std::ostream &oss, const ExplicitDynamicsDataTpl< S > &self)
auto getConstraintProductSet(const ConstraintStackTpl< Scalar > &constraints)
Definition workspace.hpp:15
Convenience class to manage a stack of constraints.
Definition fwd.hpp:101
Data struct for stage models StageModelTpl.
Definition fwd.hpp:93
A stage in the control problem.
Definition fwd.hpp:90
Trajectory optimization problem.
Definition fwd.hpp:104
Base workspace struct for the algorithms.
Definition fwd.hpp:116
std::size_t nsteps
Number of steps in the problem.
std::vector< VectorXs > trial_us
TrajOptDataTpl< Scalar > problem_data
Problem data.
std::vector< VectorXs > dyn_slacks
Dynamical infeasibility gaps.
std::vector< VectorXs > trial_xs
Workspace for solver SolverProxDDP.
Definition workspace.hpp:28
ALIGATOR_DYNAMIC_TYPEDEFS(Scalar)
WorkspaceTpl(const WorkspaceTpl &)=delete
VectorXs state_dual_infeas
Dual infeasibility in the states for each stage of the problem.
gar::LQRProblemTpl< Scalar > lqr_problem
Definition workspace.hpp:43
std::vector< VectorXs > dlams
Definition workspace.hpp:85
std::vector< VectorXs > dvs
Definition workspace.hpp:84
std::size_t nsteps
Number of steps in the problem.
std::vector< VectorXs > trial_lams
Definition workspace.hpp:58
std::vector< VectorXs > vs_plus
Definition workspace.hpp:65
std::vector< VecBool > active_constraints
Masks for active constraint sets.
Definition workspace.hpp:76
friend std::ostream & operator<<(std::ostream &oss, const WorkspaceTpl< T > &self)
LQRProblemType::KnotVector knots
Definition workspace.hpp:42
std::vector< VectorXs > dxs
Definition workspace.hpp:82
std::vector< VectorXs > lams_plus
Definition workspace.hpp:63
std::vector< VectorXs > Lus
Definition workspace.hpp:48
std::vector< VectorXs > shifted_constraints
Shifted constraints the projection operators should be applied to.
Definition workspace.hpp:70
std::vector< VectorXs > prev_lams
Definition workspace.hpp:93
std::vector< VectorXs > Lxs
Definition workspace.hpp:47
WorkspaceTpl(const TrajOptProblemTpl< Scalar > &problem)
std::vector< VectorXs > Lvs
Definition workspace.hpp:49
std::vector< VectorXs > lams_pdal
Definition workspace.hpp:64
Eigen::Matrix< bool, Eigen::Dynamic, 1 > VecBool
Definition workspace.hpp:32
VectorXs stage_cstr_violations
Constraint violation measures for each stage and constraint.
Definition workspace.hpp:99
std::vector< BlkJacobianType > cstr_proj_jacs
Projected path constraint Jacobians (used to symmetrize the LQ subproblem)
Definition workspace.hpp:74
std::vector< VectorXs > vs_pdal
Definition workspace.hpp:66
std::vector< VectorXs > prev_vs
Definition workspace.hpp:92
std::vector< VectorXs > prev_us
Definition workspace.hpp:91
std::vector< VectorXs > dus
Definition workspace.hpp:83
VectorXs stage_inner_crits
Subproblem termination criterion for each stage.
Definition workspace.hpp:97
std::vector< VectorXs > stage_infeasibilities
Stagewise infeasibilities.
WorkspaceTpl & operator=(const WorkspaceTpl &)=delete
WorkspaceTpl & operator=(WorkspaceTpl &&)=default
std::vector< ConstraintSetProduct > cstr_product_sets
Cartesian products of the constraint sets of each stage.
Definition workspace.hpp:78
proxsuite::nlp::ConstraintSetProductTpl< Scalar > ConstraintSetProduct
Definition workspace.hpp:34
std::vector< VectorXs > cstr_lu_corr
Definition workspace.hpp:72
Scalar inner_criterion
Overall subproblem termination criterion.
std::vector< VectorXs > prev_xs
Definition workspace.hpp:90
std::vector< VectorXs > cstr_lx_corr
Definition workspace.hpp:71
WorkspaceTpl(WorkspaceTpl &&)=default
void cycleAppend(const TrajOptProblemTpl< Scalar > &problem, shared_ptr< StageDataTpl< Scalar > > data)
VectorXs control_dual_infeas
Dual infeasibility in the controls for each stage of the problem.
std::vector< VectorXs > trial_vs
Definition workspace.hpp:57
std::vector< VectorXs > Lds
Definition workspace.hpp:50
Struct describing a stage of a constrained LQ problem.
std::vector< KnotType > KnotVector