ptolemy.actor.lib
Class RandomSource
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Source
ptolemy.actor.lib.RandomSource
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TypedActor
- Direct Known Subclasses:
- Bernoulli, DiscreteRandomSource, Gaussian, Rician, Uniform
- public abstract class RandomSource
- extends Source
A base class for sources of random numbers.
It uses the class java.util.Random.
This base class manages the seed.
- Since:
- Ptolemy II 0.3
- Version:
- $Id: RandomSource.java,v 1.29 2004/04/13 19:07:57 cxh Exp $
- Author:
- Edward A. Lee, Steve Neuendorffer
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
|
Field Summary |
protected java.util.Random |
_random
|
Parameter |
seed
The seed that controls the random number generation.
|
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
Constructor Summary |
RandomSource(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name. |
|
Method Summary |
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace. |
void |
initialize()
Initialize the random number generator with the seed, if it
has been given. |
| Methods inherited from class ptolemy.actor.lib.Source |
fire |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup |
| Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
seed
public Parameter seed
- The seed that controls the random number generation.
A seed of zero is interpreted to mean that no seed is specified,
which means that each execution of the model could result in
distinct data. For the value 0, the seed is set to
System.currentTimeMillis() + hashCode(), which means that
with extremely high probability, two distinct actors will have
distinct seeds. However, current time may not have enough
resolution to ensure that two subsequent executions of the
same model have distinct seeds.
This parameter contains a LongToken, initially with value 0.
_random
protected java.util.Random _random
RandomSource
public RandomSource(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.
clone
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
- Clone the actor into the specified workspace. This calls the
base class and then creates new ports and parameters.
- Overrides:
clone in class AtomicActor
- 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.
initialize
public void initialize()
throws IllegalActionException
- Initialize the random number generator with the seed, if it
has been given. A seed of zero is interpreted to mean that no
seed is specified. In such cases, a seed based on the current
time and this instance of a RandomSource is used to be fairly
sure that two identical sequences will not be returned.
- Specified by:
initialize in interface Executable- Overrides:
initialize in class AtomicActor
- Throws:
IllegalActionException - If the parent class throws it.