Package org.ptolemy.machineLearning.hsmm
Class HSMMGenerator
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- org.ptolemy.machineLearning.hsmm.HSMMGenerator
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
HSMMGeneratorGaussianEmissions
,HSMMGeneratorMultinomialEmissions
public abstract class HSMMGenerator extends TypedAtomicActor
An abstract class that implements a Bayesian network used to simulate an Explicit-Duration Hidden Markov Model.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Ilge Akkaya
- Pt.AcceptedRating:
- Pt.ProposedRating:
- Red (ilgea)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected double[][]
_A
Cached transition matrix value.protected double[][]
_D
current duration distribution.protected double[][]
_D0
initial duration distribution.protected int
_dt
Duration variable: d(t).protected double[]
_durationPriors
Duration priors: an nStates-by-nDurations matrix.protected boolean
_firstIteration
Boolean indicating the first iteration of the generator.protected int
_maxDuration
Cardinality of the support of duration distribution.protected int
_nStates
Cardinality of state space.protected int
_windowSize
Generation window size.protected double[]
_x0
maximum duration ( in time steps).protected int
_xt
State variable: x(t).protected double[][]
D_new
new duration distribution.PortParameter
durationPriors
The user-provided initial guess on the prior probability distribution.PortParameter
durationProbabilities
The user-provided initial guess on the prior probability distribution.TypedIOPort
hiddenState
Output port for corresponding state sequence.protected static int
MAX_TRIALS
In the presence of window-based constraints, number of runs allowable until valid trace found.TypedIOPort
observation
Output port for observation array.PortParameter
powerUpperBound
Power limit on generation window.PortParameter
statePriors
Prior state distribution.PortParameter
transitionMatrix
Transition Probability matrix estimate.TypedIOPort
trigger
Trigger generation.Parameter
windowSize
Generation window size.-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
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 HSMMGenerator(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract int
_propagateState()
Sample next state given current state.protected abstract int
_sampleDurationForState()
Sample a duration value given current state.protected abstract int
_sampleDurationFromPrior()
Sample duration value from prior duration distribution.protected abstract int
_sampleHiddenStateFromPrior()
Sample state at this iteration from the state prior.protected abstract double[]
_sampleObservation()
Sample an observation value given current state.void
attributeChanged(Attribute attribute)
React to a change in an attribute.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
preinitialize()
Create receivers and declare delay dependencies.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, 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, requestChange, 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
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
durationPriors
public PortParameter durationPriors
The user-provided initial guess on the prior probability distribution.
-
durationProbabilities
public PortParameter durationProbabilities
The user-provided initial guess on the prior probability distribution.
-
transitionMatrix
public PortParameter transitionMatrix
Transition Probability matrix estimate.
-
statePriors
public PortParameter statePriors
Prior state distribution.
-
trigger
public TypedIOPort trigger
Trigger generation.
-
observation
public TypedIOPort observation
Output port for observation array.
-
hiddenState
public TypedIOPort hiddenState
Output port for corresponding state sequence.
-
windowSize
public Parameter windowSize
Generation window size.
-
powerUpperBound
public PortParameter powerUpperBound
Power limit on generation window.
-
_durationPriors
protected double[] _durationPriors
Duration priors: an nStates-by-nDurations matrix.
-
D_new
protected double[][] D_new
new duration distribution.
-
_D0
protected double[][] _D0
initial duration distribution.
-
_D
protected double[][] _D
current duration distribution.
-
_x0
protected double[] _x0
maximum duration ( in time steps).
-
_A
protected double[][] _A
Cached transition matrix value.
-
_firstIteration
protected boolean _firstIteration
Boolean indicating the first iteration of the generator.
-
_nStates
protected int _nStates
Cardinality of state space.
-
_maxDuration
protected int _maxDuration
Cardinality of the support of duration distribution.
-
_dt
protected int _dt
Duration variable: d(t).
-
_xt
protected int _xt
State variable: x(t).
-
_windowSize
protected int _windowSize
Generation window size.
-
MAX_TRIALS
protected static int MAX_TRIALS
In the presence of window-based constraints, number of runs allowable until valid trace found.
-
-
Constructor Detail
-
HSMMGenerator
public HSMMGenerator(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an actor with the given container and name.- Parameters:
container
- The container.name
- The name of this actor- Throws:
IllegalActionException
- If the actor cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Description copied from class:TypedAtomicActor
Clone the actor into the specified workspace.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
preinitialize
public void preinitialize() throws IllegalActionException
Description copied from class:AtomicActor
Create receivers and declare delay dependencies. Derived classes can override this method to perform additional initialization functions, but they should call this base class methods or create the receivers themselves. This method gets executed exactly once prior to any other action methods. It cannot produce output data since type resolution is typically not yet done. It also gets invoked prior to any static scheduling that might occur in the domain, so it can change scheduling information.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
Description copied from class:NamedObj
React to a change in an attribute. This method is called by a contained attribute when its value changes. In this base class, the method does nothing. In derived classes, this method may throw an exception, indicating that the new attribute value is invalid. It is up to the caller to restore the attribute to a valid value if an exception is thrown.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the change is not acceptable to this container (not thrown in this base class).
-
_sampleObservation
protected abstract double[] _sampleObservation()
Sample an observation value given current state.- Returns:
- Observation
-
_sampleDurationForState
protected abstract int _sampleDurationForState()
Sample a duration value given current state.- Returns:
- Duration
-
_propagateState
protected abstract int _propagateState() throws IllegalActionException
Sample next state given current state.- Returns:
- Next state index.
- Throws:
IllegalActionException
-
_sampleHiddenStateFromPrior
protected abstract int _sampleHiddenStateFromPrior()
Sample state at this iteration from the state prior.- Returns:
- The hidden state at this iteration
-
_sampleDurationFromPrior
protected abstract int _sampleDurationFromPrior()
Sample duration value from prior duration distribution.- Returns:
- sampled duration value
-
-