EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
Upkeep.h File Reference

Upkeep (decisions.md [upkeep], [rao-blackwellized-core]): the actions Resample, Roughen, PruneBelow, PruneTail, PruneToSize, Subdivide, FloorModes, and RepairCovariance, the triggers When, WhenEss, and WhenSize that run them, the Sequence that runs them all, and None, which a caller applies to a filter's state between steps or gives the filter to run by maintain(). More...

#include <concepts>
#include <cstddef>
#include <expected>
#include <optional>
#include <random>
#include <tuple>
#include <type_traits>
#include <utility>
#include <variant>
#include <EmrysFilter/Core/Execution.h>
#include <EmrysFilter/Core/Macros.h>
#include <EmrysFilter/Core/Multiply.h>
#include <EmrysFilter/Core/NumericError.h>
#include <EmrysFilter/Distributions/Categorical.h>
#include <EmrysFilter/Distributions/Mixture.h>
#include <EmrysFilter/Distributions/ParticleSet.h>
#include <EmrysFilter/Core/Resampling.h>
#include <EmrysFilter/Distributions/Roots.h>
#include <EmrysFilter/Distributions/SampleSet.h>
#include <EmrysFilter/Distributions/Sampling.h>
#include <EmrysFilter/Distributions/Statistics.h>
#include <EmrysFilter/Core/Weights.h>

Go to the source code of this file.

Classes

class  Emrys::upkeep::Resample< G, Resampler_, Policy_ >
 Action that resamples a set in proportion to its weights, drawing from the generator G with the resampler Resampler_ (systematic by default) under the execution policy Policy_ (sequential by default), to a given size if one is given and to the set's size otherwise. More...
class  Emrys::upkeep::Roughen< G, Scalar_, Policy_ >
 Action that moves each particle by an independent draw from a Gaussian kernel, to restore the diversity resampling removes: the regularized particle filter. More...
struct  Emrys::upkeep::When< Predicate, Actions >
 Trigger that runs its actions when its predicate holds for the state: the general trigger, of which WhenEss and WhenSize are two. More...
struct  Emrys::upkeep::None
 The upkeep a filter holds when it is given none: it takes any state, changes nothing, and returns false, so that maintain() can be called on every filter (decisions.md [upkeep]). More...
struct  Emrys::upkeep::PruneBelow< Scalar_ >
 Action that removes every point whose normalized probability is below probability, renormalizing the rest; the most probable point is always kept. More...
struct  Emrys::upkeep::PruneTail< Scalar_ >
 Action that removes the least probable points, as many as can be while their combined probability stays below fraction, renormalizing the rest. More...
struct  Emrys::upkeep::PruneToSize
 Action that removes the least probable points until at most maxSize remain, renormalizing the rest. More...
struct  Emrys::upkeep::Subdivide
 Action that splits every point into factor points along each axis, sharing its probability equally. More...
struct  Emrys::upkeep::FloorModes< Scalar_ >
 Action that raises every mode less probable than probability to it, scaling the others down to keep the sum one, so that no mode is ruled out for good. More...
struct  Emrys::upkeep::RepairCovariance< Repair_ >
 Action that repairs every covariance of the state that is not positive definite, by the Repair Repair_ (roots::Ridge by default), so that its density can be read. More...

Namespaces

namespace  Emrys::upkeep
 The upkeep operations, each made by its factory (decisions.md [policy-factories], [upkeep]): the actions resample(), roughen(), pruneBelow(), pruneTail(), pruneToSize(), subdivide(), floorModes(), and repairCovariance(), the triggers when(), whenEss(), and whenSize(), sequence(), and none().

Concepts

concept  Emrys::UpkeepOperation
 An upkeep operation on a State: an action or a trigger, the library's or the caller's own, a function object called as operation(state) that returns whether it changed the state, or the NumericError that stopped it, a WeightError or a GaussianError (decisions.md [upkeep], [user-extension-points]).

Typedefs

template<typename Compare, RealScalar Scalar_, typename... Actions>
using Emrys::upkeep::WhenEss = When<internal::EssTest<Compare, Scalar_>, Actions...>
 Trigger that runs its actions when compare holds between a set's effective sample size and fraction of its size: a When whose predicate is an internal::EssTest.
template<typename Compare, typename... Actions>
using Emrys::upkeep::WhenSize = When<internal::SizeTest<Compare>, Actions...>
 Trigger that runs its actions when compare holds between a state's number of elements and a limit, such as a mixture's components or a grid's live cells: a When whose predicate is an internal::SizeTest.
