FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > > Class Template Reference

JUnit test of the ODPOP agent. More...

Inheritance diagram for frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >:

Public Member Functions

 ODPOPagentTestFullDomain (String string, boolean useCentralMailer, boolean useDelay, MessageType startMsgType, Class< V > domClass, Class< U > utilClass)
 Creates a JUnit test case corresponding to the input method.
void setUp () throws Exception
void testRandomSharedMemory () throws Exception
 Tests the ODPOPagent on a random problem using QueueIOPipes for inter-agent communication.
void testRandomTCP () throws Exception
 Tests the ODPOPagent on a random problem using TCP pipes for inter-agent communication.
void testRandom (boolean useTCP, Class< ? extends XCSPparser< V, U > > parserClass) throws JDOMException, IOException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
 Tests the DPOPagent on a random problem.
Collection< MessageTypegetMsgTypes ()
void notifyIn (Message msg)
void setQueue (Queue queue)
 Does nothing.
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 tearDown () throws Exception

Private Member Functions

void setStartMsgType (MessageType startMsgType) throws JDOMException
 Sets the type of the start message for all modules.
void setStartMsgType (Element messages, MessageType startMsgType)
 Overwrites the type of the start messages.

Private Attributes

final int maxNbrVars = 10
 Maximum number of variables in the problem.
final int maxNbrEdges = 15
 Maximum number of binary constraints in the problem.
final int maxNbrAgents = 10
 Maximum number of agents.
Queue queue
 The queue used to listen to the agents.
Map< Object, QueueOutputPipeInterfacepipes
 For each agent, the output pipe to it.
QueueIOPipe pipe
 The testers pipe.
Map< String, AgentInterface< V > > agents
 All agents, indexed by their IDs.
int nbrAgents
 Total number of agents.
int nbrMsgsReceived
 Used to track the number of various types of messages received from the agents.
int nbrAgentsFinished
 Number of agents finished.
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.
UTILpropagationFullDomain< V, U, LeafNode< U > > statsGathererUTIL
 The UTILpropagation stats gatherer listening for the solution.
SolutionCollector< V, U > solCollector
 The solution collector.
DFSgeneration< V, U > statsGathererDFS
 The DFS tree generation stats gatherer listening for DFS tree information.
MessageType startMsgType
 The type of the start message.
Document agentDesc
 The description of the agent.
boolean useCentralMailer
 true if the algorithm must be tested with the central mailer
boolean useDelay
 true if the central mailer must be tested with added delays
CentralMailer mailman
 The CentralMailer.
boolean maximize
 when true a maximization problem should be generated, when false a minimization problem
Class< V > domClass
 The class used for variable values.
Class< U > utilClass
 The class used for utility values.

Detailed Description

JUnit test of the ODPOP agent.

Author
Brammert Ottens, Thomas Leaute
Parameters
<V>the type used for variable values
<U>the type used for utility values
Todo
REUSE CODE WITH ODPOPagentTest!!!

Constructor & Destructor Documentation

◆ ODPOPagentTestFullDomain()

frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.ODPOPagentTestFullDomain ( String string,
boolean useCentralMailer,
boolean useDelay,
MessageType startMsgType,
Class< V > domClass,
Class< U > utilClass )

Creates a JUnit test case corresponding to the input method.

Parameters
stringname of the method
useCentralMailertrue when the central mailer is to be tested
useDelaywhether to use message delays
startMsgTypethe type of the start message
domClassThe class used for variable values
utilClassthe class used for utility values

References domClass, startMsgType, useCentralMailer, useDelay, and utilClass.

Referenced by suite().

Member Function Documentation

◆ getMsgTypes()

◆ notifyIn()

◆ setQueue()

void frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.setQueue ( Queue queue)

◆ setStartMsgType() [1/2]

void frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.setStartMsgType ( Element messages,
MessageType startMsgType )
private

Overwrites the type of the start messages.

Parameters
messagesmessages element
startMsgTypethe new type of the start messages

References startMsgType.

◆ setStartMsgType() [2/2]

void frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.setStartMsgType ( MessageType startMsgType) throws JDOMException
private

Sets the type of the start message for all modules.

Parameters
startMsgTypethe new type for the start message
Exceptions
JDOMExceptionif parsing the agent configuration file failed

References agentDesc, setStartMsgType(), frodo2.algorithms.AgentInterface< V extends Addable< V > >.START_AGENT, and startMsgType.

Referenced by setStartMsgType(), and setUp().

Here is the call graph for this function:

◆ setUp()

◆ suite()

TestSuite frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.suite ( )
static
Returns
the test suite

References ODPOPagentTestFullDomain(), and suite().

Referenced by frodo2.algorithms.odpop.tests.AllTestsODPOP.suite(), and suite().

Here is the call graph for this function:

◆ tearDown()

void frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.tearDown ( ) throws Exception
protected
See also
junit.framework.TestCase#tearDown()

References agents, mailman, pipe, pipes, queue, solCollector, and statsGathererUTIL.

◆ testRandom()

void frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.testRandom ( boolean useTCP,
Class< ? extends XCSPparser< V, U > > parserClass ) throws JDOMException, IOException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException

Tests the DPOPagent on a random problem.

