MATSIM
Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.matsim.withinday.trafficmonitoring.WithinDayTravelTime Class Reference
Inheritance diagram for org.matsim.withinday.trafficmonitoring.WithinDayTravelTime:
Inheritance graph
[legend]

Classes

class  TravelTimeInfo
 
class  TripBin
 
class  UpdateMeanTravelTimesRunnable
 

Public Member Functions

 WithinDayTravelTime (Scenario scenario, Set< String > analyzedModes)
 
final void addNetworkChangeEvent (NetworkChangeEvent networkChangeEvent)
 
double getLinkTravelTime (Link link, double time, Person person, Vehicle vehicle)
 
void reset (int iteration)
 
void handleEvent (LinkEnterEvent event)
 
void handleEvent (LinkLeaveEvent event)
 
void handleEvent (PersonStuckEvent event)
 
void handleEvent (VehicleLeavesTrafficEvent event)
 
void handleEvent (VehicleEntersTrafficEvent event)
 
void notifyMobsimInitialized (MobsimInitializedEvent e)
 
void notifyMobsimAfterSimStep (MobsimAfterSimStepEvent e)
 
void notifyMobsimBeforeSimStep (MobsimBeforeSimStepEvent e)
 
void notifyMobsimBeforeCleanup (MobsimBeforeCleanupEvent e)
 

Private Member Functions

void init ()
 
void addNetworkChangeEventToLocalDataStructure (NetworkChangeEvent networkChangeEvent)
 
void printInfo (double time)
 
void run (double time)
 
void initParallelThreads ()
 

Private Attributes

Network network
 
Map< Id< Vehicle >, TripBinregularActiveTrips
 
Map< Id< Link >, TravelTimeInfo > travelTimeInfos
 
TravelTimeInfoProvider travelTimeInfoProvider
 
TreeMap< Double, Map< Link, Double > > changedLinksByTime
 
CyclicBarrier startBarrier
 
CyclicBarrier endBarrier
 
UpdateMeanTravelTimesRunnable [] updateMeanTravelTimesRunnables
 
final int numOfThreads
 
final int infoTimeStep = 3600
 
int nextInfoTime = 0
 
Set< Id< Vehicle > > vehiclesToFilter
 
final Set< String > analyzedModes
 
final boolean filterModes
 
boolean problem = true
 
int resetCnt = 0
 
double now = Double.NEGATIVE_INFINITY
 

Static Private Attributes

static final Logger log = LogManager.getLogger(WithinDayTravelTime.class)
 

Detailed Description

Collects link travel times over a given time span (storedTravelTimesBinSize) and calculates an average travel time over this time span.

TODO:

Author
cdobler

Definition at line 86 of file WithinDayTravelTime.java.

Constructor & Destructor Documentation

◆ WithinDayTravelTime()

org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.WithinDayTravelTime ( Scenario  scenario,
Set< String >  analyzedModes 
)

Definition at line 131 of file WithinDayTravelTime.java.

References org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.analyzedModes, org.matsim.api.core.v01.Scenario.getConfig(), org.matsim.api.core.v01.Scenario.getNetwork(), org.matsim.core.config.groups.GlobalConfigGroup.getNumberOfThreads(), org.matsim.core.config.Config.global(), and org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.init().

131  {
132 // log.setLevel(Level.DEBUG);
133 
134  /*
135  * The parallelization should scale almost linear, therefore we do use
136  * the number of available threads according to the config file.
137  */
138  this.network = scenario.getNetwork();
139  this.numOfThreads = scenario.getConfig().global().getNumberOfThreads();
140 
141  if (analyzedModes == null || analyzedModes.size() == 0) {
142  this.filterModes = false;
143  this.analyzedModes = null;
144  } else {
145  this.analyzedModes = new HashSet<>(analyzedModes);
146  filterModes = true;
147  }
148 
149  init();
150  }
Here is the call graph for this function:

Member Function Documentation

◆ init()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.init ( )
private

Definition at line 152 of file WithinDayTravelTime.java.

References org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.addNetworkChangeEventToLocalDataStructure(), org.matsim.api.core.v01.network.Network.getLinks(), and org.matsim.core.network.NetworkUtils.getNetworkChangeEvents().

Referenced by org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.reset(), and org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.WithinDayTravelTime().

