akreon-control
Optimal and robust control and state estimation in C++26.
Loading...
Searching...
No Matches
h2_polytopic_state_feedback.hpp
Go to the documentation of this file.
1/*
2 * Copyright © 2025-2026 Akreon LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#pragma once
7
9#include "akreon/convex/convex_problem.hpp"
10#include "akreon/convex/intersection.hpp"
11#include "akreon/convex/variable.hpp"
12
13namespace control {
14
26template <ContinuousPlantModelLike Plant, std::size_t N>
29 using Model = linalg::remove_cvref_t<Plant>;
32
33 static constexpr std::size_t StateDim = VertexFeedback::StateDim;
34 static constexpr std::size_t InputDim = VertexFeedback::InputDim;
35 static constexpr std::size_t OutputDim = VertexFeedback::OutputDim;
36 static constexpr std::size_t QDim = VertexFeedback::QDim;
37 static constexpr std::size_t YDim = VertexFeedback::YDim;
38 static constexpr std::size_t ZDim = VertexFeedback::ZDim;
39 static constexpr std::size_t DecVarDim = VertexFeedback::DecVarDim;
40
41 using QMat = typename VertexFeedback::QMat;
42 using YMat = typename VertexFeedback::YMat;
43 using KMat = typename VertexFeedback::KMat;
44 using ZMat = typename VertexFeedback::ZMat;
46 using Polytope = linalg::Vector<Plant, N>;
47
57 template <convex::AtomLike DecVar>
58 constexpr auto operator()(const Polytope& poly, const DecVar& Z_hat,
59 T margin = 1e-6) const {
60 return apply(poly, Z_hat, margin);
61 }
62
72 template <convex::AtomLike DecVar>
73 constexpr auto apply(const Polytope& poly, const DecVar& Z_hat,
74 T margin = 1e-6) const {
75 static_assert(convex::is_var_type_v<DecVar>, "Input atom is not a var");
76 using DecVarDom = convex::meta_dom_t<convex::atom_meta_t<DecVar>>;
77 static_assert(convex::dom_vartype_v<DecVarDom> == convex::VarType::FREE,
78 "Merged decision var must be free");
79 static_assert(std::same_as<DecVarSpace, convex::dom_space_t<DecVarDom>>,
80 "Expected merged decision size [svec(Q); vec(Y); svec(Z)]");
81
82 auto make_vertex_lmis = [&]<std::size_t idx>() {
83 return VertexFeedback()(poly(idx), Z_hat, margin);
84 };
85
87 [&]<std::size_t... Is>(std::index_sequence<Is...>) {
88 return convex::Intersection(
89 make_vertex_lmis.template operator()<Is>()...);
90 };
91
92 return form_intersection(std::make_index_sequence<N>{});
93 }
94
102 template <convex::AtomLike DecVar>
103 constexpr auto objective(const DecVar& Z_hat) const {
104 return VertexFeedback().objective(Z_hat);
105 }
106
115 constexpr auto K(const QMat& Q, const YMat& Y) const {
116 return VertexFeedback().K(Q, Y);
117 }
118};
119
129template <ContinuousPlantModelLike Plant, std::size_t N,
130 convex::AtomLike DecVar>
132 const linalg::Vector<Plant, N>& poly, const DecVar& Z_hat,
135 const auto lmis = h2(poly, Z_hat, margin);
136 const auto prob = convex::make_problem(Z_hat).in_set(lmis);
137 const auto obj = h2.objective(Z_hat);
138 return prob.minimize(obj);
139}
140
141} // namespace control
constexpr bool is_continuous_v
check if continuous or not
constexpr auto make_h2_polytopic_state_feedback_problem(const linalg::Vector< Plant, N > &poly, const DecVar &Z_hat, plant_type_t< Plant > margin=1e-6)
make polytopic H2
typename plant_traits< linalg::remove_cvref_t< Plant > >::T plant_type_t
extract scalar type from plant
linalg::remove_cvref_t< Plant > Model
extracting alias and types
constexpr auto operator()(const Polytope &poly, const DecVar &Z_hat, T margin=1e-6) const
operator overload to form H2 polytopic state feedback
constexpr auto objective(const DecVar &Z_hat) const
objective
typename VertexFeedback::DecVarSpace DecVarSpace
constexpr auto K(const QMat &Q, const YMat &Y) const
K (feedback gain)
constexpr auto apply(const Polytope &poly, const DecVar &Z_hat, T margin=1e-6) const
apply
linalg::RowVector< T, DecVarDim > DecVarSpace
linalg::Matrix< T, InputDim, StateDim > YMat
static constexpr std::size_t InputDim
linalg::Matrix< T, StateDim, StateDim > QMat
static constexpr std::size_t StateDim
linalg::Matrix< T, OutputDim, OutputDim > ZMat
static constexpr std::size_t OutputDim
static constexpr std::size_t QDim
static constexpr std::size_t ZDim
static constexpr std::size_t DecVarDim
linalg::Matrix< T, InputDim, StateDim > KMat
static constexpr std::size_t YDim