Пример #1
0
 public AbstractEvent nextEvent() {
   AbstractEvent pr = null;
   if (T.stopRequest()) return null;
   if (T.currentTimePoint % 60 == 0) {
     int x = R.nextInt() % probPeople;
     // x = 0;
     if (x == 0) {
       r_id++;
       int pickupLocation = map.V.get(R.nextInt(map.V.size()));
       int deliveryLocation = map.V.get(R.nextInt(map.V.size()));
       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;
     }
     // }
     // if(T.currentTimePoint%60 == 0){
     x = R.nextInt() % probParcel;
     if (x == 0) {
       r_id++;
       int pickupLocation = map.V.get(R.nextInt(map.V.size()));
       int deliveryLocation = map.V.get(R.nextInt(map.V.size()));
       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 pr;
 }
Пример #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;
  }