MATSIM
HermesConfigGroup.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * *
4  * *********************************************************************** *
5  * *
6  * copyright : (C) 2014 by the members listed in the COPYING, *
7  * LICENSE and WARRANTY file. *
8  * email : info at matsim dot org *
9  * *
10  * *********************************************************************** *
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * See also COPYING, LICENSE and WARRANTY file *
17  * *
18  * *********************************************************************** */
19 package org.matsim.core.mobsim.hermes;
20 
21 import jakarta.validation.constraints.Positive;
22 import org.apache.logging.log4j.LogManager;
24 import org.matsim.core.config.Config;
27 import org.matsim.core.utils.misc.Time;
28 
29 import java.util.Map;
30 import java.util.Set;
31 
32 public final class HermesConfigGroup extends ReflectiveConfigGroup {
33  public static final String NAME = "hermes";
34  private static final String END_TIME = "endTime";
35 
36  // Maximum number of links (limited to 24 bits in the plan)
37  public static final int MAX_LINK_ID = 16777216;
38  // Maximum number of stops (limited to 20bits in the plan)
39  public static final int MAX_STOP_ROUTE_ID = 65536;
40  // Maximum vehicle velocity (limited to 8 bits in the plan: integers 0-99 reserved for speeds 0.0 - 9.9
41  // and 100-255 reserved for speeds 10 - 165)
42  public static final int MAX_VEHICLE_VELOCITY = 165;
43  // Maximum vehicle PCE types (limited to 4 bits)
44  public static final int MAX_VEHICLE_PCETYPES = 15;
45  // Maximum number of events per agent (limited to 16 bits in the plan)
46  public static final int MAX_EVENTS_AGENT = 65536;
47 
48  private static final String DETPT = "useDeterministicPt";
49 
50  // Number of simulation steps
51  public static int SIM_STEPS = 30 * 60 * 60;
52  // Number of ticks that are added to every agent advancing links.
53  public static final int LINK_ADVANCE_DELAY = 1;
54  private static final String FLOW_CAPACITY_FACTOR = "flowCapacityFactor";
55  private static final String STORAGE_CAPACITY_FACTOR = "storageCapacityFactor";
56 
57  private static final String STUCKTIMEPARAM = "stuckTime";
58  private static final String STUCKTIMEPARAMDESC = "time in seconds. Time after which the frontmost vehicle on a link is called `stuck' if it does not move."
59  + " Set to Integer.MAX_VALUE to disable this behavior";
60 
61  private static final String MAINMODESPARAM = "mainMode";
62  private static final String MAINMODESPARAMDESC = "[comma-separated list] Modes that are handled in the mobsim along links. By default: car";
63  private Set<String> mainModes = Set.of(TransportMode.car);
64 
65  private static final String DETPTDESC = "treats PT as deterministic. PT vehicles will run with a steady speed. Should be used with separate network layers for PT and other network modes.";
66  private boolean deterministicPt = false;
67  public static final boolean DEBUG_REALMS = false;
68  public static final boolean DEBUG_EVENTS = false;
69  public static final boolean CONCURRENT_EVENT_PROCESSING = true;
70 
71  @Positive
72  private double storageCapacityFactor = 1.0;
73 
74  @Positive
75  private double flowCapacityFactor = 1.0;
76 
77  @Positive
78  private int stuckTime = 10;
79 
80  public Set<String> getMainModes() {
81  return mainModes;
82  }
83 
84  public void setMainModes(Set<String> mainModes) {
85  this.mainModes = mainModes;
86  }
87 
88  @StringSetter(MAINMODESPARAM)
89  public void setMainModes(String mainModes) {
90  this.mainModes = CollectionUtils.stringToSet(mainModes);
91  }
92 
93  @StringGetter(MAINMODESPARAM)
94  public String getMainModesAsString() {
95  return CollectionUtils.setToString(mainModes);
96  }
97 
98  public HermesConfigGroup() {
99  super(NAME);
100  }
101 
102  public int getEndTime() {
103  return SIM_STEPS;
104  }
105 
107  public boolean isDeterministicPt() {
108  return deterministicPt;
109  }
110 
112  public void setDeterministicPt(boolean deterministicPt) {
114  }
115 
117  public int getStuckTime() {
118  return stuckTime;
119  }
120 
122  public void setStuckTime(int stuckTime) {
123  this.stuckTime = stuckTime;
124  }
125 
129  }
130 
132  public double getFlowCapacityFactor() {
133  return this.flowCapacityFactor;
134  }
135 
139  }
140 
142  public double getStorageCapacityFactor() {
143  return storageCapacityFactor;
144  }
145 
147  public static void setEndTime(String endTime) {
148  SIM_STEPS = (int) Time.parseTime(endTime);
149  }
150 
152  public String getEndTimeAsString() {
153  return Time.writeTime(SIM_STEPS);
154  }
155 
156  @Override
157  public Map<String, String> getComments() {
158  Map<String, String> comments = super.getComments();
159  comments.put(END_TIME, "Simulation End Time");
160  comments.put(STUCKTIMEPARAM, STUCKTIMEPARAMDESC);
161  comments.put(DETPT, DETPTDESC);
162  return comments;
163  }
164 
165 
166 
167  @Override
168  protected void checkConsistency(Config config) {
169  super.checkConsistency(config);
170  if (config.eventsManager().getOneThreadPerHandler()!=true && config.controller().getMobsim().equals("hermes")){
171  LogManager.getLogger(getClass()).warn("Hermes should be run with one thread per handler.");
172  }
173  }
174 }
static Set< String > stringToSet(final String values)
static String setToString(final Set< String > values)
EventsManagerConfigGroup eventsManager()
Definition: Config.java:467
void setFlowCapacityFactor(double flowCapacityFactor)
static final double parseTime(final String time)
Definition: Time.java:163
void setStorageCapacityFactor(double storageCapacityFactor)
static final String writeTime(final double seconds, final String timeformat)
Definition: Time.java:80
final ControllerConfigGroup controller()
Definition: Config.java:399