Rashi,

  Noone's mentioned this yet but, at a more general level, why do you want to retain the visualisations for batch runs of multiple model instances?

If you don't want to run them in parallel (i.e. you want sequential runs just set up automatically and with visualisations created/destroyed as you go along) then I guess you'd follow Ernesto's route (but you obviously lose the big performance gain of running in parallel). But that doesn't seem very useful since the visualisations will disappear as each run ends. (I guess if the run lengths are sufficiently long you still have a window to see what's going on....)

If you do want to run them in parallel you'd typically not have any visualisations (and I think there are issues anyway due to Java GUIs inherently being single-threaded animals).

Stuart

On 27 October 2015 at 11:50, Rashi Aswani <[log in to unmask]> wrote:
Hello,

I am sorry for not being clear earlier. I believe my question is a Mason related one. More specifically I want to run an experiment that will be repeated 100 times (each iteration has some randomly generated parameters). One obvious way is to run an iteration and then manually start the program. However this is time consuming, hence I am trying to automate the runs.  

In each iteration, there are multiple agents each modeled as thread in Mason. There is a display frame that gets created in each iteration which gets closed at the end of the iteration. In order to make it automated I am setting the display frame to null by using displayFrame.dispose() and then displayFrame = null after the run is completed so in the next iteration a new display frame comes up. However this is creating an issue since the old display frame was not getting killed. In order to make sure it gets killed correctly, I had to put in an arbitrary sleep so that all the threads are finished and then the frame is killed. However the sleep is leading to:
(a) Long run times (hours) once I set up more runs.
(b) As I am making the frame null, it is not freeing up the memory hence I get memory dump after some point. I also tried using unregisterFrame() and unregisterAllFrames() but none of these worked.

In short, I'm trying to find out,
(a)Is there a functionality in Mason that can detect when all the threads are done so we know when to close the display frame?
(b)Is there a way to close the display frame instead of specifically nullifying it?

Thanks,
Rashi

On Mon, Oct 12, 2015 at 11:09 PM, Eric 'Siggy' Scott <[log in to unmask]> wrote:

Rashi,

How to wait for threads until they complete is a general Java question, not a Mason question.  General multithreaded programming is out of the scope of this list.

Of course, perhaps I've misunderstood your question, and you are using something Mason-specific to control your threads.  In that case perhaps you could give us a little more detail about what you're doing and what you'd like to do.

Cheers,

Siggy



On Mon, Oct 12, 2015 at 11:18 AM, Rashi Aswani <[log in to unmask]> wrote:
Hello,

I'm using mason for a simulation having various threads and I'm trying to run the same simulation again with different parameter values. I'm currently using thread.sleep (to pause main thread) before creating one more simulation (in next iteration) so as provide enough time for existing simulation to run.
It would be great to know if there is any other way of handling threads, as the sleep increases runtime to a great extent.
Thanking you in advance.

Regards,
Rashi Aswani




--

Ph.D student in Computer Science, George Mason University
CFO and Web Director, Journal of Mason Graduate Research




--
________________________________
Stuart Rossiter
[log in to unmask]