152  {
153  this.regularActiveTrips = new HashMap<>();
154  this.travelTimeInfos = new ConcurrentHashMap<>();
155  this.changedLinksByTime = new TreeMap<>();
156  this.vehiclesToFilter = new HashSet<>();
157 
158  // one TravelTimeInfo per link:
159  for (Link link : this.network.getLinks().values()) {
160  TravelTimeInfo travelTimeInfo = new TravelTimeInfo();
161  this.travelTimeInfos.put(link.getId(), travelTimeInfo);
162  }
163 
164  /*
165  * If no RoutingNetwork is used, ArrayBasedTravelTimeInfoProvider uses
166  * a MapBasedTravelTimeInfoProvider as fall back solution. This increases
167  * routing times of a AStarLandmarks router by ~5%.
168  */
169 // this.travelTimeInfoProvider = new MapBasedTravelTimeInfoProvider(this.travelTimeInfos);
170  this.travelTimeInfoProvider = new ArrayBasedTravelTimeInfoProvider(this.travelTimeInfos, this.network);
171 
172  /*
173  * If the network is time variant, we have to update the link parameters
174  * according to the network change events.
175  */
176  Queue<NetworkChangeEvent> networkChangeEvents = NetworkUtils.getNetworkChangeEvents(this.network);
177 
178  // I just changed the return type of the network change events from Collection to Queue.
179  // This should, in a first step, allow to remove the separate changedLinksByTime data structure.
180  // In a second step, this should allow to insert link change events after everything
181  // has started. kai, dec'17
182  // Well, but maybe I don't even want this, and I want this class here recognize changes
183  // only when someone observes them??? (bushfire evacuation use case). kai, dec'17
184 
185  // If one looks at transport telematics, then we need to also be able to set expected
186  // speeds for the future! Which would indeed justify its own data model. kai, dec'17
187  // (in contrast, watch out: the NetworkChangeEventsEngine also keeps its own
188  // copy for the mobsim)
189 
190  if (networkChangeEvents != null) {
191  for (NetworkChangeEvent networkChangeEvent : networkChangeEvents) {
192  addNetworkChangeEventToLocalDataStructure(networkChangeEvent);
193  }
194  }
195  }
void addNetworkChangeEventToLocalDataStructure(NetworkChangeEvent networkChangeEvent)
Map< Id< Link >, ? extends Link > getLinks()
Here is the call graph for this function:

◆ addNetworkChangeEventToLocalDataStructure()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.addNetworkChangeEventToLocalDataStructure ( NetworkChangeEvent  networkChangeEvent)
private

Definition at line 197 of file WithinDayTravelTime.java.

References org.matsim.core.network.NetworkChangeEvent.getFreespeedChange(), org.matsim.core.network.NetworkChangeEvent.getLinks(), org.matsim.core.network.NetworkChangeEvent.getStartTime(), org.matsim.core.network.NetworkChangeEvent.ChangeValue.getType(), and org.matsim.core.network.NetworkChangeEvent.ChangeValue.getValue().

Referenced by org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.addNetworkChangeEvent(), and org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.init().

197  {
198  ChangeValue freespeedChange = networkChangeEvent.getFreespeedChange();
199  if (freespeedChange != null) {
200  double startTime = networkChangeEvent.getStartTime();
201  Map<Link,Double> newLinkSpeedsAtThisTime = changedLinksByTime.computeIfAbsent(startTime, k -> new HashMap<>());
202  for ( Link link : networkChangeEvent.getLinks() ) {
203  // yy seems that the following should be available centrally. kai, dec'17
204  double newSpeed ;
205  switch ( freespeedChange.getType() ) {
206  case ABSOLUTE_IN_SI_UNITS:
207  newSpeed = freespeedChange.getValue() ;
208  break;
209  case FACTOR:
210  newSpeed = link.getFreespeed() * freespeedChange.getValue() ;
211  break;
212  case OFFSET_IN_SI_UNITS:
213  newSpeed = link.getFreespeed() + freespeedChange.getValue() ;
214  break;
215  default:
216  throw new RuntimeException("change event type not implemented") ;
217  }
218  if ( startTime > 0. ) {
219  log.debug( "registering a change event for time=" + startTime
220  + "; linkId=" + link.getId() ) ;
221  }
222  newLinkSpeedsAtThisTime.put( link, newSpeed ) ;
223  }
224  }
225  }
Here is the call graph for this function:

◆ addNetworkChangeEvent()

final void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.addNetworkChangeEvent ( NetworkChangeEvent  networkChangeEvent)

Definition at line 227 of file WithinDayTravelTime.java.

References org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.addNetworkChangeEventToLocalDataStructure().

