Class MultiInstanceComposite

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

    public class MultiInstanceComposite
    extends TypedCompositeActor
    A TypedCompositeActor that creates multiple instances of itself during the preinitialize phase of model execution.

    A MultiInstanceComposite actor may be used to instantiate nInstances identical processing blocks within a model. This actor (the "master") creates nInstances - 1 additional instances (clones) of itself during the preinitialize() phase of model execution and destroys these additional instances during model CompositeActor.wrapup(). MultiInstanceComposite must be opaque (have a director), so that its Actor interface methods (preinitialize(), ..., wrapup()) are invoked during model initialization. Each instance may refer to its instance [0..nInstances-1] parameter which is set automatically by the master if it needs to know its instance number.

    MultiInstanceComposite input ports must not be multiports (for now) and may be connected to multiports or regular ports. During preinitialize(), the master MultiInstanceComposite determines how its input ports are connected, and creates additional relations in its container (the model it is embedded in) to connect the input ports of its clones (instances) to the same output port if that port is a multiport. If that output port is a regular port, the clone's input port is linked to the already existing relation between that output port and the master's input port. MultiInstanceComposite output ports must not be multiports (for now) and must be connected to input multiports. The master MultiInstanceComposite creates additional relations to connect the output ports of its clones to the input port. Finally, after all these connections are made, the master's preinitialize() calls preinitialize() of the clones.

    From here on until wrapup(), nothing special happens. Type resolution occurs on all instances in the modified model, so does initialize() and the computation of schedules by directors of the master and clones.

    During model wrapup(), the master MultiContextComposite deletes any relations created, unlinks any ports if needed, and deletes the clones it created. To re-synchronize vergil's model graph, an empty ChangeRequest is also queued with the Manager.

    Actor parameters inside MultiInstanceComposite may refer to parameters of the container model. This presents a problem during cloning() and wrapup() where the container model's parameters are not in scope during the clone's validateSettables() (unless the MultiInstanceComposite is built as a moml class having its own set of parameters). This problem is for now solved by providing a temporary scope copy using a ScopeExtendingAttribute for the cloning() and wrapup() phases of the clones.

    Since:
    Ptolemy II 4.0
    Version:
    $Id$
    Author:
    Zoltan Kemenczy, Sean Simmons, Research In Motion Limited
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (zkemenczy)
    • Field Detail

      • nInstances

        public Parameter nInstances
        The total number of instances to instantiate including instance 0 (the master copy).
      • instance

        public Parameter instance
        The index of this instance.
      • showClones

        public Parameter showClones
        If true, show the clones.
    • Constructor Detail

      • MultiInstanceComposite

        public MultiInstanceComposite​(Workspace workspace)
        Construct a MultiInstanceComposite actor in the specified workspace with no container and an empty string as a name.
        Parameters:
        workspace - The workspace of this object.