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

Public Member Functions | |
| VariableElectionTest (boolean useTCP, boolean useXML, Class< ? extends ScoringHeuristic<?> > heuristic, Class< ? extends ScoringHeuristic<?> > tiebreaking) | |
| Constructor that instantiates a test only for the input method. | |
| void | testRandom () throws IOException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException |
| Tests the variable election protocol on a random graph. | |
| Collection< MessageType > | getMsgTypes () |
| void | notifyIn (Message msg) |
| Keeps track of the output of the leader election protocol sent by each variable. | |
| 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 () |
Protected Member Functions | |
| void | setUp () |
| void | tearDown () throws Exception |
| Ends all queues. | |
| void | checkOutputs (Class<?> heuristic, Map< String, S > allUniqueIDs) |
| Checks that the outputs of the module are consistent with the correct outputs for the given heuristic. | |
| void | initiateParamAndListener (XCSPparser< AddableInteger, AddableReal > parser, Class< ? extends ScoringHeuristic<?> > heuristic, Class< ? extends ScoringHeuristic<?> > tiebreaking, int diameter) throws NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException |
| Initiate the parameter and the listener by reflection. | |
| VariableElection<?> | getNewInstance (Constructor<?> constr, Object[] args) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException |
Protected Attributes | |
| Map< String, MessageLEoutput< S > > | outputs |
| For each variable, the output of VariableElection. | |
| int | remainingOutputs |
| Current number of variables that have not yet sent 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. | |
| Map< String, Queue > | queues |
| List of queues, indexed by agent name. | |
| 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. | |
| boolean | useTCP |
true whether TCP pipes should be used instead of QueueIOPipes | |
Private Attributes | |
| final int | maxNbrVars = 12 |
| Maximum number of variables in the random graph. | |
| final int | maxNbrEdges = 30 |
| Maximum number of edges in the random graph. | |
| final int | maxNbrAgents = 4 |
| Maximum number of agents. | |
| boolean | useXML |
| Whether we should use the VariableElection constructor that takes in XML elements. | |
| Class< ? extends ScoringHeuristic<?> > | heuristic |
| The ScoringHeuristic. | |
| Class< ? extends ScoringHeuristic<?> > | tiebreaking |
| The tie-breaking heuristic. | |
JUnit test for the class VariableElection.
| <S> | type used for scores |
| frodo2.algorithms.varOrdering.election.tests.VariableElectionTest< S extends Comparable< S > &Serializable >.VariableElectionTest | ( | boolean | useTCP, |
| boolean | useXML, | ||
| Class< ? extends ScoringHeuristic<?> > | heuristic, | ||
| Class< ? extends ScoringHeuristic<?> > | tiebreaking ) |
Constructor that instantiates a test only for the input method.
| useTCP | true whether TCP pipes should be used instead of QueueIOPipes |
| useXML | Whether we should use the VariableElection constructor that takes in XML elements |
| heuristic | The ScoringHeuristic |
| tiebreaking | The tie-breaking heuristic |
References heuristic, tiebreaking, useTCP, and useXML.
Referenced by suite().
|
protected |
Checks that the outputs of the module are consistent with the correct outputs for the given heuristic.
| heuristic | the heuristic used |
| allUniqueIDs | the unique IDs |
References frodo2.algorithms.varOrdering.election.tests.LeaderElectionMaxIDTest< S extends Comparable< S > >.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, heuristic, and outputs.
Referenced by testRandom().

