MaDKit forum

Welcome All !
Please, use explicit topic names when creating new threads. Thanks.

You are not logged in.

#1 2016-06-28 16:48:03

ximog
Member
Registered: 2016-05-02
Posts: 4

Run several simulations in parallel

Hello,
I am simulating a society of agents which perform several tasks in a space.

My idea potentially is to generate a lot of different scenarios at the same time and extract statistical information about how these agents behave in these scenarios.

As I am not an expert in java, and I have been working with TurtleKit for less than two months, I do not know if it is possible to build several simulations in parallel and how to do it in MadKit/turtleKit.

Furthermore, how could I do to run one simulation after another without having to rerun again everytime the simulation finishes?

Thank you very much,

XG.

Offline

#2 2016-06-29 09:21:55

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 176
Website

Re: Run several simulations in parallel

Hello,

ximog wrote:

I do not know if it is possible to build several simulations in parallel and how to do it in MadKit/turtleKit.

It is, that is to say that you can, within a regular main method of a dedicated class, launch several instances of TurtleKit with different options (no overlap normally). Still it could be easier and probably as fast to launch them in sequentially.

ximog wrote:

Furthermore, how could I do to run one simulation after another without having to rerun again everytime the simulation finishes?

I personally use shell script (which could be easily adapted to windows). Here is one example:

rm $1
touch $1
date >> $1
echo "phero nb = $3 ..... Simulation duration = $2"
echo "envSize;totalTime;agentsComputationTime;envComputationTime;percentage;nbAgents" >> $1
for i in 30 70 100 120
do
	echo "" >> $1
	echo  "---------$i%" >> $1
	echo $i
	for size in 600 
	do 
		for nbIteration in $(seq 3)
		do
			java -Xmx12G -Xms4G -cp bin:lib/turtlekit-3.0.0.4.jar bench.phero.RandBenchTurtle $size $i --csv.file $1 $2
			sleep 4
		done
	echo "" >> $1
	done
done
date >> $1

$1 is the name of the current csv file.
This name is known at runtime using

String csvFile = getMadkitProperty("cvs.file");

Other $ are arguments which are passed to main method of a Turtle :

	
                public static void main(String[] args) {
		float percentage = Float.parseFloat(args[1])/100;
		int size = Integer.parseInt(args[0]);
		int nbAgents = (int) ((float) size * size * percentage);
		executeThisTurtle(nbAgents
				,Option.envDimension.toString(),args[0]+","+size
				,args[2]
				,"--cvs.file",args[4]
				,Option.startSimu.toString()
				,Option.endTime.toString(),args[5]
				,Option.scheduler.toString(),BenchScheduler.class.getName()
				,Option.viewers.toString(),"null"
				);

There are many other ways (using @Test series witgh Junit, using a Java program instead of a script, etc.).

Hope this help.

Fabien

Offline

#3 2016-07-13 16:16:34

ximog
Member
Registered: 2016-05-02
Posts: 4

Re: Run several simulations in parallel

Thank you very much Fabien, it was really useful.

Offline

Board footer