CoPS.agents
Class CoPSTaskResponsible

java.lang.Object
  extended byAgent
      extended byCoPS.agents.CoPSAgent
          extended byCoPS.agents.CoPSTaskResponsible
Direct Known Subclasses:
CheckUpTaskResponsible

public abstract class CoPSTaskResponsible
extends CoPSAgent

Class implementing the Task Responsible role. The Task Responsible is responisble for administering the problem solving process.

See Also:
Serialized Form

Constructor Summary
CoPSTaskResponsible()
           
 
Method Summary
protected abstract  ACLMessage composePSM(ACLMessage request)
          Method specifying how to compose the psms.
 AID getDecomposer()
          Method returning the AID of a decomposer.
protected  FileWriter getFileWriter()
          Method returning the filewriter, associated with the file belonging to this task responsible agent.
protected abstract  java.lang.String getFinalPSM()
          Method returning the last PSM to compose.
protected abstract  Ontology getOntology()
          Abstract method to get the ontology this agent knows of.
protected  java.util.ArrayList getProblemSolvers()
          Method returning a list containing list of the different actions of the tmst and the agents performing these actions.
protected  long getReplyByTime()
          Method for getting the time to wait before starting to handle all responses collected in the Contract net part of the Team Formation process step.
protected  ACLMessage getRequest()
          Method for getting the request gotten from the agent which this agent works for
protected  ACLMessage getResponse()
          Method returning the response stored
protected  java.lang.String getSolution()
          Method returning the solution of the problem being solved
protected  java.lang.String getSolutionLanguage()
          This method should be implemented as a protected abstract method which has to be defined by the language the problem is formated as.
protected  java.lang.String getTask()
          Method for getting the current task which the agent is working with.
 AID getTeamSpaceAgent()
          Method returning the AID of a TeamSpaceAgent.
protected  TMST getTMST()
          Method returning the tmst describing the possible solutions for the current problem being solved
protected abstract  Ontology intializeOntology()
          Method for initializing which ontology this agent knows
protected  AID[] lookupProblemSolvers(Action action)
          Method returning all problem solvers registered in the system which carry out a specified actiontype
protected  java.util.Vector makeCfps(ACLMessage cfp, java.util.ArrayList actionsAndAgents)
          Method that generates a vector of all CFPs needed for solving the decomsposed problem.
protected  java.util.Vector makeInvitations(java.util.Vector responses)
          Method making the invitations used by the Form Team Behaviour as a part of the Contract Net protocol for forming a team.
protected  void mapAgentToExecutor(ACLMessage response)
          Method taking a ACLMessage (a proposal) and maps the sender agent to the action in the tmst the agent has volunteered for.
abstract  boolean problemSolved()
          Method returning true if the current problem is solved.
abstract  boolean reviewProblem(java.lang.String task)
          Method which reviews whether a received task has a format that this TR understands.
protected  void setReplyByTime(long waitForMillis)
          Method for setting time to wait for starting handling all of the responses from the agents which have been sent cfps.
protected  void setRequest(ACLMessage request)
          Method setting the response for the agent which the CoPSTR works for.
protected  void setResponse(ACLMessage response)
          Method setting the response for the agent which the CoPSTR works for.
protected  void setSolution(java.lang.String solution)
          Method for storing the solution of a problem.
protected  void setTask(java.lang.String task)
          Method for setting the current task.
protected  void setTMST(TMST tmst)
          Method for setting the tmst describing the possible solutions for the task which is hopefully being solved.
 void setup()
          The setup method.
 
Methods inherited from class CoPS.agents.CoPSAgent
setServiceDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoPSTaskResponsible

public CoPSTaskResponsible()
Method Detail

setup

public void setup()
The setup method. Modified by Kari Roessland.


getFileWriter

protected FileWriter getFileWriter()
Method returning the filewriter, associated with the file belonging to this task responsible agent. New method added by Kari Roessland.

Returns:
The FileWriter.

reviewProblem

public abstract boolean reviewProblem(java.lang.String task)
Method which reviews whether a received task has a format that this TR understands.


problemSolved

public abstract boolean problemSolved()
Method returning true if the current problem is solved.

Returns:
boolean True if problem solved, false else.

intializeOntology

protected abstract Ontology intializeOntology()
Method for initializing which ontology this agent knows


getOntology

protected abstract Ontology getOntology()
Abstract method to get the ontology this agent knows of.

Returns:
Ontology The ontology

getProblemSolvers

protected java.util.ArrayList getProblemSolvers()
Method returning a list containing list of the different actions of the tmst and the agents performing these actions. Actions are stored in the list as Action objects and agents are stored as AIDs. Modified by Kari Roessland.

