FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable > Class Template Reference

This distributed leader election protocol chooses a leader agent as the one with highest unique ID. More...

Inheritance diagram for frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >:

Classes

class  MessageLEoutput
 Message class used for the output of the protocol. More...

Public Member Functions

Collection< MessageTypegetMsgTypes ()
void setQueue (Queue queue)
 LeaderElectionMaxID (String comID, T myID, Collection< String > neighbors, int nbrSteps)
 Constructor.
 LeaderElectionMaxID (DCOPProblemInterface<?, ?> problem, Element params)
 Constructor.
void notifyIn (Message msg)
 The actual algorithm.
Public Member Functions inherited from frodo2.communication.IncomingMsgPolicyInterface< T >
default void notifyIn (Message msg, Object toAgent)
 Notifies the listener of an incoming message.

Static Public Attributes

static MessageType START_MSG_TYPE = new MessageType ("VarOrdering", "LeaderElectionMaxID", "Start")
 The type of the message used to tell the protocol to start.
static final MessageType LE_MSG_TYPE = new MessageType ("VarOrdering", "LeaderElectionMaxID", "ELECT")
 The type of the messages used to carry agent IDs.
static final MessageType OUTPUT_MSG_TYPE = new MessageType ("VarOrdering", "LeaderElectionMaxID", "Output")
 The type of the output message.

Protected Member Functions

getMaxID ()

Protected Attributes

myID
 This agent's ID.
maxID
 Current computed maximum ID.
int stepCountdown = 0
 Index of the current step in the protocol, decremented until it reaches 0.

Private Attributes

MaxIDmsg< T > lastSentMsg
 The last MaxIDmsg sent.
final int nbrNeighbors
 The number of neighbors of the agent.
HashSet< String > thisStepSenders
 IDs of the agents from which we have received messages since the beginning of the current step.
HashMap< String, T > nextStepIDs = new HashMap<String, T> ()
 Messages belonging to the next step that have already been received.
Queue queue
 The queue on which it should call sendMessage().
final String comID
 Communication ID.
Collection< String > neighbors
 The neighbors of this agent.
boolean started = false
 Whether this agent has already received the message that tells it to start the protocol.
final AgentScoringHeuristic< T > heuristic
 The heuristic.

Detailed Description

This distributed leader election protocol chooses a leader agent as the one with highest unique ID.

Author
Thomas Leaute
Parameters
<T>the type used for agent IDs
Warning
This protocol elects an agent, not a variable. Therefore, we should assume that all agents own non-disconnected subproblems, otherwise we take the risk of having a component of the global constraint graph without a leader...

Constructor & Destructor Documentation

◆ LeaderElectionMaxID() [1/2]

frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.LeaderElectionMaxID ( String comID,
T myID,
Collection< String > neighbors,
int nbrSteps )

Constructor.

Parameters
comIDcommunication ID used to identify this agent as the sender of messages
myIDID that uniquely identifies this agent
neighborsthe neighbors of this agent
nbrStepsNumber of steps the protocol should run before it terminates
Note
nbrSteps must be an upper bound on the total number of agents for the algorithm to work properly.

References comID, myID, nbrNeighbors, neighbors, and thisStepSenders.

Referenced by LeaderElectionMaxID().

◆ LeaderElectionMaxID() [2/2]

frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.LeaderElectionMaxID ( DCOPProblemInterface<?, ?> problem,
Element params )

Constructor.

Parameters
problemthe agent's subproblem
paramsthis module's parameters

References LeaderElectionMaxID(), and nbrNeighbors.

Here is the call graph for this function:

Member Function Documentation

◆ getMaxID()

T frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.getMaxID ( )
protected
Returns
the current maxID

References maxID.

◆ getMsgTypes()

◆ notifyIn()

void frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.notifyIn ( Message msg)

The actual algorithm.

The algorithm is triggered by the reception of a message of type either this.startMsgType or this.LEmsgType. At each step, the protocol computes the max of its ID and of the IDs in all received messages, and forwards it. After a specified number of steps, the algorithm terminates, and returns a message of type this.outputMsgType if its ID matches the last computed max ID (it is then the leader).

Parameters
msgthe message that was just received

Implements frodo2.communication.IncomingMsgPolicyInterface< T >.

References frodo2.communication.MessageType.equals(), frodo2.algorithms.heuristics.AgentScoringHeuristic< S extends Comparable< S > &Serializable >.getScore(), notifyIn(), and START_MSG_TYPE.

Referenced by notifyIn().

Here is the call graph for this function:

◆ setQueue()

Member Data Documentation

◆ comID

final String frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.comID
private

Communication ID.

This is used to identify the agent as the sender of messages. It can be different from myID.

Referenced by LeaderElectionMaxID().

◆ heuristic

final AgentScoringHeuristic<T> frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.heuristic
private

The heuristic.

◆ lastSentMsg

MaxIDmsg<T> frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.lastSentMsg
private

The last MaxIDmsg sent.

◆ LE_MSG_TYPE

◆ maxID

T frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.maxID
protected

Current computed maximum ID.

Referenced by getMaxID().

◆ myID

T frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.myID
protected

This agent's ID.

Referenced by LeaderElectionMaxID().

◆ nbrNeighbors

final int frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.nbrNeighbors
private

The number of neighbors of the agent.

Referenced by LeaderElectionMaxID(), and LeaderElectionMaxID().

◆ neighbors

Collection<String> frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.neighbors
private

The neighbors of this agent.

Referenced by LeaderElectionMaxID().

◆ nextStepIDs

HashMap<String, T> frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.nextStepIDs = new HashMap<String, T> ()
private

Messages belonging to the next step that have already been received.

Maps a sender ID to the maxID value it sent.

◆ OUTPUT_MSG_TYPE

◆ queue

Queue frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.queue
private

The queue on which it should call sendMessage().

Referenced by setQueue().

◆ START_MSG_TYPE

MessageType frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.START_MSG_TYPE = new MessageType ("VarOrdering", "LeaderElectionMaxID", "Start")
static

◆ started

boolean frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.started = false
private

Whether this agent has already received the message that tells it to start the protocol.

◆ stepCountdown

int frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.stepCountdown = 0
protected

Index of the current step in the protocol, decremented until it reaches 0.

◆ thisStepSenders

HashSet<String> frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.thisStepSenders
private

IDs of the agents from which we have received messages since the beginning of the current step.

Referenced by LeaderElectionMaxID().


The documentation for this class was generated from the following file: