Exemplo n.º 1
0
  public ParcelRequest getParcelRequestLongDistance() {
    if (T.stopRequest()) return null;
    if (T.currentTimePoint % 60 == 0) {
      int x = R.nextInt() % probParcel;
      if (x == 0) {
        r_id++;
        Window w = WM.notEmptyWindows.get(WM.notEmptyWindows.size() - 1);
        Window wd = WM.farest.get(w);
        ArrayList<Integer> P = WM.lstPoints.get(w);
        ArrayList<Integer> PD = WM.lstPoints.get(wd);

        int pickupLocation = -1; // map.V.get(R.nextInt(map.V.size()));
        while (true) {
          pickupLocation = P.get(R.nextInt(P.size())); // map.V.get(R.nextInt(map.V.size()));
          // if(used.get(pickupLocation) == null)
          break;
          // System.out.println("EventGenerator::getParcelRequest repeat.....");
        }
        used.put(pickupLocation, true);

        int deliveryLocation = PD.get(R.nextInt(PD.size())); // map.V.get(R.nextInt(map.V.size()));
        while (true) {
          deliveryLocation = PD.get(R.nextInt(PD.size())); // map.V.get(R.nextInt(map.V.size()));
          // if(used.get(deliveryLocation) == null)
          break;
          // System.out.println("EventGenerator::getParcelRequest repeat.....");
        }
        used.put(deliveryLocation, true);

        ParcelRequest pr = new ParcelRequest(pickupLocation, deliveryLocation);
        pr.id = r_id;
        log.println(
            "EventGenerator::nextEvent --> At "
                + T.currentTimePointHMS()
                + "["
                + T.currentTimePoint
                + "]"
                + " --> parcel request from "
                + pickupLocation
                + " to "
                + deliveryLocation
                + " arrive");
        return pr;
      }
    }
    return null;
  }
Exemplo n.º 2
0
  public ParcelRequest getParcelRequest() {
    if (T.stopRequest()) return null;
    if (T.currentTimePoint % 60 == 0) {
      int x = R.nextInt() % probParcel;
      if (x == 0) {
        r_id++;
        int pickupLocation = -1; // map.V.get(R.nextInt(map.V.size()));
        while (true) {
          pickupLocation = map.V.get(R.nextInt(map.V.size()));
          if (used.get(pickupLocation) == null) break;
          System.out.println("EventGenerator::getParcelRequest repeat.....");
        }
        used.put(pickupLocation, true);

        int deliveryLocation = map.V.get(R.nextInt(map.V.size()));
        while (true) {
          deliveryLocation = map.V.get(R.nextInt(map.V.size()));
          if (used.get(deliveryLocation) == null) break;
          System.out.println("EventGenerator::getParcelRequest repeat.....");
        }
        used.put(deliveryLocation, true);

        ParcelRequest pr = new ParcelRequest(pickupLocation, deliveryLocation);
        pr.id = r_id;
        log.println(
            "EventGenerator::nextEvent --> At "
                + T.currentTimePointHMS()
                + "["
                + T.currentTimePoint
                + "]"
                + " --> parcel request from "
                + pickupLocation
                + " to "
                + deliveryLocation
                + " arrive");
        return pr;
      }
    }
    return null;
  }