Magentix2
2.1.1
|
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) |
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
Definition at line 35 of file FIPA_CONTRACTNET_Initiator.java.
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doBegin | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed at the beginning of the conversation
myProcessor | the CProcessor managing the conversation |
msg | first 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
myProcessor | the CProcessor managing the conversation |
proposes | Proposals |
acceptances | Accepted proposals |
rejections | Rejected proposals |
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doFinal | ( | CProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method executed when the initiator ends the conversation
myProcessor | the CProcessor managing the conversation |
messageToSend | final message of this conversation |
Definition at line 361 of file FIPA_CONTRACTNET_Initiator.java.
{ messageToSend = myProcessor.getLastSentMessage(); }
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doReceiveFailure | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the initiator receives a failure
myProcessor | the CProcessor managing the conversation |
msg | the 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
myProcessor | the CProcessor managing the conversation |
msg | inform message |
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doReceiveNotUnderstood | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the initiator receives a not-understood message
myProcessor | the CProcessor managing the conversation |
msg | not-understood message |
Definition at line 86 of file FIPA_CONTRACTNET_Initiator.java.
{ }
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doReceiveProposal | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the initiator receives a proposal
myProcessor | the CProcessor managing the conversation |
msg | proposal message |
Definition at line 140 of file FIPA_CONTRACTNET_Initiator.java.
{
ArrayList<ACLMessage> proposes = (ArrayList<ACLMessage>) myProcessor
.getInternalData().get("proposes");
proposes.add(msg);
}
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doReceiveRefuse | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the initiator receives a refuse message
myProcessor | the CProcessor managing the conversation |
msg | refuse message |
Definition at line 112 of file FIPA_CONTRACTNET_Initiator.java.
{ }
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doSolicitProposals | ( | CProcessor | myProcessor, |
ACLMessage | messageToSend | ||
) | [protected] |
Method executed when the initiator calls for proposals
myProcessor | the CProcessor managing the conversation |
messageToSend | Message 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());
}
void es.upv.dsic.gti_ia.cAgents.protocols.FIPA_CONTRACTNET_Initiator.doTimeout | ( | CProcessor | myProcessor, |
ACLMessage | msg | ||
) | [protected] |
Method executed when the timeout is reached while the initiator was waiting for proposals
myProcessor | the CProcessor managing the conversation |
msg | timeout 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
name | of the factory |
filter | message filter |
template | first message to send |
availableConversations | maximum number of conversation this CFactory can manage simultaneously |
myAgent | agent owner of this Cfactory |
participants | number of participants |
deadline | for waiting for proposals |
timeout | for waiting for inform |
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; }