|
From: Tatara, E. R. <ta...@an...> - 2009-07-07 22:52:47
|
OK makes sense. You can't run multiple simulations in the same JVM
since the RunEnvironment and RunState use static singletons. I'll
consult with the other developers to see if there is a straigtforward
solution.
eric
Eric Tatara, Ph.D.
Assistant Software Engineer
Center for Complex Adaptive Agent Systems Simulation
Decision and Information Sciences Division
Argonne National Laboratory
________________________________
From: Bojan Lovric [mailto:Boj...@un...]
Sent: Friday, July 03, 2009 12:38 AM
To: Tatara, Eric R.; rep...@li...
Subject: RE: [Repast-interest] Multiple Simphony Runs
Hi Eric
Yes, I was attempting to run multiple instances in same JVM.
This was attempted by creating an instance (runner) of RepastRunner
extends AbstractRunner which is almost identical to TestRunner_2 class
discussed within this forum at the beginning January 2008, and November
2008.
Initially I created many of these instances and tried performing
runner.step(); method on each separate instance (this is the part that
does not work )
I also had trouble implementing a play button, which I eventually
achieved by iteration of runner.step() method. Is there a more
sophisticated way of doing this ?
As I was unable to run multiple instances of Simphony in parallel within
same JVM (this would be nice ... ?) I decided to do this sequentially.
In this case I initialise only one instance, run it to the end and then
I reset, reinitialise, and run again for as many times as desired.
Finally when all iterations (loops) are completed I end the entire
Simulation. This code can be seen below:
************************************************************************
************************************************
RepastRunner runner = new RepastRunner();
while (running) {
if (!GeneticAlgorithmCoordinator.loopCompleted) {
runner.step();
tickCountFiled.setText(""+runner.getSimphonyTickCount());
}
else{
iterationField.setText((String.valueOf(GeneticAlgorithmCoordinator.loopC
ount+1)));
if (GeneticAlgorithmCoordinator.simulationCompleted){
TextDisplay.getInstance().render();
new SummaryReportDisplay();
TextDisplay.getInstance().endIteration();
RunEnvironment.getInstance().endRun();
hide();
running = false;
}
else{
runner.stop();
runner.cleanUpRun();
try{
runner.load(file);
}catch (Exception e){
e.printStackTrace();
}
runner.runInitialize();
GeneticAlgorithmCoordinator.loopCompleted = false;
}
}
}
************************************************************************
************************************************
Thanks
Bojan
From: Tatara, Eric R. [mailto:ta...@an...]
Sent: Friday, 3 July 2009 4:39 AM
To: Bojan Lovric; rep...@li...
Subject: RE: [Repast-interest] Multiple Simphony Runs
How are you running multiple instances? If more than one in the same
JVM it might be problematic.
eric
Eric Tatara, Ph.D.
Assistant Software Engineer
Center for Complex Adaptive Agent Systems Simulation
Decision and Information Sciences Division
Argonne National Laboratory
________________________________
From: Bojan Lovric [mailto:Boj...@un...]
Sent: Friday, June 19, 2009 2:12 AM
To: rep...@li...
Subject: [Repast-interest] Multiple Simphony Runs
Hi
I am trying to run multiple instances of Simphony 1.2 with partial
success.
In my current example I try to run 5 instances and only the last one
seems to be working, and first four return tick count of -1. This might
indicate that there is no actions scheduled, however this is not the
case.
I check for actions scheduled with following code:
System.out.println("Checking Status at "+
GetTickCount());
System.out.println("Actions: "+runner.getActionCount());
System.out.println("Actions: "+runner.getModelActionCount());
System.out.println(runner.getNextScheduledTime());
Here is my output for each Simphony instance:
1st:
Checking Status at -1.0
Actions: 7
Actions: 3
0.0
2nd:
Checking Status at -1.0
Actions: 7
Actions: 3
0.0
3rd:
Checking Status at -1.0
Actions: 7
Actions: 3
0.0
4th:
Checking Status at -1.0
Actions: 7
Actions: 3
0.0
5th: (working)
Checking Status at 0.0
Checking Status at 0.0
Checking Status at 0.0
Checking Status at 0.0
Actions: 12
Actions: 8
1.0
Checking Status at 1.0
Checking Status at 1.0
Checking Status at 1.0
Checking Status at 1.0
Checking Status at 1.0
Actions: 12
Actions: 8
1.083
I just can not figure this one out. Any suggestions are welcome.
Thanks
Bojan
|