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

A convenience class to create agents. More...

Inheritance diagram for frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >:

Public Member Functions

 AgentFactory (Document problemDesc, Document agentDesc)
 Constructor.
 AgentFactory (Document problemDesc, Document agentDesc, String outputFilePath)
 Constructor.
 AgentFactory (Document problemDesc, Document agentDesc, long timeout)
 Constructor.
 AgentFactory (Document problemDesc, Document agentDesc, String outputFilePath, long timeout)
 Constructor.
 AgentFactory (Document problemDesc, Document agentDesc, Collection<? extends StatsReporter > solGatherers)
 Constructor.
 AgentFactory (Document problemDesc, Document agentDesc, String outputFilePath, Collection<? extends StatsReporter > solGatherers, Long timeout, boolean statsToController)
 Constructor.
 AgentFactory (Document problemDesc, Document agentDesc, Collection<? extends StatsReporter > solGatherers, Long timeout, boolean statsToController)
 Constructor.
 AgentFactory (Document problemDesc, Document agentDesc, Collection<? extends StatsReporter > solGatherers, Long timeout, boolean useTCP, boolean statsToController)
 Constructor.
 AgentFactory (Document problemDesc, Document agentDesc, String outputFilePath, Collection<? extends StatsReporter > solGatherers, Long timeout, boolean useTCP, boolean statsToController)
 Constructor.
 AgentFactory (ProblemInterface< V, U > problem, Document agentDesc, Collection<? extends StatsReporter > solGatherers, Long timeout)
 Constructor.
 AgentFactory (ProblemInterface< V, U > problem, Document agentDesc, Collection<? extends StatsReporter > solGatherers, Long timeout, boolean useTCP)
 Constructor.
 AgentFactory (ProblemInterface< V, U > problem, Document agentDesc, Collection<? extends StatsReporter > solGatherers, Long timeout, boolean useTCP, boolean statsToController)
 Constructor.
 AgentFactory (ProblemInterface< V, U > problem, Document agentDesc, String outputFilePath, Collection<? extends StatsReporter > solGatherers, Long timeout, boolean useTCP, boolean statsToController)
 Constructor.
void restart (ProblemInterface< V, U > problem)
 Restarts the algorithm on a new problem.
void end ()
 Kills all agents and threads.
Collection< MessageTypegetMsgTypes ()
void notifyIn (Message msg)
void setQueue (Queue queue)
 Does nothing.
long getNcccs ()
long getTime ()
int getNbrMsgs ()
long getTotalMsgSize ()
long getOverallMaxMsgSize ()
TreeMap< MessageType, Integer > getMsgNbrs ()
TreeMap< Object, Integer > getMsgNbrsSentPerAgent ()
TreeMap< Object, Integer > getMsgNbrsReceivedPerAgent ()
TreeMap< MessageType, Long > getMsgSizes ()
TreeMap< Object, Long > getMsgSizesSentPerAgent ()
TreeMap< Object, Long > getMsgSizesReceivedPerAgent ()
TreeMap< MessageType, Long > getMaxMsgSizes ()
boolean timedOut ()
boolean outOfMemory ()
Map< String, V > getCurrentSolution ()
 Method used to obtain the final solution in the case of a time out or an OutOfMemory exceptions.
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< V extends Addable< V > U extends Addable< U > AgentInterface< V > createAgent (QueueOutputPipeInterface toDaemonPipe, QueueOutputPipeInterface toControllerPipe, ProblemInterface< V, U > probDesc, Document agentDesc, int port)
static< V extends Addable< V > U extends Addable< U > AgentInterface< V > createAgent (QueueOutputPipeInterface toDaemonPipe, QueueOutputPipeInterface toControllerPipe, ProblemInterface< V, U > probDesc, Document agentDesc, boolean statsToController, int port)
static< V extends Addable< V > U extends Addable< U > AgentInterface< V > createAgent (QueueOutputPipeInterface controllerPipe, ProblemInterface< V, U > probDesc, Document agentDesc, CentralMailer mailman)
static void main (String[] args)
 Runs the input algorithm on the input problem.
