Magentix2  2.1.1
es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant Class Reference
Collaboration diagram for es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant:

List of all members.

Classes

class  BEGIN_Method
class  FINAL_Method
class  RECEIVE_BID_CALL_Method
class  RECEIVE_END_CONFIRMATION_Method
class  RECEIVE_NEW_CONV_DATA_Method
class  RECEIVE_WINNER_CONFIRM_Method
class  SEND_AGREE_Method
class  TIMEOUT_Method

Public Member Functions

 Jason_JAuc_Participant (TransitionSystem ts)
ConvCFactory newFactory (String name, MessageFilter filter, ACLMessage template, int availableConversations, ConvJasonAgent myAgent, int timeout)

Protected Member Functions

void doBegin (CProcessor myProcessor, ACLMessage msg)
String doReceiveNewConvData (ConvCProcessor myProcessor, ACLMessage msg)
String doReceiveBidceCall (ConvCProcessor myProcessor, ACLMessage msg)
void doSendAgree (ConvCProcessor myProcessor, ACLMessage messageToSend)
void doTimeout (ConvCProcessor myProcessor, ACLMessage msg)
void doReceiveWinnerConfirm (ConvCProcessor myProcessor, ACLMessage msg)
void doFinal (ConvCProcessor myProcessor, ACLMessage messageToSend)

Protected Attributes

TransitionSystem Ts

Detailed Description

This class represents a template for a Japanese Auction Protocol from the participant perspective for being used in the Conversations Factory from Jason agents.

Author:
Bexy Alfonso Espinosa

Definition at line 35 of file Jason_JAuc_Participant.java.


Constructor & Destructor Documentation


Member Function Documentation

Method executed at the beginning of the conversation

Parameters:
myProcessorthe CProcessor managing the conversation
msgfirst message assigned to this conversation

Definition at line 51 of file Jason_JAuc_Participant.java.

                                                                       {
                myProcessor.getInternalData().put("InitialMessage", msg);
        }

Method executed when the conversation ends

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendfinal message

Definition at line 202 of file Jason_JAuc_Participant.java.

                                                                                     {
                JAucPartConversation conv = (JAucPartConversation)myProcessor.getConversation();
                myProcessor.getMyAgent().removeFactory(conv.factoryName);
                messageToSend = myProcessor.getLastSentMessage();
        }

Method executed when the participant receives a call for bid acceptance

Parameters:
myProcessorthe CProcessor managing the conversation
msgbid acceptance message
Returns:
next state of this conversation

Definition at line 98 of file Jason_JAuc_Participant.java.

                                                                                       {
                JAucPartConversation conv;
                conv = (JAucPartConversation) myProcessor.getConversation();
                conv.AuctionLevel = msg.getHeaderValue("auctionlevel");
                String result = "";
                AgentID Sender = myProcessor.getLastReceivedMessage().getSender();
                String request = msg.getContent();
                String bid = msg.getHeaderValue("bid");
                String participants = msg.getHeaderValue("participants");
                String newMsgContent = "callforbid"+"("+Sender.name+","+request+","+participants+","+bid+","+conv.jasonConvID+")[source(self)]";
                List<Literal> allpercep = new ArrayList<Literal>();
                allpercep.add(Literal.parseLiteral(newMsgContent));
                ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allpercep);
                
                conv.aquire_semaphore();
                
                if (conv.Accept){  //it must be setted
                        result = "SEND_AGREE"; 
                }else result = "FINAL"; 
                return result;
        }

Method executed when the participant receives the new converstaion internal information

Parameters:
myProcessorthe CProcessor managing the conversation
msgbid acceptance message
Returns:
next state of this conversation

Definition at line 67 of file Jason_JAuc_Participant.java.

                                                                                         {
                JAucPartConversation newConv;
                Conversation conv = myProcessor.getConversation();
                if (conv.jasonConvID.compareTo("")==0){
                        String jasonConvID = msg.getHeaderValue("jasonID");
                        String factName = conv.factoryName;
                        //At this point the conversation associated to the CProcessor has no value
                        //for the internal conversation ID so it is updated. The factory name is already setted
                        conv.jasonConvID = jasonConvID;
                        conv.initiator = msg.getSender();
                        newConv = new JAucPartConversation(conv.jasonConvID, conv.internalConvID, conv.initiator,"",factName);
                        ((ConvCFactory)myProcessor.getMyFactory()).UpdateConv(newConv, myProcessor);
                }else{
                        newConv = (JAucPartConversation) myProcessor.getConversation();
                }
                return "WAIT_FOR_BID_CALL";
        }

