Ptolemy II Domain Compatibility

In Ptolemy II, domains may be embedded within one another.

Below we describe some of the issues and include a chart that describes what combinations should work.

Contents

  • A portion of the "Composing Models of Computation in Kepler/Ptolemy II" paper
  • Expanded Domain Compatibility Graph
  • DE inside SDF

  • Composing Models of Computation in Kepler/Ptolemy II

    Below is a portion of a paper:
    Antoon Goderis, Christopher Brooks, Ilkay Altintas, Edward A. Lee, Carole Goble. Composing Different Models of Computation in Kepler and Ptolemy II, 2007 Proceedings, International Conference on Computational Science (ICCS), May, 2007.
    See also the ancillary site for the paper.

    Although prior work has offered formalisms for comparing MoCs, e.g. [Lee & S.V. 98], MoC compositions have not been well treated. To address the void, we develop a classification of valid MoC combinations in Kepler/Ptolemy II.

    In the Kepler environment, opaque composite actors can be put into workflows with a different type of director, thereby combining different models of computation in one workflow. The choice of director determines whether a given actor can be put on the inside or outside of other actors.

    To determine which combinations are possible, we need to know two things about a director:

    1. What properties it assumes of the actors under its control, and
    2. What properties it exports via the opaque composite actor in which it is placed.

    If a director’s exported properties match those assumed by another director, then it can be used within that other director. Otherwise, it cannot. If the SDF director exports properties that match those assumed by the PN director, then the SDF can be used inside PN. The properties in question can be formulated in terms of actor abstract semantics.

    Actor Abstract Semantics

    All models of computation in Kepler and Ptolemy II share a common abstraction that we call the actor abstract semantics.

    Actors and directors are instances of Java classes that implement the Executable interface, which defines action methods. The action methods include two distinct initialization methods:

    1. preinitialize(). invoked prior any static analysis performed on the workflow (such as static scheduling, type inference, checking for deadlock, etc.).
    2. initialize(). invoked to initialize an actor or director to its initial conditions. This is invoked after all static analysis has been performed, but it can also be invoked during execution to reinitialize an actor.

    The action methods also include three distinct execution methods that are invoked in sequence repeatedly during an execution of the workflow:

    3. prefire(): invoked to check whether an actor is ready to fire (for example, an actor may return false if there are not enough input data tokens).
    4. fire(). In this method, the actor should read input tokens from input ports and write tokens to output ports, but it should not change its state. That is, if the fire() method is invoked repeatedly with the same input tokens, then the resulting output tokens should be the same.
    5. postfire(). In this method, the actor can read input tokens and update its state.

    Finally, there is a finalization method:

    6. wrapup(). This method is invoked for each actor just prior to finishing execution of a workflow.

    All of the methods are required to be finite (they must eventually return).

    The method definitions specify a contract, but not all actors obey this contract. Any actor that strictly conforms to this contract is said to be domain polymorphic, and the actor may be used by any director that operates on actors (which is all the directors above except FSM, which operates on states).

    Actors that do not obey the contract are more specialized, and may only work with specific directors. They are not domain polymorphic (strictly obeying the actor abstract semantics) and come in two flavors. The first flavor obeys a looser version of the abstract semantics where the fire() method provides no assurance that the state of the actor is unchanged. The second is still looser in that it that also provides no assurance that any of these methods is finite.

    Based on these three levels of obeyance to actor abstract semantics, we can now classify the directors.

    Abstract semantics assumed by a director of the actors under its control

    The PN director only assumes the loosest of these abstract semantics. It does not require that any method be finite because it invokes all of these methods, in order, in a thread that belongs entirely to the actors. If an actor chooses to run forever in the preinitialize() method, that does not create any problems for the director. The director will happily let it run. Dataflow directors require that actors conform with the loose actor semantics, where all methods are finite. But they do not require that actors leave the state unchanged in the fire() method. CT requires that actors obey the strictest form of the semantics. The director iteratively fires actors until some condition is satisfied. The strict actor semantics ensures that the answers will always be the same given the same inputs. FSM requires loose actor semantics. A firing of an FSM in Ptolemy II consists of a firing of the refinement of the current state (if there is one), followed by evaluation of the guards and a state transition. Clearly, the firing of the refinement must be finite for this to be useful.

    Abstract semantics exported by a director via the actor in which it is placed

    A director also implements the Executable interface. If a director conforms to the strict actor semantics, then any opaque composite actor containing that director also conforms to the contract. Such a director can be used safely within opaque composite actors that use any of the directors. None ot the directors conforms to the strict actor semantics in the current version of Ptolemy II (version 6.0). The undiscussed SR director does however and in principle CT and DE can be made to conform. Currently these and the dataflow directors all conform to the looser version of the abstract semantics, but still guarantee that all methods return after finite time. PN only conforms to the loosest version, providing no guarantees about methods ever returning. The FSM director exports whatever the state refinements export.

    Director compatibility

    We classify directors according to two criteria. They require that the actors they control are either strict, looser, or loosest, depending on whether they must conform with the strictest, looser, or loosest form of abstract semantics. They similarly export either strict, looser, or loosest. Ideally, any director should export the same version of the contract it assumes or a stricter version, but this is not the case in currently.

    The current status of the directors is given in Table 1. The rule applied to determine director compatibility is that exported abstract semantics should be stricter or equal to required abstract semantics. The table is on-line (http://www.mygrid.org.uk/wiki/Papers/IccsPaper2007) and will evolve over time. Where available, the on-line version links each entry to example actors.

    Table 1. Rules for hierarchically mixing directors in Kepler and Ptolemy II

    Inner director
    (exports X)
    Outer director ↓
    (requires Y)
    PN SDF DDF CT DE SR FSM
    (loosest) (loose) (loose) (strict) (loose) (strict) (loose)
    PN (loosest) Yes No No No No No No
    SDF(loose) Yes Yes Yes No Yes No Yes
    DDF(loose) Yes Yes Yes No Yes No Yes
    CT (loose) No Yes Yes No Yes Yes Yes
    DE (loose) No Yes Yes Yes Yes No Yes
    SR (strict) Yes Yes Yes Yes Yes Yes Yes
    FSM (refinement) Yes if the refinement is stricter than or equal to Y

    Discussion of PN, Dataflow and FSM Directors

    A key question may arise at this point. If actors can be made domain polymorphic by conforming to the strict actor semantics, then why not design all directors to conform? In some cases, the semantics of the MoC precludes this. In other cases, it would simply be too costly. We examine some of these cases.

    PN. The PN director is apparently the least restrictive in the actors it can manage, but also the least useful in an opaque composite actor. The reason for this is very fundamental. If the PN director were to define a finite fire() method, what should that method do? Each of the actors under its control is executing in its own thread of control. How much execution should be performed? One possible answer is "as little as possible," but this would result in nondeterminate execution. If two actors have threads that are able to perform computation, which should be allowed to perform computation? The only other obvious answer is "as much as possible." This can be made determinate, but typical PN workflows can execute forever if given the opportunity. Hence, "as much as possible" turns out to be an infinite amount. Sometimes it is finite, in that a PN model may deadlock after a finite computation. However, PN is sufficiently expressive that determining whether a workflow deadlocks is equivalent to solving the famous halting problem in computation. Hence, whether a workflow deadlocks is undecidable [Buck 93].

    When a workflow has potential to be reused inside others, PN should be avoided and, if possible, replaced by a more reusable director.

    DDF. DDF is as expressive as PN, and hence potentially suffers from the same limitation. However, DDF has an advantage. It assumes that all actors under its control have finite firings. Thus, it is relatively easy for the designer of a workflow to specify how many firings of the component actors constitute a single firing of the enclosing opaque composite actor. The DDF director assumes a simple default if these numbers are not given by the workflow designer: one firing of a DDF opaque composite actor constitutes at most one firing of each component actor. The actor is fired if possible, and not fired if not, given the available input data. This yields a simple, finite, and determinate notion of a finite firing for the director to export.

    SDF. SDF is still simpler in that it is not as expressive as PN, and there is a simple unique finite firing that is natural and easy to define [Lee & Messerschmitt 87]. However, for both DDF and SDF, it is difficult to define a fire() of an opaque composite actor that does not update the state of the workflow because data values stored on buffers change during the firing of the component actors. In order for SDF and DDF to export the strict actor semantics, they would have to backtrack or restore the state of these buffers on repeated invocations of the fire() method. While this is doable in principle, it might be sufficiently computationally expensive that it is not worth it. A promising technique, however, that could make it computationally attractive is the lightweight backtracking mechanism developed in [Feng & Lee 06].

    FSM. A particularly interesting case is FSM and modal models. Modal models always use opaque composite actors as state refinements, and these must at a minimum have finite firings to be useful (given the semantics of an FSM in Ptolemy II discussed before). Hence, it does not make sense to use PN inside the refinement of a state. But any other of the directors described above can be used in a Modal Model.

    Expanded Domain Compatibility Graph

    Below is a table that lists heterogenous models by top level domain and second level domain.

    Click on the + or - to see examples that work and don't work.

    Note that not all combinations make semantic sense.

    Outer Director
    (requires Y)
        CSP Rendezvous PN CT DDF DE FSM Giotto GR PSDF SDF Continuous DE2 SR
        (loosest) (loosest) (loosest) (strict) (loose)4 (loose) (loose)   (loose)5 (loose) (loose) (strict) (strict) (strict)
    Inner Director
    (exports X)
    CSP (loosest)                            
    Rendezvous (loosest)                            
    PN (loosest)     PN/PN -     DE/PN -                
    DDF (loose) CSP/DDF   PN/DDF   DDF/DDF DE/DDF FSM/DDF ?   PSDF/DDF SDF/DDF +, +, +      
    CT (loose) CSP/CT Rendezvous/CT PN/CT CT/CT3 CT was removed between Ptolemy II 8.0 and 10.0. $PTII/ptolemy/domains/ct/test/auto/CTCompositeActor.xml +, $PTII/ptolemy/domains/ct/test/auto/CTCompositeActor2.xml +, $PTII/ptolemy/domains/ct/test/auto/CTCompositeActor3.xml +, $PTII/ptolemy/domains/ct/test/auto/CTCompositeActor4.xml +, $PTII/ptolemy/domains/ct/test/auto/CTCompositeActor5.xml + DDF/CT DE/CT $PTII/ptolemy/domains/ct/demo/CTInsideDE/CTInsideDE.xml +, $PTII/ptolemy/domains/ct/demo/SigmaDelta/SigmaDelta.xml +, $PTII/ptolemy/domains/ct/test/auto/CTInsideDESimplel.xml + FSM/CT ? GR/CT + PSDF/CT SDF/CT      
    SDF (loose) CSP/SDF + Rendezvous/SDF +, + PN/SDF +, - +, + CT/SDF $PTII/ptolemy/domains/ct/demo/CarTracking/CarTracking.xml + + DDF/SDF + DE/SDF + FSM/SDF ? GR/SDF + PSDF/SDF SDF/SDF +     SR/SDF +, -, -
    PSDF (loose) CSP/PSDF Rendezvous/PSDF PSDF/PSDF + CT/PSDF DDF/PSDF DE/PSDF FSM/PSDF ? GR/PSDF PN/PSDF + PSDF/PSDF     SR/PSDF
    DE (loose)     PN/DE< + CT/DE +, + DDF/SDF DE/DE + FSM/DE ? GR/DE PSDF/DE ?      
    FSM (refinement) CSP/FSM1 RendezvousCSP/FSM1 PN/FSM1 CT/FSM2 $PTII/ptolemy/domains/ct/demo/Switch/Switch.xml+ DDF/FSM1 DE/FSM1 + FSM/FSM ? GR/FSM PSDF/FSM1 SDF/FSM1 + Continuous/FSM1 + DE2/FSM1 SR/FSM1
    Giotto ? ? ? ? ? DE/Giotto + ? Giotto/Giotto + ? ? ? ? ? ?
    Continuous(strict) CSP/Continuous Rendezvous/Continuous PN/Continuous CT/Continuous DDF/Continuous DE/Continuous + FSM/Continuous + ? GR/Continuous PSDF/Continuous SDF/Continuous Continuous/Continuous + DE2/Continuous SR/Continuous
    DE2(strict)6 CSP/DE2 Rendezvous/DE2 PN/DE2 CT/DE2 DDF/DE2 DE/DE2 FSM/DE2 ? GR/DE2 PSDF/DE2 SDF/DE2 Continuous/DE2 DE2/DE2 SR/DE2
    GR(strict) CSP/GR Rendezvous/GR PN/GR CT/GR $PTII/ptolemy/domains/ct/demo/BouncingBall/BouncingBall.xml +, $PTII/ptolemy/domains/ct/demo/CartPendulum/CartPendulum.xml +, $PTII/ptolemy/domains/ct/demo/NewtonsCradle/NewtonsCradleAnimated.xml + DDF/GR + DE/GR + FSM/GR ? GR/GR PSDF/GR SDF/GR + Continuous/GR + DE2/GR SR/GR
    SR(strict) CSP/SR +, + Rendezvous/SR PN/SR +, +, -, - CT/SR DDF/SR DE/SR + FSM/SR ? GR/SR PSDF/SR SDF/SR +, +, - Continuous/SR DE2/SR SR/SR +
    1 iff FSM has no CSP, Rendezvous, or PN refinement
    2 iff FSM has continuous, DE2 or SR (all export strict)
    3 CT inside CT requires that the inner director be a CTEmbeddedDirector.
    4 DDF as an inner domain is exports loose if we annotate the graph.
    5 GR exports strict.
    Interestingly, GR doesn't require strict however. This is a twist. GR submodels never have output ports (except possibly to another GR model), and hence GR can do all its work in postfire().
    Note that this lack of output ports is not enforced, and so one could construct models that misuse GR and get unexpected results.
    GR requires loose, it probably does not make sense to have PN inside GR.
    6DE2 is a bug fix to DE

    The rules are

    Loose goes into Loose
    Loose goes inside Strict
    Strict goes inside Strict
    

    DE inside SDF

    A DE component inside an SDF model may not be that useful
  • SDF assumes that every actor consumes and produces a fixed number of tokens on each input and output port on each firing. For example, the DE VariableDelay doesn't do that.
  • - You can sometimes get away with it anyway because many actors (such as Scalar, AddSubtract, ...) just do nothing in the fire() method if there are no inputs. Thus, the SDF scheduler has no way of knowing that its assumptions were violated because no actor complains. (Internally, we refer to this as the "sneaky SDF trick". We do not advise using this feature.)
  • The Expression actor is more rigorous. Its prefire() method checks to see whether all inputs are present, and if they are not, then it returns false, indicating to the SDF scheduler that it is not ready to fire. The SDF scheduler now knows its assumptions were violated, so it complains. Thus, the "sneaky SDF trick" doesn't work with Expression.
  • VariableDelay will produce an output only if current time exactly matches the time of the output (after being delayed). If time passes the time of an output without firing VariableDelay, then VariableDelay will henceforth produce no output. If you have DE within SDF, then this can easily happen, since the SDF outer level will fire the DE submodel only at multiples of its period. Note that they have to exactly match... Since time is a double (sort of), quantization errors could become a problem.
  • Possible solutions:
    1. Stick with SDF inside SDF, don't use VariableDelay. You could get a similar effect to VariableDelay by explicitly modeling presence or absence using, for example, a boolean.
    2. Use DE at the top level. Some care would be needed to make sure that SDF subsystems that exepected to fire once per day are in fact provided with input tokens once per day (e.g., using PeriodicSampler).
    3. Use DE within SDF, but ensure that the DE model never needs to do anything except at multiples of the period. This solution is fragile because it will be vulnerable to quantization errors in the time variable.

    Last updated $Id$