227  {
228  this.addNetworkChangeEventToLocalDataStructure(networkChangeEvent);
229  }
void addNetworkChangeEventToLocalDataStructure(NetworkChangeEvent networkChangeEvent)
Here is the call graph for this function:

◆ getLinkTravelTime()

double org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.getLinkTravelTime ( Link  link,
double  time,
Person  person,
Vehicle  vehicle 
)

Returns the travel time for the specified link at the specified time.

Parameters
linkThe link for which the travel time is calculated.
timeThe departure time (in seconds since 00:00) at the beginning of the link for which the travel time is calculated.
personTODO
vehicleTODO
Returns
The time (in seconds) needed to travel over the link link, departing at time time.

Implements org.matsim.core.router.util.TravelTime.

Definition at line 232 of file WithinDayTravelTime.java.

References org.matsim.withinday.trafficmonitoring.TravelTimeInfoProvider.getTravelTimeInfo().

232  {
233  final double travelTime = this.travelTimeInfoProvider.getTravelTimeInfo(link).travelTime;
234  return travelTime;
235  }
TravelTimeInfo getTravelTimeInfo(final Id< Link > linkId)
Here is the call graph for this function:

◆ reset()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.reset ( int  iteration)

Gives the event handler the possibility to clean up its internal state. Within a Controler-Simulation, this is called before the mobsim starts.

Parameters
iterationthe up-coming iteration from which up-coming events will be from.

Implements org.matsim.core.events.handler.EventHandler.

Definition at line 238 of file WithinDayTravelTime.java.

References org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.init().

238  {
239  init();
240  resetCnt++ ;
241  if ( resetCnt >1 ) {
242  if ( problem ) {
243  throw new RuntimeException("using WithinDayTravelTime, but mobsim notifications not called between two resets. "
244  + "Did you really add this as a mobsim listener?") ;
245  }
246  }
247  }
Here is the call graph for this function:

◆ handleEvent() [1/5]

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.handleEvent ( LinkEnterEvent  event)

Implements org.matsim.api.core.v01.events.handler.LinkEnterEventHandler.

Definition at line 250 of file WithinDayTravelTime.java.

References org.matsim.api.core.v01.events.LinkEnterEvent.getVehicleId().

250  {
251  /*
252  * If only some modes are analyzed, we check whether the vehicle
253  * performs a trip with one of those modes. if not, we skip the event.
254  */
255  if (filterModes && vehiclesToFilter.contains(event.getVehicleId())) return;
256 
257  Id<Vehicle> vehicleId = event.getVehicleId();
258  double time = event.getTime();
259 
260  TripBin tripBin = new TripBin();
261  tripBin.enterTime = time;
262 
263  this.regularActiveTrips.put(vehicleId, tripBin);
264  }
Here is the call graph for this function:

◆ handleEvent() [2/5]

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.handleEvent ( LinkLeaveEvent  event)

Implements org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler.

Definition at line 267 of file WithinDayTravelTime.java.

References org.matsim.withinday.trafficmonitoring.TravelTimeInfoProvider.getTravelTimeInfo().

267  {
268  Id<Link> linkId = event.getLinkId();
269  Id<Vehicle> vehicleId = event.getVehicleId();
270  double time = event.getTime();
271 
272  TripBin tripBin = this.regularActiveTrips.remove(vehicleId);
273  if (tripBin != null) {
274  tripBin.leaveTime = time;
275 
276  double tripTime = tripBin.leaveTime - tripBin.enterTime;
277 
278  TravelTimeInfo travelTimeInfo = this.travelTimeInfoProvider.getTravelTimeInfo(linkId);
279  travelTimeInfo.tripBins.add(tripBin);
280  travelTimeInfo.addedTravelTimes += tripTime;
281  travelTimeInfo.addedTrips++;
282 
283  travelTimeInfo.checkActiveState();
284  travelTimeInfo.checkBinSize(tripTime);
285  }
286  }
TravelTimeInfo getTravelTimeInfo(final Id< Link > linkId)
Here is the call graph for this function:

◆ handleEvent() [3/5]

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.handleEvent ( PersonStuckEvent  event)

Implements org.matsim.api.core.v01.events.handler.PersonStuckEventHandler.

Definition at line 293 of file WithinDayTravelTime.java.

293  {
294 
295  }

◆ handleEvent() [4/5]

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.handleEvent ( VehicleLeavesTrafficEvent  event)

Implements org.matsim.api.core.v01.events.handler.VehicleLeavesTrafficEventHandler.

