public class ContinuousIntegrator extends TypedAtomicActor implements ContinuousStatefulComponent, ContinuousStepSizeController
+---------------+ dx/dt | | x +--------->| Integrator |---------+-----> | | | | | +----^-----^----+ | | | | |---------| | +-------------| f(x, t) |<-----------+ |---------|
An integrator also has a port-parameter called initialState. The parameter provides the initial state for integration during the initialization stage of execution. If during execution an input token is provided on the port, then the state of the integrator will be reset at that time to the value of the token. The default value of the parameter is 0.0.
An integrator also has an input port named impulse. When present, a token at the impulse input port is interpreted as the weight of a Dirac delta function. It causes an increment or decrement to the state at the time of the arrival of the value. If both impulse and initialState have data on the same microstep, then initialState dominates.
Note that both impulse and reset expect to receive discrete inputs. To preserve continuity, this means that those inputs should be present only when the solver step size is zero. If this assumption is violated, then this actor will throw an exception.
An integrator can generate an output (its current state) before the derivative input is known, and hence can be used in feedback loops like that above without creating a causality loop. Since impulse and initialState inputs affect the output immediately, using them in feedback loops may require inclusion of a TimeDelay actor.
For different ODE solving methods, the functionality of an integrator may be different. The delegation and strategy design patterns are used in this class, the abstract ODESolver class, and the concrete ODE solver classes. Some solver-dependent methods of integrators delegate to the concrete ODE solvers.
An integrator can possibly have several auxiliary variables for the ODE solvers to use. The ODE solver class provides the number of variables needed for that particular solver. The auxiliary variables can be set and get by setAuxVariables() and getAuxVariables() methods.
This class is based on the CTBaseIntegrator by Jie Liu and Haiyang Zheng, but it has more ports and provides more functionality.
Red (yuhong) |
Yellow (hyzheng) |
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
TypedIOPort |
derivative
The derivative port.
|
TypedIOPort |
impulse
The impulse input port.
|
PortParameter |
initialState
The initial state of type DoubleToken.
|
TypedIOPort |
state
The state port.
|
_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 |
---|
ContinuousIntegrator(CompositeEntity container,
java.lang.String name)
Construct an integrator with the specified name and a container.
|
Modifier and Type | Method and Description |
---|---|
void |
attributeChanged(Attribute attribute)
If the specified attribute is initialState, then reset
the state of the integrator to its value.
|
java.lang.Object |
clone(Workspace workspace)
Clone this actor into the specified workspace.
|
void |
fire()
If the value at the derivative port is known, and the
current step size is bigger than 0, perform an integration.
|
double[] |
getAuxVariables()
Return the auxiliary variables in a double array.
|
CausalityInterface |
getCausalityInterface()
Return a causality interface for this actor.
|
double |
getDerivative()
Get the current value of the derivative input port.
|
double |
getState()
Return the state of the integrator.
|
double |
getTentativeState()
Return the tentative state.
|
void |
initialize()
Initialize the integrator.
|
boolean |
isStepSizeAccurate()
Return true if the state is resolved successfully.
|
boolean |
isStrict()
Return false.
|
boolean |
postfire()
Update the state.
|
boolean |
prefire()
If either the impulse or initialState input is unknown,
then return false.
|
double |
refinedStepSize()
Return the estimation of the refined next step size.
|
void |
rollBackToCommittedState()
Roll back to committed state.
|
void |
setAuxVariables(int index,
double value)
Set the value of an auxiliary variable.
|
void |
setTentativeState(double value)
Set the tentative state.
|
double |
suggestedStepSize()
Return the suggested next step size.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, iterate, newReceiver, outputPortList, 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, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, iterate, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public TypedIOPort impulse
public TypedIOPort derivative
public TypedIOPort state
public PortParameter initialState
public ContinuousIntegrator(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name.NameDuplicationException
- If the name is used by
another actor in the container.IllegalActionException
- If ports can not be created, or
thrown by the super class.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that has changed.IllegalActionException
- If the new parameter value
is not valid.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class TypedAtomicActor
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
- If the input is infinite or
not a number, or if thrown by the solver,
or if data is present at either impulse
or initialState and the step size is greater than zero.public double[] getAuxVariables()
setAuxVariables(int, double)
public CausalityInterface getCausalityInterface()
getCausalityInterface
in interface Actor
getCausalityInterface
in class AtomicActor<TypedIOPort>
public double getDerivative() throws NoTokenException, IllegalActionException
NoTokenException
- If reading the input throws it.IllegalActionException
- If thrown while reading
the input.public final double getState()
public double getTentativeState()
setTentativeState(double)
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor<TypedIOPort>
IllegalActionException
- If there is no director,
or the director has no ODE solver, or the initialState
parameter does not contain a valid token, or the superclass
throws it.public boolean isStepSizeAccurate()
isStepSizeAccurate
in interface ContinuousStepSizeController
public boolean isStrict()
isStrict
in interface Executable
isStrict
in class AtomicActor<TypedIOPort>
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor<TypedIOPort>
IllegalActionException
- Not thrown in this base class.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the superclass throws it.public double suggestedStepSize()
suggestedStepSize
in interface ContinuousStepSizeController
public double refinedStepSize()
refinedStepSize
in interface ContinuousStepSizeController
public void rollBackToCommittedState()
rollBackToCommittedState
in interface ContinuousStatefulComponent
public void setAuxVariables(int index, double value) throws InvalidStateException
index
- The index in the auxVariables array.value
- The value to be set.InvalidStateException
- If the index is out of the range
of the auxiliary variable array.getAuxVariables()
public final void setTentativeState(double value)
value
- The value to be set.getTentativeState()