MATSIM
CapacityDependentInVehicleCostCalculator.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.* *
3  *
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2023 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 package ch.sbb.matsim.routing.pt.raptor;
21 
23 import org.matsim.vehicles.Vehicle;
24 
58 
59  double minimumCostFactor = 0.4;
60  double lowerCapacityLimit = 0.3;
61  double higherCapacityLimit = 0.6;
62  double maximumCostFactor = 1.8;
63 
65  }
66 
67  public CapacityDependentInVehicleCostCalculator(double minimumCostFactor, double lowerCapacityLimit, double higherCapacityLimit, double maximumCostFactor) {
68  this.minimumCostFactor = minimumCostFactor;
69  this.lowerCapacityLimit = lowerCapacityLimit;
70  this.higherCapacityLimit = higherCapacityLimit;
71  this.maximumCostFactor = maximumCostFactor;
72  }
73 
74  @Override
75  public double getInVehicleCost(double inVehicleTime, double marginalUtility_utl_s, Person person, Vehicle vehicle, RaptorParameters paramters, RouteSegmentIterator iterator) {
76  double costSum = 0;
77  double seatCount = vehicle.getType().getCapacity().getSeats();
78  double standingRoom = vehicle.getType().getCapacity().getStandingRoom();
79 
80  boolean considerSeats = standingRoom * 2 < seatCount; // at least 2/3 of capacity are seats, so passengers could expect a seat
81 
82  double relevantCapacity = considerSeats ? seatCount : (seatCount + standingRoom);
83 
84  while (iterator.hasNext()) {
85  iterator.next();
86  double inVehTime = iterator.getInVehicleTime();
87  double paxCount = iterator.getPassengerCount();
88  double occupancy = paxCount / relevantCapacity;
89  double baseCost = inVehTime * -marginalUtility_utl_s;
90  double factor = 1.0;
91 
92  if (occupancy < this.lowerCapacityLimit) {
93  factor = this.minimumCostFactor + (1.0 - this.minimumCostFactor) / this.lowerCapacityLimit * occupancy;
94  }
95  if (occupancy > this.higherCapacityLimit) {
96  factor = 1.0 + (this.maximumCostFactor - 1.0) / (1.0 - this.higherCapacityLimit) * (occupancy - this.higherCapacityLimit);
97  }
98 
99  costSum += baseCost * factor;
100  }
101  return costSum;
102  }
103 }
CapacityDependentInVehicleCostCalculator(double minimumCostFactor, double lowerCapacityLimit, double higherCapacityLimit, double maximumCostFactor)
final VehicleCapacity getCapacity()
double getInVehicleCost(double inVehicleTime, double marginalUtility_utl_s, Person person, Vehicle vehicle, RaptorParameters paramters, RouteSegmentIterator iterator)