EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
Emrys::GaussianMixtureFilter< Space_, Model_, Method_, Scalar_, Allocator_, Upkeep_ > Class Template Reference

The MixtureFilter over a GaussianMixtureParams, the spelling for the common case (decisions.md [filters-and-recursions]): each component a KalmanFilter's step, reweighted by its likelihood. More...

#include <EmrysFilter/Filters/MixtureFilter.h>

Inheritance diagram for Emrys::GaussianMixtureFilter< Space_, Model_, Method_, Scalar_, Allocator_, Upkeep_ >:
Emrys::MixtureFilter< Component_, Model_, Method_, Allocator_, Recursion_, Upkeep_ >

Public Types

using Base
 the filter this is
Public Types inherited from Emrys::MixtureFilter< Component_, Model_, Method_, Allocator_, Recursion_, Upkeep_ >
using Scalar = typename Params<Component_>::Scalar
 the scalar type
using SpaceType = typename Params<Component_>::SpaceType
 the state space
using ModelType = Model_
 the process model
using MethodType = Method_
 the prediction method
using StateType = MixtureParams<Component_, Allocator_>
 the state the filter owns
using ComponentType = Params<Component_>
 one component of the state
using allocator_type = Allocator_
 the state's allocator
using RecursionType = Recursion_
 the steps each component runs (see Recursion)
using JointType = GaussianMixturePredictedJoint<SpaceType, Scalar, Allocator_>
 what predictJoint() returns, for Gaussian components
template<Measurement M>
using ResultType
 What update() with M fills when given a result: one component's update per component, each with the filter's allocator for what in it is sized by a run-time count.
template<Measurement M>
using UpdateType = std::expected<ResultType<M>, NumericError>
 What update() with M returns: the ResultType in a std::expected (decisions.md [innovation-cholesky]).

Public Member Functions

template<typename... Args>
requires ( std::constructible_from<Base, Args...> && !(sizeof...(Args) == 1 && (std::is_same_v<std::remove_cvref_t<Args>,
GaussianMixtureFilter> && ...)) )
 GaussianMixtureFilter (Args &&... args)
 The filter MixtureFilter's constructor makes from args.
Public Member Functions inherited from Emrys::MixtureFilter< Component_, Model_, Method_, Allocator_, Recursion_, Upkeep_ >
 MixtureFilter (Model_ model, StateType state, MethodFor< Model_, Method_ > method={}, std::type_identity_t< Upkeep_ > upkeep={})
 A filter with process model model, initial state state, prediction method method, which a fixed-step model carries instead, and upkeep upkeep, which maintain() runs.
 MixtureFilter (Model_ model, StateType state, std::type_identity_t< Upkeep_ > upkeep)
 A filter with process model model, initial state state, the default prediction method, and upkeep upkeep, which maintain() runs.
 MixtureFilter (Recursion_ recursion, StateType state, std::type_identity_t< Upkeep_ > upkeep={})
 A filter that runs recursion, the library's or one of the user's own (see Recursion), on each component of the initial state state, which must have at least one, with upkeep upkeep, which maintain() runs.
allocator_type get_allocator () const
StateType const & state () const
StateType & state ()
void setState (StateType state)
 Replaces the state estimate, as when reinitializing, with one that has at least one component and whose space the process model's writes partition, as the constructor's must.
RecursionType const & recursion () const
Model_ const & model () const
Model_ & model ()
Method_ const & method () const
template<typename... Inputs>
requires (!isFixedStep<Model_>)
auto predict (TimeStep< Scalar > auto const &dt, Inputs const &... inputs)
 Moves each component forward by dt, any TimeStep (see Time steps), through the process model, with inputs passed to its blocks as in Emrys::predict().
template<ExecutionPolicy P, typename... Inputs>
requires (!isFixedStep<Model_>)
auto predict (P &&policy, TimeStep< Scalar > auto const &dt, Inputs const &... inputs)
 predict(dt, inputs...) under policy, a for-each over the components, so the result is Sequential's (see Execution policies).
template<typename... Inputs>
requires (isFixedStep<Model_> && !internal::leadsWithPolicy<Inputs...> && !internal::leadsWithSteps<Inputs...>)
auto predict (Inputs const &... inputs)
 Moves each component forward by the fixed-step model's step, with inputs passed as in Emrys::predict().
