private VrpPathWithTravelData calculateFromPickupToPickup( VrpPathWithTravelData previous, TaxibusRequest current, double time) { return VrpPaths.calcAndCreatePath( previous.getToLink(), current.getFromLink(), time, routerWithCache, optimContext.travelTime); }
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; }
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); }
@Override protected void scheduleUnplannedRequests() { Set<TaxibusRequest> handledRequests = new HashSet<>(); for (TaxibusRequest req : unplannedRequests) { TaxibusLine line = dispatcher.findLineForRequest(req); if (line == null) { log.error("rejecting reqeuest" + req.getId() + " f " + req.getPassenger()); req.setRejected(true); handledRequests.add(req); continue; } if (this.optimContext.timer.getTimeOfDay() > req.getT0() - 3600) { TaxibusDispatch requestPath = this.currentRequestPathForLine.get(line.getId()); if (requestPath == null) { Vehicle veh = line.getNextEmptyVehicle(); if (veh == null) break; VrpPathWithTravelData path = calculateVrpPath(veh, req); requestPath = new TaxibusDispatch(veh, req, path); this.currentRequestPathForLine.put(line.getId(), requestPath); double twmax = Math.max(req.getT0(), path.getArrivalTime()) + line.getCurrentTwMax(); this.currentTwMax.put(line.getId(), twmax); } else { double departureTime = requestPath.getEarliestNextDeparture(); VrpPathWithTravelData path = calculateFromPickupToPickup(requestPath.getLastPathAdded(), req, departureTime); requestPath.addRequestAndPath(req, path); } handledRequests.add(req); if (line.getCurrentOccupationRate() == requestPath.requests.size()) { fillPathWithDropOffsAndSchedule(requestPath, line.getId()); this.currentRequestPathForLine.put(line.getId(), null); this.currentTwMax.put(line.getId(), null); } } } unplannedRequests.removeAll(handledRequests); }