EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models > Class Template Reference

A process model that switches between modes: a Markov chain on a discrete mode space, and the process model each mode follows [switching-models]. More...

#include <EmrysFilter/Models/SwitchingModel.h>

Public Types

using Scalar = Scalar_
 the scalar type of the chain's probabilities
using ModeSpaceType = ModeSpace_
 the discrete mode space
using ChainType = MarkovChain<ModeSpace_, Scalar_>
 the chain's type

Public Member Functions

 SwitchingModel (ChainType chain, Models... models)
 The chain chain on the modes, and models, one per value of the axis Path_ (one shared by every mode if there is only one and Path_ is the mode space).
template<typename... Others>
requires ( sizeof...(Others) == sizeof...(Models) && !(std::is_same_v<Others, Models> && ...) && (std::is_convertible_v<Others
const &, Models> && ...) )
 SwitchingModel (SwitchingModel< ModeSpace_, Scalar_, Path_, Others... > const &other)
 other with each of its models converted to this one's: how a filter binds a switching model of fixedStep() results to its state's space.
ChainType const & chain () const
ChainType & chain ()
ModeSpace_ const & modeSpace () const
template<std::size_t I>
auto const & model () const
template<std::size_t I>
auto & model ()
std::size_t modelIndex (Eigen::Index mode) const
template<typename F>
decltype(auto) visit (Eigen::Index mode, F &&f) const
template<typename Fallback, typename F>
decltype(auto) visit (Eigen::Index mode, Fallback const &fallback, F &&f) const
template<typename Space>
bool partitions (Space const &space) const

Static Public Member Functions

template<typename Space>
static consteval internal::StaticPartition staticPartition ()

Static Public Attributes

static constexpr bool Shared = sizeof...(Models) == 1 && std::is_same_v<Path_, ModeSpace_>
 Whether one model serves every mode: one model and no path, the path being the whole mode space.

Detailed Description

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
class Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >

A process model that switches between modes: a Markov chain on a discrete mode space, and the process model each mode follows [switching-models].

Each model is a process model over the whole state (see ProcessModel), and every mode shares the state space; a mode that doesn't use a block holds it. There are three ways to assign models to modes:

  • one model per mode, in flat-index order: SwitchingModel{chain, cruise, turn};
  • one model per value of one axis of the mode space, when the others (such as a sensor's inlier/outlier state) don't affect the dynamics: switchingModel<Maneuver>(chain, cruise, turn);
  • one model shared by every mode, when only the measurements depend on the mode: SwitchingModel{chain, model}.

The chain moves the mode once per prediction, whatever its time step.

Each mode predicts by the filter's method, unless its model carries a method of its own: a model given to withMethod() does, so that a constant-velocity mode, affine and exact under Linearized, need not run through the sigma points a coordinated-turn mode beside it takes.

The models are all FixedStepModel over one step or none are. With fixed-step models the switching model is fixed-step too (isFixedStep), its filter's predict() takes no time step and no method, and each mode predicts by its own model's method, which may differ from mode to mode. Models made by fixedStep(model, dt), not yet bound to a space, are bound to the state's space by the filter given the switching model.

The Markovian switching of Blom and Bar-Shalom (1988): a jump Markov linear system whose mode selects the dynamics.

Template Parameters
ModeSpace_the discrete mode space (see Discrete spaces)
Scalar_scalar type of the chain's probabilities
Path_the mode axis that selects the model, as a tag or TagPath; the whole mode space when it is ModeSpace_ itself
Modelsthe process models, in the order of the axis's values, each of which may be a ModelWithMethod
See also
ImmFilter, MarkovChain, processModel(), withMethod()

Constructor & Destructor Documentation

◆ SwitchingModel()

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
template<typename... Others>
requires ( sizeof...(Others) == sizeof...(Models) && !(std::is_same_v<Others, Models> && ...) && (std::is_convertible_v<Others
const &, Models> && ...) )
Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::SwitchingModel ( SwitchingModel< ModeSpace_, Scalar_, Path_, Others... > const & other)
inline

other with each of its models converted to this one's: how a filter binds a switching model of fixedStep() results to its state's space.

Implicit, as FixedStepModel's is, so that a filter's constructor takes the switching model where its deduction guide names this type.

Member Function Documentation

◆ chain() [1/2]

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
ChainType & Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::chain ( )
inlinenodiscard
Returns
the Markov chain on the modes, to change it

◆ chain() [2/2]

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
ChainType const & Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::chain ( ) const
inlinenodiscard
Returns
the Markov chain on the modes

◆ model() [1/2]

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
template<std::size_t I>
auto & Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::model ( )
inlinenodiscard
Returns
process model I, to change its parameters

◆ model() [2/2]

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
template<std::size_t I>
auto const & Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::model ( ) const
inlinenodiscard
Returns
process model I; for a model given to withMethod(), the model it was given

◆ modelIndex()

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
std::size_t Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::modelIndex ( Eigen::Index mode) const
inlinenodiscard
Returns
the index of the process model that the mode with flat index mode follows

◆ modeSpace()

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
ModeSpace_ const & Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::modeSpace ( ) const
inlinenodiscard
Returns
the mode space

◆ partitions()

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
template<typename Space>
bool Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::partitions ( Space const & space) const
inlinenodiscard
Returns
whether every model's blocks cover every coordinate of space exactly once

◆ staticPartition()

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
template<typename Space>
consteval internal::StaticPartition Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::staticPartition ( )
inlinestaticnodiscardconsteval
Returns
what the models' types say about whether their writes partition Space: that they fail if one model's do, that they hold if every model's do, and otherwise unknown

◆ visit() [1/2]

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
template<typename F>
decltype(auto) Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::visit ( Eigen::Index mode,
F && f ) const
inline
Returns
f applied to the process model that the mode with flat index mode follows

◆ visit() [2/2]

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
template<typename Fallback, typename F>
decltype(auto) Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::visit ( Eigen::Index mode,
Fallback const & fallback,
F && f ) const
inline
Returns
f applied to the process model that the mode with flat index mode follows and to the method it predicts by: its own, if it was given to withMethod() or is a FixedStepModel, and fallback, the filter's, otherwise

Member Data Documentation

◆ Shared

template<DiscreteSpace ModeSpace_, RealScalar Scalar_, typename Path_, typename... Models>
bool Emrys::SwitchingModel< ModeSpace_, Scalar_, Path_, Models >::Shared = sizeof...(Models) == 1 && std::is_same_v<Path_, ModeSpace_>
staticconstexpr

Whether one model serves every mode: one model and no path, the path being the whole mode space.

One model with a path that names an axis is one per value of that axis, and its count is checked, so that a forgotten model is an error rather than dynamics every mode shares.


The documentation for this class was generated from the following file: