FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.controller.ConfigurationManager Class Reference

The ConfigurationManager takes care of setting up the experiments. More...

Inheritance diagram for frodo2.controller.ConfigurationManager:

Public Member Functions

 ConfigurationManager (Controller control, boolean local, String workDir)
 The constructor of the Configuration manager.
 ConfigurationManager (Controller control, boolean local)
 The constructor of the Configuration manager.
Collection< MessageTypegetMsgTypes ()
void notifyIn (Message msg)
 The Configuration Manager is triggered by the reception of a CONFIGURATION message, containing a filename that points to the configuration file.
void setQueue (Queue queue)
int parseConfigurationFile (String configFile) throws JDOMException, IOException
 This function parses the "configuration" element in the experiment file.
boolean getDebug ()
 A getter function for testing purposes.
String getAgentDescription ()
 A getter function for testing purposes.
int getTimeOut ()
 A getter function for testing purposes.
String getLogClass ()
 A getter function for testing purposes.
String getResultFile ()
 A getter function for testing purposes.
HashMap< String, AgentAddressgetDaemonList ()
 A getter function for testing purposes.
long getNCCCs ()
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 Attributes

static final MessageType AGENT_CONFIGURATION_MESSAGE = MessageType.SYSTEM.newChild("ConfigurationManager", "Agent-Configuration")
 The message send to the Daemon that contain the configuration of an agent.
static final MessageType REQUEST_DAEMONS_CONFIG_MSG = MessageType.SYSTEM.newChild("ConfigurationManager", "Request-Daemons-Config")
 The message type used to ask the white pages for a list of available daemons.
static final MessageType START = MessageType.SYSTEM.newChild("ConfigurationManager", "Start")
 Message used to tell the white pages that the algorithm can start.
static final MessageType CONNECT = MessageType.SYSTEM.newChild("ConfigurationManager", "Connect")
 Message used to tell the white pages that the agent can connect to their neighbours.
static final MessageType KILL_ALL_AGENTS = MessageType.SYSTEM.newChild("ConfigurationManager", "Kill-All-Agents")
 Message to signal to the white pages to kill the agents.
static final String END_TEXT = "All experiments are finished"
 The text displayed when the experiment is over.

Protected Member Functions

 ConfigurationManager ()
 Empty constructor.
void tellUser (String message)
 This function is used to send a message to the user via the UI.
void runExperiment (String filename)
 This file sets up a specific problem and tells the agents to run it.
void distributeAgents (DCOPProblemInterface<?, ?> problem) throws Exception
 Distributes the agents among the daemons.

Protected Attributes

Queue queue
 The queue on which it should call sendMessage().
ArrayList< MessageTypemsgTypes = new ArrayList <MessageType> ()
 The list of messages types this listener wants to be notified of.
Element problemList
 After the configuration file has been loaded, this contains a list of problems that will be solved when the experiment starts.
Document agentDescriptionDoc
 The JDOM Document describing the agent configuration.
int problem
 the experiment that is currently run
int numberOfAgents
 Number of agents in the problem that is currently run.
int numberOfAgentsFinished
 The number of agents that reported to be finished.
String workDir
 Folder containing the files mentioned in the configuration document.

Private Member Functions

void sendEmptyConfigs ()
 Sends empty configuration messages to all daemons, telling them to look up their own local config files.
void cleanProblem ()
 Reset all the fields used in monitoring the problem.

Private Attributes

Document configDoc
 contains the parsed XML tree with the configuration information
boolean debug
 when debug is true, debugging is enabled
String logClass
 logClass contains the name of the class that the agents should use when logging their actions
String agentDescriptionFile
 agentDescription contains the filename of the XML file that describes the default agent that should be used
int timeOut
 timeOut contains the maximum time any agent should run the algorithm.
String resultFile
 resultFile contains the file name of the file where the results of the experiments should be stored
HashMap< String, AgentAddressdaemonList
 The list of daemons that are available.
Controller control
 The main controller class.
