public class NodeRandomizer extends TypedAtomicActor
This actor assumes that the location is represented in an object of class Locatable (which is an attribute that implements Settable) with name "_location". This is how Vergil represents locations.
The range parameter is an array of arrays giving the range of possible values for each dimension of the location. For example, if the location is in two dimensions, then range has the form {{x1, x2}, {y1, y2}}, indicating that the X value of the location is uniformly distributed between x1 and x2, and that the Y value is uniformly distributed between y1 and y2.
If the resetOnEachRun parameter is true (the default value), then each run resets the random number generator. If the seed is non-zero, then this makes each run identical. This is useful for constructing tests. If the seed is zero, then a new seed is generated on each run (using the current time and the hash code of this object).
The maxPrecision parameter specifies the number of digits to be used when generating a random location; results are rounded to this precision. If the value is 0 (the default value), then use the maximum precision allowed by the Java double type and the random number generator.
Locatable
Red (sanjeev) |
Yellow (eal) |
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
Parameter |
isPersistent
If the isPersistent parameter is false, then the MoMLChangeRequest
that places the nodes will not be persistent so the user will not
be prompted to save the model upon closing.
|
Parameter |
maxPrecision
The maximum precision (number of digits to be used, results
are rounded to this precision) of the generated locations.
|
Parameter |
randomizeInInitialize
If set to true, randomly distribute nodes in initialize().
|
Parameter |
range
The range of values for locations to be set when randomizing.
|
Parameter |
resetOnEachRun
If set to true, reset the random number generator with the
seed value each time preinitialize() is invoked.
|
Parameter |
seed
The seed that controls the random number generation to use when
randomizing.
|
TypedIOPort |
trigger
A trigger input to cause this actor to fire in domains
that require a trigger.
|
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
NodeRandomizer(CompositeEntity container,
java.lang.String name)
Construct an actor in the given container with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
_getLocationSetMoML(CompositeEntity container,
Entity node,
double[] location)
Return moml that will set the location of the specified node.
|
protected void |
_randomize()
Randomly distribute the nodes in the model that contain a
boolean valued parameter named "randomize" with value true.
|
void |
attributeChanged(Attribute attribute)
Override the base class to react to changes in maxPrecision.
|
void |
fire()
Issue a change request to randomize the locations of the nodes.
|
void |
initialize()
Override the base class to randomize the positions of the
nodes if randomizeInInitialize is set to true.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, 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
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public Parameter isPersistent
public Parameter maxPrecision
public Parameter randomizeInInitialize
public Parameter range
public Parameter resetOnEachRun
public Parameter seed
public TypedIOPort trigger
public NodeRandomizer(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- Container of the actor.name
- Name of the actor.IllegalActionException
- If the
actor is not compatible with the specified container.NameDuplicationException
- If the name collides
with an entity in the container.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that changed.IllegalActionException
- If the change is not acceptable
to this container (not thrown in this base class).public void fire() throws IllegalActionException
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the superclass throws it.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the initialize() method of
one of the associated actors throws it, or if the range parameter
is malformed.protected void _randomize() throws IllegalActionException
If the isPersistent parameter is true, then the change is marked as a persistent change, which will cause the model to be modified, which means the user will be prompted to save the model upon exiting.
IllegalActionException
- If the range parameter is malformed.protected java.lang.String _getLocationSetMoML(CompositeEntity container, Entity node, double[] location) throws IllegalActionException
container
- The container.location
- The specified location.node
- The node for which to set the location.IllegalActionException
- If the location attribute
cannot be set.