fr.lifl.magique
Class Agent

java.lang.Object
  extended byfr.lifl.magique.AbstractAgent
      extended byfr.lifl.magique.AtomicAgent
          extended byfr.lifl.magique.Agent
Direct Known Subclasses:
AcquAgent

public class Agent
extends AtomicAgent

This class defines particular agent : the Magique agent. They are defined through a refinement of the AtomicAgent simply by changing the skills known at creation. This class allows to create basic agent (specialist) and supervisor (leader of group). Agents are organized via a hierarchic structure: a supervisor manages some other agents (basic or other supervisors - with own team) called its team. A team contains inofrmation about its memeber abilities. Task achievement can require ability/skills that agent does not have. Therefore the agent must ask someone else to achieve it. Then to achieve a task following process is applied :

Here messages are in fact Request objects. The text member of a request object is a name of a method (args can be provided). Therefore, an agent can "ask" another agent to achieve a "method" for him. Agent creation : Creating an agent looks like scripting. This is due to dynamic skill learning. Here is to what agent creation looks like:
import fr.lifl.magique.*;
...
Agent myAgent = new Agent("myName"); // agent creation
platform.addAgent(myAgent); // agent subscribes to a defined platform

myAgent.addSkill(new SkillOne()); //
myAgent.addSkill(new SkillTwo()); // skills learning
myAgent.addSkill(new SkillThree()); //
myAgent.setAction(new MyAgentAction()); // proactive part setting

