top of page

Dynamic vs static property in block

Updated: Feb 27, 2023

Have you wasted hours trying to solve an unexpected behavior when using a Process Modeling Library block? Do you know what is the difference between a dynamic and static property? Let's take a closer look at an example with the Delay block.

Lets say we have a small process where agents go through a delay, and wait either in the blue square or the red square, randomly:

You would expect for the agents to randomly appear in both squares, but when you run the simulation this happens:

This is because, unlike the "Delay time" property, the "Agent location" property is a static property

  • Dynamic property - performed/calculated whenever an agent enters the block

  • Static property - performed/calculated when the block is created, usually at model start-up

In our example above, the red square was selected randomly at model start-up and this decision/calculation remains true throughout the simulation.

How do we know which properties are dynamic or static?

This information is provided on the help section of each block - usually dynamic properties are highlighted - but an easier way is to hover over the small arrow/icon next to the property name and it will display the type (grayed out text)

How do overcome this feature?

For all static properties, there is a "set" method available, in this case, we have set_entityLocation() which allows us to change the value set when the block was created.

In this specific example calling this method when an agent enters the block will also change the location of previously entered agents, you will see all agents that are waiting in a square jump to the other square when a new agent enters the block.

Be aware of using these in-built "set" methods for static parameters, it might result in unexpected behavior like this example.

An actual solution for this specific example is for each agent to handle his location and not relying on the Delay block to do it.

You can download the example with the correct solution here:

Download ZIP • 5KB

Or you can play and download the model from the AnyLogic Cloud here

What next?

If you liked this post, you are welcome to read more posts by following the links above to similar posts. Why not subscribe to our blog or follow us on any of the social media accounts for future updates. The links are in the Menu bar at the top of the footer at the bottom.

If you really want to make a difference in supporting us please consider joining our Patreon community here

If you want to contact us for some advice, maybe a potential partnership or project or just to say "Hi!", feel free to get in touch here and we will get back to you soon!

304 views0 comments


Post: Blog2_Post
bottom of page