Magentix2  2.1.1
es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator Class Reference

List of all members.

Classes

class  BEGIN_Method
class  EVALUATE_PROPOSALS_Method
class  FINAL_Method
class  RECEIVE_FAILURE_Method
class  RECEIVE_INFORM_Method
class  RECEIVE_NOT_UNDERSTOOD_Method
class  RECEIVE_PROPOSE_Method
class  RECEIVE_REFUSE_Method
class  SEND_Method
class  SOLICIT_PROPOSALS_Method
class  TIMEOUT_Method

Public Member Functions

CFactory newFactory (String name, MessageFilter filter, ACLMessage template, int availableConversations, CAgent myAgent, int participants, long deadline, int timeout)

Protected Member Functions

void doBegin (CProcessor myProcessor, ACLMessage msg)
void doSolicitProposals (CProcessor myProcessor, ACLMessage messageToSend)
void doReceiveNotUnderstood (CProcessor myProcessor, ACLMessage msg)
void doReceiveRefuse (CProcessor myProcessor, ACLMessage msg)
void doReceiveProposal (CProcessor myProcessor, ACLMessage msg)
void doTimeout (CProcessor myProcessor, ACLMessage msg)
abstract void doEvaluateProposals (CProcessor myProcessor, ArrayList< ACLMessage > proposes, ArrayList< ACLMessage > acceptances, ArrayList< ACLMessage > rejections)
void doReceiveFailure (CProcessor myProcessor, ACLMessage msg)
abstract void doReceiveInform (CProcessor myProcessor, ACLMessage msg)
void doFinal (CProcessor myProcessor, ACLMessage messageToSend)

Detailed Description

Template for CFactories that manage fipa contract net initiator conversation. The user has to create his/her own class extending from this one. And implement the abstract methods. Other methods can be overriden in order to modify the default behaviour

Author:
ricard
Javier Jorge Cano - jjorge@dsic.upv.es

Definition at line 35 of file FIPA_CONTRACTNET_Initiator.java.


Member Function Documentation

Method executed at the beginning of the conversation

Parameters:
myProcessorthe CProcessor managing the conversation
msgfirst message to send in the conversation

Definition at line 45 of file FIPA_CONTRACTNET_Initiator.java.

                                                                       {
                myProcessor.getInternalData().put("InitialMessage", msg);
        }
abstract void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doEvaluateProposals ( CProcessor  myProcessor,
ArrayList< ACLMessage proposes,
ArrayList< ACLMessage acceptances,
ArrayList< ACLMessage rejections 
) [protected, pure virtual]

Evaluate proposals. Each accepted proposal has to be added to the acceptances list. Each rejected proposal has to be added to the rejected list

Parameters:
myProcessorthe CProcessor managing the conversation
proposesProposals
acceptancesAccepted proposals
rejectionsRejected proposals

Method executed when the initiator ends the conversation

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendfinal message of this conversation

Definition at line 361 of file FIPA_CONTRACTNET_Initiator.java.

                                                                                 {
                messageToSend = myProcessor.getLastSentMessage();
        }

Method executed when the initiator receives a failure

Parameters:
myProcessorthe CProcessor managing the conversation
msgthe failure message

Definition at line 303 of file FIPA_CONTRACTNET_Initiator.java.

                                                                                {
        }
abstract void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doReceiveInform ( CProcessor  myProcessor,
ACLMessage  msg 
) [protected, pure virtual]

Method executed when the initiator receives a inform

Parameters:
myProcessorthe CProcessor managing the conversation
msginform message

Method executed when the initiator receives a not-understood message

Parameters:
myProcessorthe CProcessor managing the conversation
msgnot-understood message

Definition at line 86 of file FIPA_CONTRACTNET_Initiator.java.

                                                                                      {
        }

Method executed when the initiator receives a proposal

Parameters:
myProcessorthe CProcessor managing the conversation
msgproposal message

Definition at line 140 of file FIPA_CONTRACTNET_Initiator.java.

                                                                                 {
                ArrayList<ACLMessage> proposes = (ArrayList<ACLMessage>) myProcessor
                                .getInternalData().get("proposes");
                proposes.add(msg);
        }

Method executed when the initiator receives a refuse message

Parameters:
myProcessorthe CProcessor managing the conversation
msgrefuse message

