FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest Class Reference

JUnit test for the class DFSgeneration. More...

Inheritance diagram for frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest:

Public Member Functions

 DFSgenerationTest (boolean useTCP, boolean useXML, Class< ? extends ScoringHeuristic<?> > heuristic)
 Constructor.
void testRandom () throws IOException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
 Tests the DFS generation protocol on a random graph.
Collection< MessageTypegetMsgTypes ()
void notifyIn (Message msg)
 Keeps track of the output of the DFS generation 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 ()
static void checkDFS (Map< String, ? extends DFSview<?, ?> > dfs, Map< String, Set< String > > neighborhoods, LinkedList< String > path)
 Checks that the input is indeed a DFS tree.

Protected Member Functions

void setUp ()
void tearDown () throws Exception
 Ends all queues.
Class<?> getDFSclass ()
void sendLEoutputs (String agent, Map< String, String > rootForVar)
 Sends the LEoutput messages.
Element createDFSparams (Element heuristicParams)
 Create the XML parameters for the DFS module.
MessageType getOutputMsgType ()

Protected Attributes

int nbrOutputMessagesPerVar = 2
 Number of output messages expected per variable.
int remainingOutputs
 Current number of variables that still need to send their output of the DFS generation protocol.
Map< String, DFSview< AddableInteger, AddableReal > > dfs = new HashMap< String, DFSview<AddableInteger, AddableReal> > (maxNbrVars)
 Output of the DFS generation protocol.
RandGraphFactory.Graph graph
 Random graph used to generate a constraint graph.

Private Member Functions

void checkMostConnected ()
 Checks that the DFS implements the Most Connected heuristicClass.

Private Attributes

final int maxNbrVars = 15
 Maximum number of variables in the random graph.
final int maxNbrEdges = 100
 Maximum number of edges in the random graph.
final int maxNbrAgents = 5
 Maximum number of agents.
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, Queuequeues
 List of queues, indexed by agent name.
XCSPparser< AddableInteger, AddableRealparser
 Parser for the random XCSP problem.
Map< String, QueueOutputPipeInterfacepipes
 One output pipe used to send messages to each queue, indexed by the queue's agent name.
boolean useTCP
 Whether to use TCP or SharedMemory pipes.
boolean useXML
 Whether to use the XML-based constructor.
Class< ? extends ScoringHeuristic<?> > heuristicClass
 The ScoringHeuristic.

Detailed Description

JUnit test for the class DFSgeneration.

Author
Thomas Leaute

Constructor & Destructor Documentation

◆ DFSgenerationTest()

frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.DFSgenerationTest ( boolean useTCP,
boolean useXML,
Class< ? extends ScoringHeuristic<?> > heuristic )

Constructor.

Parameters
useTCPtrue whether TCP pipes should be used instead of QueueIOPipes
useXMLwhether we should use the DFSgeneration constructor that takes in XML elements
heuristicthe class of the ScoringHeuristic used

References useTCP, and useXML.

Referenced by suite().

Member Function Documentation

◆ checkDFS()

void frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.checkDFS ( Map< String, ? extends DFSview<?, ?> > dfs,
Map< String, Set< String > > neighborhoods,
LinkedList< String > path )
static

◆ checkMostConnected()

void frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.checkMostConnected ( )
private

Checks that the DFS implements the Most Connected heuristicClass.

The idea of the Most Connected heuristicClass is that, for any variable, its least connected child is more connected than any of its pseudo-children.

References graph.

Referenced by testRandom().

◆ createDFSparams()

Element frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.createDFSparams ( Element heuristicParams)
protected

Create the XML parameters for the DFS module.

Parameters
heuristicParamsthe parameters for the DFS heuristic
Returns
the XML parameters for the DFS module

Reimplemented in frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationParallelTest, and frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationWithOrderTest.

◆ getDFSclass()

Class<?> frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.getDFSclass ( )
protected

◆ getMsgTypes()

Collection< MessageType > frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.getMsgTypes ( )
See also
frodo2.communication.IncomingMsgPolicyInterface.getMsgTypes()

It listens to the output of the DFS generation protocol.

Implements frodo2.communication.MessageListener< T >.

Reimplemented in frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationWithOrderTest.

References getOutputMsgType().

Here is the call graph for this function:

◆ getOutputMsgType()

MessageType frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.getOutputMsgType ( )
protected

◆ notifyIn()

void frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.notifyIn ( Message msg)

◆ sendLEoutputs()

void frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.sendLEoutputs ( String agent,
Map< String, String > rootForVar )
protected

Sends the LEoutput messages.

Parameters
agentthe name of the current agent
rootForVarfor each variable, its root

Reimplemented in frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationParallelTest.

References graph, and queues.

Referenced by testRandom().

◆ setQueue()

void frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.setQueue ( Queue queue)

Does nothing in this case.

Parameters
queuethe queue

Implements frodo2.communication.MessageListener< T >.

◆ setUp()

void frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.setUp ( )
protected
See also
junit.framework.TestCase#setUp()