Method executed when the initiator sends the winner confirmation

Parameters:
myProcessorthe CProcessor managing the conversation
msgaccept message

Definition at line 163 of file Jason_JAuc_Participant.java.

                                                                                         {
                JAucPartConversation conv = (JAucPartConversation)myProcessor.getConversation();
                AgentID Sender = myProcessor.getLastReceivedMessage().getSender();
                String finalbid =  msg.getContent();
                String request = msg.getHeaderValue("request");
                String newMsgContent = "winner"+"(\""+Sender.name+"\","+request+","+finalbid+","+conv.jasonConvID+")[source(self)]";
                List<Literal> allpercep = new ArrayList<Literal>();
                allpercep.add(Literal.parseLiteral(newMsgContent));
                ((ConvMagentixAgArch)Ts.getUserAgArch()).setPerception(allpercep);
        }

Method executed when the participant sends a proposal

Parameters:
myProcessorthe CProcessor managing the conversation
messageToSendproposal message

Definition at line 131 of file Jason_JAuc_Participant.java.

                                                 {
                JAucPartConversation conv = (JAucPartConversation)myProcessor.getConversation();
                messageToSend.setSender(myProcessor.getMyAgent().getAid());
                messageToSend.setReceiver(conv.initiator);
                messageToSend.setContent("agree");
                messageToSend.setHeader("auctionlevel", conv.AuctionLevel);
                messageToSend.setPerformative(ACLMessage.ACCEPT_PROPOSAL);
                messageToSend.setProtocol("japanese-auction");
        }
ConvCFactory es.upv.dsic.gti_ia.jason.conversationsFactory.participant.Jason_JAuc_Participant.newFactory ( String  name,
MessageFilter  filter,
ACLMessage  template,
int  availableConversations,
ConvJasonAgent  myAgent,
int  timeout 
)

Creates a new contract-net participant CFactory

Parameters:
namefactory's name
filtermessage filter
templatefirst message to send
availableConversationsmaximum number of conversation this CFactory can manage simultaneously
myAgentagent owner of this CFactory
timeoutfor waiting after sending the proposal
Returns:
a new fipa contract net participant factory

