Bayesian Filtering Library  Generated from SVN r
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ParticleFilter< StateVar, MeasVar > Class Template Reference

Virtual Class representing all particle filters. More...

#include <particlefilter.h>

Inheritance diagram for ParticleFilter< StateVar, MeasVar >:
Filter< StateVar, MeasVar > ASIRFilter< StateVar, MeasVar > BootstrapFilter< StateVar, MeasVar > Optimalimportancefilter< StateVar, MeasVar >

Public Member Functions

 ParticleFilter (MCPdf< StateVar > *prior, ConditionalPdf< StateVar, StateVar > *proposal, int resampleperiod=0, double resamplethreshold=0, int resamplescheme=DEFAULT_RS)
 Constructor. More...
 
 ParticleFilter (MCPdf< StateVar > *prior, MCPdf< StateVar > *post, ConditionalPdf< StateVar, StateVar > *proposal, int resampleperiod=0, double resamplethreshold=0, int resamplescheme=DEFAULT_RS)
 Constructor. More...
 
virtual ~ParticleFilter ()
 Destructor.
 
 ParticleFilter (const ParticleFilter< StateVar, MeasVar > &filt)
 Copy Constructor. More...
 
virtual void ProposalSet (ConditionalPdf< StateVar, StateVar > *const cpdf)
 Set the proposal density. More...
 
ConditionalPdf< StateVar, StateVar > * ProposalGet ()
 Get a pointer to the proposal density. More...
 
virtual MCPdf< StateVar > * PostGet ()
 Get Posterior density. More...
 
virtual void Reset (Pdf< StateVar > *prior)
 Reset Filter.
 
virtual bool Update (SystemModel< StateVar > *const sysmodel, const StateVar &u, MeasurementModel< MeasVar, StateVar > *const measmodel, const MeasVar &z, const StateVar &s)
 Full Update (system with inputs/sensing params) More...
 
virtual bool Update (SystemModel< StateVar > *const sysmodel, MeasurementModel< MeasVar, StateVar > *const measmodel, const MeasVar &z, const StateVar &s)
 Full Update (system without inputs, with sensing params) More...
 
virtual bool Update (SystemModel< StateVar > *const sysmodel, MeasurementModel< MeasVar, StateVar > *const measmodel, const MeasVar &z)
 Full Update (system without inputs/sensing params) More...
 
virtual bool Update (SystemModel< StateVar > *const sysmodel, const StateVar &u, MeasurementModel< MeasVar, StateVar > *const measmodel, const MeasVar &z)
 Full Update (system with inputs, without sensing params) More...
 
virtual bool Update (SystemModel< StateVar > *const sysmodel, const StateVar &u)
 System Update (system with inputs) More...
 
virtual bool Update (SystemModel< StateVar > *const sysmodel)
 System Update (system without inputs) More...
 
virtual bool Update (MeasurementModel< MeasVar, StateVar > *const measmodel, const MeasVar &z, const StateVar &s)
 Measurement Update (system with "sensing params") More...
 
virtual bool Update (MeasurementModel< MeasVar, StateVar > *const measmodel, const MeasVar &z)
 Measurement Update (system without "sensing params") More...
 
int TimeStepGet () const
 Get current time. More...
 

Protected Member Functions

virtual bool UpdateInternal (SystemModel< StateVar > *const sysmodel, const StateVar &u, MeasurementModel< MeasVar, StateVar > *const measmodel, const MeasVar &z, const StateVar &s)
 Actual implementation of Update, varies along filters. More...
 
virtual bool ProposalStepInternal (SystemModel< StateVar > *const sysmodel, const StateVar &u, MeasurementModel< MeasVar, StateVar > *const measmodel, const MeasVar &z, const StateVar &s)
 Proposal step. More...
 
virtual bool UpdateWeightsInternal (SystemModel< StateVar > *const sysmodel, const StateVar &u, MeasurementModel< MeasVar, StateVar > *const measmodel, const MeasVar &z, const StateVar &s)
 Update Weights. More...
 
