20 package ch.sbb.matsim.config;
22 import com.google.common.base.Verify;
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.HashMap;
29 import java.util.HashSet;
30 import java.util.List;
33 import org.apache.logging.log4j.LogManager;
34 import org.apache.logging.log4j.Logger;
46 public static final String
GROUP =
"swissRailRaptor";
52 "least cost (default) or randomly chosen out of the available access / egress modes.";
61 private static final String
PARAM_USE_CAPACITY_CONSTRAINTS_DESC =
"If true, SwissRailRaptor tries to detect when agents cannot board a vehicle in the previous iteration because it is already full and tries to find an alternative route instead.";
64 private static final String
PARAM_TRANSFER_WALK_MARGIN_DESC =
"time deducted from transfer walk leg during transfers between pt legs in order to avoid missing a vehicle by a few seconds due to delays.";
68 private static final String
PARAM_TRANFER_CALCULATION_DESC =
"Defines whether all potential transfers are precomputed at the beginning of the simulation (Initial) or whether they are constructed on-demand when needed (Adaptive). The former incurs potentially long up-front caclulations, but quicker routing. The latter avoids any initial computation, but may require longer routing time.";
94 CalcLeastCostModePerStop, RandomSelectOneModePerRoutingRequestAndDirection
265 return switch (type){
271 default ->
throw new IllegalArgumentException(
"Unsupported parameterset-type: " + type);
290 throw new IllegalArgumentException(
"Unsupported parameterset: " +
set.getClass().
getName());
296 super.addParameterSet(
set);
306 if (subpops.isEmpty()) {
309 for (String subpop : subpops) {
313 super.addParameterSet(settings);
322 super.removeParameterSet(paramSet);
328 if (subpops.isEmpty()) {
331 for (String subpop : subpops) {
335 super.addParameterSet(settings);
344 super.removeParameterSet(paramSet);
350 super.addParameterSet(paramSet);
359 super.addParameterSet(paramSet);
373 private static final String
TYPE =
"rangeQuerySettings";
402 this.subpopulations.clear();
403 this.subpopulations.addAll(subpopulations);
429 private static final String
TYPE =
"routeSelector";
432 private static final String PARAM_BETA_TRAVELTIME =
"betaTravelTime";
433 private static final String PARAM_BETA_DEPARTURETIME =
"betaDepartureTime";
434 private static final String PARAM_BETA_TRANSFERS =
"betaTransferCount";
437 private double betaTravelTime = 1;
438 private double betaDepartureTime = 1;
439 private double betaTransfers = 300;
460 this.subpopulations.clear();
461 this.subpopulations.addAll(subpopulations);
465 public
double getBetaTravelTime() {
466 return this.betaTravelTime;
470 public
void setBetaTravelTime(
double betaTravelTime) {
471 this.betaTravelTime = betaTravelTime;
475 public
double getBetaDepartureTime() {
476 return betaDepartureTime;
480 public
void setBetaDepartureTime(
double betaDepartureTime) {
481 this.betaDepartureTime = betaDepartureTime;
485 public
double getBetaTransfers() {
486 return betaTransfers;
490 public
void setBetaTransfers(
double betaTransfers) {
491 this.betaTransfers = betaTransfers;
497 private static final String
TYPE =
"intermodalAccessEgress";
499 private static final String PARAM_MODE =
"mode";
500 private static final String PARAM_MAX_RADIUS =
"maxRadius";
501 private static final String PARAM_INITIAL_SEARCH_RADIUS =
"initialSearchRadius";
502 private static final String PARAM_SEARCH_EXTENSION_RADIUS =
"searchExtensionRadius";
503 private static final String PARAM_LINKID_ATTRIBUTE =
"linkIdAttribute";
504 private static final String PARAM_PERSON_FILTER_ATTRIBUTE =
"personFilterAttribute";
505 private static final String PARAM_PERSON_FILTER_VALUE =
"personFilterValue";
506 private static final String PARAM_STOP_FILTER_ATTRIBUTE =
"stopFilterAttribute";
507 private static final String PARAM_STOP_FILTER_VALUE =
"stopFilterValue";
508 private static final String PARAM_SHARE_TRIP_SEARCH_RADIUS =
"shareTripSearchRadius";
512 private double initialSearchRadius = Double.NEGATIVE_INFINITY;
513 private double searchExtensionRadius = 200;
519 private double shareTripSearchRadius = Double.POSITIVE_INFINITY;
526 public String getMode() {
537 public
double getMaxRadius() {
543 this.maxRadius = maxRadius;
548 public
double getInitialSearchRadius() {
549 return initialSearchRadius;
554 this.initialSearchRadius = initialSearchRadius;
559 public
double getSearchExtensionRadius() {
560 return searchExtensionRadius;
565 this.searchExtensionRadius = searchExtensionRadius;
570 public String getLinkIdAttribute() {
571 return linkIdAttribute;
576 this.linkIdAttribute = linkIdAttribute;
581 public String getPersonFilterAttribute() {
582 return this.personFilterAttribute;
587 this.personFilterAttribute = personFilterAttribute;
592 public String getPersonFilterValue() {
593 return this.personFilterValue;
598 this.personFilterValue = personFilterValue;
603 public String getStopFilterAttribute() {
604 return stopFilterAttribute;
609 this.stopFilterAttribute = stopFilterAttribute;
614 public String getStopFilterValue() {
615 return stopFilterValue;
620 this.stopFilterValue = stopFilterValue;
625 public
double getShareTripSearchRadius() {
626 return shareTripSearchRadius;
631 this.shareTripSearchRadius = shareTripSearchRadius;
637 Map<String, String> map = super.getComments();
638 map.put(PARAM_LINKID_ATTRIBUTE,
"If the mode is routed on the network, specify which linkId acts as access link to this stop in the transport modes sub-network.");
639 map.put(PARAM_STOP_FILTER_ATTRIBUTE,
"Name of the transit stop attribute used to filter stops that should be included in the set of potential stops for access and egress. The attribute should be of type String. 'null' disables the filter and all stops within the specified radius will be used.");
640 map.put(PARAM_STOP_FILTER_VALUE,
"Only stops where the filter attribute has the value specified here will be considered as access or egress stops.");
641 map.put(PARAM_PERSON_FILTER_ATTRIBUTE,
"Name of the person attribute used to figure out if this access/egress mode is available to the person.");
642 map.put(PARAM_PERSON_FILTER_VALUE,
"Only persons where the filter attribute has the value specified here can use this mode for access or egress. The attribute should be of type String.");
643 map.put(PARAM_MAX_RADIUS,
"Radius from the origin / destination coord in which transit stops are accessible by this mode.");
644 map.put(PARAM_INITIAL_SEARCH_RADIUS,
"Radius from the origin / destination coord in which transit stops are searched. Only if less than 2 transit stops are found the search radius is increased step-wise until the maximum search radius set in param radius is reached.");
645 map.put(PARAM_SEARCH_EXTENSION_RADIUS,
"If less than 2 stops were found in initialSearchRadius take the distance of the closest transit stop and add this extension radius to search again.The search radius will not exceed the maximum search radius set in param radius. Default is 200 meters.");
646 map.put(PARAM_SHARE_TRIP_SEARCH_RADIUS,
"The share of the trip crowfly distance within which the stops for access and egress will be searched for. This is a harder constraint than initial search radius. Default is positive infinity.");
654 private static final String
TYPE =
"modeMapping";
656 private static final String PARAM_ROUTE_MODE =
"routeMode";
657 private static final String PARAM_PASSENGER_MODE =
"passengerMode";
659 private String routeMode = null;
660 private String passengerMode = null;
668 this.routeMode = routeMode;
669 this.passengerMode = passengerMode;
673 public String getRouteMode() {
678 public
void setRouteMode(String routeMode) {
679 this.routeMode = routeMode;
683 public String getPassengerMode() {
684 return passengerMode;
688 public
void setPassengerMode(String passengerMode) {
689 this.passengerMode = passengerMode;
694 private static final String
TYPE =
"modeToModeTransferPenalty";
696 @
Comment(
"from Transfer PT Sub-Mode")
697 public String fromMode;
699 @
Comment("to Transfer PT Sub-Mode")
700 public String toMode;
702 @
Comment("Transfer Penalty per Transfer between modes")
703 public
double transferPenalty = 0.0;
711 this.fromMode = fromMode;
712 this.toMode = toMode;
713 this.transferPenalty = transferPenalty;
721 Map<String, String> comments = super.getComments();
737 +
"combination with plans without a routing mode is not supported.");
739 +
"modes defined. Add at least one parameterset with an access/egress mode and ensure " 740 +
"SwissRailRaptorConfigGroup is loaded correctly.");
743 Verify.verifyNotNull(paramset.mode,
"mode of an IntermodalAccessEgressParameterSet " 744 +
"is undefined. Please set a value in the config.");
745 Verify.verify(paramset.maxRadius > 0.0,
"maxRadius of IntermodalAccessEgressParameterSet " 746 +
"for mode " + paramset.mode +
" is negative or 0. Please set a positive value in the config.");
747 Verify.verify(paramset.initialSearchRadius > 0.0,
"initialSearchRadius of IntermodalAccessEgressParameterSet " 748 +
"for mode " + paramset.mode +
" is negative or 0. Please set a positive value in the config.");
749 Verify.verify(paramset.searchExtensionRadius > 0.0,
"searchExtensionRadius of IntermodalAccessEgressParameterSet " 750 +
"for mode " + paramset.mode +
" is negative or 0. Please set a positive value in the config.");
752 Verify.verify(paramset.maxRadius >= paramset.initialSearchRadius,
"maxRadius of IntermodalAccessEgressParameterSet " 753 +
"for mode " + paramset.mode +
" is smaller than initialSearchRadius. This is inconsistent.");
void setIntermodalLegOnlyHandling(IntermodalLegOnlyHandling intermodalLegOnlyHandling)
List< IntermodalAccessEgressParameterSet > getIntermodalAccessEgressParameterSets()
void setTransferPenaltyBaseCost(double baseCost)
static final String PARAM_TRANSFER_CALCULATION
void addRouteSelector(RouteSelectorParameterSet settings)
Map< String, String > getComments()
void setSubpopulations(String subpopulation)
int getMaxEarlierDeparture()
void setMaxEarlierDeparture(int maxEarlierDeparture)
static final String PARAM_INTERMODAL_ACCESS_EGRESS_MODE_SELECTION_DESC
RouteSelectorParameterSet()
double getTransferWalkMargin()
static Set< String > stringToSet(final String values)
RaptorTransferCalculation transferCalculation
RangeQuerySettingsParameterSet()
void addModeMappingForPassengers(ModeMappingForPassengersParameterSet paramSet)
final List< ModeToModeTransferPenalty > modeToModeTransferPenaltyParameterSets
static final String PARAM_TRANFER_CALCULATION_DESC
Collection< ModeMappingForPassengersParameterSet > getModeMappingForPassengers()
static String setToString(final Set< String > values)
void setTransferPenaltyCostPerTravelTimeHour(double hourlyCost)
void addParameterSet(ConfigGroup set)
ConfigGroup createParameterSet(String type)
List< ModeToModeTransferPenalty > getModeToModeTransferPenaltyParameterSets()
void setUseModeMappingForPassengers(boolean useModeMapping)
static final String PARAM_USE_CAPACITY_CONSTRAINTS_DESC
void setSubpopulations(Set< String > subpopulations)
static final String PARAM_SUBPOPS
final List< IntermodalAccessEgressParameterSet > intermodalAccessEgressSettings
static final String PARAM_TRANSFER_PENALTY_BASE
void setTransferPenaltyMinCost(double minCost)
boolean isUseRangeQuery()
RangeQuerySettingsParameterSet getRangeQuerySettings(String subpopulation)
RangeQuerySettingsParameterSet removeRangeQuerySettings(String subpopulation)
final Map< String, ModeMappingForPassengersParameterSet > modeMappingForPassengersByRouteMode
static final String PARAM_TRANSFER_PENALTY_PERHOUR
double transferPenaltyHourlyCost
boolean isUseCapacityConstraints()
static final String PARAM_SCORING_PARAMETERS
double transferWalkMargin
double transferPenaltyMinCost
void setIntermodalLegOnlyHandling(String intermodalLegOnlyHandling)
boolean isUseIntermodalAccessEgress()
static final String PARAM_TRANSFER_PENALTY_MIN
final Map< String, RouteSelectorParameterSet > routeSelectorPerSubpop
double getTransferPenaltyBaseCost()
ModeMappingForPassengersParameterSet(String routeMode, String passengerMode)
void setIntermodalAccessEgressModeSelection(IntermodalAccessEgressModeSelection intermodalAccessEgressModeSelection)
static final String PARAM_TRANSFER_WALK_MARGIN
void setTransferCalculation(RaptorTransferCalculation transferCalculation)
static final String GROUP
void addRangeQuerySettings(RangeQuerySettingsParameterSet settings)
final Map< String, RangeQuerySettingsParameterSet > rangeQuerySettingsPerSubpop
void setSubpopulations(Set< String > subpopulations)
static final String PARAM_MAX_LATER_DEPARTURE
void checkConsistency(Config config)
IntermodalLegOnlyHandling intermodalLegOnlyHandling
void setUseCapacityConstraints(boolean useCapacityConstraints)
double getTransferPenaltyMaxCost()
ModeMappingForPassengersParameterSet getModeMappingForPassengersParameterSet(String routeMode)
Set< String > getSubpopulations()
IntermodalAccessEgressModeSelection intermodalAccessEgressModeSelection
void addModeToModeTransferPenalty(ModeToModeTransferPenalty set)
final HandlingOfPlansWithoutRoutingMode getHandlingOfPlansWithoutRoutingMode()
Set< String > getSubpopulations()
IntermodalAccessEgressModeSelection getIntermodalAccessEgressModeSelection()
final PlansConfigGroup plans()
boolean useCapacityConstraints
static final String PARAM_MAX_EARLIER_DEPARTURE
Map< String, String > getComments()
void setScoringParameters(ScoringParameters scoringParameters)
String getIntermodalLegOnlyHandlingString()
String personFilterAttribute
int getMaxLaterDeparture()
double getTransferPenaltyCostPerTravelTimeHour()
static final String PARAM_INTERMODAL_LEG_ONLYHANDLING
RouteSelectorParameterSet removeRouteSelector(String subpopulation)
ScoringParameters scoringParameters
static final String PARAM_INTERMODAL_ACCESS_EGRESS_MODE_SELECTION
ModeToModeTransferPenalty(String fromMode, String toMode, double transferPenalty)
IntermodalLegOnlyHandling getIntermodalLegOnlyHandling()
SwissRailRaptorConfigGroup()
double transferPenaltyBaseCost
ModeMappingForPassengersParameterSet()
void addIntermodalAccessEgress(IntermodalAccessEgressParameterSet paramSet)
static final String PARAM_INTERMODAL_LEG_ONLYHANDLING_DESC
RaptorTransferCalculation getTransferCalculation()
IntermodalAccessEgressParameterSet()
final Set< String > subpopulations
static final String PARAM_USE_INTERMODAL_ACCESS_EGRESS
String getSubpopulationsAsString()
void setTransferWalkMargin(double transferWalkMargin)
double getTransferPenaltyMinCost()
boolean isUseModeMappingForPassengers()
RouteSelectorParameterSet getRouteSelector(String subpopulation)
static final String PARAM_TRANSFER_PENALTY_MAX
void setUseIntermodalAccessEgress(boolean useIntermodality)
void setUseRangeQuery(boolean useRangeQuery)
String stopFilterAttribute
void setMaxLaterDeparture(int maxLaterDeparture)
double transferPenaltyMaxCost
void setTransferPenaltyMaxCost(double maxCost)
static final String PARAM_USE_RANGE_QUERY
static final String PARAM_USE_CAPACITY_CONSTRAINTS
static final String PARAM_TRANSFER_WALK_MARGIN_DESC
static final String PARAM_USE_MODE_MAPPING
ScoringParameters getScoringParameters()