Class ParticleFilter
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity
-
- ptolemy.kernel.CompositeEntity
-
- ptolemy.actor.CompositeActor
-
- ptolemy.actor.TypedCompositeActor
-
- org.ptolemy.machineLearning.particleFilter.AbstractParticleFilter
-
- org.ptolemy.machineLearning.particleFilter.ParticleFilter
-
- All Implemented Interfaces:
java.lang.Cloneable
,MapConstrained
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
ParticleFilterRange
public class ParticleFilter extends AbstractParticleFilter
A Particle Filter ImplementationThe particle filter runs on a state space model given by
X_{t+1} = f(X_t, U_t, t) Y_{t} = g(X_t, U_t, t) X(0) = X0
where X is the state vector, U is the input vector, Y is the observation vector, and t is the model time. To use this actor :- For each control input in U, create an input port with an arbitrary name. This actor will automatically create a parameter with the same name as the input port. That parameter will have its value set during execution to match the value of the input.
- Fill in the stateVariableNames parameter, which is an array of strings, with the names of the state variables in X. These names can be arbitrary, since you will refer them to by name rather than by the symbol X.
- Specify an update function (part of f above) for each state variable by creating a parameter named name_update, where name is the name of the state variable. The value of this parameter should be an expression giving the rate of change of this state variable as a function of any of the state variables, any input, any other actor parameter, and (possibly), the variable t, representing current time.
- For each measurement input, create an input port with name measurementName_m, where measurementName is an arbitrary measurement name. Add a parameter to the actor named measurementName, which is an expression describing the measurement's correspondence to the state space. Namely, the measurement equation should be a function of stateVariableNames, U and t.
- Fill in the measurement covariance parameter, that should be a square double matrix with dimension equal to the number of measurement equations defined. In case the measurements are independent, the matrix should be a scaled identity
- Fill in the processNoise parameter, which should be a function that samples from the (possibly multivariate) distribution the state transition process noise is distributed according to. The return type should be an array of size equal to the state-space size
- Specify the prior distribution as a random function from which the particles will be sampled. For instance, use the the random() function to draw uniform random variables in [0,1] or use multivariateGaussian() or gaussian() for Gaussian priors.The return type should be an array of size equal to the state-space size
- It is important to note how multiple measurement inputs are interpreted by the actor. This implementation interprets multiple measurement inputs to be conditionally independent given the hidden state. This allows the likelihood (weight) of each particle at time step t to be computed as a product of its likelihood with respect to each measurement at that time.
- For additional parameters that are time varying, add arbitrarily many PortParameters to the actor and refer to the port parameter by port name within measurement and/or update equations.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Ilge Akkaya
- Pt.AcceptedRating:
- Red (ilgea)
- Pt.ProposedRating:
- Red (ilgea)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.ptolemy.machineLearning.particleFilter.AbstractParticleFilter
AbstractParticleFilter.InputType
-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
measurementCovariance
Standard deviation of the measurement noise ( assuming Gaussian measurement noise at the moment).Parameter
prior
An expression for the prior distribution from which the samples are drawn.Parameter
processNoise
The process noise.Parameter
stateVariableNames
The names of the state variables, in an array of strings.-
Fields inherited from class org.ptolemy.machineLearning.particleFilter.AbstractParticleFilter
_inputRelations, _particleLabels, _particleTypes, _Sigma, _stateLabels, _stateNames, _stateTypes, _upToDate, bootstrap, lowVarianceSampler, MEASUREMENT_NOISE, MEASUREMENT_POSTFIX, outputParticleCount, particleCount, particleOutput, PRIOR_NAME, PROCESS_NOISE, resetOnEachRun, seed, STATE_VARIABLE_NAMES, stateEstimate, t, UPDATE_POSTFIX
-
Fields inherited from class ptolemy.actor.CompositeActor
_actorFiringListeners, _causalityInterface, _derivedPiggybacks, _initializables, _notifyingActorFiring, _piggybacks, _publishedPorts, _publisherRelations, _stopRequested, _subscribedPorts
-
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description ParticleFilter(CompositeEntity container, java.lang.String name)
Construct the composite actor with a name and a container.ParticleFilter(Workspace workspace)
Construct a PF in the specified workspace with no container and an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_checkParameters()
Check the dimensions of all parameters and ports.void
attributeChanged(Attribute attribute)
If the argument is any parameter other than stateVariableNames t, or any parameter matching an input port, then request reinitialization.protected AbstractParticleFilter.InputType
getInputType(java.lang.String inputName)
Get input type by name referenceprotected Parameter
getMeasurementParameter(java.lang.String fullName)
Returns a parameter value corresponding to a measurement.protected Parameter
getNoiseParameter(java.lang.String inputName)
Returns a parameter value corresponding to a noise distribution.protected Parameter
getUserDefinedParameter(java.lang.String parameterName)
Return the Parameter that is part of a state space model.boolean
satisfiesMapConstraints(double[] coordinates)
Return true if the the coordinates satisfy the map constraints.-
Methods inherited from class org.ptolemy.machineLearning.particleFilter.AbstractParticleFilter
_constrainParticles, fire, getMeasurementParameterExpression, getUserDefinedParameterExpression, preinitialize, wrapup
-
Methods inherited from class ptolemy.actor.TypedCompositeActor
_addEntity, _addPort, _addRelation, _checkTypesFromTo, _destinationTypeConstraints, attributeTypeChanged, isBackwardTypeInferenceEnabled, newPort, newRelation, resolveTypes, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.CompositeActor
_actorFiring, _actorFiring, _finishedAddEntity, _setDirector, _transferPortParameterInputs, addActorFiringListener, addInitializable, addPiggyback, clone, connectionsChanged, createReceivers, createSchedule, getCausalityInterface, getDirector, getExecutiveDirector, getManager, getPublishedPort, getPublishedPortChannel, getPublishedPorts, getSubscribedPortChannel, inferringWidths, inferWidths, initialize, inputPortList, isFireFunctional, isOpaque, isPublishedPort, isStrict, iterate, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, linkToPublishedPort, needsWidthInference, newInsideReceiver, newReceiver, notifyConnectivityChange, outputPortList, postfire, prefire, recordFiring, registerPublisherPort, registerPublisherPort, removeActorFiringListener, removeInitializable, removePiggyback, requestChange, setContainer, setDirector, setManager, stop, stopFire, terminate, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unlinkToPublishedPort, unregisterPublisherPort, unregisterPublisherPort
-
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, statistics, uniqueName
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
measurementCovariance
public Parameter measurementCovariance
Standard deviation of the measurement noise ( assuming Gaussian measurement noise at the moment).
-
prior
public Parameter prior
An expression for the prior distribution from which the samples are drawn.
-
processNoise
public Parameter processNoise
The process noise. If the system contains multiple state variables, the process noise should be an expression that returns an ArrayToken. See multivariateGaussian for one such function.
-
stateVariableNames
public Parameter stateVariableNames
The names of the state variables, in an array of strings. The default is an ArrayToken of an empty String.
-
-
Constructor Detail
-
ParticleFilter
public ParticleFilter(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct the composite actor with a name and a container. This constructor creates the ports, parameters, and the icon.- Parameters:
container
- The container.name
- The name.- Throws:
NameDuplicationException
- If another entity already had this name.IllegalActionException
- If there was an internal problem.
-
ParticleFilter
public ParticleFilter(Workspace workspace) throws IllegalActionException, NameDuplicationException
Construct a PF in the specified workspace with no container and an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace.- Parameters:
workspace
- The workspace that will list the actor.- Throws:
IllegalActionException
- If the name has a period in it, or the director is not compatible with the specified container.NameDuplicationException
- If the container already contains an entity with the specified name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the argument is any parameter other than stateVariableNames t, or any parameter matching an input port, then request reinitialization.- Overrides:
attributeChanged
in classAbstractParticleFilter
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the numerator and the denominator matrix is not a row vector.
-
_checkParameters
protected void _checkParameters() throws IllegalActionException
Check the dimensions of all parameters and ports.- Specified by:
_checkParameters
in classAbstractParticleFilter
- Throws:
IllegalActionException
- If the dimensions are illegal.
-
getUserDefinedParameter
protected Parameter getUserDefinedParameter(java.lang.String parameterName) throws IllegalActionException
Return the Parameter that is part of a state space model.- Specified by:
getUserDefinedParameter
in classAbstractParticleFilter
- Parameters:
parameterName
- Name of parameter- Returns:
- Parameter object
- Throws:
IllegalActionException
- If the parameter cannot be found.
-
getMeasurementParameter
protected Parameter getMeasurementParameter(java.lang.String fullName) throws IllegalActionException
Description copied from class:AbstractParticleFilter
Returns a parameter value corresponding to a measurement.- Specified by:
getMeasurementParameter
in classAbstractParticleFilter
- Parameters:
fullName
- Name of measurement parameter- Returns:
- a Parameter object that by name reference corresponds to a specific measurement.
- Throws:
IllegalActionException
-
getInputType
protected AbstractParticleFilter.InputType getInputType(java.lang.String inputName)
Description copied from class:AbstractParticleFilter
Get input type by name reference- Specified by:
getInputType
in classAbstractParticleFilter
- Parameters:
inputName
- The name of the input- Returns:
- an InputType object indicating the type of input
-
getNoiseParameter
protected Parameter getNoiseParameter(java.lang.String inputName)
Description copied from class:AbstractParticleFilter
Returns a parameter value corresponding to a noise distribution.- Specified by:
getNoiseParameter
in classAbstractParticleFilter
- Parameters:
inputName
- Name of noise parameter- Returns:
- a Parameter object that by name reference corresponds to a specific noise distribution
-
satisfiesMapConstraints
public boolean satisfiesMapConstraints(double[] coordinates)
Description copied from interface:MapConstrained
Return true if the the coordinates satisfy the map constraints.- Parameters:
coordinates
- The coordinates- Returns:
- true if the the coordinates satisfy the map constraints.
-
-