Discord
@hash/des
Behavior
3
0
Public

Discrete Event Library

This Library allows you to incorporate Discrete Event-style logic into your simulations. Discrete Event simulations operate by specifying when certain events should occur.

This Library allows you to incorporate Discrete Event-style logic into your simulations. Discrete Event simulations operate by specifying when certain events should occur. You can read more about DES in the HASH wiki.

Discrete Event Triggers

The behaviors in this library are all used to generate "triggers", messages that go out to a set of agents notifying them of an event. These behaviors will use certain criteria to decide if they should be triggered, based on the behavior and the given parameters.

When a behavior is triggered, one or more messages will be sent notifying other agents that an event has been triggered.

Schedule-based

The /@hash/des/scheduler.js behavior will trigger events at certain set times based on a csv dataset. This dataset must have the following format in every row: , <agent_name> or <agent_id>, .

Here are is an example dataset:

1, manager, meeting
4, employee, lunch
10, manager, stop
10, employee, stop

The agent will also need to have certain parameters set:

"schedule": { 
  "dataset": string, // name of the schedule dataset
  "timer": string, // the field on the agent storing the reference time
}

Message-based

The @hash/des/message_trigger.js behavior triggers when enough messages of a certain type have been received. On triggering, an event message is sent. The parameters for these triggers must be stored on an agent's "message_triggers" field, and be formatted as an array of objects. If the type is "cumulative" it will gather messages and trigger once enough have been collected. If "single" then it must receive enough messages a single step of the simulation:

"message_triggers": [
  {
    "type": "cumulative" or "single_step",
    "message_type": string, // the type of message to count for the trigger
    "received": [], only required for "cumulative" type
    "timer": string, // the time field on the agent to increment
    "messages_needed": number, // number of messages needed to trigger
    "triggered_message": { // formatted as a standard HASH message
      "to": [],
      "type": string,
      "data": {}
    }
  }
  ...
]

Neighbor-based

In @hash/des/neighbor_trigger.js the triggers operate very similarly to message-based triggers, but instead of counting the number of specific messages received, this behavior will count the number of visible agents whose particular field matches a certain value.

The parameters for these triggers must be stored on an agent's "neighbor_triggers" field, and be formatted similarly to message triggers:

"neighbor_triggers": [
  {
    "type": "cumulative" or "single_step",
    "field": string, // the field to match on neighbors
    "value": // the value of the field to match
    "received": [], // only required for "cumulative" type
    "timer": string, // the time field on the agent to increment
    "neighbors_needed": number, // number of agents needed to trigger
    "triggered_message": { // formatted as a standard HASH message
      "to": [],
      "type": string,
      "data": {}
    }
  }
  ...
]