References frodo2.algorithms.test.AllTests.generateProblem(), frodo2.algorithms.RandGraphFactory.getRandGraph(), graph, maxNbrAgents, maxNbrEdges, maxNbrVars, and parser.

Here is the call graph for this function:

◆ suite()

TestSuite frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.suite ( )
static

◆ tearDown()

void frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.tearDown ( ) throws Exception
protected

Ends all queues.

See also
junit.framework.TestCase#tearDown()

References dfs, graph, parser, pipes, and queues.

◆ testRandom()

void frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.testRandom ( ) throws IOException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException

Tests the DFS generation protocol on a random graph.

Exceptions
IOExceptionif the method fails to create pipes
NoSuchMethodExceptionif the DFSgeneration class does not have a public constructor that takes in a ProblemInterface and a JDOM Element
InvocationTargetExceptionif the DFSgeneration constructor throws an exception
IllegalAccessExceptionif the DFSgeneration class does not have a public constructor that takes in a ProblemInterface and a JDOM Element
InstantiationExceptionif the heuristicClass class is abstract
IllegalArgumentExceptionif the DFSgeneration constructor does not take the proper arguments

Reimplemented in frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationWithOrderTest.

References frodo2.communication.Queue.addIncomingMessagePolicy(), checkDFS(), checkMostConnected(), frodo2.algorithms.varOrdering.election.tests.LeaderElectionMaxIDTest< S extends Comparable< S > >.computeLeaders(), frodo2.algorithms.test.AllTests.createQueueNetwork(), dfs, frodo2.communication.Queue.end(), frodo2.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.getAgents(), getDFSclass(), 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.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getSolutionSpaces(), frodo2.algorithms.varOrdering.dfs.DFSgeneration< V extends Addable< V >, U extends Addable< U > >.getStatsFromQueue(), frodo2.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.getUtilClass(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getVarScopes(), graph, parser, pipes, queues, remainingOutputs, sendLEoutputs(), frodo2.communication.Queue.setProblem(), frodo2.algorithms.varOrdering.dfs.DFSgeneration< V extends Addable< V >, U extends Addable< U > >.setSilent(), frodo2.algorithms.AgentInterface< V extends Addable< V > >.START_AGENT, frodo2.algorithms.AgentInterface< V extends Addable< V > >.STATS_MONITOR, frodo2.algorithms.varOrdering.dfs.DFSgeneration< V extends Addable< V >, U extends Addable< U > >.STATS_MSG_TYPE, testRandom(), useTCP, and useXML.

Referenced by testRandom().

Here is the call graph for this function:

Member Data Documentation

◆ dfs

Map< String, DFSview<AddableInteger, AddableReal> > frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.dfs = new HashMap< String, DFSview<AddableInteger, AddableReal> > (maxNbrVars)
protected

Output of the DFS generation protocol.

For each variable, stores its relationships with neighboring variables

Referenced by checkDFS(), notifyIn(), tearDown(), and testRandom().

◆ finished

final Condition frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.finished = finished_lock.newCondition()
private

Used to wake up the test thread when all agents have finished.

◆ finished_lock

final ReentrantLock frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.finished_lock = new ReentrantLock ()
private

Used to make the test thread wait.

◆ graph

RandGraphFactory.Graph frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.graph
protected

◆ heuristicClass

Class< ? extends ScoringHeuristic<?> > frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.heuristicClass
private

◆ maxNbrAgents

final int frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.maxNbrAgents = 5
private

Maximum number of agents.

Referenced by setUp().

◆ maxNbrEdges

final int frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.maxNbrEdges = 100
private

Maximum number of edges in the random graph.

Referenced by setUp().

◆ maxNbrVars

final int frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.maxNbrVars = 15
private

Maximum number of variables in the random graph.

Note
Must be at least 2.

Referenced by setUp().

◆ nbrOutputMessagesPerVar

int frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.nbrOutputMessagesPerVar = 2
protected

Number of output messages expected per variable.

Referenced by frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationWithOrderTest.testRandom().

◆ parser

XCSPparser<AddableInteger, AddableReal> frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.parser
private

Parser for the random XCSP problem.

Referenced by setUp(), tearDown(), and testRandom().

◆ pipes

Map<String, QueueOutputPipeInterface> frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.pipes
private

One output pipe used to send messages to each queue, indexed by the queue's agent name.

Referenced by tearDown(), and testRandom().

◆ queues

Map<String, Queue> frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.queues
private

List of queues, indexed by agent name.

Referenced by sendLEoutputs(), tearDown(), and testRandom().

◆ remainingOutputs

int frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.remainingOutputs
protected

Current number of variables that still need to send their output of the DFS generation protocol.

Referenced by testRandom().

◆ useTCP

boolean frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.useTCP
private

◆ useXML

boolean frodo2.algorithms.varOrdering.dfs.tests.DFSgenerationTest.useXML
private

Whether to use the XML-based constructor.

Referenced by DFSgenerationTest(), and testRandom().


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