ptolemy.domains.ct.lib
Class LinearStateSpace

java.lang.Object
  |
  +--ptolemy.kernel.util.NamedObj
        |
        +--ptolemy.kernel.Entity
              |
              +--ptolemy.kernel.ComponentEntity
                    |
                    +--ptolemy.kernel.CompositeEntity
                          |
                          +--ptolemy.actor.CompositeActor
                                |
                                +--ptolemy.actor.TypedCompositeActor
                                      |
                                      +--ptolemy.domains.ct.lib.LinearStateSpace
All Implemented Interfaces:
Actor, java.lang.Cloneable, Debuggable, Executable, Nameable, java.io.Serializable, TypedActor

public class LinearStateSpace
extends TypedCompositeActor

The State-Space model implements a system whose behavior is defined by:

dx/dt = Ax + Bu
y = Cx + Du
x(0) = x0
where x is the state vector, u is the input vector, and y is the output vector. The matrix coefficients must have the following characteristics:
A must be an n-by-n matrix, where n is the number of states.
B must be an n-by-m matrix, where m is the number of inputs.
C must be an r-by-n matrix, where r is the number of outputs.
D must be an r-by-m matrix.
The actor accepts m inputs and generates r outputs through a multi-input port and a multi-output port. The widths of the ports must match the number of rows and columns in corresponding matrices, otherwise, an exception will be thrown.

This actor works like a higher-order function. It is opaque after construction or the change of parameters. Upon preinitialization, the actor will create a subsystem using integrators, adders, and scales. After that, the actor becomes transparent, and the director takes over the control of the actors contained by this actor.

Since:
Ptolemy II 1.0
Version:
$Id: LinearStateSpace.java,v 1.21 2002/02/21 19:39:27 cxh Exp $
Author:
Jie Liu
See Also:
CTBaseIntegrator, Serialized Form

Inner classes inherited from class ptolemy.kernel.util.NamedObj
NamedObj.MoMLInfo
 
Field Summary
 Parameter A
          The A matrix in the state-space representation.
 Parameter B
          The B matrix in the state-space representation.
 Parameter C
          The C matrix in the state-space representation.
 Parameter D
          The D matrix in the state-space representation.
 Parameter initialStates
          The initial condition for the state variables.
 TypedIOPort input
          Multi-input port.
 TypedIOPort output
          Multi-output port.
 TypedIOPort stateOutput
          state outputs ports.
 
Fields inherited from class ptolemy.kernel.CompositeEntity
_containedEntities
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _debugging, _debugListeners, _uniqueNameIndex, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
LinearStateSpace(CompositeEntity container, java.lang.String name)
          Construct the composite actor with a name and a container.
 
Method Summary
 void attributeChanged(Attribute attribute)
          If the argument is A, B, C, D or initialState parameters, check that they are indeed matrices and vectors, and request for initialization from the director if there is one.
 Director getDirector()
          Return the executive director, regardless what isOpaque() returns.
 boolean isOpaque()
          Return the opaqueness of this composite actor.
 void preinitialize()
          Sanity check the parameters; if the parameters are legal create a continuous-time subsystem that implement the model, preinitialize all the actors in the subsystem, and set the opaqueness of this actor to true.
 void wrapup()
          Set the opaqueness back to true and call the wrapup() method of the super class.
 
Methods inherited from class ptolemy.actor.TypedCompositeActor
_addEntity, _addPort, _addRelation, newPort, newRelation, resolveTypes, typeConstraintList
 
Methods inherited from class ptolemy.actor.CompositeActor
_setDirector, clone, connectionsChanged, fire, getExecutiveDirector, getManager, initialize, inputPortList, iterate, newInsideReceiver, newReceiver, outputPortList, postfire, prefire, requestChange, setContainer, setDirector, setManager, stopFire, terminate
 
Methods inherited from class ptolemy.kernel.CompositeEntity
_description, _exportMoMLContents, _removeEntity, _removeRelation, allAtomicEntityList, allowLevelCrossingConnect, connect, connect, deepEntityList, deepGetEntities, entityList, entityList, exportLinks, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, uniqueName
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, getContainer, setName
 
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _removeAttribute, _splitName, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getFullName, getMoMLInfo, getName, getName, removeChangeListener, removeDebugListener, setDeferMoMLDefinitionTo, toplevel, toString, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
fire, initialize, iterate, postfire, prefire, stopFire, terminate
 

Field Detail

input

public TypedIOPort input
Multi-input port.

output

public TypedIOPort output
Multi-output port.

stateOutput

public TypedIOPort stateOutput
state outputs ports.

A

public Parameter A
The A matrix in the state-space representation. It must be a square matrix. The default value is [[1.0]].

B

public Parameter B
The B matrix in the state-space representation. The number of rows must equal to the number of rows of the A matrix. The number of columns must equal to the width of the input port. The default value is [[1.0]].

C

public Parameter C
The C matrix in the state-space representation. The number of columns must equal to the number of columns of the A matrix. The number of rows must equal to the width of the output port. The default value is [[1.0]].

D

public Parameter D
The D matrix in the state-space representation. The number of columns must equal to the width of the input port. The number of rows must equal to the width of the output port. The default value is [[0.0]].

initialStates

public Parameter initialStates
The initial condition for the state variables. This must be a vector (double matrix with only one row) whose length equals to the number of state variables. The default value is [0.0].
Constructor Detail

LinearStateSpace

public LinearStateSpace(CompositeEntity container,
                        java.lang.String name)
                 throws NameDuplicationException,
                        IllegalActionException
Construct the composite actor with a name and a container. This constructor creates the ports, parameters, and the icon.
Parameters:
container - The container.
name - The name.
Throws:
NameDuplicationException - If another entity already had this name.
IllegalActionException - If there was an internal problem.
Method Detail

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
If the argument is A, B, C, D or initialState parameters, check that they are indeed matrices and vectors, and request for initialization from the director if there is one. Other sanity checks like the dimensions of the matrices will be done in the preinitialize() method.
Overrides:
attributeChanged in class NamedObj
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the numerator and the denominator matrix is not a row vector.

isOpaque

public boolean isOpaque()
Return the opaqueness of this composite actor. This actor is opaque if it has not been preinitialized after creation or changes of parameters. Otherwise, it is not opaque.
Overrides:
isOpaque in class CompositeActor
Following copied from class: ptolemy.kernel.CompositeEntity
Returns:
True if the entity is opaque.
See Also:
CompositeEntity

preinitialize

public void preinitialize()
                   throws IllegalActionException
Sanity check the parameters; if the parameters are legal create a continuous-time subsystem that implement the model, preinitialize all the actors in the subsystem, and set the opaqueness of this actor to true. This method needs the write access on the workspace.
Overrides:
preinitialize in class CompositeActor
Throws:
IllegalActionException - If there is no CTDirector, or any contained actors throw it in its preinitialize() method.

getDirector

public Director getDirector()
Return the executive director, regardless what isOpaque() returns.
Overrides:
getDirector in class CompositeActor
Returns:
the executive director.

wrapup

public void wrapup()
            throws IllegalActionException
Set the opaqueness back to true and call the wrapup() method of the super class.
Overrides:
wrapup in class CompositeActor
Throws:
IllegalActionException - If there is no director.