示例#1
0
  private void fillPathWithDropOffsAndSchedule(TaxibusDispatch requestPath, Id<TaxibusLine> id) {

    Set<TaxibusRequest> allRequests = new LinkedHashSet<TaxibusRequest>();
    allRequests.addAll(requestPath.requests);

    // sort drop offs in meaningful manner by shortest segment time
    while (!allRequests.isEmpty()) {
      Tuple<VrpPathWithTravelData, TaxibusRequest> nextTuple =
          getNextDropoffSegment(
              allRequests,
              requestPath.getEarliestNextDeparture(),
              requestPath.getLastPathAdded().getToLink());
      requestPath.addPath(nextTuple.getFirst());
      allRequests.remove(nextTuple.getSecond());
    }
    Link toLink =
        this.optimContext
            .scenario
            .getNetwork()
            .getLinks()
            .get(this.dispatcher.calculateNextHoldingPointForTaxibus(requestPath.vehicle, id));
    VrpPathWithTravelData lastPath =
        VrpPaths.calcAndCreatePath(
            requestPath.getLastPathAdded().getToLink(),
            toLink,
            requestPath.getEarliestNextDeparture(),
            routerWithCache,
            optimContext.travelTime);
    requestPath.addPath(lastPath);
    optimContext.scheduler.scheduleRequest(requestPath);

    // in the very end, add path to opposite direction
  }
示例#2
0
 private VrpPathWithTravelData calculateFromPickupToPickup(
     VrpPathWithTravelData previous, TaxibusRequest current, double time) {
   return VrpPaths.calcAndCreatePath(
       previous.getToLink(),
       current.getFromLink(),
       time,
       routerWithCache,
       optimContext.travelTime);
 }
示例#3
0
 private VrpPathWithTravelData calculateVrpPath(Vehicle veh, TaxibusRequest req) {
   LinkTimePair departure = optimContext.scheduler.getImmediateDiversionOrEarliestIdleness(veh);
   return departure == null
       ? //
       null
       : VrpPaths.calcAndCreatePath(
           departure.link,
           req.getFromLink(),
           departure.time,
           routerWithCache,
           optimContext.travelTime);
 }
示例#4
0
  private Tuple<VrpPathWithTravelData, TaxibusRequest> getNextDropoffSegment(
      Set<TaxibusRequest> allRequests, double departureTime, Link departureLink) {

    double bestTime = Double.MAX_VALUE;
    Tuple<VrpPathWithTravelData, TaxibusRequest> bestSegment = null;
    for (TaxibusRequest request : allRequests) {
      VrpPathWithTravelData segment =
          VrpPaths.calcAndCreatePath(
              departureLink,
              request.getToLink(),
              departureTime,
              routerWithCache,
              optimContext.travelTime);
      if (segment.getTravelTime() < bestTime) {
        bestTime = segment.getTravelTime();
        bestSegment = new Tuple<>(segment, request);
      }
    }

    return bestSegment;
  }