decent_bench.network#

class decent_bench.network.Network(graph: Graph, noise_scheme: NoiseScheme, compression_scheme: CompressionScheme, drop_scheme: DropScheme)[source]#

Bases: object

Network of agents that communicate by sending and receiving messages.

Parameters:
  • graph – topology defining how the agents are connected

  • noise_scheme – message noise setting

  • compression_scheme – message compression setting

  • drop_scheme – message drops setting

property metropolis_weights: ndarray[tuple[Any, ...], dtype[float64]][source]#

Symmetric, doubly stochastic matrix for consensus weights.

Use metropolis_weights[i, j] or metropolis_weights[i.id, j.id] to get the weight between agent i and j.

get_all_agents() list[Agent][source]#

Get all agents in the network.

get_neighbors(agent: Agent) list[Agent][source]#

Get all neighbors of an agent.

get_active_agents(iteration: int) list[Agent][source]#

Get all active agents.

Whether an Agent is active or not at a given time is defined by its AgentActivationScheme.

send(sender: Agent, receiver: Agent, msg: ndarray[tuple[Any, ...], dtype[float64]]) None[source]#

Send message to a neighbor.

The message may be compressed, distorted by noise, and/or dropped depending on the network’s CompressionScheme, NoiseScheme, and DropScheme.

The message will stay in-flight until it is received or replaced by a newer message from the same sender to the same receiver. After being received or replaced, the message is destroyed.

broadcast(sender: Agent, msg: ndarray[tuple[Any, ...], dtype[float64]]) None[source]#

Send message to all neighbors.

The message may be compressed, distorted by noise, and/or dropped depending on the network’s CompressionScheme, NoiseScheme, and DropScheme.

The message will stay in-flight until it is received or replaced by a newer message from the same sender to the same receiver. After being received or replaced, the message is destroyed.

receive(receiver: Agent, sender: Agent) None[source]#

Receive message from a neighbor.

Received messages are stored in Agent.received_messages.

receive_all(receiver: Agent) None[source]#

Receive messages from all neighbors.

Received messages are stored in Agent.received_messages.

decent_bench.network.create_distributed_network(problem: BenchmarkProblem) Network[source]#

Create a distributed network - a network with peer-to-peer communication only, no coordinator.

Raises:

ValueError – if there are less agent activation schemes or cost functions than agents