virtual bool DynamicResampleStep ()
 Resample if necessary. More...
 
virtual bool StaticResampleStep ()
 Resample if wanted. More...
 
virtual bool Resample ()
 Actual Resampling happens here;.
 

Protected Attributes

ConditionalPdf< StateVar, StateVar > * _proposal
 Pointer to the Proposal Density. More...
 
WeightedSample< StateVar > _sample
 While updating use sample<StateVar>
 
vector< WeightedSample< StateVar > > _old_samples
 While updating store list of old samples.
 
vector< WeightedSample< StateVar > > _new_samples
 While updating store list of new samples.
 
vector< Sample< StateVar > > _new_samples_unweighted
 While resampling.
 
vector< WeightedSample< StateVar > >::iterator _os_it
 Iterator for old list of samples.
 
vector< WeightedSample< StateVar > >::iterator _ns_it
 Iterator for new list of samples.
 
int _resamplePeriod
 Number of timestep between resampling from the Posterior Pdf. More...
 
double _resampleThreshold
 Threshold used when dynamic resampling.
 
int _resampleScheme
 Which resample algorithm (see top of particle.h for #defines)
 
bool _dynamicResampling
 Dynamic resampling or fixed period resampling?
 
bool _proposal_depends_on_meas
 Proposal depends on last measurement?
 
bool _created_post
 created own post
 
Pdf< StateVar > * _prior
 prior Pdf
 
Pdf< StateVar > * _post
 Pointer to the Posterior Pdf. More...
 
int _timestep
 Represents the current timestep of the filter. More...
 

Detailed Description

template<typename StateVar, typename MeasVar>
class BFL::ParticleFilter< StateVar, MeasVar >

Virtual Class representing all particle filters.

This is a virtual class representing the family of all particle filters. Particle filters are filters in which the Posterior density is represented by a set of particles (aka (weighted) samples). In other words, the posterior density is a Monte Carlo Pdf (class MCPdf)

However, the updating of the Posterior density can still be done in several ways, that's why the System and Measurement update members are still pure virtual functions.

This class is the base class for all sorts of particle filters.

Todo:
: Actually all particle filters represented by this class are of the "Sequential importance sampling methods" type. Typical of those methods is the so called Proposal density. In theory it would be possible to create Filters using a recursive version of other Monte Carlo methods (eg. MCMC methods), although I am not aware of any of these (due to the increased complexity).
See also
MCPdf
Sample
WeightedSample
Bug:
Resampling is not implemented generically enough yet. There's only the possibility to choose between static period resampling and dynamic resampling as proposed by Jun Liu. The correct way of implementing this would be to create a virtual function that has to be implemented by the user, but this creates more hassle for the user (a different particle filter for each scheme).

Definition at line 159 of file particlefilter.h.

Constructor & Destructor Documentation

§ ParticleFilter() [1/3]

ParticleFilter ( MCPdf< SV > *  prior,
ConditionalPdf< SV, SV > *  proposal,
int  resampleperiod = 0,
double  resamplethreshold = 0,
int  resamplescheme = DEFAULT_RS 
)

Constructor.

Precondition
you created the necessary models and the prior
Parameters
priorpointer to the Monte Carlo Pdf prior density
proposalpointer to the proposal density to use
resampleperiodfixed resampling period (if desired)
resamplethresholdthreshold used when dynamic resampling
resampleschemeresampling scheme, see header file for different defines and their meaning
Bug:

prior should be of type pdf and not mcpdf. See also notes with implementation

let the user implement her/his own resamplescheme

Definition at line 29 of file particlefilter.h.

§ ParticleFilter() [2/3]

ParticleFilter ( MCPdf< SV > *  prior,
MCPdf< SV > *  post,
ConditionalPdf< SV, SV > *  proposal,
int  resampleperiod = 0,
double  resamplethreshold = 0,
int  resamplescheme = DEFAULT_RS 
)

Constructor.

Precondition
you created the necessary models and the prior
Parameters
priorpointer to the Monte Carlo Pdf prior density
postpointer to the Monte Carlo Pdf post density
proposalpointer to the proposal density to use
resampleperiodfixed resampling period (if desired)
resamplethresholdthreshold used when dynamic resampling
resampleschemeresampling scheme, see header file for different defines and their meaning
Bug:

prior should be of type pdf and not mcpdf. See also notes with implementation

let the user implement her/his own resamplescheme

Definition at line 74 of file particlefilter.h.

§ ParticleFilter() [3/3]

ParticleFilter ( const ParticleFilter< SV, MV > &  filt)

Copy Constructor.

Bug:
implementation probably contains a bug

Definition at line 123 of file particlefilter.h.

Member Function Documentation

§ DynamicResampleStep()

bool DynamicResampleStep ( )
protectedvirtual

Resample if necessary.

Bug:
let the user implement her/his own resamplescheme

Definition at line 272 of file particlefilter.h.

§ PostGet()

MCPdf< SV > * PostGet ( )
virtual

Get Posterior density.

Get the current Posterior density

Returns
a pointer to the current posterior

Reimplemented from Filter< StateVar, MeasVar >.

Definition at line 390 of file particlefilter.h.

§ ProposalGet()

ConditionalPdf< SV, SV > * ProposalGet ( )

Get a pointer to the proposal density.

Returns
a pointer to the proposal density

Definition at line 139 of file particlefilter.h.

§ ProposalSet()

void ProposalSet ( ConditionalPdf< SV, SV > *const  cpdf)
virtual

Set the proposal density.

Parameters
cpdfthe new proposal density. The order of the conditional arguments is fixed and should be: x (state), u (input), z (measurement), s (sensor param). Off course all of them are optional

Definition at line 133 of file particlefilter.h.

§ ProposalStepInternal()

bool ProposalStepInternal ( SystemModel< SV > *const  sysmodel,
const SV &  u,
MeasurementModel< MV, SV > *const  measmodel,
const MV &  z,
const SV &  s 
)
protectedvirtual

Proposal step.

Implementation of proposal step

Parameters
sysmodelpointer to the used system model
uinput param for proposal density
measmodelpointer to the used measurementmodel
zmeasurement param for proposal density
ssensor param for proposal density
Bug:
Make sampling method variable. See implementation.

Definition at line 145 of file particlefilter.h.

§ StaticResampleStep()

bool StaticResampleStep ( )
protectedvirtual

Resample if wanted.

Bug:
let the user implement her/his own resamplescheme

Definition at line 308 of file particlefilter.h.

§ TimeStepGet()

int TimeStepGet ( ) const
inherited

Get current time.

Get the current time of the filter

Returns
the current timestep

Definition at line 50 of file filter.h.

§ Update() [1/8]

bool Update ( SystemModel< SVar > *const  sysmodel,
const SVar &  u,
MeasurementModel< MVar, SVar > *const  measmodel,
const MVar &  z,
const SVar &  s 
)
virtualinherited

Full Update (system with inputs/sensing params)

Parameters
sysmodelpointer to the system model to use for update
uinput to the system
measmodelpointer to the measurement model to use for update
zmeasurement
s"sensing parameter"

Definition at line 56 of file filter.h.

§ Update() [2/8]

bool Update ( SystemModel< SVar > *const  sysmodel,
MeasurementModel< MVar, SVar > *const  measmodel,
const MVar &  z,
const SVar &  s 
)
virtualinherited

Full Update (system without inputs, with sensing params)

Parameters
sysmodelpointer to the system model to use for update
measmodelpointer to the measurement model to use for update
zmeasurement
s"sensing parameter"

Definition at line 66 of file filter.h.

§ Update() [3/8]

bool Update ( SystemModel< SVar > *const  sysmodel,
MeasurementModel< MVar, SVar > *const  measmodel,
const MVar &  z 
)
virtualinherited

Full Update (system without inputs/sensing params)

Parameters
sysmodelpointer to the system model to use for update
measmodelpointer to the measurement model to use for update
zmeasurement

Definition at line 76 of file filter.h.

§ Update() [4/8]

bool Update ( SystemModel< SVar > *const  sysmodel,
const SVar &  u,
MeasurementModel< MVar, SVar > *const  measmodel,
const MVar &  z 
)
virtualinherited

Full Update (system with inputs, without sensing params)

Parameters
sysmodelpointer to the system model to use for update
uinput to the system
measmodelpointer to the measurement model to use for update
zmeasurement

Definition at line 85 of file filter.h.

§ Update() [5/8]

bool Update ( SystemModel< SVar > *const  sysmodel,
const SVar &  u 
)
virtualinherited

System Update (system with inputs)

Parameters
sysmodelpointer to the system model to use for update
uinput to the system

Definition at line 95 of file filter.h.

§ Update() [6/8]

bool Update ( SystemModel< SVar > *const  sysmodel)
virtualinherited

System Update (system without inputs)

Parameters
sysmodelpointer to the system model to use for update

Definition at line 103 of file filter.h.

§ Update() [7/8]

bool Update ( MeasurementModel< MVar, SVar > *const  measmodel,
const MVar &  z,
const SVar &  s 
)
virtualinherited

Measurement Update (system with "sensing params")

Parameters
measmodelpointer to the measurement model to use for update
zmeasurement
s"sensing parameter"

Definition at line 110 of file filter.h.

§ Update() [8/8]

bool Update ( MeasurementModel< MVar, SVar > *const  measmodel,
const MVar &  z 
)
virtualinherited

Measurement Update (system without "sensing params")

Parameters
measmodelpointer to the measurement model to use for update
zmeasurement

Definition at line 119 of file filter.h.

§ UpdateInternal()

bool UpdateInternal ( SystemModel< StateVar > *const  sysmodel,
const StateVar &  u,
MeasurementModel< MeasVar, StateVar > *const  measmodel,
const MeasVar &  z,
const StateVar &  s 
)
protectedvirtual

Actual implementation of Update, varies along filters.

Parameters
sysmodelpointer to the used system model
uinput param for proposal density
measmodelpointer to the used measurementmodel
zmeasurement param for proposal density
ssensor param for proposal density

Implements Filter< StateVar, MeasVar >.

Reimplemented in ASIRFilter< StateVar, MeasVar >, BootstrapFilter< StateVar, MeasVar >, and EKParticleFilter.

Definition at line 318 of file particlefilter.h.

§ UpdateWeightsInternal()

bool UpdateWeightsInternal ( SystemModel< SV > *const  sysmodel,
const SV &  u,
MeasurementModel< MV, SV > *const  measmodel,
const MV &  z,
const SV &  s 
)
protectedvirtual

Update Weights.

Parameters
sysmodelpointer to the used system model
uinput param for proposal density
measmodelpointer to the used measurementmodel
zmeasurement param for proposal density
ssensor param for proposal density

Definition at line 201 of file particlefilter.h.

Member Data Documentation

§ _post

Pdf<StateVar>* _post
protectedinherited

Pointer to the Posterior Pdf.

The Posterior Pdf represents the subjective belief of the person applying the filter AFTER processing inputs and measurements. A filter does not maintain the beliefs at all timesteps t, since this leads to non-constant (or ever growing if you prefer) memory requirements. However, it is possible, to copy the Posterior density at all timesteps in your application by means of the PostGet() member function

See also
PostGet()

Definition at line 95 of file filter.h.

§ _proposal

ConditionalPdf<StateVar,StateVar>* _proposal
protected

Pointer to the Proposal Density.

Every particle filter (or more correct: every Sequential Importance Sampling method) uses a proposal density to do the forward sampling step

Definition at line 174 of file particlefilter.h.

§ _resamplePeriod

int _resamplePeriod
protected

Number of timestep between resampling from the Posterior Pdf.

By choosing this period, one can avoid numerical instability (aka Degeneration of the particle filter

Definition at line 193 of file particlefilter.h.

§ _timestep

int _timestep
protectedinherited

Represents the current timestep of the filter.

Todo:
Check wether this really belongs here

Definition at line 100 of file filter.h.


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