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

JUnit test for DUCT. More...

Inheritance diagram for frodo2.algorithms.duct.tests.DUCTagentTest:

Public Member Functions

 DUCTagentTest (boolean useTCP, boolean useCentralMailer, boolean measureMsgs, String samplingMethodClass, String termination, String bound)
 Creates a JUnit test case corresponding to the input method.
 DUCTagentTest (boolean useTCP, boolean useCentralMailer, Class< ? extends XCSPparser< AddableInteger, AddableReal > > parserClass, boolean measureMsgs, String samplingMethod, String termination, String bound)
 Creates a JUnit test case corresponding to the input method.
void setUp () throws Exception
void testRandom () throws Exception
 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 setStartMsgType (MessageType startMsgType) throws JDOMException
 Sets the type of the start message for all modules.
void tearDown () throws Exception
void checkOutput () throws Exception
 Checks that the output of the algorithm is correct.

Protected Attributes

final int maxNbrVars = 5
 Maximum number of variables in the problem.
final int maxNbrEdges = 20
 Maximum number of binary constraints in the problem.
final int maxNbrAgents = 5
 Maximum number of agents.
Document agentConfig
 The agent configuration file.
Queue queue
 The queue used to listen to the agents.
Map< Object, QueueOutputPipeInterfacepipes
 For each agent, the output pipe to it.
RandGraphFactory.Graph graph
 Random graph used to generate a constraint graph.
int nbrMsgsReceived
 Used to track the number of various types of messages received from the agents.
int nbrAgentsFinished
 Number of agents finished.
boolean useCentralMailer = false
 true if the algorithm should be tested with the central mailer
boolean measureMsgs
 Whether to measure message numbers and sizes.
Document problemDoc
 The XCSP random problem file.
Class< ? extends XCSPparser< AddableInteger, AddableReal > > parserClass
 The class of the parser/subsolver to use.
DCOPProblemInterface< AddableInteger, AddableRealproblem
 The problem.
Normalize< AddableIntegernormModule
 The module listening for the optimal utility to the problem.
Sampling< AddableIntegersamplingModule
 The module listening for the optimal assignment to the problem.
String samplingMethod
 The sampling method to be used.
String terminationMethod
 The termination method to be used.
String bound
 The bound to be used.
MessageType startMsgType
 The type of the start message.
boolean maximize = true
 Whether we should maximize or minimize.
CentralMailer mailman
 The CentralMailer.

Private Attributes

QueueIOPipe pipe
 The testers pipe.
Map< String, AgentInterface< AddableInteger > > agents
 All agents, indexed by their IDs.
int nbrAgents
 Total 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.
boolean useTCP
 Whether TCP pipes should be used for communication between agents.

Detailed Description

JUnit test for DUCT.

Author
Brammert Ottens
Todo
Many tests should inherit this class to favor code reuse.

Constructor & Destructor Documentation

◆ DUCTagentTest() [1/2]

frodo2.algorithms.duct.tests.DUCTagentTest.DUCTagentTest ( boolean useTCP,
boolean useCentralMailer,
boolean measureMsgs,
String samplingMethodClass,
String termination,
String bound )

Creates a JUnit test case corresponding to the input method.

Parameters
useTCPwhether TCP pipes should be used for communication between agents
useCentralMailertrue when the central mailer should be tested
measureMsgstrue when message sizes have to be measured
samplingMethodClassThe sampling method to be used
terminationThe termination method to be used
boundThe bound to be used

References bound, DUCTagentTest(), measureMsgs, useCentralMailer, and useTCP.

Referenced by DUCTagentTest(), and suite().

Here is the call graph for this function:

◆ DUCTagentTest() [2/2]

frodo2.algorithms.duct.tests.DUCTagentTest.DUCTagentTest ( boolean useTCP,
boolean useCentralMailer,
Class< ? extends XCSPparser< AddableInteger, AddableReal > > parserClass,
boolean measureMsgs,
String samplingMethod,
String termination,
String bound )

Creates a JUnit test case corresponding to the input method.

Parameters
useTCPwhether TCP pipes should be used for communication between agents
useCentralMailertrue when the central mailer should be tested
parserClassthe class of the parser/subsolver
measureMsgswhether to measure message numbers and sizes
samplingMethodThe sampling method to be used
terminationThe termination method to be used
boundThe bound to be used