String agentName
 The name of the agent, used to find the agent description when the configuration file is to be found in a jar file.
int numberOfAgentsReported
 The number of agents that reported to be white pages.
int numberOfAgentsConnected
 The number of agents that are connected to their children.
boolean local
 Used to determine whether experiments should be run local or not.
long finalNCCCcount = -1
 The nccc stamp of the AGENT_FINISHED message with the highest nccc stamp.
boolean measureMsgs = false
 Whether to measure the number of messages and the total amount of information sent.
TreeMap< MessageType, Integer > msgNbrs
 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
 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
 For each message type, the size (in bytes) of the largest message.
Collection< StatsReporterstatsReporters
 The statistics listeners.
long startTime
 The start time of the algorithm, in milliseconds.

Detailed Description

The ConfigurationManager takes care of setting up the experiments.

Author
Brammert Ottens
Thomas Leaute

Constructor & Destructor Documentation

◆ ConfigurationManager() [1/3]

frodo2.controller.ConfigurationManager.ConfigurationManager ( )
protected

Empty constructor.

Referenced by parseConfigurationFile().

◆ ConfigurationManager() [2/3]

frodo2.controller.ConfigurationManager.ConfigurationManager ( Controller control,
boolean local,
String workDir )

The constructor of the Configuration manager.

Parameters
controla pointer to the control to stop the UI when something goes wrong
localtrue if the experiments run on the same machine
workDirfolder containing the files mentioned in the configuration document. Must end with a slash.

References frodo2.algorithms.AgentInterface< V extends Addable< V > >.AGENT_CONNECTED, frodo2.algorithms.AgentInterface< V extends Addable< V > >.AGENT_FINISHED, frodo2.controller.WhitePages.AGENT_REPORTED, frodo2.controller.WhitePages.ALL_AGENTS_KILLED, frodo2.controller.userIO.UserIO.CONFIGURATION_MSG, control, frodo2.controller.WhitePages.DEAMONS_CONFIG_MSG, local, msgTypes, frodo2.controller.userIO.UserIO.START_MSG, and workDir.

◆ ConfigurationManager() [3/3]

frodo2.controller.ConfigurationManager.ConfigurationManager ( Controller control,
boolean local )

The constructor of the Configuration manager.

Parameters
controla pointer to the control to stop the UI when something goes wrong
localtrue if the experiments run on the same machine

References control, and local.

Member Function Documentation

◆ cleanProblem()

void frodo2.controller.ConfigurationManager.cleanProblem ( )
private

Reset all the fields used in monitoring the problem.

References frodo2.communication.Queue.deleteStatsReporters(), finalNCCCcount, numberOfAgents, numberOfAgentsConnected, numberOfAgentsFinished, numberOfAgentsReported, and statsReporters.

Here is the call graph for this function:

◆ distributeAgents()

void frodo2.controller.ConfigurationManager.distributeAgents ( DCOPProblemInterface<?, ?> problem) throws Exception
protected

Distributes the agents among the daemons.

Parameters
problemthe problem instance
Exceptions
Exceptionif an error occurs

Reimplemented in frodo2.daemon.LocalConfigManager.

References AGENT_CONFIGURATION_MESSAGE, daemonList, local, numberOfAgents, numberOfAgentsConnected, numberOfAgentsFinished, numberOfAgentsReported, problem, and queue.

Referenced by runExperiment().

◆ getAgentDescription()

String frodo2.controller.ConfigurationManager.getAgentDescription ( )

A getter function for testing purposes.

Returns
agentDescription

References agentDescriptionFile.

◆ getDaemonList()

HashMap< String, AgentAddress > frodo2.controller.ConfigurationManager.getDaemonList ( )

A getter function for testing purposes.

Returns
daemonList

References daemonList.

◆ getDebug()

boolean frodo2.controller.ConfigurationManager.getDebug ( )

A getter function for testing purposes.

Returns
debug

References debug.

◆ getLogClass()

String frodo2.controller.ConfigurationManager.getLogClass ( )

