Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

DALT_Client::Agent Class Reference

This class provides the template for an agent. More...

#include <agent.h>

Inheritance diagram for DALT_Client::Agent:

Inheritance graph
[legend]
Collaboration diagram for DALT_Client::Agent:

Collaboration graph
[legend]
List of all members.

Public Methods

 Agent (string type, int id, DALTClient *client)
 agent constructor. More...

 ~Agent ()
 agent destructor. More...

virtual void addSense (Sense *sense)
 adds a sense to the available senses vector. More...

virtual void senseAndAct ()=0
 this is the core of the agent which is to be over-written by each simulation; normally this is where the agent would scan its senses and decide on an action to take. More...

virtual void newCycle ()
 this function is called by the DALTClient to signal that the agent should start processing a new cycle the function unblocks the thread and notifies the chronometer of the start of a new cycle. More...

virtual void finishedCycle ()
 this function has to be called by the agent itself when a processing cycle is complete. More...

virtual int executeAction (Action &action)=0
 This method will be called by the DALTClient when an action request involving this agent is received. More...

virtual void queueAction (Action *act)
 This method will be called by the DALTClient when an action request involving this agent is received. More...

virtual void clone ()
 some agents (preferably most) will be able to clone themselves by generating a createAgent message with an agent template containing enough information for a client to create an agent identical to this one. More...

virtual void kill () throw (Synchronization_Exception)
 call this to instruct an agent to kill itself. More...

virtual void run () throw ()
 this function contains the execution loop for an agent; you might want to re-code this loop in order to implement your own processing code. More...


Public Attributes

RunTimeInfo rti
 class containing and gathering information about time taken to process a cycle for this agent. More...


Protected Attributes

Mutex stay_alive_mutex
 mutex used to protect access to stay alive. More...

Mutex method_mutex
 mutex used to control method access in Agent objects. More...

vector<Sense*> senses
 senses available to this agent. More...

float fitness
 many simulations use a fitness variable to describe the fitness of an agent. This is provided for comodity. More...

bool is_clonable
 true if the clone() method is supported, false otherwise. More...

DALTClientdalt_client
 the client. More...

Semaphore* locker
 semaphore used to control the agent (ie make it pause at the end of each cycle). More...

SOAPMethod* state_change_method
 method used for dispatching state change requests. More...

bool stay_alive
 flag used to keep alive or destroy the thread. More...

LockedQueue<Action*> action_queue
 actions waiting in the queue. More...


Static Protected Attributes

Mutex agent_sync
 this mutex is used to mutually exclude regions of the agent code which use external resources (such as dipatching messages to the server). More...


Detailed Description

This class provides the template for an agent.

Each agent runs on a separate thread; all outgoing communication (senses and action requests) goes straight to the server. Incoming communication is received by DALTClient and routed through to the right agent. This way particular agent implementations will not necessarly have to deal with handling SOAP requests.

Author:
Vlad Mereuta

Definition at line 49 of file agent.h.


Constructor & Destructor Documentation

DALT_Client::Agent::Agent ( string type,
int id,
DALTClient * client )
 

agent constructor.

Parameters:
type   the type of the agent
id   the unique id associated with this agent
client   pointer to the DALTClient class managing this cell of the simulation
Parameters:
type  
id  
client  

DALT_Client::Agent::~Agent ( )
 

agent destructor.


Member Function Documentation

void DALT_Client::Agent::addSense ( Sense * sense ) [virtual]
 

adds a sense to the available senses vector.

Parameters:
sense  

void DALT_Client::Agent::clone ( ) [virtual]
 

some agents (preferably most) will be able to clone themselves by generating a createAgent message with an agent template containing enough information for a client to create an agent identical to this one.

It goes without saying that the reciprocal method of deseralising this message into an agent class has to be implemented by the Client.

int DALT_Client::Agent::executeAction ( Action & action ) [pure virtual]
 

This method will be called by the DALTClient when an action request involving this agent is received.

this method will have to handle all the possible actions that can have as target this agent

Parameters:
action  

Reimplemented in Cell.

void DALT_Client::Agent::finishedCycle ( ) [virtual]
 

this function has to be called by the agent itself when a processing cycle is complete.

The function notifies the agent manager that the computation finished and stops the chronometer

void DALT_Client::Agent::kill ( ) throw (Synchronization_Exception) [virtual]
 

call this to instruct an agent to kill itself.

void DALT_Client::Agent::newCycle ( ) [virtual]
 

this function is called by the DALTClient to signal that the agent should start processing a new cycle the function unblocks the thread and notifies the chronometer of the start of a new cycle.

void DALT_Client::Agent::queueAction ( Action * act ) [virtual]
 

This method will be called by the DALTClient when an action request involving this agent is received.

this method will have to handle all the possible actions that can have as target this agent

Parameters:
act  

void DALT_Client::Agent::run ( ) throw () [virtual]
 

this function contains the execution loop for an agent; you might want to re-code this loop in order to implement your own processing code.

If this is the case,

void DALT_Client::Agent::senseAndAct ( ) [pure virtual]
 

this is the core of the agent which is to be over-written by each simulation; normally this is where the agent would scan its senses and decide on an action to take.

Reimplemented in Cell.


Member Data Documentation

LockedQueue< Action *> DALT_Client::Agent::action_queue [protected]
 

actions waiting in the queue.

Definition at line 74 of file agent.h.

Mutex DALT_Client::Agent::agent_sync [static, protected]
 

this mutex is used to mutually exclude regions of the agent code which use external resources (such as dipatching messages to the server).

Definition at line 53 of file agent.h.

DALTClient * DALT_Client::Agent::dalt_client [protected]
 

the client.

Definition at line 65 of file agent.h.

float DALT_Client::Agent::fitness [protected]
 

many simulations use a fitness variable to describe the fitness of an agent. This is provided for comodity.

Definition at line 61 of file agent.h.

bool DALT_Client::Agent::is_clonable [protected]
 

true if the clone() method is supported, false otherwise.

Definition at line 63 of file agent.h.

Semaphore * DALT_Client::Agent::locker [protected]
 

semaphore used to control the agent (ie make it pause at the end of each cycle).

Definition at line 67 of file agent.h.

Mutex DALT_Client::Agent::method_mutex [protected]
 

mutex used to control method access in Agent objects.

Definition at line 57 of file agent.h.

RunTimeInfo DALT_Client::Agent::rti
 

class containing and gathering information about time taken to process a cycle for this agent.

Definition at line 79 of file agent.h.

vector< Sense *> DALT_Client::Agent::senses [protected]
 

senses available to this agent.

Definition at line 59 of file agent.h.

SOAPMethod * DALT_Client::Agent::state_change_method [protected]
 

method used for dispatching state change requests.

Definition at line 69 of file agent.h.

bool DALT_Client::Agent::stay_alive [protected]
 

flag used to keep alive or destroy the thread.

Definition at line 72 of file agent.h.

Mutex DALT_Client::Agent::stay_alive_mutex [protected]
 

mutex used to protect access to stay alive.

Definition at line 55 of file agent.h.


The documentation for this class was generated from the following file:
Generated at Thu Jan 31 15:20:18 2002 for DALT Client by doxygen1.2.8 written by Dimitri van Heesch, © 1997-2001