MATSIM
ConfigConsistencyCheckerImpl.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * ConfigConsistencyCheckerImpl
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2009 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 org.matsim.core.config.consistency;
21 
22 import org.apache.logging.log4j.LogManager;
23 import org.apache.logging.log4j.Logger;
25 import org.matsim.core.config.Config;
31 import org.matsim.pt.PtConstants;
32 
39 
40  private static final Logger log = LogManager.getLogger(ConfigConsistencyCheckerImpl.class);
41 
42  public ConfigConsistencyCheckerImpl() { // explicit constructor so that I can eclipse-search for instantiation. kai, may'11
43  // nothing to do
44  }
45 
46  @Override
47  public void checkConsistency(final Config config) {
52  checkPlanCalcScore(config);
53  checkTransit(config);
54  checkConsistencyBetweenRouterAndTravelTimeCalculator( config );
55  }
56 
57  static boolean checkConsistencyBetweenRouterAndTravelTimeCalculator( final Config config ) {
58  boolean problem = false ;
59 // if ( config.travelTimeCalculator().getSeparateModes() ) {
60 // if ( ! config.travelTimeCalculator().getAnalyzedModes().containsAll( config.plansCalcRoute().getNetworkModes() ) ) {
61 // log.warn("AnalyzedModes in travelTimeCalculator config is not superset of network routing modes. Will fail later except when defined by other means.");
62 // problem = true ;
63 // }
64 // }
65  // not sure if it ever worked like this, but now the analyzedModes are honoured only when separateModes is false and so the check does not make
66  // sense IMO. kai, jun'19
67  return problem ;
68  }
69 
70  /*package because of test */ static void checkPlanCalcScore(final Config c) {
71  ModeParams ptModeParams = c.scoring().getModes().get(TransportMode.pt);
72  if (ptModeParams!=null && ptModeParams.getMarginalUtilityOfTraveling() > 0) {
73  log.warn(ScoringConfigGroup.GROUP_NAME + ".travelingPt is > 0. This values specifies a utility. " +
74  "Typically, this should be a disutility, i.e. have a negative value.");
75  }
76  ModeParams carModeParams = c.scoring().getModes().get(TransportMode.car);
77  if (carModeParams!=null && carModeParams.getMarginalUtilityOfTraveling() > 0) {
78  log.warn(ScoringConfigGroup.GROUP_NAME + ".traveling is > 0. This values specifies a utility. " +
79  "Typically, this should be a disutility, i.e. have a negative value.");
80  }
81  ModeParams bikeModeParams = c.scoring().getModes().get(TransportMode.bike);
82  if (bikeModeParams!=null && bikeModeParams.getMarginalUtilityOfTraveling() > 0) {
83  log.warn(ScoringConfigGroup.GROUP_NAME + ".travelingBike is > 0. This values specifies a utility. " +
84  "Typically, this should be a disutility, i.e. have a negative value.");
85  }
86  ModeParams walkModeParams = c.scoring().getModes().get(TransportMode.walk);
87  if (walkModeParams!=null && walkModeParams.getMarginalUtilityOfTraveling() > 0) {
88  log.warn(ScoringConfigGroup.GROUP_NAME + ".travelingWalk is > 0. This values specifies a utility. " +
89  "Typically, this should be a disutility, i.e. have a negative value.");
90  }
91 
92 
94  if ( ptAct != null ) {
95 // if ( ptAct.getClosingTime()!=0. && ptAct.getClosingTime()!=Time.getUndefinedTime() ) {
96 // if ( !c.vspExperimental().isAbleToOverwritePtInteractionParams()==true ) {
97 // throw new RuntimeException("setting the pt interaction activity closing time away from 0/undefined is not allowed because it breaks pt scoring." +
98 // " If you need this anyway (for backwards compatibility reasons), you can allow this by a parameter in VspExperimentalConfigGroup.") ;
99 // }
100 // }
101  if ( ptAct.isScoringThisActivityAtAll() ) {
103  throw new RuntimeException("Scoring " + ptAct.getActivityType() + " is not allowed because it breaks pt scoring." +
104  " If you need this anyway (for backwards compatibility reasons), you can allow this by a parameter in VspExperimentalConfigGroup.") ;
105  }
106  }
107  }
108 
109  }
110 
111  private static void checkEventsFormatLanesSignals(final Config c) {
112  if (c.qsim().isUseLanes()) {
113  if (!c.controller().getEventsFileFormats().contains(EventsFileFormat.xml)){
114  log.error("Xml events are not enabled, but lanes and possibly signal systems" +
115  "are enalbed. Events from this features will only be written to the xml format, consider" +
116  "to add xml events in the controler config module");
117  }
118  }
119  }
120 
121  private static void checkScenarioFeaturesEnabled(final Config c) {
122  if (! ("qsim".equals(c.controller().getMobsim()) || c.qsim() != null)){
123  log.warn("The signal system implementation is only supported by the org.matsim.ptproject.qsim mobility simulation that is not activated. Please make sure you are using the correct" +
124  "mobility simulation. This warning can be ingored if a customized mobility simulation developed outside of org.matsim is used and set correctly.");
125  }
126  }
127 
128 
129  private static void checkTravelTimeCalculationRoutingConfiguration(final Config config){
130  if (config.controller().isLinkToLinkRoutingEnabled() &&
132  throw new IllegalStateException("LinkToLinkRouting is activated in config and" +
133  " link to link traveltime calculation is not enabled but required!");
134  }
135 
139  log.warn("Config enables link travel time calculation and link to link " +
140  "travel time calculation. This requires at least twice as much memory as " +
141  "if only one method is used, however it might be necessary to enable " +
142  "a certain module configuration.");
143  }
144 
146  log.warn("Link travel time calculation is switched off, be aware that this optimization" +
147  "might not work with all modules. ");
148  }
149 
151  config.qsim().isRemoveStuckVehicles()){
152  throw new IllegalStateException("Link to link travel time calculation is not" +
153  "available if using the remove stuck vehicles option!");
154  }
155 
156  if ( config.controller().isLinkToLinkRoutingEnabled() &&
158  log.warn("We don't know if non-Dijkstra routing works together with LinkToLink routing.");
159  }
160 
161  }
162 
163 
164  private static void checkLaneDefinitionRoutingConfiguration(final Config config) {
165  if ((config.qsim().isUseLanes()) &&
167  log.warn("Using lanes without enabling linktolinkrouting might not lead to expected simulation results");
168  }
169  }
170 
171  private static void checkTransit(final Config config) {
172 // if ( config.transit().isUseTransit() && config.transit().getVehiclesFile()==null ) {
173 // log.warn("Your are using Transit but have not provided a transit vehicles file. This most likely won't work.");
174 // }
175  // The warning will also be logged when the vehicles are defined in code, which is perfectly acceptable. kai, jun'19
176  }
177 }
static final String TRANSIT_ACTIVITY_TYPE
final ScoringConfigGroup scoring()
Definition: Config.java:407
TravelTimeCalculatorConfigGroup travelTimeCalculator()
Definition: Config.java:431
VspExperimentalConfigGroup vspExperimental()
Definition: Config.java:443
QSimConfigGroup qsim()
Definition: Config.java:447
final ControllerConfigGroup controller()
Definition: Config.java:399