Skip to main content

Module sim

Module sim 

Source
Expand description

A deterministic simulated network for running teams of agents: seeded delays, losses, topologies and partitions.

A Simulation runs any Participant, such as a cbba::Agent. Each Simulation::step is one tick:

flowchart LR
    deliver[deliver due messages] --> round[every agent's round]
    round --> broadcast[broadcast every outbox]
    broadcast --> deliver

Agents may also answer a delivered message right away; those answers go out with the tick’s broadcasts. A broadcast reaches every agent the sender has a link to in the Topology and is not cut off from by an active Partition; others hear of it only when it is relayed. Each copy is lost with probability Network::loss_per_mille / 1000, and otherwise arrives after 1 to 1 + max_delay ticks, so messages overtake each other. Agents process the messages that arrive in a tick in arrival order. Everything random comes from Network::seed: the same seed gives the same run.

When a team is settled is up to the protocol (Participant::is_settled). For CBBA, every agent believes in the same winners, every agent’s bundle holds exactly the tasks it wins, no bundle phase would change anything, and every message still in flight carries those same winners. Nothing can change after that.

Structs§

Network
How the simulated network behaves.
Partition
A time interval in which agents in different groups cannot reach each other.
Simulation
A team of agents on a simulated network.
Stats
Message counts over a run.

Enums§

Topology
Which pairs of agents can exchange messages directly. Agents without a direct link only hear of each other through relays.

Traits§

Participant
An agent that a Simulation can run: it works in rounds, broadcasts messages, and handles the messages that reach it.