Definition at line 303 of file WithinDayTravelTime.java.

References org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent.getVehicleId().

303  {
304  Id<Vehicle> vehicleId = event.getVehicleId();
305 
306  this.regularActiveTrips.remove(vehicleId);
307 
308  // try to remove vehicle from set with filtered vehicles
309  if (filterModes) this.vehiclesToFilter.remove(event.getVehicleId());
310  }
Here is the call graph for this function:

◆ handleEvent() [5/5]

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.handleEvent ( VehicleEntersTrafficEvent  event)

Implements org.matsim.api.core.v01.events.handler.VehicleEntersTrafficEventHandler.

Definition at line 313 of file WithinDayTravelTime.java.

References org.matsim.api.core.v01.events.VehicleEntersTrafficEvent.getNetworkMode(), and org.matsim.api.core.v01.events.VehicleEntersTrafficEvent.getVehicleId().

313  {
314  /*
315  * If filtering transport modes is enabled and the vehicle
316  * starts a leg on a non analyzed transport mode, add the vehicle
317  * to the filtered vehicles set.
318  */
319  if (filterModes && !analyzedModes.contains(event.getNetworkMode())) this.vehiclesToFilter.add(event.getVehicleId());
320  }
Here is the call graph for this function:

◆ notifyMobsimInitialized()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.notifyMobsimInitialized ( MobsimInitializedEvent  e)

Implements org.matsim.core.mobsim.framework.listeners.MobsimInitializedListener.

Definition at line 326 of file WithinDayTravelTime.java.

References org.matsim.api.core.v01.network.Network.getLinks(), org.matsim.withinday.trafficmonitoring.TravelTimeInfoProvider.getTravelTimeInfo(), org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.infoTimeStep, and org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.initParallelThreads().

326  {
327  problem = false ;
328 
329  if (e.getQueueSimulation() instanceof QSim) {
330  double simStartTime = ((QSim) e.getQueueSimulation()).getSimTimer().getSimStartTime();
331 
332  /*
333  * infoTime may be < simStartTime, this ensures to print
334  * out the info at the very first timestep already
335  */
336  this.nextInfoTime = (int)(Math.floor(simStartTime / this.infoTimeStep) * this.infoTimeStep);
337  }
338 
339 
340  for (Link link : this.network.getLinks().values()) {
341  double freeSpeedTravelTime = link.getLength() / link.getFreespeed();
342 
343  TravelTimeInfo travelTimeInfo = this.travelTimeInfoProvider.getTravelTimeInfo(link);
344  travelTimeInfo.travelTime = freeSpeedTravelTime;
345  travelTimeInfo.init(freeSpeedTravelTime);
346  }
347 
348  // Now initialize the Parallel Update Threads
350  }
TravelTimeInfo getTravelTimeInfo(final Id< Link > linkId)
Map< Id< Link >, ? extends Link > getLinks()
Here is the call graph for this function:

◆ notifyMobsimAfterSimStep()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.notifyMobsimAfterSimStep ( MobsimAfterSimStepEvent  e)

Implements org.matsim.core.mobsim.framework.listeners.MobsimAfterSimStepListener.

Definition at line 354 of file WithinDayTravelTime.java.

References org.matsim.api.core.v01.Identifiable< T >.getId(), org.matsim.api.core.v01.network.Link.getLength(), org.matsim.core.mobsim.framework.events.MobsimAfterSimStepEvent< T extends Mobsim >.getSimulationTime(), and org.matsim.withinday.trafficmonitoring.TravelTimeInfoProvider.getTravelTimeInfo().

