akreon-control
Optimal and robust control and state estimation in C++26.
Loading...
Searching...
No Matches
h2_polytopic_state_observer.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 = VertexObserver::StateDim;
34 static constexpr std::size_t ExogenousDim = VertexObserver::ExogenousDim;
35 static constexpr std::size_t MeasurementDim = VertexObserver::MeasurementDim;
36 static constexpr std::size_t PerformanceDim = VertexObserver::PerformanceDim;
37 static constexpr std::size_t QDim = VertexObserver::QDim;
38 static constexpr std::size_t WDim = VertexObserver::WDim;
39 static constexpr std::size_t ZDim = VertexObserver::ZDim;
40 static constexpr std::size_t DecVarDim = VertexObserver::DecVarDim;
41
42 using QMat = typename VertexObserver::QMat;
43 using WMat = typename VertexObserver::WMat;
44 using LMat = typename VertexObserver::LMat;
45 using ZMat = typename VertexObserver::ZMat;
47 using Polytope = linalg::Vector<Plant, N>;
48
58 template <convex::AtomLike DecVar>
59 constexpr auto operator()(const Polytope& poly, const DecVar& Z_hat,
60 T margin = 1e-6) const {
61 return apply(poly, Z_hat, margin);
62 }
63
73 template <convex::AtomLike DecVar>
74 constexpr auto apply(const Polytope& poly, const DecVar& Z_hat,
75 T margin = 1e-6) const {
76 static_assert(convex::is_var_type_v<DecVar>, "Input atom is not a var");
77 using DecVarDom = convex::meta_dom_t<convex::atom_meta_t<DecVar>>;
78 static_assert(convex::dom_vartype_v<DecVarDom> == convex::VarType::FREE,
79 "Merged decision var must be free");
80 static_assert(std::same_as<DecVarSpace, convex::dom_space_t<DecVarDom>>,
81 "Expected merged decision size [svec(Q); vec(W); svec(Z)]");
82
83 auto make_vertex_lmis = [&]<std::size_t idx>() {
84 return VertexObserver()(poly(idx), Z_hat, margin);
85 };
86
88 [&]<std::size_t... Is>(std::index_sequence<Is...>) {
89 return convex::Intersection(
90 make_vertex_lmis.template operator()<Is>()...);
91 };
92
93 return form_intersection(std::make_index_sequence<N>{});
94 }
95
103 template <convex::AtomLike DecVar>
104 constexpr auto objective(const DecVar& Z_hat) const {
105 return VertexObserver().objective(Z_hat);
106 }
107
116 constexpr auto L(const QMat& Q, const WMat& W) const {
117 return VertexObserver().L(Q, W);
118 }
119};
120
130template <ContinuousPlantModelLike Plant, std::size_t N,
131 convex::AtomLike DecVar>
133 const linalg::Vector<Plant, N>& poly, const DecVar& Z_hat,
136 const auto lmis = h2(poly, Z_hat, margin);
137 const auto prob = convex::make_problem(Z_hat).in_set(lmis);
138 const auto obj = h2.objective(Z_hat);
139 return prob.minimize(obj);
140}
141
142} // namespace control
constexpr bool is_continuous_v
check if continuous or not
constexpr auto make_h2_polytopic_state_observer_problem(const linalg::Vector< Plant, N > &poly, const DecVar &Z_hat, plant_type_t< Plant > margin=1e-6)
make polytopic state observer
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 objective(const DecVar &Z_hat) const
objective
typename VertexObserver::DecVarSpace DecVarSpace
constexpr auto operator()(const Polytope &poly, const DecVar &Z_hat, T margin=1e-6) const
operator overload to form H2 polytopic state observer
constexpr auto apply(const Polytope &poly, const DecVar &Z_hat, T margin=1e-6) const
apply
constexpr auto L(const QMat &Q, const WMat &W) const
L (observer gain)
static constexpr std::size_t PerformanceDim
linalg::RowVector< T, DecVarDim > DecVarSpace
linalg::Matrix< T, StateDim, MeasurementDim > LMat
static constexpr std::size_t ZDim
static constexpr std::size_t MeasurementDim
linalg::Matrix< T, ExogenousDim, ExogenousDim > ZMat
static constexpr std::size_t WDim
static constexpr std::size_t QDim
static constexpr std::size_t StateDim
linalg::Matrix< T, StateDim, StateDim > QMat
static constexpr std::size_t ExogenousDim
linalg::Matrix< T, StateDim, MeasurementDim > WMat
static constexpr std::size_t DecVarDim