Randomize iteration order

Author: Lukas Breitwieser
In this tutorial we show how to randomize the order that BioDynaMo uses in each iteration to process the agents.

Let's start by setting up BioDynaMo notebooks.

Let's create two helper functions:

We define an experiment which

  1. takes a simulation object as input
  2. adds four agents
  3. calls print_uid for each agent
  4. print a seperator so we can distinguish the output of the two different time steps
  5. advances to the next time step
  6. calls print_uid for each agent again

The default behavior of BioDynaMo is to iterate over the agents in the order they were added (not taking multi-threading and load balancing into account). Therefore, we expect to see the same order twice.

BioDynaMo also provides a wrapper called RandomizedRm, which, as the name suggests, randomizes the iteration order after each iteration. It just takes two lines to add this functionality to the simulation.

Let's run our experiment again. This time with the simulation which has a randomized resource manager. We expect two different orders.