| Collection< MessageType > frodo2.algorithms.varOrdering.election.tests.VariableElectionTest< S extends Comparable< S > &Serializable >.getMsgTypes | ( | ) |
It listens to the output of the leader election protocol.
Implements frodo2.communication.MessageListener< T >.
|
protected |
| constr | a constructor of VariableElection type |
| args | the argument that will fit in public constructor of VariableElection: a ProblemInterface and a JDOM Element |
| InvocationTargetException | thrown if the VariableElection constructor throws an exception |
| IllegalAccessException | thrown if the VariableElection class does not have a public constructor that takes in a ProblemInterface and a JDOM Element |
| InstantiationException | would be thrown if VariableElection were abstract |
| IllegalArgumentException | if the VariableElection constructor does not take the proper arguments |
|
protected |
Initiate the parameter and the listener by reflection.
| parser | the problem |
| heuristic | a ScoringHeuristic |
| tiebreaking | the tie-breaking ScoringHeuristic |
| diameter | the diameter of the problem |
| NoSuchMethodException | thrown if the VariableElection class does not have a public constructor that takes in a ProblemInterface and a JDOM Element |
| InvocationTargetException | thrown if the VariableElection constructor throws an exception |
| IllegalAccessException | thrown if the VariableElection class does not have a public constructor that takes in a ProblemInterface and a JDOM Element |
| InstantiationException | would be thrown if VariableElection were abstract |
| IllegalArgumentException | if the VariableElection constructor does not take the proper arguments |
References frodo2.communication.Queue.addIncomingMessagePolicy(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getSubProblem(), heuristic, queues, frodo2.communication.Queue.setProblem(), and tiebreaking.
Referenced by testRandom().

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

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

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

|
protected |
| void frodo2.algorithms.varOrdering.election.tests.VariableElectionTest< S extends Comparable< S > &Serializable >.testRandom | ( | ) | throws IOException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException |
Tests the variable election protocol on a random graph.
| IOException | thrown if the method fails to create pipes |
| NoSuchMethodException | thrown if the VariableElection class does not have a public constructor that takes in a ProblemInterface and a JDOM Element |
| InvocationTargetException | thrown if the VariableElection constructor throws an exception |
| IllegalAccessException | thrown if the VariableElection class does not have a public constructor that takes in a ProblemInterface and a JDOM Element |
| InstantiationException | would be thrown if VariableElection were abstract |
| IllegalArgumentException | if the VariableElection constructor does not take the proper arguments |
References frodo2.communication.Queue.addIncomingMessagePolicy(), checkOutputs(), frodo2.algorithms.test.AllTests.createQueueNetwork(), frodo2.algorithms.test.AllTests.generateProblem(), frodo2.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.getAgents(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getDomain(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getDomainSize(), frodo2.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.getDomClass(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getProbabilitySpacePerRandVar(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getRandVars(), frodo2.algorithms.heuristics.ScoringHeuristic< S extends Comparable< S > &Serializable >.getScores(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getSolutionSpaces(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getSubProblem(), frodo2.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.getUtilClass(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getVariables(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getVarScopes(), graph, heuristic, initiateParamAndListener(), outputs, frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.parse(), pipes, queues, frodo2.communication.Queue.setProblem(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.setUtilClass(), frodo2.algorithms.AgentInterface< V extends Addable< V > >.START_AGENT, testRandom(), useTCP, and useXML.
Referenced by 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(), setUp(), tearDown(), and testRandom().
|
private |
The ScoringHeuristic.
Referenced by checkOutputs(), initiateParamAndListener(), testRandom(), and VariableElectionTest().
|
private |
Maximum number of agents.
Referenced by setUp().
|
private |
Maximum number of edges in the random graph.
Referenced by setUp().
|
private |
|
protected |
For each variable, the output of VariableElection.
Referenced by checkOutputs(), tearDown(), and testRandom().
|
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 initiateParamAndListener(), tearDown(), and testRandom().
|
protected |
Current number of variables that have not yet sent their output of the leader election protocol.
|
private |
The tie-breaking heuristic.
Referenced by initiateParamAndListener(), and VariableElectionTest().
|
protected |
true whether TCP pipes should be used instead of QueueIOPipes
Referenced by testRandom(), and VariableElectionTest().
|
private |
Whether we should use the VariableElection constructor that takes in XML elements.
Referenced by testRandom(), and VariableElectionTest().