InterDyne Topology & Delays
When considering dynamical interaction between system components, we may wish to (i) define in advance the topology of legal interactions, and (ii) define the interaction delay that should be applied to such legal interactions (noting that delays may be asymmetric - i.e. that the delay from component A to component B may not be the same as the delay from B to A). InterDyne does not require the topology and delays to be defined, but provides support for such definition (from version 0.24 onwards).
To define topology and delays, two runtime arguments must be passed to the "sim" function (both arguments must be present): first, a function that takes two agent IDs (integers that uniquely specify the start point and end point of an interaction) and returns an integer delay in timesteps; and second, the maximum delay in the system. From InterDyne version 0.25 the delay function argument uses the data constructor DelayArg and the identifying string "DelayArg" and for backwards compatibility the maximum delay is a Double but should represent a whole number of time steps.
The experimenter has complete freedom to define the delay function, and if the interaction specified by the two agent IDs is illegal then the delay function should raise an error. Here is a very simple example for three agents:
import Simulations.RuntimeArgFunctions as RTAFuns
exampleExperiment :: IO ()
sim 60 myargs (map snd myagents)
myargs = [ convert,
(Arg (Str "maxDelay", maxDelay)),
(DelayArg (Str "DelayArg", delay)) ]
myagents = [ ("Trader", (traderWrapper, )),
("Broker", (brokerWrapper, )),
convert = RTAFuns.generateAgentBimapArg myagents
delay 1 2 = 1
delay 1 x = error "illegal interaction"
delay 2 x = 2
delay 3 2 = 3
delay 3 x = error "illegal interaction"
maxDelay = fromIntegral 3
InterDyne experimenters often find it convenient to drive the delay function from an adjacency matrix. After setting the delays as shown above, the experimenter need do no more; one-to-one messages are automatically delayed by the stated number of timesteps, and broadcast messages are split into separate messages for each recipient and delayed by the amount stated for each link.