I found this answer helpful. I have one follow-up question: You said that you use MoMLParser.parse(String) to open multiple instances. Does using teh MoMLParser.parse(URL) version of that method NOT open multiple instances?

Brian Hudson wrote:

    Do I remember correctly that Ptolemy does not in any way support
    Java concurrency or multi-threading?


This depends on your domain really. PN for example uses quite a bit of threading.

    If so, then I would assume that one couldn't safely run 2 models
    in one JVM, even if each had its own instances of
    TypedCompositeActor, Manager, Director, etc.  If one wanted
    concurrency, one would run separate JVM's, each with one model
    that would have no contact with any other model.  Right?


You can safely run multiple models in one JVM. You just need to make sure that you have two instances of the model in memory. We do this by using the MoMLParser.parser(String) to open multiple instances of the same model.

    If (in one JVM) I had a program running that wanted to run several
    models (similar to each other), one after the other, how much
    reuse of Ptolemy instances makes sense?  Would you recommend
    nulling all references after each model run, and instantiating all
    Ptolemy objects fresh?  Or would it make any sense to reuse the
    same TypedCompositeActor, Manager, Director, etc?


We do this as well. We have some code that "injects" some actors into a model before me run it, and we modify several parameters. When the execution has completed we remove these "injected" actors and reset the parameters. When running sequential runs on the same model we reuse everything.

    Does Ptolemy have a way to scrub all actors out of a model,
    allowing the creation of new ones?


We create all of our "injected" actors in their own composite at the top level. That we when we want to delete them we can simply delete that one CompositeEntity.

Brian

On Fri, Jul 25, 2008 at 12:27 PM, Richard Ware <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    1) Do I remember correctly that Ptolemy does not in any way support
    Java concurrency or multi-threading?  If so, then I would assume
    that one
    couldn't safely run 2 models in one JVM, even if each had its own
    instances of TypedCompositeActor, Manager, Director, etc.  If one
    wanted concurrency, one would run separate JVM's, each with one
    model that would have no contact with any other model.  Right?

    2)  If (in one JVM) I had a program running that wanted to run
    several models (similar to each other), one after the other, how
    much reuse
    of Ptolemy instances makes sense?  Would you recommend nulling
    all references after each model run, and instantiating all Ptolemy
    objects
    fresh?  Or would it make any sense to reuse the same
    TypedCompositeActor, Manager, Director, etc?  Regardless of
    which approach I use, I plan to delete all actors from the first
    model run
    and create all actors for the second run fresh, for reasons
    involving the
    nature of my simulation.  Does Ptolemy have a way to scrub all actors
    out of a model, allowing the creation of new ones?

     I look forward to your clarifications.

       Richard Ware





    ----------------------------------------------------------------------------
    Posted to the ptolemy-hackers mailing list.  Please send
    administrative
    mail for this list to:
    [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>


Reply via email to