template<typename... Actions>
using Emrys::upkeep::Sequence = When<internal::Always, Actions...>
 Runs its actions in order on the state every time: a When whose predicate always holds, so that a filter's whole upkeep is one value (decisions.md [upkeep]).

Functions

template<std::uniform_random_bit_generator G, typename R = resamplers::Systematic>
requires (!std::integral<R>)
constexpr Resample< G, R > Emrys::upkeep::resample (G &generator, R resampler={})
template<std::uniform_random_bit_generator G, typename R = resamplers::Systematic>
requires (!std::integral<R>)
constexpr Resample< G, R > Emrys::upkeep::resample (G &generator, Eigen::Index size, R resampler={})
template<ExecutionPolicy P, std::uniform_random_bit_generator G, typename R = resamplers::Systematic>
requires (!std::integral<R>)
constexpr Resample< G, R, std::remove_cvref_t< P > > Emrys::upkeep::resample (P &&policy, G &generator, R resampler={})
template<ExecutionPolicy P, std::uniform_random_bit_generator G, typename R = resamplers::Systematic>
requires (!std::integral<R>)
constexpr Resample< G, R, std::remove_cvref_t< P > > Emrys::upkeep::resample (P &&policy, G &generator, Eigen::Index size, R resampler={})
template<std::uniform_random_bit_generator G, typename Value = double>
requires std::is_arithmetic_v<Value>
constexpr Roughen< G, internal::DeducedScalar< Value > > Emrys::upkeep::roughen (G &generator, Value scale=1)
template<ExecutionPolicy P, std::uniform_random_bit_generator G, typename Value = double>
requires std::is_arithmetic_v<Value>
constexpr Roughen< G, internal::DeducedScalar< Value >, std::remove_cvref_t< P > > Emrys::upkeep::roughen (P &&policy, G &generator, Value scale=1)
template<typename Predicate, typename... Actions>
When< Predicate, Actions... > Emrys::upkeep::when (Predicate predicate, Actions... actions)
template<typename Compare, typename Value, typename... Actions>
requires (!ExecutionPolicy<Compare>) && std::is_arithmetic_v<Value> && std::predicate<Compare const &, internal::DeducedScalar
<Value>, internal::DeducedScalar<Value>>
WhenEss< Compare, internal::DeducedScalar< Value >, Actions... > Emrys::upkeep::whenEss (Compare compare, Value fraction, Actions... actions)
template<ExecutionPolicy P, typename Compare, typename Value, typename... Actions>
requires std::is_arithmetic_v<Value> && std::predicate<Compare const &, internal::DeducedScalar<Value>, internal::DeducedScalar
<Value>>
When< internal::EssTest< Compare, internal::DeducedScalar< Value >, std::remove_cvref_t< P > >, Actions... > Emrys::upkeep::whenEss (P &&policy, Compare compare, Value fraction, Actions... actions)
template<typename Compare, typename... Actions>
requires std::predicate<Compare const &, std::ptrdiff_t, std::ptrdiff_t>
WhenSize< Compare, Actions... > Emrys::upkeep::whenSize (Compare compare, std::ptrdiff_t limit, Actions... actions)
template<typename... Actions>
Sequence< Actions... > Emrys::upkeep::sequence (Actions... actions)
constexpr None Emrys::upkeep::none ()
template<typename Value>
requires std::is_arithmetic_v<Value>
constexpr PruneBelow< internal::DeducedScalar< Value > > Emrys::upkeep::pruneBelow (Value probability)
template<typename Value>
requires std::is_arithmetic_v<Value>
constexpr PruneTail< internal::DeducedScalar< Value > > Emrys::upkeep::pruneTail (Value fraction)
constexpr PruneToSize Emrys::upkeep::pruneToSize (std::ptrdiff_t maxSize)
constexpr Subdivide Emrys::upkeep::subdivide (std::ptrdiff_t factor=2)
template<typename Value>
requires std::is_arithmetic_v<Value>
constexpr FloorModes< internal::DeducedScalar< Value > > Emrys::upkeep::floorModes (Value probability)
template<Repair R = roots::Ridge<>>
constexpr RepairCovariance< R > Emrys::upkeep::repairCovariance (R repair={})

Detailed Description

Upkeep (decisions.md [upkeep], [rao-blackwellized-core]): the actions Resample, Roughen, PruneBelow, PruneTail, PruneToSize, Subdivide, FloorModes, and RepairCovariance, the triggers When, WhenEss, and WhenSize that run them, the Sequence that runs them all, and None, which a caller applies to a filter's state between steps or gives the filter to run by maintain().

Read Divergence.h next.