MATSIM
IndividualRaptorParametersForPerson.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 
24 import org.matsim.core.config.Config;
30 
31 import jakarta.inject.Inject;
32 import java.util.Map;
33 
42  private final Config config;
45 
46  @Inject
48  this.config = config;
49  this.raptorConfig = ConfigUtils.addOrGetModule(config, SwissRailRaptorConfigGroup.class);
50  this.parametersForPerson = parametersForPerson;
51  }
52 
53  @Override
55  RaptorParameters raptorParameters = RaptorUtils.createParameters(config);
56  ScoringParameters scoringParameters = parametersForPerson.getScoringParameters(person);
57 
58  double marginalUtilityOfPerforming = scoringParameters.marginalUtilityOfPerforming_s;
59 
60  raptorParameters.setMarginalUtilityOfWaitingPt_utl_s(
61  scoringParameters.marginalUtilityOfWaitingPt_s - marginalUtilityOfPerforming);
62 
63  ScoringConfigGroup pcsConfig = config.scoring();
64 
65  for (Map.Entry<String, ScoringConfigGroup.ModeParams> e : pcsConfig.getModes().entrySet()) {
66  String mode = e.getKey();
67  ModeUtilityParameters modeParams = scoringParameters.modeParams.get(mode);
68 
69  if (modeParams != null) {
70  raptorParameters.setMarginalUtilityOfTravelTime_utl_s(mode,
71  modeParams.marginalUtilityOfTraveling_s - marginalUtilityOfPerforming);
72  }
73  }
74 
75  double costPerHour = this.raptorConfig.getTransferPenaltyCostPerTravelTimeHour();
76  if (costPerHour == 0.0) {
77  // backwards compatibility, use the default utility of line switch
78  raptorParameters.setTransferPenaltyFixCostPerTransfer(-scoringParameters.utilityOfLineSwitch);
79  } else {
80  raptorParameters.setTransferPenaltyFixCostPerTransfer(this.raptorConfig.getTransferPenaltyBaseCost());
81  }
82  raptorParameters.setTransferPenaltyPerTravelTimeHour(costPerHour);
83  raptorParameters.setTransferPenaltyMinimum(this.raptorConfig.getTransferPenaltyMinCost());
84  raptorParameters.setTransferPenaltyMaximum(this.raptorConfig.getTransferPenaltyMaxCost());
85 
86  return raptorParameters;
87  }
88 }
void setTransferPenaltyFixCostPerTransfer(double transferPenaltyFixCostPerTransfer)
static< T extends ConfigGroup > T addOrGetModule(Config config, Class< T > moduleClass)
IndividualRaptorParametersForPerson(Config config, ScoringParametersForPerson parametersForPerson)
final Map< String, ModeUtilityParameters > modeParams
void setTransferPenaltyMinimum(double transferPenaltyMinimum)
final ScoringConfigGroup scoring()
Definition: Config.java:407
static RaptorParameters createParameters(Config config)
void setMarginalUtilityOfTravelTime_utl_s(String mode, double marginalUtilityOfTravelTime_utl_s)
void setTransferPenaltyPerTravelTimeHour(double transferPenaltyPerTravelTimeHour)
void setTransferPenaltyMaximum(double transferPenaltyMaximum)
void setMarginalUtilityOfWaitingPt_utl_s(double marginalUtilityOfWaitingPt_utl_s)