static void printMsgStats (Map< MessageType, Integer > msgNbrs, Map< Object, Integer > msgNbrsSentPerAgent, Map< Object, Integer > msgNbrsReceivedPerAgent, Map< MessageType, Long > msgSizes, Map< Object, Long > msgSizesSentPerAgent, Map< Object, Long > msgSizesReceivedPerAgent, Map< MessageType, Long > maxMsgSizes)
 Prints the message statistics.

Static Public Attributes

static long DEFAULT_TIMEOUT = 600000
 The default timeout in milliseconds.

Protected Member Functions

 AgentFactory ()
 Empty constructor.

Static Package Functions

 [static initializer]

Private Member Functions

void init (Collection<? extends StatsReporter > solGatherers, Long timeout, boolean statsToController)
 Convenience method called by constructors to reuse code.
ProblemInterface parseProblem (Document problemDesc) throws ClassNotFoundException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
 Parses the given problem.
void waitForEnd ()
 Waits for the algorithm to terminate.
void writeSol ()
 Writes the reported solution to the output file.

Static Private Member Functions

static boolean assertWarning ()
 Prints a warning a returns true.
static< V extends Addable< V > U extends Addable< U > AgentInterface< V > instantiateAgent (ProblemInterface< V, U > probDesc, Document agentDesc, CentralMailer mailman) throws ClassNotFoundException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException

Private Attributes

Queue queue
 The queue used to listen to the agents.
int nbrAgents
 Total number of agents.
Map< String, AgentInterface< V > > agents
 All agents, indexed by their IDs.
Map< String, ProblemInterface< V, U > > subProbs
 Each agent's subproblem.
int nbrAgentsFinished
 Number of agents finished.
Object nbrAgentsFinished_lock = new Object ()
 Used to synchronize access to nbrAgentsFinished.
boolean done = false
 Whether the agents have finished.
Map< Object, QueueOutputPipeInterfacepipes = new HashMap<Object, QueueOutputPipeInterface> ()
 For each agent, its input pipe.
QueueIOPipe pipe
 The central listener's own pipe.
int nbrMsgsReceived = 0
 Used to track the number of various types of messages received from the agents.
final boolean measureMsgs
 Whether to measure the number of messages and the total amount of information sent.
TreeMap< MessageType, Integer > msgNbrs = new TreeMap<MessageType, Integer> ()
 For each message type, the number of messages sent of that type.
TreeMap< Object, Integer > msgNbrsSentPerAgent = new TreeMap<Object, Integer> ()
 For each agent, the number of messages sent by that agent.
TreeMap< Object, Integer > msgNbrsReceivedPerAgent = new TreeMap<Object, Integer> ()
 For each agent, the number of messages received by that agent.
TreeMap< MessageType, Long > msgSizes = new TreeMap<MessageType, Long> ()
 For each message type, the total amount of information sent in messages of that type, in bytes.
TreeMap< Object, Long > msgSizesSentPerAgent = new TreeMap<Object, Long> ()
 For each agent, the total amount of information sent by that agent, in bytes.
TreeMap< Object, Long > msgSizesReceivedPerAgent = new TreeMap<Object, Long> ()
 For each agent, the total amount of information received by that agent, in bytes.
TreeMap< MessageType, Long > maxMsgSizes = new TreeMap<MessageType, Long> ()
 For each message type, the size (in bytes) of the largest message.
boolean statsToController
 If true, stats should be sent to the controller; else, to the daemon.
long startTime
 The start time of the algorithm, in milliseconds.
boolean silent = false
 Whether information should be printed out.
long finalTime = -1
 The timestamp (in nanoseconds) of the AGENT_FINISHED message with the highest time stamp.
long finalNCCCcount = -1
 The nccc stamp of the AGENT_FINISHED message with the highest nccc stamp.
long timeout = DEFAULT_TIMEOUT
 The timeout in milliseconds.
boolean timedOut = false
 true when the agent factory timed out before all the agents finished
final boolean measureTime
 Whether we should measure simulated time (true) or wall clock time (false).
Document agentDesc
 The agent configuration.
ProblemInterface< V, U > problem
 The problem.
CentralMailer mailman
 The CentralMailer.
