Class LinearStateSpace

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class LinearStateSpace
    extends TypedCompositeActor
    Linear state space model in the CT domain.

    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.

    This actor is based on the ptolemy.domains.ct.lib.LinearStateSpace actor by Jie Liu.

    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Edward A. Lee, Contributor: Jie Liu
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (liuj)
    • Field Detail

      • stateOutput

        public TypedIOPort stateOutput
        State output multiport.
      • 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​(Workspace workspace)
                         throws IllegalActionException,
                                NameDuplicationException
        Construct a LinearStateSpace in the specified workspace with no container and an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace.
        Parameters:
        workspace - The workspace that will list the actor.
        Throws:
        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.
    • 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 TypedCompositeActor
        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
        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.
        Specified by:
        preinitialize in interface Initializable
        Overrides:
        preinitialize in class CompositeActor
        Throws:
        IllegalActionException - If there is no CTDirector, or any contained actors throw it in its preinitialize() method.
      • stopFire

        public void stopFire()
        Stop the current firing. This method overrides the stopFire() method in TypedCompositeActor base class, so that it will not invoke the local director (since there is none). This method should not be called after initialization phase, i.e. when the actor is transparent.
        Specified by:
        stopFire in interface Executable
        Overrides:
        stopFire in class CompositeActor