Overview  Package   Class  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

sajas.proto
Class ContractNetInitiator
java.lang.Object
  sajas.core.behaviours.Behaviour
      sajas.core.behaviours.CompositeBehaviour
          sajas.core.behaviours.SerialBehaviour
              sajas.core.behaviours.FSMBehaviour
                  sajas.proto.ContractNetInitiator
All Implemented Interfaces:
jade.util.leap.Serializable, Serializable

public class ContractNetInitiator
extends FSMBehaviour
Note: this class has been re-implemented to redirect the use of the agent, behaviour and protocol classes to SAJaS versions.
Author:
hlc
See Also:
jade.proto.ContractNetInitiator

Nested classes/interfaces inherited from class sajas.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
Field Summary
String
ALL_ACCEPTANCES_KEY
          key to retrieve from the DataStore of the behaviour the vector of ACCEPT/REJECT_PROPOSAL ACLMessage objects that have to be sent
String
ALL_CFPS_KEY
          key to retrieve from the DataStore of the behaviour the vector of CFP ACLMessage objects that have to be sent.
protected String
ALL_INITIATIONS_K
String
ALL_RESPONSES_KEY
          key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that have been received as response.
String
ALL_RESULT_NOTIFICATIONS_KEY
          key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that have been received as result notifications.
String
CFP_KEY
          key to retrieve from the DataStore of the behaviour the ACLMessage object passed in the constructor of the class.
protected static String
CHECK_IN_SEQ
protected static String
CHECK_SESSIONS
protected static String
DUMMY_FINAL
protected static String
HANDLE_FAILURE
protected static String
HANDLE_NOT_UNDERSTOOD
protected static String
HANDLE_OUT_OF_SEQ
protected String
INITIATION_K
protected static String
PREPARE_INITIATIONS
protected static String
RECEIVE_REPLY
protected String
REPLY_K
String
REPLY_KEY
          key to retrieve from the DataStore of the behaviour the last ACLMessage object that has been received (null if the timeout expired).
protected MsgReceiver
replyReceiver
protected jade.lang.acl.MessageTemplate
replyTemplate
protected static String
SEND_INITIATIONS
protected jade.util.leap.Map
sessions
Fields inherited from class sajas.core.behaviours.FSMBehaviour
currentName, lastStates
Fields inherited from class sajas.core.behaviours.CompositeBehaviour
currentExecuted
Fields inherited from class sajas.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
Constructor Summary
ContractNetInitiator(Agent a, jade.lang.acl.ACLMessage cfp)
          Constructor for the class that creates a new empty DataStore
ContractNetInitiator(Agent a, jade.lang.acl.ACLMessage cfp, DataStore store)
          Constructs a ContractNetInitiator behaviour
Method Summary
protected void
adjustReplyTemplate(jade.lang.acl.ACLMessage msg)
protected boolean
checkInSequence(jade.lang.acl.ACLMessage reply)
          Check whether a reply is in-sequence and update the appropriate Session
protected int
checkSessions(jade.lang.acl.ACLMessage reply)
          Check the status of the sessions after the reception of the last reply or the expiration of the timeout
protected String
createConvId(Vector msgs)
          Create a new conversation identifier to begin a new interaction.
protected sajas.proto.Initiator.ProtocolSession
getSession(jade.lang.acl.ACLMessage msg, int sessionIndex)
          Return a ProtocolSession object to manage replies to a given initiation message
protected String[]
getToBeReset()
          Return the states that must be reset before they are visited again.
protected void
handleAllResponses(Vector responses, Vector acceptances)
          This method is called when all the responses have been collected or when the timeout is expired.
protected void
handleAllResultNotifications(Vector resultNotifications)
          This method is called when all the result notification messages have been collected.
protected void
handleFailure(jade.lang.acl.ACLMessage failure)
          This method is called every time a failure message is received, which is not out-of-sequence according to the protocol rules.
protected void
handleInform(jade.lang.acl.ACLMessage inform)
          This method is called every time a inform message is received, which is not out-of-sequence according to the protocol rules.
protected void
handleNotUnderstood(jade.lang.acl.ACLMessage notUnderstood)
          This method is called every time a not-understood message is received, which is not out-of-sequence according to the protocol rules.
protected void
handleOutOfSequence(jade.lang.acl.ACLMessage msg)
          This method is called every time a message is received, which is out-of-sequence according to the protocol rules.
protected void
handlePropose(jade.lang.acl.ACLMessage propose, Vector acceptances)
          This method is called every time a propose message is received, which is not out-of-sequence according to the protocol rules.
protected void
handleRefuse(jade.lang.acl.ACLMessage refuse)
          This method is called every time a refuse message is received, which is not out-of-sequence according to the protocol rules.
protected void
initializeDataStore(jade.lang.acl.ACLMessage msg)
          Initialize the data store.
