Magentix2
2.1.1
|
Public Member Functions | |
String | run (CProcessor myProcessor) |
Definition at line 283 of file Jason_FCN_Initiator.java.
String es.upv.dsic.gti_ia.jason.conversationsFactory.initiator.Jason_FCN_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 285 of file Jason_FCN_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); //We create dynamically 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) 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){ System.out.println("SEND_ACCEPTANCE_"+(i-1)); 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) myProcessor.addTransition("SEND_REJECTION_"+(j-1), "WAIT_FOR_RESULTS"); if(accept) return "SEND_ACCEPTANCE_0"; else if(reject) return "SEND_REJECTION_0"; else return "FINAL"; }