template<ExecutionPolicy P, typename... Inputs>
requires (isFixedStep<Model_> && !internal::leadsWithSteps<Inputs...>)
auto predict (P &&policy, Inputs const &... inputs)
 predict(inputs...) under policy, as predict(policy, dt, inputs...) runs.
template<typename... Inputs>
requires isFixedStep<Model_>
auto predict (Steps steps, Inputs const &... inputs)
 Moves each component forward by steps of the fixed-step model, as that many calls of predict(inputs...) do, with inputs at every step, returning as predict(inputs...) does.
template<ExecutionPolicy P, typename... Inputs>
requires isFixedStep<Model_>
auto predict (P &&policy, Steps steps, Inputs const &... inputs)
 predict(steps, inputs...) under policy, as that many calls of predict(policy, inputs...) run, stopping at the first that reports an error.
template<typename... Inputs>
requires (!isFixedStep<Model_> && isGaussian<ComponentType>)
JointType predictJoint (TimeStep< Scalar > auto const &dt, Inputs const &... inputs)
 Moves each Gaussian component forward as predict(dt, inputs...) does, and starts the state's lineage over (MixtureParams::startLineage()).
template<typename JointAllocator, typename... Inputs>
requires (!isFixedStep<Model_> && isGaussian<ComponentType>)
void predictJoint (TimeStep< Scalar > auto const &dt, GaussianMixturePredictedJoint< SpaceType, Scalar, JointAllocator > &joint, Inputs const &... inputs)
 As predictJoint(dt, inputs...), but into joint, whose storage is reused: with the same joint at every step, recording allocates nothing once it has been as large.
template<ExecutionPolicy P, typename JointAllocator, typename... Inputs>
requires (!isFixedStep<Model_> && isGaussian<ComponentType>)
void predictJoint (P &&policy, TimeStep< Scalar > auto const &dt, GaussianMixturePredictedJoint< SpaceType, Scalar, JointAllocator > &joint, Inputs const &... inputs)
 predictJoint(dt, joint, inputs...) under policy, a for-each over the components into the joint's slots, so the joint and the state are Sequential's (see Execution policies).
template<typename... Inputs>
requires ( isFixedStep<Model_> && isGaussian<ComponentType> && !internal::leadsWithPolicy<Inputs...> && !internal::leadsWithSteps
<Inputs...> )
JointType predictJoint (Inputs const &... inputs)
 Moves each Gaussian component forward as predict(inputs...) does with a fixed-step model, and starts the state's lineage over.
template<typename JointAllocator, typename... Inputs>
requires (isFixedStep<Model_> && isGaussian<ComponentType>)
void predictJoint (GaussianMixturePredictedJoint< SpaceType, Scalar, JointAllocator > &joint, Inputs const &... inputs)
 As predictJoint(inputs...), but into joint, whose storage is reused.
template<ExecutionPolicy P, typename JointAllocator, typename... Inputs>
requires (isFixedStep<Model_> && isGaussian<ComponentType>)
void predictJoint (P &&policy, GaussianMixturePredictedJoint< SpaceType, Scalar, JointAllocator > &joint, Inputs const &... inputs)
 predictJoint(joint, inputs...) under policy, as predictJoint(policy, dt, joint, inputs...) runs.
template<Measurement M, typename Policy = reductions::Collapse>
requires ( !isGaussian<ComponentType> || MixtureReductionPolicy<Policy, internal::MeasuredUpdate<ComponentType, M>, Component_> )
UpdateType< M > update (M const &measurement, Policy const &policy={})
 Conditions each component on measurement, by the measurement's own method, reduces its branches with policy, a MixtureReductionPolicy over the component (Collapse, Select, Keep, or a Gate), and multiplies the weight of what the policy keeps by \( p(z \mid i) \) times its share among the branches: for a Gate the passing branches' share, so that a branch the gate fails counts as impossible.
template<ExecutionPolicy P, Measurement M, typename Policy = reductions::Collapse>
requires ( !isGaussian<ComponentType> || MixtureReductionPolicy<Policy, internal::MeasuredUpdate<ComponentType, M>, Component_> )
UpdateType< M > update (P &&executionPolicy, M const &measurement, Policy const &policy={})
 update(measurement, policy) under executionPolicy: each component's update is a for-each into slots made first, and the reweighting, the evidence, and the posterior then follow in order, so the result is Sequential's (see Execution policies).