Definition at line 226 of file Jason_JAuc_Participant.java.

                                                                                                              {

                // Create factory

                if (filter == null) {
                        filter = new MessageFilter("protocol = japanese-auction AND purpose = startdata");
                }
                
                ConvCFactory theFactory = new ConvCFactory(name, filter,
                                availableConversations, myAgent);

                // Processor template setup

                ConvCProcessor processor = theFactory.cProcessorTemplate();

                // BEGIN State

                BeginState BEGIN = (BeginState) processor.getState("BEGIN");
                BEGIN.setMethod(new BEGIN_Method());
                
                // WAIT_FOR_NEW_CONV_DATA State
                WaitState WAIT_FOR_NEW_CONV_DATA = new WaitState("WAIT_FOR_NEW_CONV_DATA", 4000);
                processor.registerState(WAIT_FOR_NEW_CONV_DATA);
                processor.addTransition(BEGIN, WAIT_FOR_NEW_CONV_DATA);
                
                // RECEIVE_NEW_CONV_DATA State
                ReceiveState RECEIVE_NEW_CONV_DATA = new ReceiveState(
                                "RECEIVE_NEW_CONV_DATA");
                RECEIVE_NEW_CONV_DATA.setMethod(new RECEIVE_NEW_CONV_DATA_Method());
                filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.INFORM)+" AND purpose = startdata");
                RECEIVE_NEW_CONV_DATA.setAcceptFilter(filter);
                processor.registerState(RECEIVE_NEW_CONV_DATA);
                processor.addTransition(WAIT_FOR_NEW_CONV_DATA,
                                RECEIVE_NEW_CONV_DATA);
                
                // WAIT_FOR_BID_CALL State
                WaitState WAIT_FOR_BID_CALL = new WaitState("WAIT_FOR_BID_CALL", timeout);
                processor.registerState(WAIT_FOR_BID_CALL);
                processor.addTransition(RECEIVE_NEW_CONV_DATA, WAIT_FOR_BID_CALL);
                
                // RECEIVE_BID_CALL State

                ReceiveState RECEIVE_BID_CALL = new ReceiveState(
                                "RECEIVE_BID_CALL");
                RECEIVE_BID_CALL.setMethod(new RECEIVE_BID_CALL_Method());
                filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.PROPOSE)+" AND ( purpose = start OR purpose = bid )");
                RECEIVE_BID_CALL.setAcceptFilter(filter);
                processor.registerState(RECEIVE_BID_CALL);
                processor.addTransition(WAIT_FOR_BID_CALL,
                                RECEIVE_BID_CALL);

                // SEND_AGREE State

                SendState SEND_AGREE = new SendState("SEND_AGREE");

                SEND_AGREE.setMethod(new SEND_AGREE_Method());
                template.setProtocol("japanese-auction");
                template.setPerformative(ACLMessage.ACCEPT_PROPOSAL);
                SEND_AGREE.setMessageTemplate(template);
                processor.registerState(SEND_AGREE);
                processor.addTransition(RECEIVE_BID_CALL, SEND_AGREE);
                
                

                // WAIT_FOR_BID_CALL2 State
                WaitState WAIT_FOR_BID_CALL2 = new WaitState("WAIT_FOR_BID_CALL2", timeout);
                processor.registerState(WAIT_FOR_BID_CALL2);
                processor.addTransition(SEND_AGREE, WAIT_FOR_BID_CALL2);
                processor.addTransition(WAIT_FOR_BID_CALL2,RECEIVE_BID_CALL);
                
                // TIMEOUT State

                ReceiveState TIMEOUT = new ReceiveState("TIMEOUT");
                TIMEOUT.setMethod(new TIMEOUT_Method());
                filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.INFORM)+" AND purpose = waitMessage");
                TIMEOUT.setAcceptFilter(filter);
                processor.registerState(TIMEOUT);
                processor.addTransition(WAIT_FOR_NEW_CONV_DATA, TIMEOUT);
                processor.addTransition(WAIT_FOR_BID_CALL, TIMEOUT);
                processor.addTransition(WAIT_FOR_BID_CALL2, TIMEOUT);


                // RECEIVE_WINNER_CONFIRMATION State

                ReceiveState RECEIVE_WINNER_CONFIRM = new ReceiveState(
                                "RECEIVE_WINNER_CONFIRM");
                RECEIVE_WINNER_CONFIRM.setMethod(new RECEIVE_WINNER_CONFIRM_Method());
                filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.INFORM)+" AND purpose = winner");
                RECEIVE_WINNER_CONFIRM.setAcceptFilter(filter);
                processor.registerState(RECEIVE_WINNER_CONFIRM);
                processor.addTransition(WAIT_FOR_BID_CALL2,
                                RECEIVE_WINNER_CONFIRM);

                
                // RECEIVE_END_CONFIRMATION State
                ReceiveState RECEIVE_END_CONFIRMATION = new ReceiveState(
                "RECEIVE_END_CONFIRMATION");
                RECEIVE_END_CONFIRMATION.setMethod(new RECEIVE_END_CONFIRMATION_Method());
                filter = new MessageFilter("performative = "+ACLMessage.getPerformative(ACLMessage.INFORM)+" AND purpose = end");
                RECEIVE_END_CONFIRMATION.setAcceptFilter(filter);
                processor.registerState(RECEIVE_END_CONFIRMATION);
                processor.addTransition(WAIT_FOR_BID_CALL2, RECEIVE_END_CONFIRMATION);
                
                // FINAL State

                FinalState FINAL = new FinalState("FINAL");

                FINAL.setMethod(new FINAL_Method());

                processor.registerState(FINAL);
                processor.addTransition(RECEIVE_WINNER_CONFIRM, FINAL);                 
                processor.addTransition(RECEIVE_BID_CALL, FINAL);
                processor.addTransition(TIMEOUT, FINAL);
                processor.addTransition(RECEIVE_END_CONFIRMATION, FINAL);
                return theFactory;
        } 

Member Data Documentation


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