EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
AmmFilter.h
Go to the documentation of this file.
1#pragma once
2
9
10#include <concepts>
11#include <utility>
12
21
22namespace Emrys
23{
24
80template <
81 Component Component_,
82 typename Model_,
83 typename Method_ = DefaultMethodFor<Model_>,
84 typename Allocator_ = DefaultAllocator,
85 typename Upkeep_ = upkeep::None>
86class AmmFilter : public ImmFilter<Component_, Model_, Method_, Allocator_, Upkeep_>
87{
88public:
89
91
95 template <typename... Models>
96 requires std::constructible_from<Model_, typename Model_::ChainType, Models...>
97 AmmFilter(typename Base::StateType state, Models... models)
98 // The braces sequence the arguments, so the chain copies the modes before the state moves.
99 : Base{Model_{typename Model_::ChainType{state.modeSpace()}, std::move(models)...}, std::move(state)}
100 {}
101
106 template <typename... Models>
107 requires(!isFixedStep<Model_> && std::constructible_from<Model_, typename Model_::ChainType, Models...>)
108 AmmFilter(Method_ method, typename Base::StateType state, Models... models)
109 : Base{
110 Model_{typename Model_::ChainType{state.modeSpace()}, std::move(models)...},
111 std::move(state),
112 std::move(method)
113 }
114 {}
115
119 template <typename... Models>
120 requires(
121 !std::same_as<Upkeep_, Emrys::upkeep::None>
122 && std::constructible_from<Model_, typename Model_::ChainType, Models...>
123 )
124 AmmFilter(std::type_identity_t<Upkeep_> upkeep, typename Base::StateType state, Models... models)
125 : Base{
126 Model_{typename Model_::ChainType{state.modeSpace()}, std::move(models)...},
127 std::move(state),
128 MethodFor<Model_, Method_>{},
129 std::move(upkeep)
130 }
131 {}
132
134 template <typename... Models>
135 requires(
136 !isFixedStep<Model_> && !std::same_as<Upkeep_, Emrys::upkeep::None>
137 && std::constructible_from<Model_, typename Model_::ChainType, Models...>
138 )
139 AmmFilter(Method_ method, std::type_identity_t<Upkeep_> upkeep, typename Base::StateType state, Models... models)
140 : Base{
141 Model_{typename Model_::ChainType{state.modeSpace()}, std::move(models)...},
142 std::move(state),
143 std::move(method),
144 std::move(upkeep)
145 }
146 {}
147};
148
150template <Component C, typename ModeSpace, typename Allocator, typename... Models>
151AmmFilter(HybridParams<C, ModeSpace, Allocator>, Models...) -> AmmFilter<
152 C,
153 SwitchingModel<
154 ModeSpace,
155 typename C::Scalar,
156 ModeSpace,
157 internal::BoundStep<Models, typename Params<C>::SpaceType, typename Params<C>::Scalar>...>,
158 DefaultMethodFor<SwitchingModel<ModeSpace, typename C::Scalar, ModeSpace, Models...>>,
159 Allocator>;
160
161template <typename Method, Component C, typename ModeSpace, typename Allocator, typename... Models>
162 requires(!internal::UpkeepArgument<Method>)
163AmmFilter(Method, HybridParams<C, ModeSpace, Allocator>, Models...) -> AmmFilter<
164 C,
165 SwitchingModel<
166 ModeSpace,
167 typename C::Scalar,
168 ModeSpace,
169 internal::BoundStep<Models, typename Params<C>::SpaceType, typename Params<C>::Scalar>...>,
170 Method,
171 Allocator>;
172
173template <typename U, Component C, typename ModeSpace, typename Allocator, typename... Models>
174 requires internal::UpkeepArgument<U>
175AmmFilter(U, HybridParams<C, ModeSpace, Allocator>, Models...) -> AmmFilter<
176 C,
177 SwitchingModel<
178 ModeSpace,
179 typename C::Scalar,
180 ModeSpace,
181 internal::BoundStep<Models, typename Params<C>::SpaceType, typename Params<C>::Scalar>...>,
182 DefaultMethodFor<SwitchingModel<ModeSpace, typename C::Scalar, ModeSpace, Models...>>,
183 Allocator,
184 U>;
185
186template <typename Method, typename U, Component C, typename ModeSpace, typename Allocator, typename... Models>
187AmmFilter(Method, U, HybridParams<C, ModeSpace, Allocator>, Models...) -> AmmFilter<
188 C,
189 SwitchingModel<
190 ModeSpace,
191 typename C::Scalar,
192 ModeSpace,
193 internal::BoundStep<Models, typename Params<C>::SpaceType, typename Params<C>::Scalar>...>,
194 Method,
195 Allocator,
196 U>;
198
199} // namespace Emrys
200
201#ifndef EMRYS_FILTER_NO_IO
202
203namespace Emrys
204{
205
206namespace internal
207{
208
210template <typename Component_, typename Model_, typename Method_, typename Allocator_, typename Upkeep_>
211void
212describe(
213 std::ostream & stream,
214 AmmFilter<Component_, Model_, Method_, Allocator_, Upkeep_> const & filter,
215 Indent indent
216)
217{
218 describeFilter(stream, "autonomous multiple model filter", filter.state(), indent);
219}
220
221} // namespace internal
222
223} // namespace Emrys
224
225#endif // EMRYS_FILTER_NO_IO
The allocator conventions of decisions.md [allocation]: DefaultAllocator, Capacity,...
The distribution over a discrete space (decisions.md [discrete-spaces], [params-and-density]): Catego...
What a container of several Gaussians needs of each one (decisions.md [component-first]): the Compone...
The hybrid state of a discrete mode and a component per mode (decisions.md [imm], [component-first]):...
ImmRecursion and ImmFilter (decisions.md [switching-models], [imm], [filters-and-recursions]): a Hybr...
Printing: operator<< and std::formatter for every distribution, every filter (which prints its name a...
Process models as functions with reads and writes (decisions.md [model-policies], [continuous-time-no...
SwitchingModel (decisions.md [switching-models], [imm]): a Markov chain on a discrete mode space and ...
AmmFilter(std::type_identity_t< Upkeep_ > upkeep, typename Base::StateType state, Models... models)
As AmmFilter(state, models...), with upkeep upkeep, which maintain() runs.
Definition AmmFilter.h:124
AmmFilter(Method_ method, typename Base::StateType state, Models... models)
As AmmFilter(state, models...), predicting by method.
Definition AmmFilter.h:108
AmmFilter(Method_ method, std::type_identity_t< Upkeep_ > upkeep, typename Base::StateType state, Models... models)
As AmmFilter(method, state, models...), with upkeep upkeep, which maintain() runs.
Definition AmmFilter.h:139
ImmFilter< Component_, Model_, Method_, Allocator_, Upkeep_ > Base
the filter this is
Definition AmmFilter.h:90
AmmFilter(typename Base::StateType state, Models... models)
A filter with initial state state whose modes follow models, one per mode in flat-index order or one ...
Definition AmmFilter.h:97
typename RecursionType::StateType StateType
Definition ImmFilter.h:1395
StateType const & state() const
Definition ImmFilter.h:1441
Method_ const & method() const
Definition ImmFilter.h:1502
ImmFilter(Model_ model, StateType state, MethodFor< Model_, Method_ > method={}, std::type_identity_t< Upkeep_ > upkeep={})
A filter with switching model model, initial state state, prediction method method,...
Definition ImmFilter.h:1404
The distribution that a container of several holds one of per element (decisions.md [component-first]...
Definition Component.h:299
std::allocator< std::byte > DefaultAllocator
The allocator a type with a run-time count uses unless given one.
Definition Allocation.h:47
typename internal::DefaultMethodOf< Model >::type DefaultMethodFor
The prediction method of a filter with process model Model, unless it is given one: Linearized,...
Definition ProcessModel.h:3220
constexpr bool isFixedStep
Whether Model is a FixedStepModel, whose predictions take no time step.
Definition ProcessModel.h:2776
std::conditional_t< isFixedStep< Model >, ModelsMethod, Method > MethodFor
The type of a filter constructor's method argument: Method, or ModelsMethod for a fixed-step Model,...
Definition ProcessModel.h:3236
The upkeep operations, each made by its factory (decisions.md [policy-factories], [upkeep]): the acti...
Definition Upkeep.h:380
The upkeep a filter holds when it is given none: it takes any state, changes nothing,...
Definition Upkeep.h:889