A getter function for testing purposes.

Returns
logClass

References logClass.

◆ getMsgTypes()

Collection< MessageType > frodo2.controller.ConfigurationManager.getMsgTypes ( )

◆ getNCCCs()

long frodo2.controller.ConfigurationManager.getNCCCs ( )
Returns
the maximum number of Non-Concurrent Constraint Checks

◆ getResultFile()

String frodo2.controller.ConfigurationManager.getResultFile ( )

A getter function for testing purposes.

Returns
resultFile

References resultFile.

◆ getTimeOut()

int frodo2.controller.ConfigurationManager.getTimeOut ( )

A getter function for testing purposes.

Returns
timeOut

References timeOut.

◆ notifyIn()

void frodo2.controller.ConfigurationManager.notifyIn ( Message msg)

The Configuration Manager is triggered by the reception of a CONFIGURATION message, containing a filename that points to the configuration file.

The configuration file is a XML file containing the following information

  • a list of problem descriptions: to be send to the different daemons
  • a result file : to store the results of a particular experiment
  • a class describing the default agent to be used
  • the following optional elements -> debugging yes/no -> which logging class to use -> the timeout that should be in place
    Parameters
    msgthe message that has been received

After the START_MSG has been received, adding a new daemon has no effect.

Todo
Perhaps in the future it would be interesting to be able to add daemons while the program is running.

When the white pages return a set of daemons, the experiments can start

An agent has reported itself

An agent is connected to all its neighbours

An agent has finished

All agents are killed, we are ready for the next problem to be solved

Implements frodo2.communication.IncomingMsgPolicyInterface< T >.

Reimplemented in frodo2.daemon.LocalConfigManager.

References frodo2.controller.userIO.UserIO.CONFIGURATION_MSG, frodo2.communication.MessageType.equals(), and notifyIn().

Referenced by notifyIn().

Here is the call graph for this function:

◆ parseConfigurationFile()

int frodo2.controller.ConfigurationManager.parseConfigurationFile ( String configFile) throws JDOMException, IOException

This function parses the "configuration" element in the experiment file.

Parameters
configFileA string containing the filename of the experimental file
Returns
0 when parsing succeeded and -1 if parsing failed
Exceptions
JDOMExceptionif an error occurred when parsing the configuration file
IOExceptionif an error occurred when accessing the configuration file

References agentDescriptionFile, agentName, configDoc, ConfigurationManager(), debug, logClass, problemList, resultFile, tellUser(), timeOut, and workDir.

Here is the call graph for this function:

◆ runExperiment()

void frodo2.controller.ConfigurationManager.runExperiment ( String filename)
protected

This file sets up a specific problem and tells the agents to run it.

Parameters
filenamethe name of the XCSP problem file (without the path)

References distributeAgents(), frodo2.algorithms.StatsReporter.getStatsFromQueue(), measureMsgs, frodo2.algorithms.XCSPparser< V extends Addable< V >, U extends Addable< U > >.parse(), problem, statsReporters, and workDir.

Referenced by frodo2.daemon.LocalConfigManager.notifyIn().

Here is the call graph for this function:

◆ sendEmptyConfigs()

void frodo2.controller.ConfigurationManager.sendEmptyConfigs ( )
private

Sends empty configuration messages to all daemons, telling them to look up their own local config files.

References AGENT_CONFIGURATION_MESSAGE, numberOfAgents, numberOfAgentsConnected, numberOfAgentsFinished, numberOfAgentsReported, and frodo2.communication.Queue.sendMessage().

Here is the call graph for this function:

◆ setQueue()

void frodo2.controller.ConfigurationManager.setQueue ( Queue queue)

◆ tellUser()

void frodo2.controller.ConfigurationManager.tellUser ( String message)
protected

This function is used to send a message to the user via the UI.

Parameters
messagethe message to be send to the user

References queue, and frodo2.controller.userIO.UserIO.USER_NOTIFICATION_MSG.

