Last updated on 16th July 2024
The Simudyne SDK adopts the Pregel approach to graph processing. This means that all computation is driven by messages. At every action
in the sequence
, every agent will process its action only if it has received a message.
In addition to this, Pregel adopts a pure message passing model that eliminates the need of shared memory and remote read, so all sharing of information between agents is done by message passing.
All messages sent must extend Message. There are a number of ways in which you may do so, each suitable for different scenarios.
For messages that have no value one can extend Message.Empty
. This is useful if your message type alone is sufficient to convey the required semantics.
For messages that contain only a single primitive value, the Simudyne SDK provides Integer
, Long
, Float
, Double
, and Boolean
message classes that can be extended. They all provide a getBody()
method that returns the primitive value. Use this whenever you need to send only one field.
For messages that require sending complex data types extend Message.Object<T>
. This will allow you to send a message who's body is the object. It also allows the receiver access to methods on the object.
If your message needs to send an arbitrary amount of data, but no explicit type exists, consider extending Message.
For organising custom message classes, see Message Organisation.
Registering messages
(Java)
public class MyClass extends AgentBasedModel<GlobalState> {
...
registerMessageTypes(Boolean.class, Messages.Vacancy.class);
...
}
There are other lower level ways of manipulating messages and action sequencing - please refer to System Messages