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

JUnit test for DPOPagent. More...

Inheritance diagram for frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >:

Public Member Functions

 DPOPagentTest (boolean useXCSP, boolean useTCP, boolean useCentralMailer, boolean useDelay, Class< V > domClass, Class< U > utilClass)
 Creates a JUnit test case corresponding to the input method.
 DPOPagentTest (boolean useXCSP, boolean swap, boolean minNCCCs, boolean countNCCCs, boolean ignoreHypercubeNCCCs)
 Constructor.
 DPOPagentTest (boolean useXCSP, boolean swap, boolean minNCCCs, boolean countNCCCs, boolean ignoreHypercubeNCCCs, String dpopPath)
 Constructor.
 DPOPagentTest (Class<? extends XCSPparser< V, U > > parserClass)
 Constructor for a test with a subsolver.
 DPOPagentTest (boolean useXCSP, boolean useTCP, boolean useCentralMailer, boolean useDelay, Class< V > domClass, Class< U > utilClass, MessageType startMsgType)
 Creates a JUnit test case corresponding to the input method.
 DPOPagentTest (boolean useXCSP, boolean useTCP, boolean useCentralMailer, boolean useDelay, Class< V > domClass, Class< U > utilClass, MessageType startMsgType, Class< ? extends XCSPparser< V, U > > parserClass, boolean swap, boolean minNCCCs, boolean countNCCCs, boolean measureMsgs, boolean ignoreHypercubeNCCCs)
 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

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
Document problemDoc
 The XCSP random problem file.
DCOPProblemInterface< V, U > problem
 The problem.
Class< V > domClass
 The class used for variable values.
Class< U > utilClass
 The class used for utility values.
UTILpropagation< V, U > utilModule
 The module listening for the optimal utility to the problem.
SolutionCollector< V, U > solCollector
 The module listening for the optimal assignment to the problem.
boolean useXCSP
 Whether to use XCSP.
MessageType startMsgType
 The type of the start message.
boolean countNCCCs
 Whether to count NCCCs.
boolean maximize = true
 Whether we should maximize or minimize.
CentralMailer mailman
 The CentralMailer.
boolean aggregate = false
 true when the weighted sum hypercube should be tested

Private Member Functions

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 = 50
 Maximum number of binary constraints in the problem.
final int maxNbrAgents = 10
 Maximum number of agents.
String dpopPath = "src/frodo2/algorithms/dpop/DPOPagent.xml"
 The path to DPOPagent.xml.
QueueIOPipe pipe
 The testers pipe.
Map< String, AgentInterface< V > > 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 useDelay
 true when the central mailer is to be tested with delays
boolean measureMsgs
 Whether to measure message numbers and sizes.
Class< ? extends XCSPparser< V, U > > parserClass
 The class of the parser/subsolver to use.
boolean useTCP
 Whether TCP pipes should be used for communication between agents.
boolean minNCCCs
 Whether to optimize runtime or NCCC count.
boolean ignoreHypercubeNCCCs
 Whether to ignore Hypercube NCCCs or not.
boolean swap
 Whether we should swap.

Detailed Description

JUnit test for DPOPagent.

Author
Thomas Leaute
Parameters
<V>the type used for variable values
<U>the type used for utility values
Todo
Many tests should inherit this class to favor code reuse.

Constructor & Destructor Documentation

◆ DPOPagentTest() [1/6]

frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.DPOPagentTest ( boolean useXCSP,
boolean useTCP,
boolean useCentralMailer,
boolean useDelay,
Class< V > domClass,
Class< U > utilClass )

Creates a JUnit test case corresponding to the input method.

Parameters
useXCSPwhether to use XCSP
useTCPwhether TCP pipes should be used for communication between agents
useCentralMailertrue when the central mailer should be tested
useDelaytrue when the central mailer should be tested with a delay
domClassthe class to be used for variable values
utilClassthe class to be used for utility values

References domClass, DPOPagentTest(), useCentralMailer, useDelay, useTCP, useXCSP, and utilClass.

Referenced by DPOPagentTest(), DPOPagentTest(), DPOPagentTest(), DPOPagentTest(), and suite().

Here is the call graph for this function:

◆ DPOPagentTest() [2/6]

frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.DPOPagentTest ( boolean useXCSP,
boolean swap,
boolean minNCCCs,
boolean countNCCCs,
boolean ignoreHypercubeNCCCs )

