#include <agent.h>
Inheritance diagram for DALT_Client::Agent:
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... | |
DALTClient* | dalt_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... |
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.
Definition at line 49 of file agent.h.
|
agent constructor.
|
|
agent destructor.
|
|
adds a sense to the available senses vector.
|
|
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. |
|
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
Reimplemented in Cell. |
|
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 |
|
call this to instruct an agent to kill itself.
|
|
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.
|
|
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
|
|
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, |
|
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. |
|
actions waiting in the queue.
|
|
this mutex is used to mutually exclude regions of the agent code which use external resources (such as dipatching messages to the server).
|
|
the client.
|
|
many simulations use a fitness variable to describe the fitness of an agent. This is provided for comodity.
|
|
true if the clone() method is supported, false otherwise.
|
|
semaphore used to control the agent (ie make it pause at the end of each cycle).
|
|
mutex used to control method access in Agent objects.
|
|
class containing and gathering information about time taken to process a cycle for this agent.
|
|
senses available to this agent.
|
|
method used for dispatching state change requests.
|
|
flag used to keep alive or destroy the thread.
|
|
mutex used to protect access to stay alive.
|