Esempio n. 1
0
  @Override
  protected ACLMessage handleAcceptProposal(ACLMessage cfp, ACLMessage propose, ACLMessage accept) {
    // TODO Handle the accept
    Cfp content = null;
    try {
      content = (Cfp) accept.getContentObject();
    } catch (UnreadableException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    //		System.out.println(myAgent.getLocalName() + ": proposta aceite:" +
    // propose.getConversationId() + " content = " + content.getOrigin().getLocalName() + " " +
    // content.getDestination().getLocalName() + " " + content.getAgv().getLocalName());
    ACLMessage reply = accept.createReply();
    reply.setPerformative(ACLMessage.INFORM);
    if (myAgent.getClass() == AGV.class) {
      AGV a = (AGV) myAgent;
      AgvTransport t = new AgvTransport((AGV) myAgent, content);
      a.setTransportBehaviour(t);
      a.addBehaviour(new AgvTransport(a, content));
    }

    return reply;
  }
Esempio n. 2
0
 private double calculateCost(String originMachine, String destinationMachine, AGV agent) {
   HashMap<String, Location> map = agent.getMachineLocation();
   double cost =
       (agent.getLocation().distanceTo(map.get(originMachine))
               + Location.distanceTo(map.get(originMachine), map.get(destinationMachine)))
           * agent.getCost();
   return cost;
 }
Esempio n. 3
0
  private Cfp calculateCosts(Cfp cfpContent, AGV agent) {
    HashMap<AID, Integer> mapCost = new HashMap<AID, Integer>();
    // TODO improve cost calculation according products in the agv
    for (DFAgentDescription dfAgent : agent.getAgentListWithService("ProcessProduct")) {

      // check if origin is diferent than the destination to calculate the cost
      if (dfAgent.getName().getName().compareTo(cfpContent.getOrigin().getName()) != 0) {
        cfpContent = cfpContent.clone();
        cfpContent.setType(ObjectType.Agv);
        cfpContent.setAgv(myAgent.getAID());
        mapCost.put(
            dfAgent.getName(),
            (int)
                calculateCost(
                    cfpContent.getOrigin().getName(), dfAgent.getName().getName(), agent));
      }
    }

    cfpContent.setMachineCostMap(mapCost);
    return cfpContent;
  }