public abstract class ParameterEstimator extends AtomicCommunicationAspect
CommunicationAspect
that, when its
sendToken(Receiver, Receiver, Token)
method is called, delays
the delivery of the specified token to the specified receiver
according to a service rule. Specifically, if the actor is
not currently servicing a previous token, then it delivers
the token with a delay given by the serviceTimeMultiplicationFactor
parameter multiplied by the messageLength parameter specified in the port.
If the actor is currently servicing a previous token, then it waits
until it has finished servicing that token (and any other pending
tokens), and then delays for an additional amount given by
serviceTimeMultiplicationFactor * messageLength.
In the default case of the messageLength = 1, the behavior is similar to
the Server
actor.
Tokens are processed in FIFO order.
To use this communication aspect, drag an instance of this Bus into the model, and (optionally) assign it a name. Then, on any input port whose communication is to be mediated by this instance of Bus, open the configuration dialogue, select the tab with the name of the bus in the title and select the enable attribute. The message length is by default set to 1 but can be configured in this tab.
Several Bus communication aspects can be used in sequence. The order in which Tokens are sent through Buses depends on the order in which these are enabled via the DecoratorAttributes.
This actor is tested in continuous and DE.
Red (derler) |
Yellow (derler) |
Modifier and Type | Class and Description |
---|---|
static class |
ParameterEstimator.BusAttributes |
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected double[][] |
_A0 |
protected int |
_batchSize |
protected double |
_likelihood |
protected double |
_likelihoodThreshold |
protected int |
_nIterations |
protected int |
_nStates |
protected double[] |
_observations |
protected java.util.HashMap<java.lang.String,java.util.List<java.lang.Double>> |
_observedTokens |
protected double[] |
_priorIn |
protected double[] |
_priors |
protected boolean |
_randomize |
protected double[][] |
_transitionMatrix |
Parameter |
A0
The user-provided initial guess of the transition probability matrix.
|
Parameter |
batchSize
The user-provided batch-size to be considered in the estimation.
|
TypedIOPort |
input
The input port that provides the sample observations.
|
(package private) double |
likelihood |
Parameter |
likelihoodThreshold
The user-provided threshold on the minimum desired improvement
on likelihood per iteration.
|
Parameter |
maxIterations
The user-provided maximum number of allowed iterations of the
Alpha-Beta Recursion.
|
(package private) java.util.HashMap |
newEstimates |
Parameter |
nStates
Number of states of the HMM.
|
Parameter |
priorDistribution
The user-provided initial guess on the prior probability
distribution.
|
TypedIOPort |
priorEstimates
The vector estimate for the prior distribution on the set of
states.
|
Parameter |
randomizeGuessVectors
Boolean that determines whether or not to randomize input
guess vectors.
|
Parameter |
serviceTimeMultiplicationFactor
The service time for the default messageLength of 1.
|
TypedIOPort |
transitionMatrix
The transition matrix estimate obtained by iterating over the
observation set.
|
_parameters, _tokenCount
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
decoratorHighlightColorName
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
ParameterEstimator(CompositeEntity container,
java.lang.String name)
Construct a Bus with a name and a container.
|
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
_checkForConvergence(int i) |
protected boolean |
_EMParameterEstimation() |
protected void |
_initializeArrays() |
protected abstract void |
_initializeEMParameters() |
protected abstract void |
_iterateEM() |
protected void |
_scheduleRefire()
Schedule a refiring of the actor.
|
protected abstract void |
_updateEstimates() |
void |
attributeChanged(Attribute attribute)
If the attribute is serviceTime, then ensure that the value
is non-negative.
|
java.lang.Object |
clone(Workspace workspace)
Clone this actor into the specified workspace.
|
DecoratorAttributes |
createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj.
|
IntermediateReceiver |
createIntermediateReceiver(Receiver receiver)
Create an intermediate receiver that wraps a given receiver.
|
protected abstract double |
emissionProbability(double y,
int hiddenState) |
void |
fire()
Send first token in the queue to the target receiver.
|
protected java.util.HashMap |
HMMAlphaBetaRecursion(double[] y,
double[][] A,
double[] prior,
int nCategories) |
protected java.util.HashMap |
HMMAlphaBetaRecursionNonNormalized(double[] y,
double[][] A,
double[] prior,
int unused) |
void |
initialize()
Initialize the actor.
|
boolean |
postfire()
If there are still tokens in the queue and a token has been produced in the fire,
schedule a refiring.
|
void |
reset()
Nothing to do.
|
void |
sendToken(Receiver source,
Receiver receiver,
Token token)
Initiate a send of the specified token to the specified
receiver.
|
void |
setContainer(CompositeEntity container)
Override the base class to first set the container, then establish
a connection with any decorated objects it finds in scope in the new
container.
|
_sendToReceiver, decoratedObjects, isGlobalDecorator, registerListener, sendCommunicationEvent
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, stop, stopFire, terminate, wrapup
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
description, getContainer, getDisplayName, getFullName, getName, getName, setName
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
getDerivedLevel, getDerivedList, propagateValue
public Parameter serviceTimeMultiplicationFactor
public Parameter A0
public Parameter likelihoodThreshold
public Parameter maxIterations
public Parameter batchSize
public Parameter nStates
public Parameter randomizeGuessVectors
public Parameter priorDistribution
public TypedIOPort input
public TypedIOPort priorEstimates
public TypedIOPort transitionMatrix
protected double[][] _A0
protected int _batchSize
protected double _likelihood
protected double _likelihoodThreshold
protected int _nIterations
protected int _nStates
protected double[] _observations
protected java.util.HashMap<java.lang.String,java.util.List<java.lang.Double>> _observedTokens
protected double[] _priors
protected double[] _priorIn
protected boolean _randomize
protected double[][] _transitionMatrix
java.util.HashMap newEstimates
double likelihood
public ParameterEstimator(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this actor.IllegalActionException
- If the container is incompatible
with this actor.NameDuplicationException
- If the name coincides with
an actor already in the container.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the service time is negative.public DecoratorAttributes createDecoratorAttributes(NamedObj target)
createDecoratorAttributes
in interface Decorator
createDecoratorAttributes
in class AtomicCommunicationAspect
target
- The NamedObj that will be decorated.public IntermediateReceiver createIntermediateReceiver(Receiver receiver) throws IllegalActionException
createIntermediateReceiver
in interface CommunicationAspect
createIntermediateReceiver
in class AtomicCommunicationAspect
receiver
- The receiver that is being wrapped.IllegalActionException
- Thrown if Bus is used in container different from the container of the bus.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class AtomicCommunicationAspect
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- If cloned ports cannot have
as their container the cloned entity (this should not occur), or
if one of the attributes cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
- Not thrown in this base class.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicCommunicationAspect
IllegalActionException
- If the superclass throws it.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor<TypedIOPort>
IllegalActionException
- Not thrown in this base class.public void sendToken(Receiver source, Receiver receiver, Token token) throws IllegalActionException
source
- Sender of the token.receiver
- The receiver to send to.token
- The token to send.IllegalActionException
- If the refiring request fails.public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class AtomicCommunicationAspect
container
- The container to attach this attribute to..IllegalActionException
- If this attribute is not of the
expected class for the container, or it has no name,
or the attribute and container are not in the same workspace, or
the proposed container would result in recursive containment.NameDuplicationException
- If the container already has
an attribute with the name of this attribute.ComponentEntity.getContainer()
public void reset()
protected boolean _EMParameterEstimation()
protected abstract double emissionProbability(double y, int hiddenState)
protected void _initializeArrays() throws IllegalActionException
IllegalActionException
protected abstract void _initializeEMParameters()
protected abstract void _iterateEM()
protected abstract boolean _checkForConvergence(int i)
protected void _scheduleRefire() throws IllegalActionException
IllegalActionException
- Thrown if the actor cannot be rescheduledprotected abstract void _updateEstimates()
protected java.util.HashMap HMMAlphaBetaRecursion(double[] y, double[][] A, double[] prior, int nCategories)
protected java.util.HashMap HMMAlphaBetaRecursionNonNormalized(double[] y, double[][] A, double[] prior, int unused)