Referenced by frodo2.daemon.LocalConfigManager.notifyIn(), and parseConfigurationFile().

Member Data Documentation

◆ AGENT_CONFIGURATION_MESSAGE

◆ agentDescriptionDoc

Document frodo2.controller.ConfigurationManager.agentDescriptionDoc
protected

The JDOM Document describing the agent configuration.

Referenced by frodo2.daemon.LocalConfigManager.distributeAgents().

◆ agentDescriptionFile

String frodo2.controller.ConfigurationManager.agentDescriptionFile
private

agentDescription contains the filename of the XML file that describes the default agent that should be used

Todo
One should be able to define the agent type for each agent, in case they are not all the same.

Referenced by getAgentDescription(), and parseConfigurationFile().

◆ agentName

String frodo2.controller.ConfigurationManager.agentName
private

The name of the agent, used to find the agent description when the configuration file is to be found in a jar file.

Referenced by parseConfigurationFile().

◆ configDoc

Document frodo2.controller.ConfigurationManager.configDoc
private

contains the parsed XML tree with the configuration information

Referenced by parseConfigurationFile().

◆ CONNECT

final MessageType frodo2.controller.ConfigurationManager.CONNECT = MessageType.SYSTEM.newChild("ConfigurationManager", "Connect")
static

Message used to tell the white pages that the agent can connect to their neighbours.

Referenced by frodo2.daemon.LocalWhitePages.LocalWhitePages(), and frodo2.controller.WhitePages.WhitePages().

◆ control

Controller frodo2.controller.ConfigurationManager.control
private

The main controller class.

Referenced by ConfigurationManager(), and ConfigurationManager().

◆ daemonList

HashMap<String, AgentAddress> frodo2.controller.ConfigurationManager.daemonList
private

The list of daemons that are available.

Referenced by distributeAgents(), and getDaemonList().

◆ debug

boolean frodo2.controller.ConfigurationManager.debug
private

when debug is true, debugging is enabled

Referenced by getDebug(), and parseConfigurationFile().

◆ END_TEXT

final String frodo2.controller.ConfigurationManager.END_TEXT = "All experiments are finished"
static

◆ finalNCCCcount

long frodo2.controller.ConfigurationManager.finalNCCCcount = -1
private

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

Referenced by cleanProblem().

◆ KILL_ALL_AGENTS

final MessageType frodo2.controller.ConfigurationManager.KILL_ALL_AGENTS = MessageType.SYSTEM.newChild("ConfigurationManager", "Kill-All-Agents")
static

◆ local

boolean frodo2.controller.ConfigurationManager.local
private

Used to determine whether experiments should be run local or not.

Referenced by ConfigurationManager(), ConfigurationManager(), and distributeAgents().

◆ logClass

String frodo2.controller.ConfigurationManager.logClass
private

logClass contains the name of the class that the agents should use when logging their actions

Referenced by getLogClass(), and parseConfigurationFile().

◆ maxMsgSizes

TreeMap<MessageType, Long> frodo2.controller.ConfigurationManager.maxMsgSizes
private

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

◆ measureMsgs

boolean frodo2.controller.ConfigurationManager.measureMsgs = false
private

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

Referenced by runExperiment().

◆ msgNbrs

TreeMap<MessageType, Integer> frodo2.controller.ConfigurationManager.msgNbrs
private

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

◆ msgNbrsReceivedPerAgent

TreeMap<Object, Integer> frodo2.controller.ConfigurationManager.msgNbrsReceivedPerAgent = new TreeMap<Object, Integer> ()
private

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

◆ msgNbrsSentPerAgent

TreeMap<Object, Integer> frodo2.controller.ConfigurationManager.msgNbrsSentPerAgent = new TreeMap<Object, Integer> ()
private

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

◆ msgSizes

TreeMap<MessageType, Long> frodo2.controller.ConfigurationManager.msgSizes
private

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

◆ msgSizesReceivedPerAgent

TreeMap<Object, Long> frodo2.controller.ConfigurationManager.msgSizesReceivedPerAgent = new TreeMap<Object, Long> ()
private

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

