Package ptolemy.actor.lib.r
Class RExpression2
- 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
-
- ptolemy.actor.lib.r.RExpression2
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class RExpression2 extends TypedAtomicActor
The RExpression actor is an actor designed to run an R script or function with inputs and outputs determined by the ports created by the user. Port names will correspond to R object names. The RExpression actor is modeled after the Ptolemy expression actor, except that that instead of using a single mathematical expression in Ptolemy's expression language, it uses a set of the more powerful, higher order expressions available under R. Both input and output port will usually be added to the actor; The names of these ports correspond to R variables used in the R script.Note that RExpression2 uses the Java/R interface from https://rforge.net/JRI/ which requires that native libraries be installed in your java.library.path.
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Dan Higgins and Matt Jones, NCEAS, UC Santa Barbara
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
displayGraphicsOutput
If true, then display plot.StringAttribute
expression
The expression that is evaluated to produce the output.TypedIOPort
graphicsFileName
The name of the default graphics output file created by the actor.StringParameter
graphicsFormat
The graphics output format.Parameter
graphicsOutput
If true, then create a graphics output port.static org.apache.commons.logging.Log
log
The log.StringParameter
numXPixels
The width of the output graphics bitmap in pixels.StringParameter
numYPixels
The height of the output graphics bitmap in pixels.TypedIOPort
output
The output port.StringParameter
Rcwd
The 'R' working directory (home dir by default).Parameter
serializeData
If true, then daata frames (and other complexe data objects will be transferred by serialization to disk.Parameter
showDebug
If true, then shoe debugging information about script.-
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 RExpression2(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean[][]
asBooleanMatrix(org.rosuda.JRI.REXP x)
Return as a matrix of booleans.static int[][]
asIntMatrix(double[][] doubles)
Return the array as an int matrix.java.lang.Object
clone(Workspace workspace)
Override the base class to set type constraints.void
fire()
Do nothing.void
initialize()
Initialize this actor.void
preinitialize()
Iterate through the ports.-
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, getCausalityInterface, getDirector, getExecutiveDirector, getManager, 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, attributeChanged, 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
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
log
public static org.apache.commons.logging.Log log
The log.
-
output
public TypedIOPort output
The output port.
-
expression
public StringAttribute expression
The expression that is evaluated to produce the output.
-
Rcwd
public StringParameter Rcwd
The 'R' working directory (home dir by default).
-
showDebug
public Parameter showDebug
If true, then shoe debugging information about script. If false, then don't. (the default)
-
serializeData
public Parameter serializeData
If true, then daata frames (and other complexe data objects will be transferred by serialization to disk. If false, then they will be converted as losslessly as possible to a Ptolemy data structure
-
displayGraphicsOutput
public Parameter displayGraphicsOutput
If true, then display plot. If false, then don't. (the default)
-
graphicsFormat
public StringParameter graphicsFormat
The graphics output format. Currently the format is either a *.pdf or a *.png
-
graphicsOutput
public Parameter graphicsOutput
If true, then create a graphics output port. (the default); If false, then don't.
-
numXPixels
public StringParameter numXPixels
The width of the output graphics bitmap in pixels.
-
numYPixels
public StringParameter numYPixels
The height of the output graphics bitmap in pixels.
-
graphicsFileName
public TypedIOPort graphicsFileName
The name of the default graphics output file created by the actor.
-
-
Constructor Detail
-
RExpression2
public RExpression2(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
Override the base class to set type constraints.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new instance of RExpression.
- 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)
-
fire
public void fire() throws IllegalActionException
Description copied from class:AtomicActor
Do nothing. Derived classes override this method to define their primary run-time action.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
initialize
public void initialize() throws IllegalActionException
Description copied from class:AtomicActor
Initialize this actor. Derived classes override this method to perform actions that should occur once at the beginning of an execution, but after type resolution. Derived classes can produce output data and schedule events.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If a derived class throws it.
-
preinitialize
public void preinitialize() throws IllegalActionException
Iterate through the ports.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If thrown by the base class or while accessing the ports.
-
asIntMatrix
public static int[][] asIntMatrix(double[][] doubles)
Return the array as an int matrix.- Parameters:
doubles
- The 2-d array of doubles.- Returns:
- The 2d array of integers.
-
asBooleanMatrix
public static boolean[][] asBooleanMatrix(org.rosuda.JRI.REXP x)
Return as a matrix of booleans.- Parameters:
x
- The R expression.- Returns:
- the result as an array of booleans.
-
-