|
FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
|
JUnit test for the class LeaderElectionMaxID. More...

Public Member Functions | |
| LeaderElectionMaxIDTest (String method) | |
| Constructor that instantiates a test only for the input method. | |
| void | testRandomSharedMemory () throws IOException |
| Tests the DFS generation protocol on a random graph using QueueIOPipes. | |
| void | testRandomTCP () throws IOException |
| Tests the DFS generation protocol on a random graph using TCP pipes. | |
| void | testRandom (boolean useTCP) throws IOException |
| Tests the leader election protocol on a random graph of "agents". | |
| Collection< MessageType > | getMsgTypes () |
| void | notifyIn (Message msg) |
| Keeps track of the output of the leader election protocol sent by each agent. | |
| void | setQueue (Queue queue) |
| Does nothing in this case. | |
| 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 Member Functions | |
| static TestSuite | suite () |
| static Map< String, String > | computeLeaders (List< String > nodes, List< List< String > > components) |
| Compute the leaders. | |
| static< S extends Comparable< S > Map< String, S > | computeLeaders (int nbrAgents, List< List< String > > components, Map< String, S > uniqueIDs) |
| Compute the leaders. | |
Protected Member Functions | |
| void | setUp () |
| void | tearDown () throws Exception |
| Ends all queues. | |
| Map< String, S > | initiatingIDandListener () |
| Compute uniqueID, link them with variable name and generate listeners. | |
| void | checkOutputs (Map< String, S > allUniqueIDs) |
| Called to verify output correctness. | |
| int | getNbrMsgsNeeded () |
Protected Attributes | |
| int | nbrAgents |
| Number of agents in the test. | |
| Map< String, Queue > | queues |
| List of queues, indexed by agent name. | |
| Map< String, MessageLEoutput< String > > | outputs |
| For each agent, the output of LeaderElectionMaxID. | |
| Integer | remainingOutputs |
| Current number of agents that still need to their output of the leader election protocol. | |
| final ReentrantLock | finished_lock = new ReentrantLock () |
| Used to make the test thread wait. | |
| final Condition | finished = finished_lock.newCondition() |
| Used to wake up the test thread when all agents have finished. | |
| RandGraphFactory.Graph | graph |
| Random graph used to generate a constraint graph. | |
| Map< String, QueueOutputPipeInterface > | pipes |
| One output pipe used to send messages to each queue, indexed by the queue's agent name. | |
Private Attributes | |
| final int | maxNbrAgents = 5 |
| Maximum number of agents in the random graph. | |
| final int | maxNbrPipes = 10 |
| Maximum number of pipes (edges) in the random graph. | |
JUnit test for the class LeaderElectionMaxID.
| <S> | type used for scores |
| frodo2.algorithms.varOrdering.election.tests.LeaderElectionMaxIDTest< S extends Comparable< S > >.LeaderElectionMaxIDTest | ( | String | method | ) |
Constructor that instantiates a test only for the input method.
| method | test method |
Referenced by suite().
|
protected |
Called to verify output correctness.
| allUniqueIDs | a mapping between Names and IDs |
References computeLeaders(), frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.MessageLEoutput< T extends Comparable< T > &Serializable >.getFlag(), frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.MessageLEoutput< T extends Comparable< T > &Serializable >.getLeader(), graph, and outputs.
Referenced by testRandom().

|
static |
Compute the leaders.
| <S> | the type used for the scores |
| nbrAgents | number of agents |
| components | components in the graph |
| uniqueIDs | for each variable, its unique ID |
References nbrAgents.
|
static |
Compute the leaders.
| nodes | list of nodes in the graph |
| components | components in the graph |
References computeLeaders().
Referenced by checkOutputs(), frodo2.algorithms.varOrdering.election.tests.VariableElectionTest< S extends Comparable< S > &Serializable >.checkOutputs(), computeLeaders(), frodo2.algorithms.dpop.privacy.test.SecureRerootingTest.randomTest(), and frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.testRandom().

