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

JUnit test of the ASODPOP agent. More...

Inheritance diagram for frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >:

Public Member Functions

 ASODPOPagentTest (String string, boolean useXCSP, boolean useCentralMailer, boolean useDelay, Class< V > domClass, Class< U > utilClass, boolean maximize, int sign)
 Creates a JUnit test case corresponding to the input method.
void setUp () throws Exception
void testRandomSharedMemory () throws Exception
 Tests the ASODPOPagent on a random problem using QueueIOPipes for inter-agent communication.
void testRandomTCP () throws Exception
 Tests the ASODPOPagent on a random problem using TCP pipes for inter-agent communication.
void testRandom (boolean useTCP, Class< ? extends XCSPparser< V, U > > parserClass, boolean aggregate) 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

Package Attributes

QueueIOPipe pipe
 The testers pipe.

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.
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.
SolutionCollector< V, U > solCollector
 The solution collector.
Document agentDesc
 The description of the agent.
boolean useCentralMailer
 true if the algorithm must be tested with the central mailer
boolean useDelay
 true when the central mailer is to be tested with delays
CentralMailer mailman
 The CentralMailer.
Class< V > domClass
 The type used for variable values.
Class< U > utilClass
 The type used for utility values.
final boolean maximize
 Maximize of minimize.
final int sign
 The sign of costs/utilities.
boolean useXCSP
 Whether to use XCSP.

Detailed Description

JUnit test of the ASODPOP agent.

Author
Brammert Ottens, Thomas Leaute
Parameters
<V>the type used for variable values
<U>the type used for utility values

Constructor & Destructor Documentation

◆ ASODPOPagentTest()

frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.ASODPOPagentTest ( String string,
boolean useXCSP,
boolean useCentralMailer,
boolean useDelay,
Class< V > domClass,
Class< U > utilClass,
boolean maximize,
int sign )

Creates a JUnit test case corresponding to the input method.

Parameters
stringname of the method
useXCSPwhether to use XCSP
useCentralMailertrue when the central mailer should be used and tested
useDelaytrue when the algorithm should be tested with the use of delay
domClassThe type used for variable values
utilClassthe type used for utility values
maximizeMaximize of minimize
signThe sign of costs/utilities

References domClass, maximize, sign, useCentralMailer, useDelay, useXCSP, and utilClass.

Referenced by suite().

Member Function Documentation

◆ getMsgTypes()

◆ notifyIn()

◆ setQueue()

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

◆ setUp()

◆ suite()

TestSuite frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.suite ( )
static
Returns
the test suite
Bug
Rarely gets stuck

References ASODPOPagentTest(), and suite().

Referenced by frodo2.algorithms.asodpop.tests.AllTestsASODPOP.suite(), and suite().

Here is the call graph for this function:

◆ tearDown()

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

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

◆ testRandom()

void frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.testRandom ( boolean useTCP,
Class< ? extends XCSPparser< V, U > > parserClass,
boolean aggregate ) 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 parser to be used
aggregatetrue when we use a model with aggregate constraints
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.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.getAgents(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getSubProblem(), frodo2.solutionSpaces.DCOPProblemInterface< V extends Addable< V >, U extends Addable< U > >.getUtility(), mailman, 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.Problem< V extends Addable< V >, U extends Addable< U > >.reset(), frodo2.algorithms.Problem< V extends Addable< V >, U extends Addable< U > >.setDomClass(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.setDomClass(), frodo2.algorithms.AbstractProblem< V extends Addable< V >, U extends Addable< U > >.setUtilClass(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.setUtilClass(), solCollector, frodo2.timeout, useCentralMailer, and utilClass.

Referenced by testRandomSharedMemory(), and testRandomTCP().

Here is the call graph for this function:

◆ testRandomSharedMemory()

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

Tests the ASODPOPagent 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.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.testRandomTCP ( ) throws Exception

Tests the ASODPOPagent 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.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.agentDesc
private

The description of the agent.

Referenced by setUp(), and testRandom().

◆ agents

Map< String, AgentInterface<V> > frodo2.algorithms.asodpop.tests.ASODPOPagentTest< 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.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.domClass
private

The type used for variable values.

Referenced by ASODPOPagentTest(), and testRandom().

◆ finished

final Condition frodo2.algorithms.asodpop.tests.ASODPOPagentTest< 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.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.finished_lock = new ReentrantLock ()
private

Used to make the test thread wait.

◆ mailman

CentralMailer frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.mailman
private

The CentralMailer.

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

◆ maximize

final boolean frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.maximize
private

Maximize of minimize.

Referenced by ASODPOPagentTest().

◆ maxNbrAgents

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

Maximum number of agents.

Referenced by testRandom().

◆ maxNbrEdges

final int frodo2.algorithms.asodpop.tests.ASODPOPagentTest< 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.asodpop.tests.ASODPOPagentTest< 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.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.nbrAgents
private

Total number of agents.

Referenced by notifyIn(), and testRandom().

◆ nbrAgentsFinished

int frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.nbrAgentsFinished
private

Number of agents finished.

Referenced by setUp(), and testRandom().

◆ nbrMsgsReceived

int frodo2.algorithms.asodpop.tests.ASODPOPagentTest< 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

QueueIOPipe frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.pipe
package

The testers pipe.

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

◆ pipes

Map<Object, QueueOutputPipeInterface> frodo2.algorithms.asodpop.tests.ASODPOPagentTest< 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.asodpop.tests.ASODPOPagentTest< 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().

◆ sign

final int frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.sign
private

The sign of costs/utilities.

Referenced by ASODPOPagentTest().

◆ solCollector

SolutionCollector<V, U> frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.solCollector
private

The solution collector.

Referenced by tearDown(), and testRandom().

◆ useCentralMailer

boolean frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.useCentralMailer
private

true if the algorithm must be tested with the central mailer

Referenced by ASODPOPagentTest(), and testRandom().

◆ useDelay

boolean frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.useDelay
private

true when the central mailer is to be tested with delays

Referenced by ASODPOPagentTest().

◆ useXCSP

boolean frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.useXCSP
private

Whether to use XCSP.

Referenced by ASODPOPagentTest().

◆ utilClass

Class<U> frodo2.algorithms.asodpop.tests.ASODPOPagentTest< V extends Addable< V >, U extends Addable< U > >.utilClass
private

The type used for utility values.

Referenced by ASODPOPagentTest(), and testRandom().


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