354  {
355  problem = false ;
356 
357  // yyyy In terms of "bushfire evacuation" design (and maybe even in terms of more general transport telematics)
358  // one would need some settable TimeDependentNetworkUpdater class. kai, dec'17
359 
360 // Collection<Link> links = changedLinksByTime.remove(e.getSimulationTime());
361  // yyyyyy I find it quite optimistic to do this with doubles. What
362  // if someone adds a link change event in between two integer
363  // time steps? kai, dec'17
364 
365  while( !changedLinksByTime.isEmpty() && changedLinksByTime.firstKey() <= e.getSimulationTime() ) {
366  Map<Link, Double> map = changedLinksByTime.pollFirstEntry().getValue();
367  for ( Map.Entry<Link,Double> link2speed : map.entrySet() ) {
368  Link link = link2speed.getKey() ;
369  double freeSpeedTravelTime = link.getLength() / link2speed.getValue() ;
370  if ( e.getSimulationTime() > ((QSim)e.getQueueSimulation()).getSimTimer().getSimStartTime() ) {
371  // (otherwise, in some simulations one gets a lot of change events at time 0. kai, dec'17)
372  log.debug("time=" + e.getSimulationTime() +
373  "; network change event for link=" + link.getId() +
374  "; new ttime="+ freeSpeedTravelTime );
375  }
376  TravelTimeInfo travelTimeInfo = this.travelTimeInfoProvider.getTravelTimeInfo(link);
377  travelTimeInfo.init(freeSpeedTravelTime);
378  travelTimeInfo.checkActiveState(); // ensure that the estimated link travel time is updated
379  }
380  }
381 
382 // if (links != null) {
383 // for (Link link : links) {
384 // double freeSpeedTravelTime = link.getLength() / link.getFreespeed(e.getSimulationTime());
385 // if ( e.getSimulationTime() > 0 ) {
386 // log.debug("time=" + e.getSimulationTime() +
387 // ";\tnetwork change event for link=" + link.getId() +
388 // ";\tnew ttime="+ freeSpeedTravelTime );
389 // }
390 // TravelTimeInfo travelTimeInfo = this.travelTimeInfoProvider.getTravelTimeInfo(link);
391 // travelTimeInfo.init(freeSpeedTravelTime);
392 // travelTimeInfo.checkActiveState(); // ensure that the estimated link travel time is updated
393 // }
394 // }
395  }
TravelTimeInfo getTravelTimeInfo(final Id< Link > linkId)
Here is the call graph for this function:

◆ notifyMobsimBeforeSimStep()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.notifyMobsimBeforeSimStep ( MobsimBeforeSimStepEvent  e)

◆ notifyMobsimBeforeCleanup()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.notifyMobsimBeforeCleanup ( MobsimBeforeCleanupEvent  e)

Implements org.matsim.core.mobsim.framework.listeners.MobsimBeforeCleanupListener.

Definition at line 412 of file WithinDayTravelTime.java.

412  {
413  problem = false ;
414 
415  /*
416  * Calling the afterSim Method of the Threads will set their
417  * simulationRunning flag to false.
418  */
419  for (UpdateMeanTravelTimesRunnable runnable : this.updateMeanTravelTimesRunnables) {
420  runnable.afterSim();
421  }
422 
423  /*
424  * Triggering the startBarrier of the UpdateMeanTravelTimesRunnables.
425  * They will check whether the Simulation is still running.
426  * It is not, so the Threads will terminate.
427  */
428  try {
429  this.startBarrier.await();
430  } catch (InterruptedException | BrokenBarrierException ex) {
431  throw new RuntimeException(ex);
432  }
433  }

◆ printInfo()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.printInfo ( double  time)
private

Definition at line 435 of file WithinDayTravelTime.java.

References org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.infoTimeStep, and org.matsim.core.utils.misc.Time.writeTime().

Referenced by org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.notifyMobsimBeforeSimStep().

435  {
436  if (time >= this.nextInfoTime) {
437  int activeLinks = 0;
438  for (UpdateMeanTravelTimesRunnable runnable : this.updateMeanTravelTimesRunnables) {
439  activeLinks += runnable.getActiveLinksCount();
440  }
441 
442  log.info("WithinDayTravelTime at " + Time.writeTime(time) + " #links=" + activeLinks);
443 
444  this.nextInfoTime += this.infoTimeStep;
445  }
446  }
Here is the call graph for this function:

◆ run()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.run ( double  time)
private

Definition at line 509 of file WithinDayTravelTime.java.

Referenced by org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.notifyMobsimBeforeSimStep().

509  {
510 
511  try {
512  // set current Time
513  for (UpdateMeanTravelTimesRunnable updateMeanTravelTimesRunnable : updateMeanTravelTimesRunnables) {
514  updateMeanTravelTimesRunnable.setTime(time);
515  }
516 
517  this.startBarrier.await();
518 
519  this.endBarrier.await();
520  } catch (InterruptedException | BrokenBarrierException e) {
521  throw new RuntimeException(e);
522  }
523  }

◆ initParallelThreads()

void org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.initParallelThreads ( )
private

Definition at line 525 of file WithinDayTravelTime.java.

References org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.numOfThreads, org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.UpdateMeanTravelTimesRunnable.setEndBarrier(), and org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.UpdateMeanTravelTimesRunnable.setStartBarrier().

Referenced by org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.notifyMobsimInitialized().