| Collection< MessageType > frodo2.algorithms.varOrdering.election.tests.LeaderElectionMaxIDTest< S extends Comparable< S > >.getMsgTypes | ( | ) |
It listens to the output of the leader election protocol.
Implements frodo2.communication.MessageListener< T >.
References frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.LE_MSG_TYPE, and frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.OUTPUT_MSG_TYPE.
|
protected |
References graph, and nbrAgents.
Referenced by testRandom().
|
protected |
Compute uniqueID, link them with variable name and generate listeners.
References frodo2.communication.Queue.addIncomingMessagePolicy(), graph, initiatingIDandListener(), nbrAgents, and queues.
Referenced by initiatingIDandListener(), and testRandom().

| void frodo2.algorithms.varOrdering.election.tests.LeaderElectionMaxIDTest< S extends Comparable< S > >.notifyIn | ( | Message | msg | ) |
Keeps track of the output of the leader election protocol sent by each agent.
Implements frodo2.communication.IncomingMsgPolicyInterface< T >.
References notifyIn(), and frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.OUTPUT_MSG_TYPE.
Referenced by notifyIn().

| void frodo2.algorithms.varOrdering.election.tests.LeaderElectionMaxIDTest< S extends Comparable< S > >.setQueue | ( | Queue | queue | ) |
Does nothing in this case.
| queue | the queue |
Implements frodo2.communication.MessageListener< T >.
|
protected |
References frodo2.algorithms.RandGraphFactory.getRandGraph(), graph, maxNbrAgents, and maxNbrPipes.

|
static |
References LeaderElectionMaxIDTest().
Referenced by frodo2.algorithms.varOrdering.election.tests.AllTestsElection.suite().

|
protected |
| void frodo2.algorithms.varOrdering.election.tests.LeaderElectionMaxIDTest< S extends Comparable< S > >.testRandom | ( | boolean | useTCP | ) | throws IOException |
Tests the leader election protocol on a random graph of "agents".
| useTCP | true whether TCP pipes should be used instead of QueueIOPipes |
| IOException | thrown if the method fails to create pipes |
References checkOutputs(), frodo2.algorithms.test.AllTests.createQueueNetwork(), getNbrMsgsNeeded(), graph, initiatingIDandListener(), nbrAgents, pipes, queues, and frodo2.algorithms.varOrdering.election.LeaderElectionMaxID< T extends Comparable< T > &Serializable >.START_MSG_TYPE.
Referenced by testRandomSharedMemory(), and testRandomTCP().

| void frodo2.algorithms.varOrdering.election.tests.LeaderElectionMaxIDTest< S extends Comparable< S > >.testRandomSharedMemory | ( | ) | throws IOException |
Tests the DFS generation protocol on a random graph using QueueIOPipes.
| IOException | thrown if the method fails to create pipes |
References testRandom().

| void frodo2.algorithms.varOrdering.election.tests.LeaderElectionMaxIDTest< S extends Comparable< S > >.testRandomTCP | ( | ) | throws IOException |
Tests the DFS generation protocol on a random graph using TCP pipes.
| IOException | thrown if the method fails to create pipes |
References testRandom().

|
protected |
Used to wake up the test thread when all agents have finished.
|
protected |
Used to make the test thread wait.
|
protected |
Random graph used to generate a constraint graph.
Referenced by checkOutputs(), getNbrMsgsNeeded(), initiatingIDandListener(), setUp(), tearDown(), and testRandom().
|
private |
|
private |
Maximum number of pipes (edges) in the random graph.
Referenced by setUp().
|
protected |
Number of agents in the test.
Referenced by computeLeaders(), getNbrMsgsNeeded(), initiatingIDandListener(), and testRandom().
|
protected |
For each agent, the output of LeaderElectionMaxID.
Referenced by checkOutputs(), and tearDown().
|
protected |
One output pipe used to send messages to each queue, indexed by the queue's agent name.
Referenced by tearDown(), and testRandom().
|
protected |
List of queues, indexed by agent name.
Referenced by initiatingIDandListener(), tearDown(), and testRandom().
|
protected |
Current number of agents that still need to their output of the leader election protocol.