-
Notifications
You must be signed in to change notification settings - Fork 181
faq 310738953
by Johan W. Joubert on 2018-08-20 08:11:37
I want to run multiple MATSim instances simultaneously, in parallel. Say, for example, five equil instances. Each is instantiated in the same Java Virtual Machine, but with different random seeds (set via the Config
).
I'm getting quite odd behaviour and would like to understand why. I expected to get repeatable results over different runs, but I don't. Even though the random seeds are set programatically, the output differs from one run (five equil instances) to the next (another five equil instances).
We tried to ensure the Scenario
and Controler
is private within the java.util.concurrent.Callable
class, but to no avail. I guess it is because of how the MatsimRandom
object is created/instantiated... but I'm speculating, and don't understand much about the on-the-fly instantiation of abstract classes. Any advice please?
by Kai Nagel on 2018-08-20 08:42:19
MatsimRandom
is global static, meaning inside the same JVM all would use the same instance. Then, presumably, they would have race conditions in drawing the random numbers. So the sequence of random numbers would be the same, but which of your five instances gets which subset would be undetermined.
You will have to start them in five separate JVMs. Sorry ...
(One could think about moving this from global static to guice. Looks like a major effort, with unclear benefits. Also, for your use case, one would also need an API change, where the RNG seed can be set deterministically based on the ID of the instance.)
You are viewing an archive of the previous MATSim Q&A site. The real site is now at https://matsim.org/faq