Magentix2
2.1.1
|
Public Member Functions | |
String | run (CProcessor myProcessor) |
Definition at line 291 of file Jason_FICN_Initiator.java.
String es.upv.dsic.gti_ia.jason.conversationsFactory.initiator.Jason_FICN_Initiator.EVALUATE_PROPOSALS_Method.run | ( | CProcessor | myProcessor | ) |
The method to be executed by the action state
myProcessor | The CProcessor of the conversation |
Implements es.upv.dsic.gti_ia.cAgents.ActionStateMethod.
Definition at line 293 of file Jason_FICN_Initiator.java.
{ ArrayList<ACLMessage> proposes = (ArrayList<ACLMessage>)myProcessor.getInternalData().get("proposes"); ArrayList<ACLMessage> acceptances = new ArrayList<ACLMessage>(); ArrayList<ACLMessage> rejections = new ArrayList<ACLMessage>(); doEvaluateProposals((ConvCProcessor) myProcessor, proposes, acceptances, rejections); FICNConversation conv = (FICNConversation)((ConvCProcessor)myProcessor).getConversation(); //We create dinamically the send states SendState send; boolean accept = false; boolean reject = false; int i; myProcessor.getInternalData().put("acceptedProposals", acceptances.size()); if(acceptances.size() > 0) accept = true; if(rejections.size() > 0) reject = true; for(i=0; i< acceptances.size(); i++){ send = new SendState("SEND_ACCEPTANCE_"+i); send.setMethod(new SEND_Method("SEND_ACCEPTANCE_"+i)); send.setMessageTemplate(acceptances.get(i)); myProcessor.registerState(send); if(i == 0) myProcessor.addTransition("EVALUATE_PROPOSALS", "SEND_ACCEPTANCE_"+i); else myProcessor.addTransition("SEND_ACCEPTANCE_"+(i-1), "SEND_ACCEPTANCE_"+i); } if(!reject && accept) { if (conv.goOnIterating) {myProcessor.addTransition("SEND_ACCEPTANCE_"+(i-1), "SOLICIT_PROPOSALS");} else {myProcessor.addTransition("SEND_ACCEPTANCE_"+(i-1), "WAIT_FOR_RESULTS");} } int j; for(j=0; j< rejections.size(); j++){ send = new SendState("SEND_REJECTION_"+j); send.setMethod(new SEND_Method("SEND_REJECTION_"+j)); send.setMessageTemplate(rejections.get(j)); myProcessor.registerState(send); if(j == 0) { if(accept){ myProcessor.addTransition("SEND_ACCEPTANCE_"+(i-1), "SEND_REJECTION_"+j); } else myProcessor.addTransition("EVALUATE_PROPOSALS", "SEND_REJECTION_"+j); } else myProcessor.addTransition("SEND_REJECTION_"+(j-1), "SEND_REJECTION_"+j); } if(reject) { if (conv.goOnIterating) {myProcessor.addTransition("SEND_REJECTION_"+(j-1), "SOLICIT_PROPOSALS");} else {myProcessor.addTransition("SEND_REJECTION_"+(j-1), "WAIT_FOR_RESULTS");} } String finalResult = ""; if(accept) { finalResult= "SEND_ACCEPTANCE_0"; } else { if(reject) { finalResult = "SEND_REJECTION_0"; } else { if (conv.goOnIterating){finalResult = "SOLICIT_PROPOSALS"; } else finalResult = "FINAL"; } } return finalResult; }