myAgent.connectToBoss("bossName@host.domain.country:4444"); // join a hierarchy (MAS)
myAgent.start(); // proactive behaviour is launched
...
Some othe properties can be set (e.g. the policy for concurrent request : setConcurrencyPolicy

See Also:
Agent, Skill, MagiqueDefaultSkill, BossTeamSkill, Platform, Request

Field Summary
 
Fields inherited from class fr.lifl.magique.AtomicAgent
allKnownSkills, monitor, myConcurrencyPolicy, mySkills, unsentRequests
 
Fields inherited from class fr.lifl.magique.AbstractAgent
questionTable, toDo, verboseLevel
 
Constructor Summary
Agent()
           
Agent(java.lang.String name)
           
 
Method Summary
 void addSkill(java.lang.Object newSkill)
          Add all the methods of the object newSkill to the agent
 void addSkill(java.lang.String n)
          Add all the methods of the object newSkill to the agent
 void broadcastToAll(Request request)
          broadcasts an order (request without answer) to everybody under me.
 void broadcastToBasis(Request request)
          broadcasts an order (request without answer) to a basic agent of my hierarchy.
 void concurrentPerform(Request request)
          treat a concurrent request : if the agent knows the method, he applies it, else he sends the request to all those in his team who knows the method, else he sends it to its supervisor
 void connectToBoss(java.lang.String bossName)
          connect this agent to another one as his boss
protected  java.lang.String getMyBoss()
           
protected  Team getMyTeam()
           
protected  MessageList getUnsentRequests()
           
protected  void initBasicSkills()
          defines the skills known by the agent at creation.
protected  boolean isBasis()
           
protected  boolean isBigBoss()
           
protected  boolean isBoss()
           
 void perform(Request request)
          treat a request : if the agent knows the method, he applies it, else if someone in his team knows the method, he sends him the request, else he sends this to its supervisor
 void removeSkill(java.lang.String key)
          Remove the "key" from the hashtable of skills.
 void send(java.lang.String to, Message msg)
          send a request to to through the platform if needed If to is unknown, boss is asked to forward request.
 void send(java.lang.String to, Request request)
           
 void sendUnsentRequestToBoss()
          sends unsent requests to my boss, it is used just after connection to boss has been performed
protected  void sendUp(Request request)
          sends a request to my boss (supervisor)
 void setAction(MagiqueActionSkill action)
          changes the action skill that corresponds to the proactive part of the agent
 
Methods inherited from class fr.lifl.magique.AtomicAgent
addSkill, connectTo, getAllKnownSkills, getPlatform, giveSkillClassNameFromSignature, initialize, interprete, myMethodsNames, processRequest, removeSkillFromClassName, sendMessage, setAction, setConcurrencyPolicy, setPlatform, start, treatUnsentRequests
 
Methods inherited from class fr.lifl.magique.AbstractAgent
addAgenda, ask, ask, ask, ask, ask, ask, ask, ask, ask, ask, ask, ask, ask, ask, askNow, askNow, askNow, askNow, askNow, askNow, askNow, askNow, askNow, askNow, askNow, askNow, askNow, askNow, concurrentAsk, concurrentAsk, concurrentAsk, concurrentAsk, concurrentAsk, concurrentAsk, concurrentAsk, createOrder, createOrder, createOrder, createOrder, createOrder, createOrder, createQuestion, createQuestion, createQuestion, createQuestion, createQuestion, createQuestion, createQuestion, createQuestion, forgetQuestion, getAgenda, getAnswerer, getListener, getName, getQuestionTable, getToDo, getVerboseLevel, isAnswerReceived, perform, perform, perform, perform, perform, perform, perform, perform, perform, perform, perform, perform, perform, processAnswer, returnAnswer, returnValue, setName, setQuestionTable, setVerboseLevel, stopListener, verbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Agent

public Agent()

Agent

public Agent(java.lang.String name)
Parameters:
name - = shortname : identifier for my name (platform hostname and port number are added)
Method Detail

getUnsentRequests

protected MessageList getUnsentRequests()
Overrides:
getUnsentRequests in class AtomicAgent
Returns:
my unsent requests list

initBasicSkills

protected void initBasicSkills()
                        throws SkillAlreadyAcquiredException
defines the skills known by the agent at creation.

Overrides:
initBasicSkills in class AtomicAgent
Throws:
SkillAlreadyAcquiredException - if agent tries to learn an already known skill

isBigBoss

protected boolean isBigBoss()

isBoss

protected boolean isBoss()

isBasis

protected boolean isBasis()

getMyTeam

protected Team getMyTeam()

getMyBoss

protected java.lang.String getMyBoss()

addSkill

public void addSkill(java.lang.String n)
              throws SkillAlreadyAcquiredException
Add all the methods of the object newSkill to the agent

Overrides:
addSkill in class AtomicAgent
Parameters:
n - the class used that contains new skills to be added.
Throws:
SkillAlreadyAcquiredException - if newSkill contains a method with the same signature as another already known

addSkill

public void addSkill(java.lang.Object newSkill)
              throws SkillAlreadyAcquiredException
Description copied from class: AtomicAgent
Add all the methods of the object newSkill to the agent

Overrides:
addSkill in class AtomicAgent
Parameters:
newSkill - the new skills to be added. Each method of the object newSkill, is added to the agent.
Throws:
SkillAlreadyAcquiredException - if newSkill contains a method with the same signature as another already known

removeSkill

public void removeSkill(java.lang.String key)
                 throws SkillNotKnownException
Remove the "key" from the hashtable of skills. This method removes all the method learned at the same time than key (that means the "full" skill which contains "key")

Overrides:
removeSkill in class AtomicAgent
Parameters:
key - a string representing the method's signature to be removed.
Throws:
SkillNotKnownException - if key is not a knwon method signature

connectToBoss

public void connectToBoss(java.lang.String bossName)
connect this agent to another one as his boss

Parameters:
bossName - the name of my boss (of the form "name@hostname:rmiport")

send

public void send(java.lang.String to,
                 Request request)
Overrides:
send in class AtomicAgent

send

public void send(java.lang.String to,
                 Message msg)
send a request to to through the platform if needed If to is unknown, boss is asked to forward request.

Overrides:
send in class AtomicAgent
Parameters:
to - name of recipient (name can be short name)
See Also:
Serializable

sendUp

protected void sendUp(Request request)
sends a request to my boss (supervisor)

Parameters:
request - the request to be sent

sendUnsentRequestToBoss

public void sendUnsentRequestToBoss()
sends unsent requests to my boss, it is used just after connection to boss has been performed


broadcastToBasis

public void broadcastToBasis(Request request)
broadcasts an order (request without answer) to a basic agent of my hierarchy. Broadcasting question (request with answer) leads to unpredictable behaviour.

Parameters:
request - the sent request

broadcastToAll

public void broadcastToAll(Request request)
broadcasts an order (request without answer) to everybody under me. Broadcasting question (request with answer) leads to unpredictable behaviour.

Parameters:
request - the sent request

perform

public void perform(Request request)
treat a request : if the agent knows the method, he applies it, else if someone in his team knows the method, he sends him the request, else he sends this to its supervisor

Overrides:
perform in class AtomicAgent
Parameters:
request - the request to be treated
Returns:
no return value

concurrentPerform

public void concurrentPerform(Request request)
treat a concurrent request : if the agent knows the method, he applies it, else he sends the request to all those in his team who knows the method, else he sends it to its supervisor

Overrides:
concurrentPerform in class AtomicAgent
Parameters:
request - the request to be treated
Returns:
no return value

setAction

public void setAction(MagiqueActionSkill action)
changes the action skill that corresponds to the proactive part of the agent

Parameters:
action - the new action skill, it must inherit ActionSkill
See Also:
ActionSkill