Message Handling Speed: #messages vs #data points

Which approach would result in faster simulation speed?

  1. An agent sending a single data point per message to an agent (e.g. 5 data points = 5 messages)

versus

  1. An agent sending all data points in a single message to an agent (e.g. 5 data points = 1 message)

Would there be a difference between hCore or hCloud?

Is there any impact on memory and hence speed for when an agent is pushing 100 variables?

Hi @lemontea,

Sending a message generally has some small overhead, because each message also needs to store the type of the message and the recipient, so sending one message with multiple data points should result in a faster simulation speed and less memory usage. This applies to hCore and hCloud.


I’m not quite sure I understand your second question. By pushing, do you mean adding hundreds of variables to different agent state variables? Or do you mean pushing values to an array in one variable? Or, maybe, sending hundreds of variables within an object inside of a message?

In any case, the obvious answer is that more data will result in higher memory usage and hence slower speed. For storing variables on an agent, the same as in the first answer applies: Each variable needs additional data to be stored (type, is it nullable, etc.), so putting everything in one array is faster and less memory-consuming. In case you know the size of the array beforehand you should use a fixed-size list for the smallest possible footprint we provide.

Hopefully, I could have answered your questions :slightly_smiling_face:

By pushing I meant exceeding in general for a given agent (not via messages) but yes the detailed explanation provides more insight and is helpful.

Currently variables are declared per agent via an initialize behavior inside the creator agent much like that in the Oil Supply Chain simulation. Could you provide a simulation example where all the variables inside an agent are placed inside an array?

Could you provide a simulation example where all the variables inside an agent are placed inside an array?

I think my answer could have been misunderstood. It’s not possible to store variables with different types in one array (one array only has one inner type), I only was not sure what you exactly meant by the second question. :slightly_smiling_face:

EDIT: Small correction, it is possible to add different types to one array using the any type, but this is expected to be slower than using concrete datatypes. Using the any datatype for something like this is not recommended, the type exists mainly for when you don’t know what datatype is needed.


initialize behavior inside the creator agent

Please note, that creator behaviors are deprecated:

Creator behaviors were commonly used in HASH before the introduction of programmable initial state. We recommend using programmable inital state and the init package of the HASH Standard Library instead of creator behaviors for 99% of use cases.

and you should use Programmable Initalization instead (Actually, the init package is available for a while now but I updated the documentation just yesterday).