final boolean useTCP
 Whether to use TCP pipes or shared memory pipes.
boolean outOfMemory
 true when algorithm ran out of memory
final String outputFilePath
 The path to the output file.
SolutionCollector< V, U > solCollector
 The solution collector.

Static Private Attributes

static int port = 5000
 The TCP port used for the first agent, which gets incremented for each subsequent agent.

Detailed Description

A convenience class to create agents.

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

Constructor & Destructor Documentation

◆ AgentFactory() [1/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( )
protected

Empty constructor.

Referenced by [static initializer](), AgentFactory(), init(), main(), and restart().

◆ AgentFactory() [2/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( Document problemDesc,
Document agentDesc )

Constructor.

Parameters
problemDescthe problem description
agentDescthe agent description

References agentDesc.

◆ AgentFactory() [3/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( Document problemDesc,
Document agentDesc,
String outputFilePath )

Constructor.

Parameters
problemDescthe problem description
agentDescthe agent description
outputFilePaththe path to the output file

References agentDesc, and outputFilePath.

◆ AgentFactory() [4/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( Document problemDesc,
Document agentDesc,
long timeout )

Constructor.

Parameters
problemDescthe problem description
agentDescthe agent description
timeoutthe timeout in milliseconds

References agentDesc, and timeout.

◆ AgentFactory() [5/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( Document problemDesc,
Document agentDesc,
String outputFilePath,
long timeout )

Constructor.

Parameters
problemDescthe problem description
agentDescthe agent description
outputFilePaththe path to the output file
timeoutthe timeout in milliseconds

References agentDesc, outputFilePath, and timeout.

◆ AgentFactory() [6/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( Document problemDesc,
Document agentDesc,
Collection<? extends StatsReporter > solGatherers )

Constructor.

Parameters
problemDescthe problem description
agentDescthe agent description
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)

References agentDesc.

◆ AgentFactory() [7/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( Document problemDesc,
Document agentDesc,
String outputFilePath,
Collection<? extends StatsReporter > solGatherers,
Long timeout,
boolean statsToController )

Constructor.

Parameters
problemDescthe problem description
agentDescthe agent description
outputFilePaththe path to the output file
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)
timeoutthe timeout, in milliseconds. If null, uses the default timeout.
statsToControllerif true, stats should be sent to the controller; else, to the daemon

References agentDesc, outputFilePath, statsToController, and timeout.

◆ AgentFactory() [8/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( Document problemDesc,
Document agentDesc,
Collection<? extends StatsReporter > solGatherers,
Long timeout,
boolean statsToController )

Constructor.

Parameters
problemDescthe problem description
agentDescthe agent description
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)
timeoutthe timeout, in milliseconds. If null, uses the default timeout.
statsToControllerif true, stats should be sent to the controller; else, to the daemon

References agentDesc, statsToController, and timeout.

◆ AgentFactory() [9/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( Document problemDesc,
Document agentDesc,
Collection<? extends StatsReporter > solGatherers,
Long timeout,
boolean useTCP,
boolean statsToController )

Constructor.

Parameters
problemDescthe problem description
agentDescthe agent description
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)
timeoutthe timeout, in milliseconds. If null, uses the default timeout.
useTCPWhether to use TCP pipes or shared memory pipes
statsToControllerif true, stats should be sent to the controller; else, to the daemon

References agentDesc, statsToController, timeout, and useTCP.

◆ AgentFactory() [10/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( Document problemDesc,
Document agentDesc,
String outputFilePath,
Collection<? extends StatsReporter > solGatherers,
Long timeout,
boolean useTCP,
boolean statsToController )

Constructor.

Parameters
problemDescthe problem description
agentDescthe agent description
outputFilePaththe path to the output file
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)
timeoutthe timeout, in milliseconds. If null, uses the default timeout.
useTCPWhether to use TCP pipes or shared memory pipes
statsToControllerif true, stats should be sent to the controller; else, to the daemon

References agentDesc, AgentFactory(), measureMsgs, measureTime, outputFilePath, parseProblem(), problem, statsToController, timeout, and useTCP.

Here is the call graph for this function:

◆ AgentFactory() [11/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( ProblemInterface< V, U > problem,
Document agentDesc,
Collection<? extends StatsReporter > solGatherers,
Long timeout )

Constructor.

Parameters
problemthe problem
agentDescthe agent description
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)
timeoutthe timeout, in milliseconds. If null, uses the default timeout.

References agentDesc, problem, and timeout.

◆ AgentFactory() [12/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( ProblemInterface< V, U > problem,
Document agentDesc,
Collection<? extends StatsReporter > solGatherers,
Long timeout,
boolean useTCP )

Constructor.

Parameters
problemthe problem
agentDescthe agent description
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)
timeoutthe timeout, in milliseconds. If null, uses the default timeout.
useTCPWhether to use TCP pipes or shared memory pipes

References agentDesc, problem, timeout, and useTCP.

◆ AgentFactory() [13/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( ProblemInterface< V, U > problem,
Document agentDesc,
Collection<? extends StatsReporter > solGatherers,
Long timeout,
boolean useTCP,
boolean statsToController )

Constructor.

Parameters
problemthe problem
agentDescthe agent description
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)
timeoutthe timeout, in milliseconds. If null, uses the default timeout.
useTCPWhether to use TCP pipes or shared memory pipes
statsToControllerif true, stats should be sent to the controller; else, to the daemon

References agentDesc, problem, statsToController, timeout, and useTCP.

◆ AgentFactory() [14/14]

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.AgentFactory ( ProblemInterface< V, U > problem,
Document agentDesc,
String outputFilePath,
Collection<? extends StatsReporter > solGatherers,
Long timeout,
boolean useTCP,
boolean statsToController )

Constructor.

Parameters
problemthe problem
agentDescthe agent description
outputFilePaththe path to the output file
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)
timeoutthe timeout, in milliseconds. If null, uses the default timeout.
useTCPWhether to use TCP pipes or shared memory pipes
statsToControllerif true, stats should be sent to the controller; else, to the daemon

References agentDesc, init(), measureMsgs, measureTime, outputFilePath, problem, statsToController, timeout, and useTCP.

Here is the call graph for this function:

Member Function Documentation

◆ [static initializer]()

frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.[static initializer]
staticpackage

References AgentFactory(), and assertWarning().

Here is the call graph for this function:

◆ assertWarning()

boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.assertWarning ( )
staticprivate

Prints a warning a returns true.

Returns
true

Referenced by [static initializer]().

◆ createAgent() [1/3]

static< V extends Addable< V > U extends Addable< U > AgentInterface< V > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.createAgent ( QueueOutputPipeInterface controllerPipe,
ProblemInterface< V, U > probDesc,
Document agentDesc,
CentralMailer mailman )
static

◆ createAgent() [2/3]

static< V extends Addable< V > U extends Addable< U > AgentInterface< V > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.createAgent ( QueueOutputPipeInterface toDaemonPipe,
QueueOutputPipeInterface toControllerPipe,
ProblemInterface< V, U > probDesc,
Document agentDesc,
boolean statsToController,
int port )
static

◆ createAgent() [3/3]

static< V extends Addable< V > U extends Addable< U > AgentInterface< V > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.createAgent ( QueueOutputPipeInterface toDaemonPipe,
QueueOutputPipeInterface toControllerPipe,
ProblemInterface< V, U > probDesc,
Document agentDesc,
int port )
static

◆ end()

◆ getCurrentSolution()

Map< String, V > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getCurrentSolution ( )

Method used to obtain the final solution in the case of a time out or an OutOfMemory exceptions.

Author
Brammert Ottens, Thomas Leaute
Returns
the solution found by the algorithm upon termination

References agents.

◆ getMaxMsgSizes()

TreeMap< MessageType, Long > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getMaxMsgSizes ( )
Returns
for each message type, the size (in bytes) of the largest message of that type

◆ getMsgNbrs()

TreeMap< MessageType, Integer > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getMsgNbrs ( )
Author
Brammert Ottens, 24 aug 2009
Returns
the total number of messages that have been sent

◆ getMsgNbrsReceivedPerAgent()

TreeMap< Object, Integer > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getMsgNbrsReceivedPerAgent ( )
Returns
the number of messages received by each agent

References msgNbrsReceivedPerAgent.

◆ getMsgNbrsSentPerAgent()

TreeMap< Object, Integer > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getMsgNbrsSentPerAgent ( )
Returns
the number of messages sent by each agent

References msgNbrsSentPerAgent.

◆ getMsgSizes()

TreeMap< MessageType, Long > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getMsgSizes ( )
Author
Brammert Ottens, 24 aug 2009
Returns
the total amount of information that has been sent

◆ getMsgSizesReceivedPerAgent()

TreeMap< Object, Long > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getMsgSizesReceivedPerAgent ( )
Returns
the amount of information received by each agent, in bytes

References msgSizesReceivedPerAgent.

◆ getMsgSizesSentPerAgent()

TreeMap< Object, Long > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getMsgSizesSentPerAgent ( )
Returns
the amount of information sent by each agent, in bytes

References msgSizesSentPerAgent.

◆ getMsgTypes()

◆ getNbrMsgs()

int frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getNbrMsgs ( )
Returns
the total number of messages sent

◆ getNcccs()

long frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getNcccs ( )
Returns
the total number of ncccs used during experimentation

◆ getOverallMaxMsgSize()

long frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getOverallMaxMsgSize ( )
Returns
the size (in bytes) of the largest message

◆ getTime()

long frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getTime ( )
Returns
the total needed time, equal to the highest timestamp across all AGENT_FINISHED messages received (in milliseconds)

References finalTime.

◆ getTotalMsgSize()

long frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.getTotalMsgSize ( )
Returns
the total amount of information sent, in bytes

◆ init()

void frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.init ( Collection<? extends StatsReporter > solGatherers,
Long timeout,
boolean statsToController )
private

Convenience method called by constructors to reuse code.

Parameters
solGathererslisteners that will be notified of the statistics sent by the agents (if not null, behaves silently)
timeoutthe timeout, in milliseconds. If null, uses the default timeout.
statsToControllerif true, stats should be sent to the controller; else, to the daemon

References agentDesc, AgentFactory(), agents, frodo2.algorithms.SolutionCollector< V extends Addable< V >, U extends Addable< U > >.getStatsFromQueue(), frodo2.algorithms.StatsReporter.getStatsFromQueue(), init(), mailman, nbrAgents, pipe, port, problem, queue, silent, statsToController, subProbs, timeout, and useTCP.

Referenced by AgentFactory(), and init().

Here is the call graph for this function:

◆ instantiateAgent()

static< V extends Addable< V > U extends Addable< U > AgentInterface< V > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.instantiateAgent ( ProblemInterface< V, U > probDesc,
Document agentDesc,
CentralMailer mailman ) throws ClassNotFoundException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
staticprivate

References agentDesc, instantiateAgent(), and mailman.

Referenced by createAgent(), createAgent(), and instantiateAgent().

Here is the call graph for this function:

◆ main()

void frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.main ( String[] args)
static

Runs the input algorithm on the input problem.

Parameters
argsthe problem file and the agent description file
Todo

Test the simple mode.

Add a way to check the version number.

References AgentFactory(), frodo2.algorithms.test.AllTests.createRandProblem(), main(), outputFilePath, frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.parse(), problem, timeout, and frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.toString().

Referenced by main(), and frodo2.algorithms.test.MASparserTest.testSampleSolve().

Here is the call graph for this function:

◆ notifyIn()

void frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.notifyIn ( Message msg)
See also
IncomingMsgPolicyInterface.notifyIn(Message)
Todo
is this synchronization necessary?...
Todo
is this synchronization necessary?...
Todo
Also report communication stats after a timeout.

Implements frodo2.communication.IncomingMsgPolicyInterface< T >.

References frodo2.controller.WhitePages.CONNECT_AGENT, frodo2.communication.MessageType.equals(), frodo2.algorithms.AgentInterface< V extends Addable< V > >.LOCAL_AGENT_REPORTING, nbrAgents, notifyIn(), pipe, pipes, and queue.

Referenced by notifyIn().

Here is the call graph for this function:

◆ outOfMemory()

boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.outOfMemory ( )
Author
Brammert Ottens, 7 jan 2010
Returns
true when the algorithm ran out of memory

◆ parseProblem()

ProblemInterface frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.parseProblem ( Document problemDesc) throws ClassNotFoundException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
private

Parses the given problem.

Parameters
problemDescthe problem in XCSP format
Returns
the problem
Exceptions
ClassNotFoundExceptionif the parser class was not found
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 class is abstract
IllegalArgumentExceptionif the argument to the parser constructor is illegal

References frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.parse(), and parseProblem().

Referenced by AgentFactory(), and parseProblem().

Here is the call graph for this function:

◆ printMsgStats()

void frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.printMsgStats ( Map< MessageType, Integer > msgNbrs,
Map< Object, Integer > msgNbrsSentPerAgent,
Map< Object, Integer > msgNbrsReceivedPerAgent,
Map< MessageType, Long > msgSizes,
Map< Object, Long > msgSizesSentPerAgent,
Map< Object, Long > msgSizesReceivedPerAgent,
Map< MessageType, Long > maxMsgSizes )
static

Prints the message statistics.

Parameters
msgNbrsFor each message type, the number of messages sent of that type
msgNbrsSentPerAgentFor each agent, the number of messages sent by that agent
msgNbrsReceivedPerAgentFor each agent, the number of messages received by that agent
msgSizesFor each message type, the total amount of information sent in messages of that type, in bytes
msgSizesSentPerAgentFor each agent, the total amount of information sent by that agent, in bytes
msgSizesReceivedPerAgentFor each agent, the total amount of information received by that agent, in bytes
maxMsgSizesFor each message type, the size (in bytes) of the largest message

References maxMsgSizes, msgNbrs, msgNbrsReceivedPerAgent, msgNbrsSentPerAgent, msgSizes, msgSizesReceivedPerAgent, and msgSizesSentPerAgent.

◆ restart()

◆ setQueue()

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

◆ timedOut()

boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.timedOut ( )
Author
Brammert Ottens, 22 sep 2009
Returns
true when the agent factory timed

◆ waitForEnd()

void frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.waitForEnd ( )
private

Waits for the algorithm to terminate.

References agents, done, frodo2.communication.mailer.CentralMailer.execute(), startTime, timedOut, timeout, and writeSol().

Referenced by restart().

Here is the call graph for this function:

◆ writeSol()

void frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.writeSol ( )
private

Member Data Documentation

◆ agentDesc

◆ agents

Map< String, AgentInterface<V> > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.agents
private

All agents, indexed by their IDs.

Referenced by end(), getCurrentSolution(), init(), restart(), and waitForEnd().

◆ DEFAULT_TIMEOUT

long frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.DEFAULT_TIMEOUT = 600000
static

The default timeout in milliseconds.

Referenced by frodo2.communication.mailer.CentralMailer.execute().

◆ done

boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.done = false
private

Whether the agents have finished.

Referenced by waitForEnd().

◆ finalNCCCcount

long frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.finalNCCCcount = -1
private

The nccc stamp of the AGENT_FINISHED message with the highest nccc stamp.

◆ finalTime

long frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.finalTime = -1
private

The timestamp (in nanoseconds) of the AGENT_FINISHED message with the highest time stamp.

Referenced by getTime().

◆ mailman

CentralMailer frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.mailman
private

◆ maxMsgSizes

TreeMap<MessageType, Long> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.maxMsgSizes = new TreeMap<MessageType, Long> ()
private

For each message type, the size (in bytes) of the largest message.

Referenced by printMsgStats().

◆ measureMsgs

final boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.measureMsgs
private

Whether to measure the number of messages and the total amount of information sent.

Referenced by AgentFactory(), and AgentFactory().

◆ measureTime

final boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.measureTime
private

Whether we should measure simulated time (true) or wall clock time (false).

Referenced by AgentFactory(), and AgentFactory().

◆ msgNbrs

TreeMap<MessageType, Integer> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.msgNbrs = new TreeMap<MessageType, Integer> ()
private

For each message type, the number of messages sent of that type.

Referenced by printMsgStats().

◆ msgNbrsReceivedPerAgent

TreeMap<Object, Integer> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.msgNbrsReceivedPerAgent = new TreeMap<Object, Integer> ()
private

For each agent, the number of messages received by that agent.

Referenced by getMsgNbrsReceivedPerAgent(), and printMsgStats().

◆ msgNbrsSentPerAgent

TreeMap<Object, Integer> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.msgNbrsSentPerAgent = new TreeMap<Object, Integer> ()
private

For each agent, the number of messages sent by that agent.

Referenced by getMsgNbrsSentPerAgent(), and printMsgStats().

◆ msgSizes

TreeMap<MessageType, Long> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.msgSizes = new TreeMap<MessageType, Long> ()
private

For each message type, the total amount of information sent in messages of that type, in bytes.

Referenced by printMsgStats().

◆ msgSizesReceivedPerAgent

TreeMap<Object, Long> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.msgSizesReceivedPerAgent = new TreeMap<Object, Long> ()
private

For each agent, the total amount of information received by that agent, in bytes.

Referenced by getMsgSizesReceivedPerAgent(), and printMsgStats().

◆ msgSizesSentPerAgent

TreeMap<Object, Long> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.msgSizesSentPerAgent = new TreeMap<Object, Long> ()
private

For each agent, the total amount of information sent by that agent, in bytes.

Referenced by getMsgSizesSentPerAgent(), and printMsgStats().

◆ nbrAgents

int frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.nbrAgents
private

Total number of agents.

Referenced by init(), and notifyIn().

◆ nbrAgentsFinished

int frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.nbrAgentsFinished
private

Number of agents finished.

◆ nbrAgentsFinished_lock

Object frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.nbrAgentsFinished_lock = new Object ()
private

Used to synchronize access to nbrAgentsFinished.

◆ nbrMsgsReceived

int frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.nbrMsgsReceived = 0
private

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

◆ outOfMemory

boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.outOfMemory
private

true when algorithm ran out of memory

◆ outputFilePath

final String frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.outputFilePath
private

The path to the output file.

Referenced by AgentFactory(), AgentFactory(), AgentFactory(), AgentFactory(), AgentFactory(), and main().

◆ pipe

QueueIOPipe frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.pipe
private

The central listener's own pipe.

Referenced by init(), notifyIn(), and restart().

◆ pipes

Map<Object, QueueOutputPipeInterface> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.pipes = new HashMap<Object, QueueOutputPipeInterface> ()
private

For each agent, its input pipe.

Referenced by notifyIn().

◆ port

int frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.port = 5000
staticprivate

The TCP port used for the first agent, which gets incremented for each subsequent agent.

Referenced by createAgent(), createAgent(), init(), and restart().

◆ problem

ProblemInterface<V, U> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.problem
private

◆ queue

Queue frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.queue
private

The queue used to listen to the agents.

Referenced by end(), init(), notifyIn(), and setQueue().

◆ silent

boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.silent = false
private

Whether information should be printed out.

Referenced by init().

◆ solCollector

SolutionCollector<V, U> frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.solCollector
private

The solution collector.

◆ startTime

long frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.startTime
private

The start time of the algorithm, in milliseconds.

Referenced by waitForEnd().

◆ statsToController

boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.statsToController
private

If true, stats should be sent to the controller; else, to the daemon.

Referenced by AgentFactory(), AgentFactory(), AgentFactory(), AgentFactory(), AgentFactory(), AgentFactory(), createAgent(), init(), and restart().

◆ subProbs

Map< String, ProblemInterface<V, U> > frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.subProbs
private

Each agent's subproblem.

Referenced by init().

◆ timedOut

boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.timedOut = false
private

true when the agent factory timed out before all the agents finished

Referenced by waitForEnd().

◆ timeout

◆ useTCP

final boolean frodo2.algorithms.AgentFactory< V extends Addable< V >, U extends Addable< U > >.useTCP
private

Whether to use TCP pipes or shared memory pipes.

Referenced by AgentFactory(), AgentFactory(), AgentFactory(), AgentFactory(), AgentFactory(), and init().


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