# Hierarchical model support¶

Author: Lukas Breitwieser
Some models require to update certain agents before others. In this tutorial we show how to execute operations first for large agents and afterwards for small ones. Lastly, we demonstrate how to run a different set of operations for large and for small agents.

Let's start by setting up BioDynaMo notebooks.

To make this demo easier to understand, we turn off multi-threading and load balancing.

We create a new agent operation which prints out its name and the diameter of the agent it is processing

We create four agents with diameter {20, 10, 20, 10}

We add the new operation to the simulation

Let's simulate one time step and observe the default behavior of BioDynaMo. We expect that the agents are processed in the order they were added ({20, 10, 20, 10})

Now we want to define the group of large and small agents and tell BioDynaMo that large agents should be processed before small ones.

This can be done with the following three lines of code.

Let's observe if the output has changed. We expect to see first the large agents {20, 20}, followed by the small ones {10, 10}.

Let's create two more instances of our TestOp. We define that:

• op1 should be run for all agents (large and small).
• op2 only for small agents
• op3 only for large agents

Now we want to execute another time step with the updated model. We expect that for each agent two operations will be executed.

For large agents OpAll and OpOnlyLarge and for small agents OpAll and OpOnlySmall. As before, we expect that first all large agents are executed, followed by all small agents.