public class CADirector extends Director
The CADirector is to be used in conjunction with the CA2DConvolution Actor. To use this director, it is highly recommended to start with one of the examples. The director contains a matrix. At each iteration, every entry in the matrix is updated according to the CA2DConvolution actor. This functionality can be useful when simulating cellular automata or other grid-based phenomena.
This director assumes the following parameters are added to the canvas:
xLocation: the xLocation in the grid (the 2D matrix) that is currently being updated.
yLocation: the yLocation in the grid (the 2D matrix) that is currently being updated.
currentValue: the currentValue in the grid at location (xLocation, yLocation).
newValue: the updated value in the grid at location (xLocation, yLocation).
neighbor1: the value of the top-left neighbor of grid location (xLocation, yLocation).
neighbor2: the value of the top neighbor of grid location (xLocation, yLocation).
neighbor3: the value of the top-right neighbor of grid location (xLocation, yLocation).
neighbor4: the value of the left neighbor of grid location (xLocation, yLocation).
neighbor5: the value of the right neighbor of grid location (xLocation, yLocation).
neighbor6: the value of the bottom-left neighbor of grid location (xLocation, yLocation).
neighbor7: the value of the bottom neighbor of grid location (xLocation, yLocation).
neighbor8: the value of the bottom-right neighbor of grid location (xLocation, yLocation).
The director sets the variables for each entry in the matrix every iteration. The number of high-level iterations (that scan the entire matrix once) can be set as a parameter in the director. Other parameters include: delay, the time delay between iterations; randomize matrix, which determines if the matrix will be populated randomly; matrix size, the dimension of the square matrix; and initial values, the initial values of the matrix with all values not explicitly defined set to 0.0.
See also the documentation on the CA2DConvolution
actor
and the CAViewer
actor.
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected Parameter |
delay
The delay time between iterations in seconds.
|
protected Parameter |
initialMatrix
The initial matrix parameter.
|
protected Parameter |
iterations
The iterations parameter.
|
protected Parameter |
random
True if the matrix will be populated with random data.
|
protected Parameter |
size
An integer representing the size of the square matrix.
|
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
_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 |
---|
CADirector(CompositeEntity container,
java.lang.String name)
Construct a new CADirector.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_initParameters()
Initialize the parameters.
|
protected boolean |
_iterate()
Enforce the user-defined delay, call _showMatrix(), and check
if the iteration limit has been reached.
|
protected void |
_setInitMatrix()
Set the initial matrix for the CAViewer (the actor that visualizes the grid).
|
protected void |
_showMatrix()
Set the current matrix for any MatrixViewer, Const with a
DoubleMatrixToken, or CAViewer actors.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
void |
fire()
Iterate the relevant actors on the canvas for a single grid location.
|
boolean |
postfire()
Update the current x and yLocations of the grid.
|
void |
preinitialize()
This method performs the initialization step.
|
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, attributeChanged, createSchedule, defaultDependency, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelNextIterationTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, initialize, invalidateResolvedTypes, invalidateSchedule, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, newReceiver, notifyTokenSentToCommunicationAspect, prefire, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, suspend, terminate, transferInputs, transferOutputs, transferOutputs, wrapup
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
protected Parameter delay
protected Parameter initialMatrix
protected Parameter iterations
protected Parameter random
protected Parameter size
public CADirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of the director.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.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Director
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- Not thrown in this base classNamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
This method is invoked once per location in the matrix per iteration (i.e., Matrix size x iteration count).
This method sets the appropriate values on the canvas and iterates the appropriate actors (e.g., the CA2DConvolution actor) and updates grid values accordingly.
fire
in interface Executable
fire
in class Director
IllegalActionException
- If an actor is unable to iterate().public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class Director
IllegalActionException
- If exception occurs in base class.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class Director
IllegalActionException
- If an exception occurs in the
base class.protected void _initParameters() throws IllegalActionException, NameDuplicationException
IllegalActionException
- If the parameters names are
invalid.NameDuplicationException
- If parameters already exist
with a specified name.protected boolean _iterate() throws IllegalActionException
IllegalActionException
- If the matrix cannot be shown.protected void _setInitMatrix()
protected void _showMatrix() throws IllegalActionException
IllegalActionException
- If thrown while reading a token or iterating
the actors