On Jun 19, 2015, at 5:56 PM, Axel Kowald <[log in to unmask]> wrote:

> The manual (e.g. 4.2.1) seems to say that only once an instance of my model is created and then the repetitions are done inside a loop that repeatedly calls state.start() and state.finish().
> However, when I run my simulation it seems that in reality for each repetition a new instance is created (i.e. the constructor is called) that is run until the end !?

While the hand-coded versions of the top-level loop do indeed reuse the same SimState, this is not the case for doLoop.  There's a good reason for this: one of the things doLoop can do is run your N jobs in *parallel*, not just in serial.

> I would like to do multiple runs and collect information from each run, which are then analysed at the end. But if each time a new instance is created the variables that hold my data are reset...

In general there's no contract that the same SimState will be used over and over again.  But if you want to do this, I suggest you hand-code your top-level loop as shown in the manual (doLoop() is merely a convenience method). 

> I also noticed that the doLoop() never returns.
> Does this mean that the program is actually terminated (after the last repetition) inside the doLoop() ??

That's correct.  doLoop calls System.exit(0) and System.exit(1) depending on different situations.

> That also makes it impossible to perform calculations on collected data at the end of the simulation !?

Why?  Just collect, manipulate, and dump the data in your finish() method.