525  {
526 
527  this.startBarrier = new CyclicBarrier(numOfThreads + 1);
528  this.endBarrier = new CyclicBarrier(numOfThreads + 1);
529 
530  Thread[] threads = new Thread[numOfThreads];
531  this.updateMeanTravelTimesRunnables = new UpdateMeanTravelTimesRunnable[numOfThreads];
532 
533  // setup threads
534  for (int i = 0; i < numOfThreads; i++) {
535  UpdateMeanTravelTimesRunnable updateMeanTravelTimesRunnable = new UpdateMeanTravelTimesRunnable();
536  updateMeanTravelTimesRunnable.setStartBarrier(this.startBarrier);
537  updateMeanTravelTimesRunnable.setEndBarrier(this.endBarrier);
538  updateMeanTravelTimesRunnables[i] = updateMeanTravelTimesRunnable;
539 
540  Thread thread = new Thread(updateMeanTravelTimesRunnable);
541  thread.setName("UpdateMeanTravelTimes" + i);
542  thread.setDaemon(true); // make the Thread demons so they will terminate automatically
543  threads[i] = thread;
544 
545  thread.start();
546  }
547 
548  /*
549  * Assign the TravelTimeInfos to the Threads
550  */
551  int roundRobin = 0;
552  for (TravelTimeInfo travelTimeInfo : this.travelTimeInfos.values()) {
553  travelTimeInfo.runnable = updateMeanTravelTimesRunnables[roundRobin % numOfThreads];
554  roundRobin++;
555  }
556 
557  /*
558  * After initialization the Threads are waiting at the endBarrier. We
559  * trigger this Barrier once so they wait at the startBarrier what has
560  * to be their state when the run() method is called.
561  */
562  try {
563  this.endBarrier.await();
564  } catch (InterruptedException | BrokenBarrierException e) {
565  throw new RuntimeException(e);
566  }
567  }
Here is the call graph for this function:

Member Data Documentation

◆ log

final Logger org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.log = LogManager.getLogger(WithinDayTravelTime.class)
staticprivate

Definition at line 92 of file WithinDayTravelTime.java.

◆ network

Network org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.network
private

Definition at line 94 of file WithinDayTravelTime.java.

◆ regularActiveTrips

Map<Id<Vehicle>, TripBin> org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.regularActiveTrips
private

Definition at line 97 of file WithinDayTravelTime.java.

◆ travelTimeInfos

Map<Id<Link>, TravelTimeInfo> org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.travelTimeInfos
private

Definition at line 98 of file WithinDayTravelTime.java.

◆ travelTimeInfoProvider

TravelTimeInfoProvider org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.travelTimeInfoProvider
private

Definition at line 100 of file WithinDayTravelTime.java.

◆ changedLinksByTime

TreeMap<Double, Map<Link,Double> > org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.changedLinksByTime
private

Definition at line 103 of file WithinDayTravelTime.java.

◆ startBarrier

CyclicBarrier org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.startBarrier
private

Definition at line 109 of file WithinDayTravelTime.java.

◆ endBarrier

CyclicBarrier org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.endBarrier
private

Definition at line 110 of file WithinDayTravelTime.java.

◆ updateMeanTravelTimesRunnables

UpdateMeanTravelTimesRunnable [] org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.updateMeanTravelTimesRunnables
private

Definition at line 111 of file WithinDayTravelTime.java.

◆ numOfThreads

final int org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.numOfThreads
private

◆ infoTimeStep

final int org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.infoTimeStep = 3600
private

◆ nextInfoTime

int org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.nextInfoTime = 0
private

Definition at line 115 of file WithinDayTravelTime.java.

◆ vehiclesToFilter

Set<Id<Vehicle> > org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.vehiclesToFilter
private

Definition at line 117 of file WithinDayTravelTime.java.

◆ analyzedModes

final Set<String> org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.analyzedModes
private

◆ filterModes

final boolean org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.filterModes
private

Definition at line 119 of file WithinDayTravelTime.java.

◆ problem

boolean org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.problem = true
private

Definition at line 121 of file WithinDayTravelTime.java.

◆ resetCnt

int org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.resetCnt = 0
private

Definition at line 122 of file WithinDayTravelTime.java.

◆ now

double org.matsim.withinday.trafficmonitoring.WithinDayTravelTime.now = Double.NEGATIVE_INFINITY
private

Definition at line 124 of file WithinDayTravelTime.java.


The documentation for this class was generated from the following file: