예제 #1
0
  public PeopleRequest getPeopleRequestLongDistance() {

    if (T.stopRequest()) return null;
    if (T.currentTimePoint % 60 == 0) {
      int x = R.nextInt() % probPeople;
      // x = 0;
      if (x == 0) {
        r_id++;
        int pickupLocation = -1; // map.V.get(R.nextInt(map.V.size()));
        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);
        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::getPeopleRequest repeat.....");
        }
        used.put(pickupLocation, true);

        int deliveryLocation = -1; // 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::getPeopleRequest repeat.....");
        }
        used.put(deliveryLocation, true);

        PeopleRequest pr = new PeopleRequest(pickupLocation, deliveryLocation);
        pr.id = r_id;
        log.println(
            "EventGenerator::nextEvent --> At "
                + T.currentTimePointHMS()
                + "["
                + T.currentTimePoint
                + "]"
                + " --> people request from "
                + pickupLocation
                + " to "
                + deliveryLocation
                + " arrive");
        return pr;
      }
    }
    return null;
  }
예제 #2
0
  public PeopleRequest getPeopleRequest() {

    if (T.stopRequest()) return null;
    if (T.currentTimePoint % 60 == 0) {
      int x = R.nextInt() % probPeople;
      // x = 0;
      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::getPeopleRequest repeat.....");
        }
        used.put(pickupLocation, true);

        int deliveryLocation = -1; // 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::getPeopleRequest repeat.....");
        }
        used.put(deliveryLocation, true);

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