void
newIteration(Vector nextMessages)
          This method can be called (typically within the handleAllResponses() method) to activate a new iteration (this means we are implementing an Iterated-Contract-Net protocol).
void
onStart()
          Override the onStart() method to initialize the vectors that will keep all the replies in the data store.
protected Vector
prepareCfps(jade.lang.acl.ACLMessage cfp)
          This method must return the vector of ACLMessage objects to be sent.
protected Vector
prepareInitiations(jade.lang.acl.ACLMessage initiation)
          Specialize (if necessary) the initiation message for each receiver
void
registerHandleAllResponses(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_ALL_RESPONSES state.
void
registerHandleAllResultNotifications(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_ALL_RESULT_NOTIFICATIONS state.
void
registerHandleFailure(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_FAILURE state.
void
registerHandleInform(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_INFORM state.
void
registerHandleNotUnderstood(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_NOT_UNDERSTOOD state.
void
registerHandleOutOfSequence(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_OUT_OF_SEQ state.
void
registerHandlePropose(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_PROPOSE state.
void
registerHandleRefuse(Behaviour b)
          This method allows to register a user defined Behaviour in the HANDLE_REFUSE state.
void
registerPrepareCfps(Behaviour b)
          This method allows to register a user-defined Behaviour in the PREPARE_CFPS state.
protected void
registerPrepareInitiations(Behaviour b)
          Attach a behaviour to the Prepare-initiations protocol state.
protected void
reinit()
          Re-initialize the internal state without performing a complete reset.
void
reset()
          reset this behaviour by putting a null ACLMessage as message to be sent
void
reset(jade.lang.acl.ACLMessage msg)
          reset this behaviour
protected void
sendInitiations(Vector initiations)
          Create and initialize the Sessions and sends the initiation messages
void
setDataStore(DataStore ds)
          Override the setDataStore() method to propagate this setting to all children.
void
skipNextResponses()
          This method can be called (typically within the handlePropose() method) to skip all responses that have not been received yet.
Methods inherited from class sajas.core.behaviours.FSMBehaviour
checkTermination, deregisterDefaultTransition, deregisterState, deregisterTransition, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, hasDefaultTransition, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, resetStates, scheduleFirst, scheduleNext, stringifyTransitionTable
Methods inherited from class sajas.core.behaviours.SerialBehaviour
handle
Methods inherited from class sajas.core.behaviours.CompositeBehaviour
action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren, setAgent
Methods inherited from class sajas.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, isRunnable, restart, root, setBehaviourName, setExecutionState
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
ALL_ACCEPTANCES_KEY
public final String ALL_ACCEPTANCES_KEY
key to retrieve from the DataStore of the behaviour the vector of ACCEPT/REJECT_PROPOSAL ACLMessage objects that have to be sent

ALL_CFPS_KEY
public final String ALL_CFPS_KEY
key to retrieve from the DataStore of the behaviour the vector of CFP ACLMessage objects that have to be sent.

ALL_INITIATIONS_K
protected final String ALL_INITIATIONS_K

ALL_RESPONSES_KEY
public final String ALL_RESPONSES_KEY
key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that have been received as response.

ALL_RESULT_NOTIFICATIONS_KEY
public final String ALL_RESULT_NOTIFICATIONS_KEY
key to retrieve from the DataStore of the behaviour the vector of ACLMessage objects that have been received as result notifications.

CFP_KEY
public final String CFP_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage object passed in the constructor of the class.

CHECK_IN_SEQ
protected static final String CHECK_IN_SEQ
See Also:
Constant Field Values

CHECK_SESSIONS
protected static final String CHECK_SESSIONS
See Also:
Constant Field Values

DUMMY_FINAL
protected static final String DUMMY_FINAL
See Also:
Constant Field Values

HANDLE_FAILURE
protected static final String HANDLE_FAILURE
See Also:
Constant Field Values

HANDLE_NOT_UNDERSTOOD
protected static final String HANDLE_NOT_UNDERSTOOD
See Also:
Constant Field Values

HANDLE_OUT_OF_SEQ
protected static final String HANDLE_OUT_OF_SEQ
See Also:
Constant Field Values

INITIATION_K
protected final String INITIATION_K

PREPARE_INITIATIONS
protected static final String PREPARE_INITIATIONS
See Also:
Constant Field Values

RECEIVE_REPLY
protected static final String RECEIVE_REPLY
See Also:
Constant Field Values

REPLY_K
protected final String REPLY_K

REPLY_KEY
public final String REPLY_KEY
key to retrieve from the DataStore of the behaviour the last ACLMessage object that has been received (null if the timeout expired).

replyReceiver
protected MsgReceiver replyReceiver

replyTemplate
protected jade.lang.acl.MessageTemplate replyTemplate

SEND_INITIATIONS
protected static final String SEND_INITIATIONS
See Also:
Constant Field Values

sessions
protected jade.util.leap.Map sessions
Constructor Detail
ContractNetInitiator
public ContractNetInitiator(Agent a,
                            jade.lang.acl.ACLMessage cfp)
Constructor for the class that creates a new empty DataStore
See Also:
ContractNetInitiator(Agent, ACLMessage, DataStore)

ContractNetInitiator
public ContractNetInitiator(Agent a,
                            jade.lang.acl.ACLMessage cfp,
                            DataStore store)
Constructs a ContractNetInitiator behaviour
Parameters:
a - The agent performing the protocol
Method Detail
prepareInitiations
protected Vector prepareInitiations(jade.lang.acl.ACLMessage initiation)
Specialize (if necessary) the initiation message for each receiver

sendInitiations
protected void sendInitiations(Vector initiations)
Create and initialize the Sessions and sends the initiation messages

checkInSequence
protected boolean checkInSequence(jade.lang.acl.ACLMessage reply)
Check whether a reply is in-sequence and update the appropriate Session

checkSessions
protected int checkSessions(jade.lang.acl.ACLMessage reply)
Check the status of the sessions after the reception of the last reply or the expiration of the timeout

getToBeReset
protected String[] getToBeReset()
Return the states that must be reset before they are visited again. Note that resetting a state before visiting it again is required only if - The onStart() method is redefined - The state has an "internal memory"

prepareCfps
protected Vector prepareCfps(jade.lang.acl.ACLMessage cfp)
This method must return the vector of ACLMessage objects to be sent. It is called in the first state of this protocol. This default implementation just returns the ACLMessage object (a CFP) passed in the constructor. Programmers might prefer to override this method in order to return a vector of CFP objects for 1:N conversations or also to prepare the messages during the execution of the behaviour.
Parameters:
cfp - the ACLMessage object passed in the constructor
Returns:
a Vector of ACLMessage objects. The value of the slot reply-with is ignored and regenerated automatically by this class.

handlePropose
protected void handlePropose(jade.lang.acl.ACLMessage propose,
                             Vector acceptances)
This method is called every time a propose message is received, which is not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
Parameters:
propose - the received propose message
acceptances - the list of ACCEPT/REJECT_PROPOSAL to be sent back. This list can be filled step by step redefining this method, or it can be filled at once redefining the handleAllResponses method.

handleRefuse
protected void handleRefuse(jade.lang.acl.ACLMessage refuse)
This method is called every time a refuse message is received, which is not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
Parameters:
refuse - the received refuse message

handleInform
protected void handleInform(jade.lang.acl.ACLMessage inform)
This method is called every time a inform message is received, which is not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
Parameters:
inform - the received inform message

handleAllResponses
protected void handleAllResponses(Vector responses,
                                  Vector acceptances)
This method is called when all the responses have been collected or when the timeout is expired. The used timeout is the minimum value of the slot replyBy of all the sent messages. By response message we intend here all the propose, not-understood, refuse received messages, which are not not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event by analysing all the messages in just one call.
Parameters:
responses - the Vector of ACLMessage objects that have been received
acceptances - the list of ACCEPT/REJECT_PROPOSAL to be sent back. This list can be filled at once redefining this method, or step by step redefining the handlePropose method.

handleAllResultNotifications
protected void handleAllResultNotifications(Vector resultNotifications)
This method is called when all the result notification messages have been collected. By result notification message we intend here all the inform, failure received messages, which are not not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event by analysing all the messages in just one call.

registerPrepareCfps
public void registerPrepareCfps(Behaviour b)
This method allows to register a user-defined Behaviour in the PREPARE_CFPS state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. It is responsibility of the registered behaviour to put the Vector of ACLMessage objects to be sent into the datastore at the ALL_CFPS_KEY key.
Parameters:
b - the Behaviour that will handle this state

registerHandlePropose
public void registerHandlePropose(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_PROPOSE state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the propose ACLMessage object received from the datastore at the REPLY_KEY key and the Vector of ACCEPT/REJECT_PROPOSAL to be sent back at the ALL_ACCEPTANCES_KEY
Parameters:
b - the Behaviour that will handle this state

registerHandleRefuse
public void registerHandleRefuse(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_REFUSE state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the refuse ACLMessage object received from the datastore at the REPLY_KEY key.
Parameters:
b - the Behaviour that will handle this state

registerHandleInform
public void registerHandleInform(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_INFORM state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the inform ACLMessage object received from the datastore at the REPLY_KEY key.
Parameters:
b - the Behaviour that will handle this state

registerHandleAllResponses
public void registerHandleAllResponses(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_ALL_RESPONSES state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the vector of ACLMessage objects, received as a response, from the datastore at the ALL_RESPONSES_KEY key and the Vector of ACCEPT/REJECT_PROPOSAL to be sent back at the ALL_ACCEPTANCES_KEY
Parameters:
b - the Behaviour that will handle this state

registerHandleAllResultNotifications
public void registerHandleAllResultNotifications(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_ALL_RESULT_NOTIFICATIONS state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the Vector of ACLMessage objects, received as a result notification, from the datastore at the ALL_RESULT_NOTIFICATIONS_KEY key.
Parameters:
b - the Behaviour that will handle this state

skipNextResponses
public void skipNextResponses()
This method can be called (typically within the handlePropose() method) to skip all responses that have not been received yet.

newIteration
public void newIteration(Vector nextMessages)
This method can be called (typically within the handleAllResponses() method) to activate a new iteration (this means we are implementing an Iterated-Contract-Net protocol).
Parameters:
nextMessages - The messages to be sent to responders at next iteration. Such messages can be CFPs (for responders actually involved in the next iteration) or REJECT_PROPOSALs (for responders no longer involved in the next iteration).
See Also:
SSIteratedContractNetResponder

reinit
protected void reinit()
Re-initialize the internal state without performing a complete reset.

initializeDataStore
protected void initializeDataStore(jade.lang.acl.ACLMessage msg)
Initialize the data store.

getSession
protected sajas.proto.Initiator.ProtocolSession getSession(jade.lang.acl.ACLMessage msg,
                                                           int sessionIndex)
Return a ProtocolSession object to manage replies to a given initiation message

handleNotUnderstood
protected void handleNotUnderstood(jade.lang.acl.ACLMessage notUnderstood)
This method is called every time a not-understood message is received, which is not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
Parameters:
notUnderstood - the received not-understood message

handleFailure
protected void handleFailure(jade.lang.acl.ACLMessage failure)
This method is called every time a failure message is received, which is not out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
Parameters:
failure - the received failure message

handleOutOfSequence
protected void handleOutOfSequence(jade.lang.acl.ACLMessage msg)
This method is called every time a message is received, which is out-of-sequence according to the protocol rules. This default implementation does nothing; programmers might wish to override the method in case they need to react to this event.
Parameters:
msg - the received message

registerPrepareInitiations
protected void registerPrepareInitiations(Behaviour b)
Attach a behaviour to the Prepare-initiations protocol state.
Parameters:
b - The behaviour object to be executed in the Prepare-initiations state.

registerHandleNotUnderstood
public void registerHandleNotUnderstood(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_NOT_UNDERSTOOD state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the not-understood ACLMessage object received from the datastore at the REPLY_KEY key.
Parameters:
b - the Behaviour that will handle this state

registerHandleFailure
public void registerHandleFailure(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_FAILURE state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the failure ACLMessage object received from the datastore at the REPLY_KEY key.
Parameters:
b - the Behaviour that will handle this state

registerHandleOutOfSequence
public void registerHandleOutOfSequence(Behaviour b)
This method allows to register a user defined Behaviour in the HANDLE_OUT_OF_SEQ state. This behaviour would override the homonymous method. This method also set the data store of the registered Behaviour to the DataStore of this current behaviour. The registered behaviour can retrieve the out of sequence ACLMessage object received from the datastore at the REPLY_KEY key.
Parameters:
b - the Behaviour that will handle this state

reset
public void reset()
reset this behaviour by putting a null ACLMessage as message to be sent
Overrides:
reset in class FSMBehaviour

reset
public void reset(jade.lang.acl.ACLMessage msg)
reset this behaviour
Parameters:
msg - is the ACLMessage to be sent

onStart
public void onStart()
Override the onStart() method to initialize the vectors that will keep all the replies in the data store.
Overrides:
onStart in class Behaviour

setDataStore
public void setDataStore(DataStore ds)
Override the setDataStore() method to propagate this setting to all children.
Overrides:
setDataStore in class Behaviour
Parameters:
ds - the DataStore that this Behaviour will use as its private data store

createConvId
protected String createConvId(Vector msgs)
Create a new conversation identifier to begin a new interaction.
Parameters:
msgs - A vector of ACL messages. If the first one has a non-empty :conversation-id slot, its value is used, else a new conversation identifier is generated.

adjustReplyTemplate
protected void adjustReplyTemplate(jade.lang.acl.ACLMessage msg)

Overview  Package   Class  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Java API documentation generated with DocFlex/Doclet 1.6.1 using JavadocPro template set.
DocFlex/Doclet is both a multi-format Javadoc doclet and a free edition of DocFlex/Javadoc, which is a template-driven programming tool for rapid development of any Javadoc-based Java API documentation generators (i.e. doclets). If you need to customize your Javadoc without writing a full-blown doclet from scratch, DocFlex/Javadoc may be the only tool able to help you! Find out more at www.docflex.com