Skip to main content

Participant

Trait Participant 

Source
pub trait Participant: Sized {
    type Message;

    // Required methods
    fn id(&self) -> AgentId;
    fn bundle(&self) -> &Bundle<TaskId>;
    fn act(&mut self, now: u64, outbox: &mut Vec<Self::Message>);
    fn receive(
        &mut self,
        now: u64,
        message: &Self::Message,
        outbox: &mut Vec<Self::Message>,
    ) -> bool;
    fn message_bytes(message: &Self::Message) -> u64;
    fn is_settled(team: &[Self], in_flight: &[&Self::Message]) -> bool;
}
Expand description

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

cbba::Agent implements it; so can other consensus protocols.

Required Associated Types§

Source

type Message

What the agent broadcasts.

Required Methods§

Source

fn id(&self) -> AgentId

The agent’s identifier.

Source

fn bundle(&self) -> &Bundle<TaskId>

The tasks the agent holds now.

Source

fn act(&mut self, now: u64, outbox: &mut Vec<Self::Message>)

One round of the agent’s own work at tick now, such as its bundle phase; pushes what it broadcasts onto outbox.

Source

fn receive( &mut self, now: u64, message: &Self::Message, outbox: &mut Vec<Self::Message>, ) -> bool

Handles message, arriving at tick now; pushes what the agent broadcasts in response onto outbox. Returns whether the agent’s winners, bids or bundle changed, for Stats::useful.

Source

fn message_bytes(message: &Self::Message) -> u64

The size of message on the wire, in bytes, for Stats::bytes.

The protocols in this crate use a nominal encoding without compression: 4 bytes per agent or task identifier (an absent winner takes a reserved value), 8 per bid, timestamp or clock, 1 per tag, and a 4-byte length before every list.

Source

fn is_settled(team: &[Self], in_flight: &[&Self::Message]) -> bool

Whether team has settled, with in_flight still on its way: the agents agree on a conflict-free assignment that nothing in flight and no further round can change.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<R: Route> Participant for TimedAgent<R>

Source§

impl<V: Valuation<TaskId>> Participant for task_allocation::acbba::Agent<V>

Source§

impl<V: Valuation<TaskId>> Participant for task_allocation::bwtc::Agent<V>

Source§

impl<V: Valuation<TaskId>> Participant for task_allocation::ccbba::Agent<V>

Source§

impl<V: Valuation<TaskId>> Participant for task_allocation::cbba::Agent<V>