References bound, measureMsgs, parserClass, samplingMethod, useCentralMailer, and useTCP.

Member Function Documentation

◆ checkOutput()

void frodo2.algorithms.duct.tests.DUCTagentTest.checkOutput ( ) throws Exception
protected

Checks that the output of the algorithm is correct.

Exceptions
Exceptionif an error occurs

Referenced by testRandom().

◆ getMsgTypes()

◆ notifyIn()

void frodo2.algorithms.duct.tests.DUCTagentTest.notifyIn ( Message msg)

◆ setQueue()

void frodo2.algorithms.duct.tests.DUCTagentTest.setQueue ( Queue queue)

◆ setStartMsgType()

void frodo2.algorithms.duct.tests.DUCTagentTest.setStartMsgType ( MessageType startMsgType) throws JDOMException
protected

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

Reimplemented in frodo2.algorithms.duct.tests.DUCTagentPruningSearchTest, and frodo2.algorithms.duct.tests.DUCTagentPruningTest.

References agentConfig, frodo2.algorithms.AgentInterface< V extends Addable< V > >.START_AGENT, and startMsgType.

Referenced by frodo2.algorithms.duct.tests.DUCTagentChildSearchTest.setUp(), frodo2.algorithms.duct.tests.DUCTagentChildTest.setUp(), and setUp().

◆ setUp()

◆ suite()

TestSuite frodo2.algorithms.duct.tests.DUCTagentTest.suite ( )
static

◆ tearDown()

void frodo2.algorithms.duct.tests.DUCTagentTest.tearDown ( ) throws Exception
protected
See also
junit.framework.TestCase#tearDown()

References agents, graph, mailman, normModule, pipe, pipes, problem, problemDoc, queue, and samplingModule.

◆ testRandom()

void frodo2.algorithms.duct.tests.DUCTagentTest.testRandom ( ) throws Exception

Tests the DPOPagent on a random problem.

Exceptions
Exceptionif an error occurs
Bug
Often times out
Bug
Often times out

References agentConfig, agents, checkOutput(), frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.createAgent(), frodo2.communication.mailer.CentralMailer.execute(), graph, mailman, nbrAgents, nbrAgentsFinished, pipe, problem, queue, useCentralMailer, and useTCP.

Here is the call graph for this function:

Member Data Documentation

◆ agentConfig

◆ agents

Map< String, AgentInterface<AddableInteger> > frodo2.algorithms.duct.tests.DUCTagentTest.agents
private

All agents, indexed by their IDs.

Referenced by tearDown(), and testRandom().

◆ bound

◆ finished

final Condition frodo2.algorithms.duct.tests.DUCTagentTest.finished = finished_lock.newCondition()
private

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

◆ finished_lock

final ReentrantLock frodo2.algorithms.duct.tests.DUCTagentTest.finished_lock = new ReentrantLock ()
private

Used to make the test thread wait.

◆ graph

◆ mailman

◆ maximize

boolean frodo2.algorithms.duct.tests.DUCTagentTest.maximize = true
protected

Whether we should maximize or minimize.

◆ maxNbrAgents

◆ maxNbrEdges

final int frodo2.algorithms.duct.tests.DUCTagentTest.maxNbrEdges = 20
protected

◆ maxNbrVars

final int frodo2.algorithms.duct.tests.DUCTagentTest.maxNbrVars = 5
protected

◆ measureMsgs

◆ nbrAgents

int frodo2.algorithms.duct.tests.DUCTagentTest.nbrAgents
private

Total number of agents.

Referenced by notifyIn(), and testRandom().

◆ nbrAgentsFinished

◆ nbrMsgsReceived

int frodo2.algorithms.duct.tests.DUCTagentTest.nbrMsgsReceived
protected

◆ normModule

Normalize<AddableInteger> frodo2.algorithms.duct.tests.DUCTagentTest.normModule
protected

The module listening for the optimal utility to the problem.

Referenced by tearDown().

◆ parserClass

◆ pipe

QueueIOPipe frodo2.algorithms.duct.tests.DUCTagentTest.pipe
private

The testers pipe.

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

◆ pipes

◆ problem

◆ problemDoc

◆ queue

◆ samplingMethod

◆ samplingModule

◆ startMsgType

◆ terminationMethod

◆ useCentralMailer

◆ useTCP


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