MATSIM
DefaultRaptorTransferCostCalculator.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 
22 import java.util.function.Supplier;
23 
28  @Override
29  public double calcTransferCost(SwissRailRaptorCore.PathElement currentPE, Supplier<Transfer> transfer, RaptorStaticConfig staticConfig, RaptorParameters raptorParams, int totalTravelTime, int transferCount, double existingTransferCosts, double currentTime) {
30  double transferCostBase = raptorParams.getTransferPenaltyFixCostPerTransfer();
31  double transferCostModeToMode = staticConfig.isUseModeToModeTransferPenalty()?staticConfig.getModeToModeTransferPenalty(transfer.get().getFromTransitRoute().getTransportMode(),transfer.get().getToTransitRoute().getTransportMode()):0.0;
32  double transferCostPerHour = raptorParams.getTransferPenaltyPerTravelTimeHour();
33  double transferCostMin = raptorParams.getTransferPenaltyMinimum();
34  double transferCostMax = raptorParams.getTransferPenaltyMaximum();
35 
36  return (calcSingleTransferCost(transferCostBase+transferCostModeToMode, transferCostPerHour, transferCostMin, transferCostMax, totalTravelTime) * transferCount) - existingTransferCosts;
37  }
38 
39  private double calcSingleTransferCost(double costBase, double costPerHour, double costMin, double costMax, double travelTime) {
40  double cost = costBase + costPerHour / 3600 * travelTime;
41  double max = Math.max(costMin, costMax);
42  double min = Math.min(costMin, costMax);
43  if (cost > max) {
44  cost = max;
45  }
46  if (cost < min) {
47  cost = min;
48  }
49  return cost;
50  }
51 
52 }
double calcTransferCost(SwissRailRaptorCore.PathElement currentPE, Supplier< Transfer > transfer, RaptorStaticConfig staticConfig, RaptorParameters raptorParams, int totalTravelTime, int transferCount, double existingTransferCosts, double currentTime)
double getModeToModeTransferPenalty(String fromMode, String toMode)
double calcSingleTransferCost(double costBase, double costPerHour, double costMin, double costMax, double travelTime)