Parameters
useTCPwhether TCP pipes should be used for communication between agents
parserClassthe class to be used when parsing a problem
Exceptions
IOExceptionif unable to access DPOPagent.xml
JDOMExceptionif unable to parse DPOPagent.xml
NoSuchMethodExceptionif the parser does not have a constructor that takes in a Document
InvocationTargetExceptionif the parser constructor throws an exception
IllegalAccessExceptionif the parser constructor is not accessible
InstantiationExceptionif the parser is abstract
IllegalArgumentExceptionshould never happen

References agentDesc, agents, frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.createAgent(), frodo2.algorithms.test.AllTests.createRandProblem(), domClass, frodo2.communication.mailer.CentralMailer.execute(), frodo2.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.getAgent(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.getAgents(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getSubProblem(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.getUtility(), mailman, maximize, maxNbrAgents, maxNbrEdges, maxNbrVars, nbrAgents, nbrAgentsFinished, frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.newInstance(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.parse(), pipe, queue, frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.setDomClass(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.setUtilClass(), solCollector, frodo2.algorithms.AbstractDCOPsolver< V extends Addable< V >, U extends Addable< U >, S extends Solution< V, U >.solve(), statsGathererDFS, statsGathererUTIL, frodo2.timeout, useCentralMailer, and utilClass.

Referenced by testRandomSharedMemory(), and testRandomTCP().

Here is the call graph for this function:

◆ testRandomSharedMemory()

void frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.testRandomSharedMemory ( ) throws Exception

Tests the ODPOPagent on a random problem using QueueIOPipes for inter-agent communication.

Exceptions
Exceptionif an error occurs

References testRandom(), and testRandomSharedMemory().

Referenced by testRandomSharedMemory().

Here is the call graph for this function:

◆ testRandomTCP()

void frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.testRandomTCP ( ) throws Exception

Tests the ODPOPagent on a random problem using TCP pipes for inter-agent communication.

Exceptions
Exceptionif an error occurs

References testRandom(), and testRandomTCP().

Referenced by testRandomTCP().

Here is the call graph for this function:

Member Data Documentation

◆ agentDesc

Document frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.agentDesc
private

The description of the agent.

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

◆ agents

Map< String, AgentInterface<V> > frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.agents
private

All agents, indexed by their IDs.

Referenced by tearDown(), and testRandom().

◆ domClass

Class<V> frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.domClass
private

The class used for variable values.

Referenced by ODPOPagentTestFullDomain(), and testRandom().

◆ finished

final Condition frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.finished = finished_lock.newCondition()
private

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

◆ finished_lock

final ReentrantLock frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.finished_lock = new ReentrantLock ()
private

Used to make the test thread wait.

◆ mailman

CentralMailer frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.mailman
private

The CentralMailer.

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

◆ maximize

boolean frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.maximize
private

when true a maximization problem should be generated, when false a minimization problem

Referenced by setUp(), and testRandom().

◆ maxNbrAgents

final int frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.maxNbrAgents = 10
private

Maximum number of agents.

Referenced by testRandom().

◆ maxNbrEdges

final int frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.maxNbrEdges = 15
private

Maximum number of binary constraints in the problem.

Referenced by testRandom().

◆ maxNbrVars

final int frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.maxNbrVars = 10
private

Maximum number of variables in the problem.

Note
Must be at least 2.

Referenced by testRandom().

◆ nbrAgents

int frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.nbrAgents
private

Total number of agents.

Referenced by notifyIn(), and testRandom().

◆ nbrAgentsFinished

int frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.nbrAgentsFinished
private

Number of agents finished.

Referenced by setUp(), and testRandom().

◆ nbrMsgsReceived

int frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.nbrMsgsReceived
private

Used to track the number of various types of messages received from the agents.

Referenced by setUp().

◆ pipe

The testers pipe.

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

◆ pipes

Map<Object, QueueOutputPipeInterface> frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.pipes
private

For each agent, the output pipe to it.

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

◆ queue

Queue frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.queue
private

The queue used to listen to the agents.

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

◆ solCollector

SolutionCollector<V, U> frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.solCollector
private

The solution collector.

Referenced by tearDown(), and testRandom().

◆ startMsgType

MessageType frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.startMsgType
private

The type of the start message.

Referenced by ODPOPagentTestFullDomain(), setStartMsgType(), and setStartMsgType().

◆ statsGathererDFS

DFSgeneration<V, U> frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.statsGathererDFS
private

The DFS tree generation stats gatherer listening for DFS tree information.

Referenced by testRandom().

◆ statsGathererUTIL

UTILpropagationFullDomain<V, U, LeafNode<U> > frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.statsGathererUTIL
private

The UTILpropagation stats gatherer listening for the solution.

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

◆ useCentralMailer

boolean frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.useCentralMailer
private

true if the algorithm must be tested with the central mailer

Referenced by ODPOPagentTestFullDomain(), and testRandom().

◆ useDelay

boolean frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.useDelay
private

true if the central mailer must be tested with added delays

Referenced by ODPOPagentTestFullDomain().

◆ utilClass

Class<U> frodo2.algorithms.odpop.tests.ODPOPagentTestFullDomain< V extends Addable< V >, U extends Addable< U > >.utilClass
private

The class used for utility values.

Referenced by ODPOPagentTestFullDomain(), and testRandom().


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