Constructor.

Parameters
useXCSPwhether to use XCSP
swapwhether we should swap
minNCCCswhether to optimize runtime or NCCC count
countNCCCswhether to count NCCCs
ignoreHypercubeNCCCsWhether to ignore Hypercube NCCCs or not

References countNCCCs, DPOPagentTest(), ignoreHypercubeNCCCs, minNCCCs, swap, and useXCSP.

Here is the call graph for this function:

◆ DPOPagentTest() [3/6]

frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.DPOPagentTest ( boolean useXCSP,
boolean swap,
boolean minNCCCs,
boolean countNCCCs,
boolean ignoreHypercubeNCCCs,
String dpopPath )

Constructor.

Parameters
useXCSPwhether to use XCSP
swapwhether we should swap
minNCCCswhether to optimize runtime or NCCC count
countNCCCswhether to count NCCCs
ignoreHypercubeNCCCsWhether to ignore Hypercube NCCCs or not
dpopPathThe path the the DPOP agent configuration file

References countNCCCs, dpopPath, ignoreHypercubeNCCCs, minNCCCs, swap, and useXCSP.

◆ DPOPagentTest() [4/6]

frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.DPOPagentTest ( Class<? extends XCSPparser< V, U > > parserClass)

Constructor for a test with a subsolver.

Parameters
parserClassclass of the parser/subsolver

References DPOPagentTest(), and parserClass.

Here is the call graph for this function:

◆ DPOPagentTest() [5/6]

frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.DPOPagentTest ( boolean useXCSP,
boolean useTCP,
boolean useCentralMailer,
boolean useDelay,
Class< V > domClass,
Class< U > utilClass,
MessageType startMsgType )

Creates a JUnit test case corresponding to the input method.

Parameters
useXCSPwhether to use XCSP
useTCPwhether TCP pipes should be used for communication between agents
useCentralMailertrue when the central mailer should be tested
useDelaytrue when the central mailer should be tested with a delay
domClassthe class to be used for variable values
utilClassthe class to be used for utility values
startMsgTypethe type of the start message

References domClass, DPOPagentTest(), startMsgType, useCentralMailer, useDelay, useTCP, useXCSP, and utilClass.

Here is the call graph for this function:

◆ DPOPagentTest() [6/6]

frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.DPOPagentTest ( boolean useXCSP,
boolean useTCP,
boolean useCentralMailer,
boolean useDelay,
Class< V > domClass,
Class< U > utilClass,
MessageType startMsgType,
Class< ? extends XCSPparser< V, U > > parserClass,
boolean swap,
boolean minNCCCs,
boolean countNCCCs,
boolean measureMsgs,
boolean ignoreHypercubeNCCCs )

Creates a JUnit test case corresponding to the input method.

Parameters
useXCSPwhether to use XCSP
useTCPwhether TCP pipes should be used for communication between agents
useCentralMailertrue when the central mailer should be tested
useDelaytrue when the central mailer should be tested with a delay
domClassthe class to be used for variable values
utilClassthe class to be used for utility values
startMsgTypethe type of the start message
parserClassthe class of the parser/subsolver
swapwhether we should swap
minNCCCswhether to optimize runtime or NCCC count
countNCCCswhether to count NCCCs
measureMsgswhether to measure message numbers and sizes
ignoreHypercubeNCCCsWhether to ignore Hypercube NCCCs or not

References countNCCCs, domClass, ignoreHypercubeNCCCs, measureMsgs, minNCCCs, parserClass, startMsgType, swap, useCentralMailer, useDelay, useTCP, useXCSP, and utilClass.

Member Function Documentation

◆ checkOutput()

◆ getMsgTypes()

◆ notifyIn()

◆ setQueue()

void frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.setQueue ( Queue queue)

◆ setStartMsgType() [1/2]

void frodo2.algorithms.dpop.test.DPOPagentTest< 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.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.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

References agentConfig, 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()

void frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.setUp ( ) throws Exception
See also
junit.framework.TestCase#setUp()

Reimplemented in frodo2.algorithms.afb.test.AFBagentTest< V extends Addable< V >, U extends Addable< U > >, frodo2.algorithms.dpop.param.test.ParamDPOPtest< V extends Addable< V >, U extends Addable< U > >, frodo2.algorithms.dpop.stochastic.robust.test.Robust_E_DPOPagentTest< V extends Addable< V > >, frodo2.algorithms.dpop.stochastic.test.E_DPOPagentTest< V extends Addable< V > >, and frodo2.algorithms.synchbb.test.SynchBBagentTest< V extends Addable< V >, U extends Addable< U > >.

References frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.addSpaceToIgnore(), agentConfig, domClass, frodo2.algorithms.test.AllTests.generateProblem(), frodo2.algorithms.RandGraphFactory.getRandGraph(), frodo2.algorithms.varOrdering.dfs.DFSgeneration< V extends Addable< V >, U extends Addable< U > >.getStatsFromQueue(), graph, mailman, maxNbrAgents, maxNbrEdges, maxNbrVars, minNCCCs, nbrAgentsFinished, nbrMsgsReceived, frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.newInstance(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.parse(), parserClass, pipes, problem, problemDoc, queue, frodo2.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.reset(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.setDomClass(), frodo2.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.setDomClass(), frodo2.algorithms.varOrdering.dfs.DFSgeneration< V extends Addable< V >, U extends Addable< U > >.setSilent(), setStartMsgType(), frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.setUtilClass(), frodo2.solutionSpaces.ProblemInterface< V extends Addable< V >, U extends Addable< U > >.setUtilClass(), solCollector, frodo2.algorithms.AgentInterface< V extends Addable< V > >.STATS_MONITOR, swap, utilClass, and utilModule.

Here is the call graph for this function:

◆ suite()

◆ tearDown()

◆ testRandom()

void frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.testRandom ( ) throws Exception

Member Data Documentation

◆ agentConfig

◆ agents

Map< String, AgentInterface<V> > frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.agents
private

All agents, indexed by their IDs.

Referenced by tearDown(), and testRandom().

◆ aggregate

boolean frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.aggregate = false
protected

true when the weighted sum hypercube should be tested

◆ countNCCCs

◆ domClass

◆ dpopPath

String frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.dpopPath = "src/frodo2/algorithms/dpop/DPOPagent.xml"
private

The path to DPOPagent.xml.

Referenced by DPOPagentTest().

◆ finished

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

Used to make the test thread wait.

◆ graph

◆ ignoreHypercubeNCCCs

boolean frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.ignoreHypercubeNCCCs
private

Whether to ignore Hypercube NCCCs or not.

Referenced by DPOPagentTest(), DPOPagentTest(), and DPOPagentTest().

◆ mailman

◆ maximize

◆ maxNbrAgents

final int frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.maxNbrAgents = 10
private

Maximum number of agents.

Referenced by setUp().

◆ maxNbrEdges

final int frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.maxNbrEdges = 50
private

Maximum number of binary constraints in the problem.

Referenced by setUp().

◆ maxNbrVars

final int frodo2.algorithms.dpop.test.DPOPagentTest< 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 setUp().

◆ measureMsgs

boolean frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.measureMsgs
private

Whether to measure message numbers and sizes.

Referenced by DPOPagentTest().

◆ minNCCCs

boolean frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.minNCCCs
private

Whether to optimize runtime or NCCC count.

Referenced by DPOPagentTest(), DPOPagentTest(), DPOPagentTest(), and setUp().

◆ nbrAgents

int frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.nbrAgents
private

Total number of agents.

Referenced by notifyIn(), and testRandom().

◆ nbrAgentsFinished

◆ nbrMsgsReceived

◆ parserClass

Class< ? extends XCSPparser<V, U> > frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.parserClass
private

The class of the parser/subsolver to use.

Referenced by checkOutput(), DPOPagentTest(), DPOPagentTest(), and setUp().

◆ pipe

QueueIOPipe frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.pipe
private

The testers pipe.

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

◆ pipes

◆ problem

◆ problemDoc

◆ queue

◆ solCollector

◆ startMsgType

◆ swap

boolean frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.swap
private

Whether we should swap.

Referenced by DPOPagentTest(), DPOPagentTest(), DPOPagentTest(), and setUp().

◆ useCentralMailer

◆ useDelay

boolean frodo2.algorithms.dpop.test.DPOPagentTest< V extends Addable< V >, U extends Addable< U > >.useDelay
private

true when the central mailer is to be tested with delays

Referenced by DPOPagentTest(), DPOPagentTest(), and DPOPagentTest().

◆ useTCP

◆ useXCSP

◆ utilClass

◆ utilModule


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