public AgentReply hasGridletsAgent(AgentRequest request, boolean trace) {
    int requestID = request.getRequestID();
    int reqrepID = request.getReqrepID();
    double evsend_time = 0;
    int agentType = request.getDst_entityType();
    int SIZE = 500;
    super.send(
        super.output,
        GridSimTags.SCHEDULE_NOW,
        Tags.HASGRIDLETS_REQUEST,
        new IO_data(request, SIZE, request.getDst_agentID()));
    evsend_time = GridSim.clock();
    String msg =
        String.format(
            "%1$f %2$d %3$s --> AM_%4$s::HASGRIDLETS_REQUEST %6$s (%7$s AID %9$d) %5$s AM_%8$s",
            evsend_time,
            reqrepID,
            this.get_name(),
            super.getEntityName(request.getDst_resID()),
            EntityTypes.toString(request.getDst_entityType()),
            Tags.toString(Tags.HASGRIDLETS_REQUEST),
            super.getEntityName(request.getDst_agentID()),
            super.getEntityName(request.getDst_moveToresID()),
            request.getDst_AID());
    if (trace) {
      this.write(msg);
    }

    Sim_type_p ptag = new Sim_type_p(Tags.HASGRIDLETS_REPLY);
    Sim_event ev = new Sim_event();
    super.sim_get_next(ptag, ev); // only look for this type of ack
    AgentReply agentReply = AgentReply.get_data(ev);
    if (agentReply == null) {
      Assert.fail();
    }
    Assert.assertEquals(requestID, agentReply.getRequestID());
    Assert.assertEquals(Tags.HASGRIDLETS_REQUEST, agentReply.getRequestTAG());
    Assert.assertEquals(ev.get_tag(), Tags.HASGRIDLETS_REPLY);

    double evrecv_time = GridSim.clock();
    msg =
        String.format(
            "%1$f %2$d %3$s <-- AM_%4$s::%7$s %8$s (%6$s AID %10$d) %5$s AM_%9$s",
            evrecv_time,
            reqrepID,
            this.get_name(),
            super.getEntityName(agentReply.getRequest().getDst_resID()),
            EntityTypes.toString(agentType),
            super.getEntityName(request.getDst_agentID()),
            agentReply.isOk(),
            Tags.toString(Tags.HASGRIDLETS_REPLY),
            super.getEntityName(request.getDst_moveToresID()),
            request.getDst_AID());
    if (trace) {
      this.write(msg);
    }
    return agentReply;
  }
  AgentReply requestToAgent(AgentRequest request, int tag) {
    int requestID = request.getRequestID();
    int reqrepID = request.getReqrepID();
    double evsend_time = 0;
    int agentType = request.getDst_entityType();
    int SIZE;
    if (tag == Tags.AGENT_RUN_REQ) {
      SIZE = request.getDst_agentSize();
    } else {
      SIZE = 500;
    }
    if ((tag == Tags.AGENT_RUN_REQ)
        || (tag == Tags.AGENT_KILL_REQ)
        || (tag == Tags.AGENT_KILLAWAIT_REQ)
        || (tag == Tags.AGENT_PAUSE_REQ)
        || (tag == Tags.AGENT_RESUME_REQ)) {
      super.send(
          super.output,
          GridSimTags.SCHEDULE_NOW,
          tag,
          new IO_data(request, SIZE, request.getDst_resID()));
    } else {
      super.send(
          super.output,
          GridSimTags.SCHEDULE_NOW,
          tag,
          new IO_data(request, SIZE, request.getDst_agentID()));
    }
    evsend_time = GridSim.clock();
    String msg =
        String.format(
            "%1$f %2$d %3$s --> AM_%4$s::REQUEST %6$s (%7$s AID %9$d) %5$s AM_%8$s",
            evsend_time,
            reqrepID,
            this.get_name(),
            super.getEntityName(request.getDst_resID()),
            EntityTypes.toString(request.getDst_entityType()),
            Tags.toString(tag),
            super.getEntityName(request.getDst_agentID()),
            super.getEntityName(request.getDst_moveToresID()),
            request.getDst_AID());
    this.write(msg);

    Sim_type_p ptag = new Sim_type_p(tag + 1);
    Sim_event ev = new Sim_event();
    super.sim_get_next(ptag, ev); // only look for this type of ack
    AgentReply agentReply = AgentReply.get_data(ev);

    if (agentReply != null) {
      Assert.assertEquals(requestID, agentReply.getRequestID());
      Assert.assertEquals(tag, agentReply.getRequestTAG());
      Assert.assertEquals(ev.get_tag(), tag + 1);

      double evrecv_time = GridSim.clock();
      msg =
          String.format(
              "%1$f %2$d %3$s <-- AM_%4$s::%7$s %8$s (%6$s AID %10$d) %5$s AM_%9$s",
              evrecv_time,
              reqrepID,
              this.get_name(),
              super.getEntityName(agentReply.getRequest().getDst_resID()),
              EntityTypes.toString(agentType),
              super.getEntityName(request.getDst_agentID()),
              agentReply.isOk(),
              Tags.toString(tag),
              super.getEntityName(request.getDst_moveToresID()),
              request.getDst_AID());
      this.write(msg);
    }
    return agentReply;
  }