Definition at line 112 of file FIPA_CONTRACTNET_Initiator.java.

                                                                               {
        }

Method executed when the initiator calls for proposals

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendMessage to send

Definition at line 64 of file FIPA_CONTRACTNET_Initiator.java.

                                                  {
                messageToSend.setProtocol("fipa-contract-net");
                messageToSend.setPerformative(ACLMessage.CFP);
                messageToSend.setSender(myProcessor.getMyAgent().getAid());
        }

Method executed when the timeout is reached while the initiator was waiting for proposals

Parameters:
myProcessorthe CProcessor managing the conversation
msgtimeout message

Definition at line 172 of file FIPA_CONTRACTNET_Initiator.java.

                                                                         {
        }
CFactory es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.newFactory ( String  name,
MessageFilter  filter,
ACLMessage  template,
int  availableConversations,
CAgent  myAgent,
int  participants,
long  deadline,
int  timeout 
)

Creates a new contract net initiator factory

Parameters:
nameof the factory
filtermessage filter
templatefirst message to send
availableConversationsmaximum number of conversation this CFactory can manage simultaneously
myAgentagent owner of this Cfactory
participantsnumber of participants
deadlinefor waiting for proposals
timeoutfor waiting for inform
Returns:
the a new contract net initiator CFactory

Definition at line 393 of file FIPA_CONTRACTNET_Initiator.java.

                                                                      {

                // Create factory

                if (filter == null) {
                        filter = new MessageFilter("performative = CFP"); // falta AND
                        // protocol
                        // =
                        // fipa-contract-net;
                }
                CFactory theFactory = new CFactory(name, filter,
                                availableConversations, myAgent);

                // Processor template setup

                CProcessor processor = theFactory.cProcessorTemplate();

                // BEGIN State

                BeginState BEGIN = (BeginState) processor.getState("BEGIN");
                BEGIN.setMethod(new BEGIN_Method());

                // SOLICIT_PROPOSALS State

                SendState SOLICIT_PROPOSALS = new SendState("SOLICIT_PROPOSALS");

                SOLICIT_PROPOSALS.setMethod(new SOLICIT_PROPOSALS_Method());
                template.setProtocol("fipa-contract-net");
                template.setPerformative(ACLMessage.CFP);
                SOLICIT_PROPOSALS.setMessageTemplate(template);
                processor.registerState(SOLICIT_PROPOSALS);
                processor.addTransition(BEGIN, SOLICIT_PROPOSALS);

                // WAIT_FOR_PROPOSALS State
                WaitState WAIT_FOR_PROPOSALS = new WaitState("WAIT_FOR_PROPOSALS",
                                deadline);
                WAIT_FOR_PROPOSALS.setWaitType(WaitState.ABSOLUT);
                processor.registerState(WAIT_FOR_PROPOSALS);
                processor.addTransition(SOLICIT_PROPOSALS, WAIT_FOR_PROPOSALS);

                // RECEIVE_NOT_UNDERSTOOD State

                ReceiveState RECEIVE_NOT_UNDERSTOOD = new ReceiveState(
                                "RECEIVE_NOT_UNDERSTOOD");
                RECEIVE_NOT_UNDERSTOOD.setMethod(new RECEIVE_NOT_UNDERSTOOD_Method());
                filter = new MessageFilter("performative = "
                                + ACLMessage.getPerformative(ACLMessage.NOT_UNDERSTOOD)); // Bexy
                                                                                                                                                        // 11/8/11
                RECEIVE_NOT_UNDERSTOOD.setAcceptFilter(filter);
                processor.registerState(RECEIVE_NOT_UNDERSTOOD);
                processor.addTransition(WAIT_FOR_PROPOSALS, RECEIVE_NOT_UNDERSTOOD);
                processor.addTransition(RECEIVE_NOT_UNDERSTOOD, WAIT_FOR_PROPOSALS);

                // RECEIVE_REFUSE State

                ReceiveState RECEIVE_REFUSE = new ReceiveState("RECEIVE_REFUSE");
                RECEIVE_REFUSE.setMethod(new RECEIVE_REFUSE_Method());
                filter = new MessageFilter("performative = REFUSE");
                RECEIVE_REFUSE.setAcceptFilter(filter);
                processor.registerState(RECEIVE_REFUSE);
                processor.addTransition(WAIT_FOR_PROPOSALS, RECEIVE_REFUSE);
                processor.addTransition(RECEIVE_REFUSE, WAIT_FOR_PROPOSALS);

                // RECEIVE_PROPOSE State

                ReceiveState RECEIVE_PROPOSE = new ReceiveState("RECEIVE_PROPOSE");
                RECEIVE_PROPOSE.setMethod(new RECEIVE_PROPOSE_Method());
                filter = new MessageFilter("performative = PROPOSE");
                RECEIVE_PROPOSE.setAcceptFilter(filter);
                processor.registerState(RECEIVE_PROPOSE);
                processor.addTransition(WAIT_FOR_PROPOSALS, RECEIVE_PROPOSE);
                processor.addTransition(RECEIVE_PROPOSE, WAIT_FOR_PROPOSALS);

                // TIMEOUT State

                ReceiveState TIMEOUT = new ReceiveState("TIMEOUT");
                TIMEOUT.setMethod(new TIMEOUT_Method());
                filter = new MessageFilter(
                                "performative = INFORM AND purpose = waitMessage");
                TIMEOUT.setAcceptFilter(filter);
                processor.registerState(TIMEOUT);
                processor.addTransition(WAIT_FOR_PROPOSALS, TIMEOUT);

                // EVALUATE_PROPOSALS State

                ActionState EVALUATE_PROPOSALS = new ActionState("EVALUATE_PROPOSALS");
                EVALUATE_PROPOSALS.setMethod(new EVALUATE_PROPOSALS_Method());
                processor.registerState(EVALUATE_PROPOSALS);
                processor.addTransition(RECEIVE_PROPOSE, EVALUATE_PROPOSALS);
                processor.addTransition(RECEIVE_NOT_UNDERSTOOD, EVALUATE_PROPOSALS);
                processor.addTransition(RECEIVE_REFUSE, EVALUATE_PROPOSALS);
                processor.addTransition(TIMEOUT, EVALUATE_PROPOSALS);

                // We don't need to register send rejections/acceptances. It is done
                // dynamically by the EVALUATE_PROPOSALS State

                // WAIT_FOR_RESULTS State

                WaitState WAIT_FOR_RESULTS = new WaitState("WAIT_FOR_RESULTS", timeout);
                processor.registerState(WAIT_FOR_RESULTS);
                // It is not necessary to add transitions to this state, it is done
                // dynamically by EVALUATE_PROPOSALS State

                // RECEIVE_FAILURE State

                ReceiveState RECEIVE_FAILURE = new ReceiveState("RECEIVE_FAILURE");
                RECEIVE_FAILURE.setMethod(new RECEIVE_FAILURE_Method());
                filter = new MessageFilter("performative = FAILURE");
                RECEIVE_FAILURE.setAcceptFilter(filter);
                processor.registerState(RECEIVE_FAILURE);
                processor.addTransition(WAIT_FOR_RESULTS, RECEIVE_FAILURE);
                processor.addTransition(RECEIVE_FAILURE, WAIT_FOR_RESULTS);

                // RECEIVE_INFORM State

                ReceiveState RECEIVE_INFORM = new ReceiveState("RECEIVE_INFORM");
                RECEIVE_INFORM.setMethod(new RECEIVE_INFORM_Method());
                filter = new MessageFilter("performative = INFORM");
                RECEIVE_INFORM.setAcceptFilter(filter);
                processor.registerState(RECEIVE_INFORM);
                processor.addTransition(WAIT_FOR_RESULTS, RECEIVE_INFORM);
                processor.addTransition(RECEIVE_INFORM, WAIT_FOR_RESULTS);

                // FINAL State

                FinalState FINAL = new FinalState("FINAL");

                FINAL.setMethod(new FINAL_Method());

                processor.registerState(FINAL);
                processor.addTransition(EVALUATE_PROPOSALS, FINAL);
                processor.addTransition(RECEIVE_INFORM, FINAL);
                processor.addTransition(RECEIVE_FAILURE, FINAL);

                // We add the internal data
                processor.getInternalData().put("participants", participants);
                processor.getInternalData().put("receivedResponses", 0);
                processor.getInternalData().put("acceptedProposals", 0);
                processor.getInternalData().put("receivedResults", 0);
                processor.getInternalData()
                                .put("proposes", new ArrayList<ACLMessage>());

                return theFactory;
        }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables