0

I have a robot simulation to run many times in order to collect statistics. In particular, I want to run the simulation with 1,2,...,10 robots, and each of them must be run 30 times, so I thought to pass the desired number of robots via the main args.

Since the simulation is very memory-intensive, I want to run them sequentially, one after another(otherwise OutOfMemory Exception is very likely). I am working in Java/Eclipse, and under run configurations one can specify arguments to be passed to the program as if it was called by the shell, but I haven't found any way to automate the process.

In short, what I would like to do is the following:

for i=1 to 10:
  for j=1 to 30:
    run simulation_instance(i)

Each run of the program has to be independent. I have tried using the Launch Group Option, but it is way too less configurable.

Are you aware of any other alternative?

Community
  • 1
  • 1
smellyarmpits
  • 1,080
  • 3
  • 13
  • 32
  • 1
    Start your java program from the commandline not from within ecpilse. – Micha Wiedenmann Oct 15 '15 at 07:30
  • Welcome to StackOverflow. While it is possible to ask a questions on StackOverflow, which is only relevant to you, it is often considered bad practice. Instead it is better to remove all your specific detail and ask a generic question, like: "How can I start my Java program multiple times from within eclipse?" (You might also take a look at: http://stackoverflow.com/help/how-to-ask.) – Micha Wiedenmann Oct 15 '15 at 07:35
  • Have you considered writing a new class that uses ProcessBuilder or if you're on an older Java version Runtime.exec? Java.http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html – Sammy Oct 15 '15 at 07:45

1 Answers1

1

There is* a way in Eclipse, using Eclipse EASE. It is very new and still in incubation. But it allows you to do exactly what you describe.

The basic steps are install Eclipse EASE and then write some javascript that looks a little like:

// load the Launch module
loadModule("/System/Launch")

// some logic for loops/etc
for (i = 0; i < 30; i++) { 
    l = launch("name of launch configuration")    
    while (!prepare.isTerminated()) {
        // do something to wait like java.lang.Thread.sleep(1)
    }
}

* As of Oct 2015, EASE is currently in incubation, and until the next release to get access to the new launch module, you need to get EASE from git.

For more details see:

Jonah Graham
  • 7,890
  • 23
  • 55