template<Measurement M, typename Policy, typename ResultAllocator>
requires ( !isGaussian<ComponentType> || MixtureReductionPolicy<Policy, internal::MeasuredUpdate<ComponentType, M>, Component_> )
std::expected< void, NumericError > update (M const &measurement, Policy const &policy, MixtureFilterUpdate< typename ResultType< M >::ComponentUpdateType, Scalar, ResultAllocator > &result)
 As update(measurement, policy), but into result, whose storage is reused: with the same result at every step, an update allocates nothing once it has been as large.
template<ExecutionPolicy P, Measurement M, typename Policy, typename ResultAllocator>
requires ( !isGaussian<ComponentType> || MixtureReductionPolicy<Policy, internal::MeasuredUpdate<ComponentType, M>, Component_> )
std::expected< void, NumericError > update (P &&executionPolicy, M const &measurement, Policy const &policy, MixtureFilterUpdate< typename ResultType< M >::ComponentUpdateType, Scalar, ResultAllocator > &result)
 update(measurement, policy, result) under executionPolicy, as update(executionPolicy, measurement, policy) runs.

Detailed Description

template<Space Space_, typename Model_, typename Method_ = DefaultMethodFor<Model_>, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator, typename Upkeep_ = upkeep::None>
class Emrys::GaussianMixtureFilter< Space_, Model_, Method_, Scalar_, Allocator_, Upkeep_ >

The MixtureFilter over a GaussianMixtureParams, the spelling for the common case (decisions.md [filters-and-recursions]): each component a KalmanFilter's step, reweighted by its likelihood.

Its arguments are deduced the same way: GaussianMixtureFilter filter{model, initial}.

It is the MixtureFilter it names with nothing added, as a derived class rather than an alias so that its arguments deduce on every compiler: MSVC does not deduce through an alias whose parameters sit inside a nested template argument, here GaussianParams<Space_, Scalar_> [filters-and-recursions]. It runs the KalmanRecursion; a filter with a recursion of the user's own is a MixtureFilter.

Template Parameters
Space_the state space (see Spaces)
Model_the process model, a ProcessModel or a FixedStepModel
Method_the prediction method; a FixedStepModel's own
Scalar_scalar type, double by default
Allocator_the state's allocator (see Allocation)
Upkeep_the upkeep maintain() runs on the state (see Upkeep), upkeep::None unless given one

Member Typedef Documentation

◆ Base

template<Space Space_, typename Model_, typename Method_ = DefaultMethodFor<Model_>, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator, typename Upkeep_ = upkeep::None>
using Emrys::GaussianMixtureFilter< Space_, Model_, Method_, Scalar_, Allocator_, Upkeep_ >::Base
Initial value:
Model_,
Method_,
Allocator_,
internal::RecursionForType<Gaussian<Space_, Scalar_>, Model_, Method_, Allocator_>,
Upkeep_>
The density of a Gaussian whose covariance has been factorized: a read-only view.
Definition Gaussian.h:1011
MixtureFilter(Model_ model, StateType state, MethodFor< Model_, Method_ > method={}, std::type_identity_t< Upkeep_ > upkeep={})
A filter with process model model, initial state state, prediction method method, which a fixed-step ...
Definition MixtureFilter.h:302

the filter this is

Constructor & Destructor Documentation

◆ GaussianMixtureFilter()

template<Space Space_, typename Model_, typename Method_ = DefaultMethodFor<Model_>, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator, typename Upkeep_ = upkeep::None>
template<typename... Args>
requires ( std::constructible_from<Base, Args...> && !(sizeof...(Args) == 1 && (std::is_same_v<std::remove_cvref_t<Args>,
GaussianMixtureFilter> && ...)) )
Emrys::GaussianMixtureFilter< Space_, Model_, Method_, Scalar_, Allocator_, Upkeep_ >::GaussianMixtureFilter ( Args &&... args)
inline

The filter MixtureFilter's constructor makes from args.

It forwards rather than inheriting the constructors, since MSVC 19.51 crashes deducing the class's arguments when C++23 lets the inherited constructors take part; the deduction guides below deduce them.


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