MATSIM
EventsManagerConfigGroup.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * ParallelEventHandlingConfigGroup.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2012 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 
21 package org.matsim.core.config.groups;
22 
23 import java.util.Map;
24 
26 
31 public final class EventsManagerConfigGroup extends ReflectiveConfigGroup {
32 
33  public static final String GROUP_NAME = "eventsManager";
34 
35  private final static String NUMBER_OF_THREADS = "numberOfThreads";
36  private Integer numberOfThreads = null;
37  public final static String NUMBER_OF_THREADS_COMMENT = "Number of threads for parallel events handler. _null_ means the framework decides by itself. 0 is currently not possible.";
38 
39  private final static String ESTIMATED_NUMBER_OF_EVENTS = "estimatedNumberOfEvents";
40  private Long estimatedNumberOfEvents = null;
41 
42  private final static String SYNCHRONIZE_ON_SIMSTEPS = "synchronizeOnSimSteps";
43  private Boolean synchronizeOnSimSteps = true;
44 
45  private final static String ONE_THREAD_PER_HANDLER = "oneThreadPerHandler";
46  private Boolean oneThreadPerHandler = false;
47 
48  private final static String EVENTS_QUEUE_SIZE = "eventsQueueSize";
49  private final static String EVENTS_QUEUE_SIZE_COMMENT = "Size of the events Queue. Increase for very large scenarios";
50  private int eventsQueueSize = 65536 * 2 ;
51 
52 
53 
54  private boolean locked = false;
55 
57  super(GROUP_NAME);
58  }
59 
60  @Override
61  public Map<String, String> getComments() {
62  Map<String, String> comments = super.getComments();
63  comments.put(NUMBER_OF_THREADS, NUMBER_OF_THREADS_COMMENT);
64  comments.put(ESTIMATED_NUMBER_OF_EVENTS, "Estimated number of events during mobsim run. An optional optimization hint for the framework.");
65  comments.put(SYNCHRONIZE_ON_SIMSTEPS, "If enabled, it is ensured that all events that are created during a time step of the mobility simulation are processed "
66  + "before the next time step is simulated. E.g. neccessary when within-day replanning is used.");
67  comments.put(ONE_THREAD_PER_HANDLER, "If enabled, each event handler is assigned to its own thread. Note that enabling this feature disabled the " + NUMBER_OF_THREADS + " option! "
68  + "This feature is still experimental!");
69  comments.put(EVENTS_QUEUE_SIZE,EVENTS_QUEUE_SIZE_COMMENT);
70  return comments;
71  }
72 
76  @StringGetter( NUMBER_OF_THREADS )
77  public Integer getNumberOfThreads() {
78  return numberOfThreads;
79  }
80 
87  public void setNumberOfThreads(Integer numberOfThreads) {
88  if ( !this.locked ) {
89  this.numberOfThreads = numberOfThreads;
90  } else {
91  throw new RuntimeException("it is too late in the control flow to modify this parameter");
92  }
93  }
94 
98  }
99 
102  if ( !this.locked ) {
104  } else {
105  throw new RuntimeException("it is too late in the control flow to modify this parameter");
106  }
107  }
108 
112  }
113 
115  public int getEventsQueueSize() {
116  return eventsQueueSize;
117  }
118 
120  public Boolean getSynchronizeOnSimSteps() {
121  return this.synchronizeOnSimSteps;
122  }
123 
126  if ( !this.locked ) {
128  } else {
129  throw new RuntimeException("it is too late in the control flow to modify this parameter");
130  }
131  }
132 
134  public Boolean getOneThreadPerHandler() {
135  return this.oneThreadPerHandler;
136  }
137 
140  if ( !this.locked ) {
142  } else {
143  throw new RuntimeException("it is too late in the control flow to modify this parameter");
144  }
145  }
146 
147  public void makeLocked() {
148  this.locked = true;
149  }
150 }