◆ msgSizesSentPerAgent

TreeMap<Object, Long> frodo2.controller.ConfigurationManager.msgSizesSentPerAgent = new TreeMap<Object, Long> ()
private

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

◆ msgTypes

ArrayList<MessageType> frodo2.controller.ConfigurationManager.msgTypes = new ArrayList <MessageType> ()
protected

The list of messages types this listener wants to be notified of.

Referenced by ConfigurationManager(), and getMsgTypes().

◆ numberOfAgents

int frodo2.controller.ConfigurationManager.numberOfAgents
protected

Number of agents in the problem that is currently run.

Referenced by cleanProblem(), distributeAgents(), and sendEmptyConfigs().

◆ numberOfAgentsConnected

int frodo2.controller.ConfigurationManager.numberOfAgentsConnected
private

The number of agents that are connected to their children.

Referenced by cleanProblem(), distributeAgents(), and sendEmptyConfigs().

◆ numberOfAgentsFinished

int frodo2.controller.ConfigurationManager.numberOfAgentsFinished
protected

The number of agents that reported to be finished.

Referenced by cleanProblem(), distributeAgents(), and sendEmptyConfigs().

◆ numberOfAgentsReported

int frodo2.controller.ConfigurationManager.numberOfAgentsReported
private

The number of agents that reported to be white pages.

Referenced by cleanProblem(), distributeAgents(), and sendEmptyConfigs().

◆ problem

int frodo2.controller.ConfigurationManager.problem
protected

◆ problemList

Element frodo2.controller.ConfigurationManager.problemList
protected

After the configuration file has been loaded, this contains a list of problems that will be solved when the experiment starts.

Referenced by frodo2.daemon.LocalConfigManager.notifyIn(), and parseConfigurationFile().

◆ queue

Queue frodo2.controller.ConfigurationManager.queue
protected

The queue on which it should call sendMessage().

Referenced by distributeAgents(), frodo2.daemon.LocalConfigManager.notifyIn(), setQueue(), and tellUser().

◆ REQUEST_DAEMONS_CONFIG_MSG

final MessageType frodo2.controller.ConfigurationManager.REQUEST_DAEMONS_CONFIG_MSG = MessageType.SYSTEM.newChild("ConfigurationManager", "Request-Daemons-Config")
static

The message type used to ask the white pages for a list of available daemons.

Referenced by frodo2.controller.WhitePages.notifyIn(), and frodo2.controller.WhitePages.WhitePages().

◆ resultFile

String frodo2.controller.ConfigurationManager.resultFile
private

resultFile contains the file name of the file where the results of the experiments should be stored

Bug
The solution is never written to the file

Referenced by getResultFile(), and parseConfigurationFile().

◆ START

final MessageType frodo2.controller.ConfigurationManager.START = MessageType.SYSTEM.newChild("ConfigurationManager", "Start")
static

Message used to tell the white pages that the algorithm can start.

Referenced by frodo2.daemon.LocalWhitePages.LocalWhitePages(), and frodo2.controller.WhitePages.WhitePages().

◆ startTime

long frodo2.controller.ConfigurationManager.startTime
private

The start time of the algorithm, in milliseconds.

◆ statsReporters

Collection<StatsReporter> frodo2.controller.ConfigurationManager.statsReporters
private

The statistics listeners.

Referenced by cleanProblem(), and runExperiment().

◆ timeOut

int frodo2.controller.ConfigurationManager.timeOut
private

timeOut contains the maximum time any agent should run the algorithm.

If timeOut = -1, not timeOut is specified

Referenced by getTimeOut(), and parseConfigurationFile().

◆ workDir

String frodo2.controller.ConfigurationManager.workDir
protected

Folder containing the files mentioned in the configuration document.

Must end with a slash.

Referenced by ConfigurationManager(), frodo2.daemon.LocalConfigManager.LocalConfigManager(), parseConfigurationFile(), and runExperiment().


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