Re: Multiple models, serially or concurrently
At 10:50 AM 7/25/2008, Paul Allen wrote: 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? No... In almost any application, if you open a file that you already have open, you just see the same instance of the file. In a text editor, for example, you don't get a new window with a new copy of the file. Same for a word processor or an IDE. If you did get a new window, then things would get very confusing. You could make a change in one copy, save it, then make a change in the other copy, save it. The first change will have been obliterated. Thus, it is generally a bug in a tool opens multiple copies of the same file as separate instances. Edward 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 mailto:[EMAIL PROTECTED][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: mailto:[EMAIL PROTECTED][EMAIL PROTECTED] Edward A. Lee Robert S. Pepper Distinguished Professor EECS Dept., 545Q Cory Hall, UC Berkeley, Berkeley, CA 94720-1770 phone: 510-643-3728, fax: 510-642-5745 [EMAIL PROTECTED], http://www.eecs.berkeley.edu/Faculty/Homepages/lee.html Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Multiple models, serially or concurrently
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] 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]
Re: Multiple models, serially or concurrently
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]