@Override public double getWalkTravelDisutility(Person person, Coord coord, Coord toCoord) { // getMarginalUtilityOfTravelTimeWalk INCLUDES the opportunity cost of time. kai, dec'12 double timeCost = - getTravelTime(coord, toCoord) * config.getMarginalUtilityOfTravelTimeWalk_utl_s() ; // (sign: margUtl is negative; overall it should be positive because it is a cost.) double distanceCost = - CoordUtils.calcEuclideanDistance(coord,toCoord) * config.getMarginalUtilityOfTravelDistancePt_utl_m() ; // (sign: same as above) return timeCost + distanceCost ; }
public RandomizingTransitRouterTravelTimeAndDisutility(TransitRouterConfig routerConfig) { super(routerConfig); prepareDataCollection(); // make sure that some parameters are not zero since otherwise the randomization will not work: // marg utl time wlk should be around -3/h or -(3/3600)/sec. Give warning if not at least 1/3600: if ( -routerConfig.getMarginalUtilityOfTravelTimeWalk_utl_s() < 1./3600. ) { Logger.getLogger(this.getClass()).warn( "marg utl of walk rather close to zero; randomization may not work") ; } // utl of line switch should be around -300sec or -0.5u. Give warning if not at least 0.1u: if ( -routerConfig.getUtilityOfLineSwitch_utl() < 0.1 ) { Logger.getLogger(this.getClass()).warn( "utl of line switch rather close to zero; randomization may not work") ; } this.originalTransitRouterConfig = routerConfig ; this.localMarginalUtilityOfTravelDistancePt_utl_m = routerConfig.getMarginalUtilityOfTravelDistancePt_utl_m(); this.localMarginalUtilityOfTravelTimePt_utl_s = routerConfig.getMarginalUtilityOfTravelTimePt_utl_s() ; this.localMarginalUtilityOfTravelTimeWalk_utl_s = routerConfig.getMarginalUtilityOfTravelTimeWalk_utl_s() ; // this.localMarginalUtilityOfWaitingPt_utl_s = routerConfig.getMarginalUtilityOfTravelTimePt_utl_s() ; this.localMarginalUtilityOfWaitingPt_utl_s = routerConfig.getMarginalUtilityOfWaitingPt_utl_s() ; this.localUtilityOfLineSwitch_utl = routerConfig.getUtilityOfLineSwitch_utl() ; } public final String getDataCollectionString( DataCollection item ) {
@Override public double getLinkTravelDisutility(Link link, double time, Person person, Vehicle vehicle) { TransitRouterNetworkWW.TransitRouterNetworkLink wrapped = (TransitRouterNetworkWW.TransitRouterNetworkLink) link; if (wrapped.route != null) return - linkTravelTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)]*this.config.getMarginalUtilityOfTravelTimePt_utl_s()*linkVehicleOccupancy.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)]>SIT_PERCENTAGE?NO_SIT_FACTOR:1 - link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m(); else if (wrapped.toNode.route!=null) // it's a wait link return - linkWaitingTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)]*this.config.getMarginalUtilityOfWaitingPt_utl_s() - this.config.getUtilityOfLineSwitch_utl(); else if(wrapped.fromNode.route==null) // it's a transfer link (walk) return -wrapped.getLength()/this.config.getBeelineWalkSpeed()*this.config.getMarginalUtilityOfTravelTimeWalk_utl_s(); else //inside link return 0; } @Override
@Override public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle, final CustomDataManager dataManager) { boolean cachedTravelDisutility = false; if(previousLink==link && previousTime==time) cachedTravelDisutility = true; TransitRouterNetworkWW.TransitRouterNetworkLink wrapped = (TransitRouterNetworkWW.TransitRouterNetworkLink) link; if (wrapped.route != null) return -(cachedTravelDisutility?cachedTravelTime:linkTravelTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)])*this.config.getMarginalUtilityOfTravelTimePt_utl_s()*linkVehicleOccupancy.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)]>SIT_PERCENTAGE?NO_SIT_FACTOR:1 - link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m(); else if (wrapped.toNode.route!=null) // it's a wait link return -(cachedTravelDisutility?cachedTravelTime:linkWaitingTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)])*this.config.getMarginalUtilityOfWaitingPt_utl_s() - this.config.getUtilityOfLineSwitch_utl(); else if(wrapped.fromNode.route==null) // it's a transfer link (walk) return -(cachedTravelDisutility?cachedTravelTime:wrapped.getLength()/this.config.getBeelineWalkSpeed())*this.config.getMarginalUtilityOfTravelTimeWalk_utl_s(); else //inside link return 0; } @Override
/** * cost of a single transfer. Fare is included in {@link RaptorDisutility.getInVehicleTravelDisutility} */ protected final double getTransferCost(final Coord fromStop, final Coord toStop) { // this is same as defaultTransferCost in TransitRouterNetworkTravelTimeAndDisutility. Amit Oct'17 double cost; double transfertime = getTransferTime(fromStop, toStop); double waittime = this.config.getAdditionalTransferTime(); // say that the effective walk time is the transfer time minus some "buffer" double walktime = transfertime - waittime; if ( walktime < 0. ) { throw new RuntimeException( "negative walk time; should not happen; needs to be repaired" ) ; } double walkDistance = CoordUtils.calcEuclideanDistance(fromStop, toStop); // weigh this "buffer" not with the walk time disutility, but with the wait time disutility: // (note that this is the same "additional disutl of wait" as in the scoring function. Its default is zero. // only if you are "including the opportunity cost of time into the router", then the disutility of waiting will // be the same as the marginal opprotunity cost of time). kai, nov'11 cost = - walktime * this.config.getMarginalUtilityOfTravelTimeWalk_utl_s() - walkDistance * this.config.getMarginalUtilityOfTravelDistancePt_utl_m() - waittime * this.config.getMarginalUtilityOfWaitingPt_utl_s() - this.config.getUtilityOfLineSwitch_utl(); return cost; }
@Override public double getLinkTravelDisutility(Link link, double time, Person person, Vehicle vehicle) { TransitRouterNetworkWW.TransitRouterNetworkLink wrapped = (TransitRouterNetworkWW.TransitRouterNetworkLink) link; if (wrapped.route != null) return - linkTravelTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)] * this.config.getMarginalUtilityOfTravelTimePt_utl_s() - link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m(); else if (wrapped.toNode.route!=null) // it's a wait link return - linkWaitingTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)] * this.config.getMarginalUtilityOfWaitingPt_utl_s() - this.config.getUtilityOfLineSwitch_utl(); else if(wrapped.fromNode.route==null) // it's a transfer link (walk) return -wrapped.getLength()/this.config.getBeelineWalkSpeed() * this.config.getMarginalUtilityOfTravelTimeWalk_utl_s(); else //inside link return 0; } @Override
@Override public double getLinkTravelDisutility(Link link, double time, Person person, Vehicle vehicle) { TransitRouterNetworkWW.TransitRouterNetworkLink wrapped = (TransitRouterNetworkWW.TransitRouterNetworkLink) link; if (wrapped.route != null) return - linkTravelTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)]*this.config.getMarginalUtilityOfTravelTimePt_utl_s() - link.getLength() * (this.config.getMarginalUtilityOfTravelDistancePt_utl_m()); else if (wrapped.toNode.route!=null) // it's a wait link return - linkWaitingTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)]*this.config.getMarginalUtilityOfWaitingPt_utl_s() - this.config.getUtilityOfLineSwitch_utl(); else if(wrapped.fromNode.route==null) // it's a transfer link (walk) return -wrapped.getLength()/this.config.getBeelineWalkSpeed()*this.config.getMarginalUtilityOfTravelTimeWalk_utl_s(); else //inside link return 0; } @Override
@Override public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle, final CustomDataManager dataManager) { boolean cachedTravelDisutility = false; if(previousLink==link && previousTime==time) cachedTravelDisutility = true; TransitRouterNetworkWW.TransitRouterNetworkLink wrapped = (TransitRouterNetworkWW.TransitRouterNetworkLink) link; if (wrapped.route != null) return -(cachedTravelDisutility?cachedLinkTime:linkTravelTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)])*this.config.getMarginalUtilityOfTravelTimePt_utl_s() - link.getLength() * (this.config.getMarginalUtilityOfTravelDistancePt_utl_m()); else if (wrapped.toNode.route!=null) // it's a wait link return -(cachedTravelDisutility?cachedLinkTime:linkWaitingTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)])*this.config.getMarginalUtilityOfWaitingPt_utl_s() - this.config.getUtilityOfLineSwitch_utl(); else if(wrapped.fromNode.route==null) // it's a transfer link (walk) return -(cachedTravelDisutility?cachedLinkTime:wrapped.getLength()/this.config.getBeelineWalkSpeed())*this.config.getMarginalUtilityOfTravelTimeWalk_utl_s(); else //inside link return 0; } @Override
@Override public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle, final CustomDataManager dataManager) { boolean cachedTravelDisutility = false; if(previousLink==link && previousTime==time) cachedTravelDisutility = true; TransitRouterNetworkWW.TransitRouterNetworkLink wrapped = (TransitRouterNetworkWW.TransitRouterNetworkLink) link; if (wrapped.route != null) return -(cachedTravelDisutility?cachedTravelTime:linkTravelTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)]) * this.config.getMarginalUtilityOfTravelTimePt_utl_s() - link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m(); else if (wrapped.toNode.route!=null) // it's a wait link return -(cachedTravelDisutility?cachedTravelTime:linkWaitingTimes.get(wrapped.getId())[time/timeSlot<numSlots?(int)(time/timeSlot):(numSlots-1)]) * this.config.getMarginalUtilityOfWaitingPt_utl_s() - this.config.getUtilityOfLineSwitch_utl(); else if(wrapped.fromNode.route==null) // it's a transfer link (walk) return -(cachedTravelDisutility?cachedTravelTime:wrapped.getLength()/this.config.getBeelineWalkSpeed())*this.config.getMarginalUtilityOfTravelTimeWalk_utl_s(); else //inside link return 0; } @Override
/** * Note that there is no off vehicle wait time. */ protected double getInVehicleTravelDisutility(final RouteSegment routeSegment) { double cost = 0.0; // this assumes dwell time as in-vehicle time double inVehicleTravelTime = routeSegment.getTravelTime(); double inVehicleBeelineDistance = CoordUtils.calcEuclideanDistance(routeSegment.getFromStop().getCoord(), routeSegment.getToStop().getCoord()); cost += - inVehicleTravelTime * this.config.getMarginalUtilityOfTravelTimePt_utl_s(); cost += - inVehicleBeelineDistance * this.config.getMarginalUtilityOfTravelDistancePt_utl_m(); // fare cost += this.costPerBoarding; cost += inVehicleBeelineDistance * this.costPerMeterTraveled; return cost; }
@Override public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle, final CustomDataManager dataManager) { double cost; if (((TransitRouterNetworkLink) link).getRoute() == null) { // "route" here means "pt route". If no pt route is attached, it means that it is a transfer link. cost = defaultTransferCost(link, time, person, vehicle); } else { double offVehWaitTime = offVehicleWaitTime(link, time); double inVehTime = getLinkTravelTime(link,time, person, vehicle) - offVehWaitTime; cost = - inVehTime * this.config.getMarginalUtilityOfTravelTimePt_utl_s() -offVehWaitTime * this.config.getMarginalUtilityOfWaitingPt_utl_s() -link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m(); } return cost; }