Returns:
Actions and the AID of all agents solving the actions, as described above in an ArrayList

makeCfps

protected java.util.Vector makeCfps(ACLMessage cfp,
                                    java.util.ArrayList actionsAndAgents)
Method that generates a vector of all CFPs needed for solving the decomsposed problem. Modified by Kari Roessland.

Parameters:
cfp - a generic CFP for using as a recipe for generating new ones.
actionsAndAgents - an ArrayList of the actions needed performing and all agents capable of performing them.
Returns:
Vector of all the CFPs generated.

makeInvitations

protected java.util.Vector makeInvitations(java.util.Vector responses)
Method making the invitations used by the Form Team Behaviour as a part of the Contract Net protocol for forming a team. Modified by Kari Roessland.

Returns:
Vector containing all invitations to joining the team. If an exception occurs an empty Vector is returned.

mapAgentToExecutor

protected void mapAgentToExecutor(ACLMessage response)
                           throws java.lang.Exception
Method taking a ACLMessage (a proposal) and maps the sender agent to the action in the tmst the agent has volunteered for. This method is modified by Kari Roessland: If an executor with the name of the sender-agent of the response-message does not exist, this one is created. Than the executor (newly created og pre-existing) is related to the action of the response-message.

Parameters:
response -
Throws:
java.lang.Exception

getDecomposer

public AID getDecomposer()
Method returning the AID of a decomposer. It picks one if more than one exist - the first one in the list returned.

Returns:
AID The AID to the selected decomposer

getTeamSpaceAgent

public AID getTeamSpaceAgent()
Method returning the AID of a TeamSpaceAgent. It picks one if more than one exist - the first one in the list returned. New method added by Kari Roessland.

Returns:
The AID to the selected decomposer

setReplyByTime

protected void setReplyByTime(long waitForMillis)
Method for setting time to wait for starting handling all of the responses from the agents which have been sent cfps. Standart is five seconds (5000 milliseconds).

Parameters:
waitForMillis - The time allowed to wait before answering the message

getReplyByTime

protected long getReplyByTime()
Method for getting the time to wait before starting to handle all responses collected in the Contract net part of the Team Formation process step. Default is five seconds.

Returns:
long Milliseconds to wait

lookupProblemSolvers

protected AID[] lookupProblemSolvers(Action action)
Method returning all problem solvers registered in the system which carry out a specified actiontype

Returns:
AID[] A list containing the AID of all the problem solvers

setTMST

protected void setTMST(TMST tmst)
Method for setting the tmst describing the possible solutions for the task which is hopefully being solved. Modified by Kari Roessland. Contains som hard coding that should be removed in a later version.

Parameters:
tmst - The task structure tree which describes the possible solutions for the problem at hand

getTMST

protected TMST getTMST()
Method returning the tmst describing the possible solutions for the current problem being solved

Returns:
TMST The task structure tree describing possible solutions for the current problem

getSolutionLanguage

protected java.lang.String getSolutionLanguage()
This method should be implemented as a protected abstract method which has to be defined by the language the problem is formated as. The solution should be specified in the same language to be shure that the requesting agent understands it (this is not the consulting business).

Returns:
String The language the solution is specified by, as string.

getSolution

protected java.lang.String getSolution()
Method returning the solution of the problem being solved

Returns:
String A string representation of the solution, specified in the language returned by the method getSolutionLanguage().

setSolution

protected void setSolution(java.lang.String solution)
Method for storing the solution of a problem. The solution is represented using a string.

Parameters:
solution - The solution to be stored.

setRequest

protected void setRequest(ACLMessage request)
Method setting the response for the agent which the CoPSTR works for.


getRequest

protected ACLMessage getRequest()
Method for getting the request gotten from the agent which this agent works for


setResponse

protected void setResponse(ACLMessage response)
Method setting the response for the agent which the CoPSTR works for.

Parameters:
response - The response to give

getResponse

protected ACLMessage getResponse()
Method returning the response stored

Returns:
ACLMessage The message which is is a response to the agent the CoPSTR works for.

setTask

protected void setTask(java.lang.String task)
Method for setting the current task.

Parameters:
task - A string representation of the task being solved

getTask

protected java.lang.String getTask()
Method for getting the current task which the agent is working with.

Returns:
String String describing the current task the agent works on solving.

composePSM

protected abstract ACLMessage composePSM(ACLMessage request)
Method specifying how to compose the psms. New method added by Kari Roessland.

Parameters:
request - The request specifying the psm requested
Returns:
ACLMessage The message specifying the solution

getFinalPSM

protected abstract java.lang.String getFinalPSM()
Method returning the last PSM to compose. New method added by Kari Roessland.

Returns:
The most top-level PSM in the TMST as a String