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

Classes

class  Builder
 

Public Member Functions

 TravelTimeCalculator (final Network network, TravelTimeCalculatorConfigGroup ttconfigGroup)
 
 TravelTimeCalculator (final Network network, final double timeslice, final int maxTime, TravelTimeCalculatorConfigGroup ttconfigGroup)
 
void handleEvent (final LinkEnterEvent e)
 
void handleEvent (final LinkLeaveEvent e)
 
void handleEvent (VehicleEntersTrafficEvent event)
 
void handleEvent (final VehicleLeavesTrafficEvent event)
 
void handleEvent (VehicleArrivesAtFacilityEvent event)
 
void handleEvent (VehicleAbortsEvent event)
 
void reset (int iteration)
 
TravelTime getLinkTravelTimes ()
 
LinkToLinkTravelTime getLinkToLinkTravelTimes ()
 

Static Public Member Functions

static TravelTimeCalculator create (Network network, TravelTimeCalculatorConfigGroup group)
 

Private Member Functions

 TravelTimeCalculator (final Network network, final double timeslice, final int maxTime, boolean calculateLinkTravelTimes, boolean calculateLinkToLinkTravelTimes, boolean filterModes, Set< String > analyzedModes)
 
TravelTimeDataArray getTravelTimeData (final Id< Link > linkId, final boolean createIfMissing)
 
TravelTimeDataArray getLinkToLinkTravelTimeData (Tuple< Id< Link >, Id< Link >> fromLinkToLink)
 
TravelTimeDataArray createTravelTimeData (Id< Link > linkId)
 
double getLinkTravelTime (final Id< Link > linkId, final double time)
 
double getLinkToLinkTravelTime (final Id< Link > fromLinkId, final Id< Link > toLinkId, double time)
 
void consolidateData (final TravelTimeData data)
 

Static Private Member Functions

static TravelTimeCalculator configure (TravelTimeCalculator calculator, TravelTimeCalculatorConfigGroup config, Network network)
 

Private Attributes

final double timeSlice
 
final int numSlots
 
final Network network
 
IdMap< Link, TravelTimeDataArray > linkData
 
Map< Tuple< Id< Link >, Id< Link > >, TravelTimeDataArray > linkToLinkData
 
final Map< Id< Vehicle >, LinkEnterEventlinkEnterEvents
 
final Set< Id< Vehicle > > vehiclesToIgnore
 
final Set< String > analyzedModes
 
final boolean filterAnalyzedModes
 
final boolean calculateLinkTravelTimes
 
final boolean calculateLinkToLinkTravelTimes
 
QSimConfigGroup qsimConfig
 

Static Private Attributes

static final Logger log = LogManager.getLogger(TravelTimeCalculator.class)
 
static final String ERROR_STUCK_AND_LINKTOLINK
 
static int cnt = 0
 

Detailed Description

Calculates actual travel times on link from events and optionally also the link-to-link travel times, e.g. if signaled nodes are used and thus turns in different directions at a node may take a different amount of time.
Travel times on links are collected and averaged in bins/slots with a specified size (binSize, in seconds, default 900 seconds = 15 minutes).

Author
dgrether
mrieser

Definition at line 69 of file TravelTimeCalculator.java.

Constructor & Destructor Documentation

◆ TravelTimeCalculator() [1/3]

org.matsim.core.trafficmonitoring.TravelTimeCalculator.TravelTimeCalculator ( final Network  network,
TravelTimeCalculatorConfigGroup  ttconfigGroup 
)

Definition at line 134 of file TravelTimeCalculator.java.

References org.matsim.core.config.groups.TravelTimeCalculatorConfigGroup.getMaxTime(), org.matsim.core.config.groups.TravelTimeCalculatorConfigGroup.getTraveltimeBinSize(), and org.matsim.core.trafficmonitoring.TravelTimeCalculator.network.

134  {
135  // one tests needs this public
136  // some tests currently use this. they are also quite happy without an events manager. kai, feb'19
137  this(network, ttconfigGroup.getTraveltimeBinSize(), ttconfigGroup.getMaxTime(), ttconfigGroup);
138  }
Here is the call graph for this function:

◆ TravelTimeCalculator() [2/3]

org.matsim.core.trafficmonitoring.TravelTimeCalculator.TravelTimeCalculator ( final Network  network,
final double  timeslice,
final int  maxTime,
TravelTimeCalculatorConfigGroup  ttconfigGroup 
)

◆ TravelTimeCalculator() [3/3]

org.matsim.core.trafficmonitoring.TravelTimeCalculator.TravelTimeCalculator ( final Network  network,
final double  timeslice,
final int  maxTime,
boolean  calculateLinkTravelTimes,
boolean  calculateLinkToLinkTravelTimes,
boolean  filterModes,
Set< String >  analyzedModes 
)
private

Definition at line 207 of file TravelTimeCalculator.java.

References org.matsim.core.trafficmonitoring.TravelTimeCalculator.Builder.analyzedModes, org.matsim.core.trafficmonitoring.TravelTimeCalculator.Builder.calculateLinkToLinkTravelTimes, org.matsim.core.trafficmonitoring.TravelTimeCalculator.Builder.calculateLinkTravelTimes, org.matsim.core.trafficmonitoring.TravelTimeCalculator.Builder.filterModes, org.matsim.api.core.v01.network.Network.getLinks(), org.matsim.core.trafficmonitoring.TimeBinUtils.getTimeBinCount(), org.matsim.core.trafficmonitoring.TravelTimeCalculator.Builder.network, org.matsim.core.trafficmonitoring.TravelTimeCalculator.reset(), and org.matsim.core.trafficmonitoring.TravelTimeCalculator.Builder.timeslice.

208  {
211  this.filterAnalyzedModes = filterModes;
213  this.network = network;
214  this.timeSlice = timeslice;
215  this.numSlots = TimeBinUtils.getTimeBinCount(maxTime, timeslice);
216  this.aggregator = new TimeSlotComputation(this.numSlots, this.timeSlice);
217  this.travelTimeGetter = new AveragingTravelTimeGetter( this.aggregator ) ;
218  if (this.calculateLinkTravelTimes) {
219  this.linkData = new IdMap<>(Link.class);
220  }
222  // assume that every link has 2 outgoing links as default
223  this.linkToLinkData = new ConcurrentHashMap<>((int) (network.getLinks().size() * 1.4 * 2));
224  }
225  this.linkEnterEvents = new ConcurrentHashMap<>();
226 
227  // if we just look at one mode, we need to ignore all vehicles with a different mode. However, the info re the mode is only in
228  // the vehicleEntersTraffic event. So we need to memorize the ignored vehicles from there ...
229  this.vehiclesToIgnore = new HashSet<>();
230 
231  this.reset(0);
232  }
final Map< Id< Vehicle >, LinkEnterEvent > linkEnterEvents
Map< Tuple< Id< Link >, Id< Link > >, TravelTimeDataArray > linkToLinkData
Map< Id< Link >, ? extends Link > getLinks()
Here is the call graph for this function:

Member Function Documentation

◆ create()

static TravelTimeCalculator org.matsim.core.trafficmonitoring.TravelTimeCalculator.create ( Network  network,
TravelTimeCalculatorConfigGroup  group 
)
static

Definition at line 101 of file TravelTimeCalculator.java.

References org.matsim.core.trafficmonitoring.TravelTimeCalculator.configure().

101  {
102  TravelTimeCalculator calculator = new TravelTimeCalculator(network, group);
103  configure(calculator, group, network);
104  return calculator;
105  }
static TravelTimeCalculator configure(TravelTimeCalculator calculator, TravelTimeCalculatorConfigGroup config, Network network)
Here is the call graph for this function:

◆ configure()

static TravelTimeCalculator org.matsim.core.trafficmonitoring.TravelTimeCalculator.configure ( TravelTimeCalculator  calculator,
TravelTimeCalculatorConfigGroup  config,
Network  network 
)
staticprivate

Definition at line 107 of file TravelTimeCalculator.java.

References org.matsim.core.config.groups.TravelTimeCalculatorConfigGroup.getTravelTimeGetterType(), org.matsim.core.trafficmonitoring.TravelTimeCalculator.numSlots, and org.matsim.core.trafficmonitoring.TravelTimeCalculator.timeSlice.

Referenced by org.matsim.core.trafficmonitoring.TravelTimeCalculator.Builder.build(), and org.matsim.core.trafficmonitoring.TravelTimeCalculator.create().

107  {
108  // This should be replaced by a builder if we need the functionality. kai/mads, feb'19
109 
110  switch( config.getTravelTimeGetterType() ){
111  case "average":
112  calculator.travelTimeGetter = new AveragingTravelTimeGetter( calculator.aggregator );
113  break;
114  case "linearinterpolation":
115  calculator.travelTimeGetter = new LinearInterpolatingTravelTimeGetter( calculator.numSlots, calculator.timeSlice, calculator.aggregator );
116  break;
117  default:
118  throw new RuntimeException( config.getTravelTimeGetterType() + " is unknown!" );
119  }
120  return calculator;
121  }
Here is the call graph for this function:

◆ handleEvent() [1/6]

void org.matsim.core.trafficmonitoring.TravelTimeCalculator.handleEvent ( final LinkEnterEvent  e)

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

Definition at line 235 of file TravelTimeCalculator.java.

References org.matsim.core.trafficmonitoring.TravelTimeCalculator.Builder.calculateLinkToLinkTravelTimes, org.matsim.api.core.v01.events.LinkEnterEvent.getLinkId(), org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkToLinkTravelTimeData(), org.matsim.api.core.v01.events.Event.getTime(), and org.matsim.api.core.v01.events.LinkEnterEvent.getVehicleId().

235  {
236  /* if only some modes are analyzed, we check whether the vehicles
237  * performs a trip with one of those modes. if not, we skip the event. */
238  if (filterAnalyzedModes && vehiclesToIgnore.contains(e.getVehicleId())) return;
239 
240  LinkEnterEvent oldEvent = this.linkEnterEvents.put(e.getVehicleId(), e);
241  if ((oldEvent != null) && this.calculateLinkToLinkTravelTimes) {
242  Tuple<Id<Link>, Id<Link>> fromToLink = new Tuple<>(oldEvent.getLinkId(), e.getLinkId());
243  TravelTimeData data = getLinkToLinkTravelTimeData(fromToLink );
244  double enterTime = oldEvent.getTime();
245 
246  final int timeSlot = this.aggregator.getTimeSlotIndex(enterTime );
247  data.addTravelTime(timeSlot, e.getTime() - enterTime );
248  data.setNeedsConsolidation( true );
249  }
250  }
final Map< Id< Vehicle >, LinkEnterEvent > linkEnterEvents
TravelTimeDataArray getLinkToLinkTravelTimeData(Tuple< Id< Link >, Id< Link >> fromLinkToLink)
Here is the call graph for this function:

◆ handleEvent() [2/6]

void org.matsim.core.trafficmonitoring.TravelTimeCalculator.handleEvent ( final LinkLeaveEvent  e)

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

Definition at line 253 of file TravelTimeCalculator.java.

References org.matsim.api.core.v01.events.LinkLeaveEvent.getLinkId(), org.matsim.api.core.v01.events.Event.getTime(), org.matsim.core.trafficmonitoring.TravelTimeCalculator.getTravelTimeData(), and org.matsim.api.core.v01.events.LinkLeaveEvent.getVehicleId().

253  {
254  if (this.calculateLinkTravelTimes) {
255  LinkEnterEvent oldEvent = this.linkEnterEvents.get(e.getVehicleId());
256  if (oldEvent != null) {
257  TravelTimeData data = this.getTravelTimeData(e.getLinkId(), true);
258  double enterTime = oldEvent.getTime();
259 
260  final int timeSlot = this.aggregator.getTimeSlotIndex(enterTime );
261  data.addTravelTime(timeSlot, e.getTime() - enterTime );
262  data.setNeedsConsolidation( true );
263  }
264  }
265  }
final Map< Id< Vehicle >, LinkEnterEvent > linkEnterEvents
TravelTimeDataArray getTravelTimeData(final Id< Link > linkId, final boolean createIfMissing)
Here is the call graph for this function:

◆ handleEvent() [3/6]

void org.matsim.core.trafficmonitoring.TravelTimeCalculator.handleEvent ( VehicleEntersTrafficEvent  event)

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

Definition at line 268 of file TravelTimeCalculator.java.

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

268  {
269  /* if filtering transport modes is enabled and the vehicles
270  * starts a leg on a non analyzed transport mode, add the vehicle
271  * to the filtered vehicles set. */
272  if (filterAnalyzedModes && !analyzedModes.contains(event.getNetworkMode())) {
273  this.vehiclesToIgnore.add(event.getVehicleId());
274  }
275  }
Here is the call graph for this function:

◆ handleEvent() [4/6]

void org.matsim.core.trafficmonitoring.TravelTimeCalculator.handleEvent ( final VehicleLeavesTrafficEvent  event)

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

Definition at line 278 of file TravelTimeCalculator.java.

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

278  {
279  /* remove EnterEvents from list when a vehicle arrives.
280  * otherwise, the activity duration would be counted as travel time, when the
281  * vehicle departs again and leaves the link! */
282  this.linkEnterEvents.remove(event.getVehicleId());
283 
284  // try to remove vehicles from set with filtered vehicles
285  if (filterAnalyzedModes) this.vehiclesToIgnore.remove(event.getVehicleId());
286  }
final Map< Id< Vehicle >, LinkEnterEvent > linkEnterEvents
Here is the call graph for this function:

◆ handleEvent() [5/6]

void org.matsim.core.trafficmonitoring.TravelTimeCalculator.handleEvent ( VehicleArrivesAtFacilityEvent  event)

Implements org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler.

Definition at line 289 of file TravelTimeCalculator.java.

References org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent.getVehicleId().

289  {
290  /* remove EnterEvents from list when a bus stops on a link.
291  * otherwise, the stop time would be counted as travel time, when the
292  * bus departs again and leaves the link! */
293  this.linkEnterEvents.remove(event.getVehicleId());
294  }
final Map< Id< Vehicle >, LinkEnterEvent > linkEnterEvents
Here is the call graph for this function:

◆ handleEvent() [6/6]

void org.matsim.core.trafficmonitoring.TravelTimeCalculator.handleEvent ( VehicleAbortsEvent  event)

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

Definition at line 297 of file TravelTimeCalculator.java.

References org.matsim.api.core.v01.events.LinkEnterEvent.getLinkId(), org.matsim.api.core.v01.events.Event.getTime(), org.matsim.core.trafficmonitoring.TravelTimeCalculator.getTravelTimeData(), and org.matsim.api.core.v01.events.VehicleAbortsEvent.getVehicleId().

297  {
298  LinkEnterEvent e = this.linkEnterEvents.remove(event.getVehicleId());
299  if (e != null) {
300  TravelTimeData data = this.getTravelTimeData(e.getLinkId(), true);
301  data.setNeedsConsolidation( true );
302 
303  // this.aggregator.addStuckEventTravelTime(data, e.getTime(), event.getTime());
304  // this functionality is no longer there.
305 
307  && event.getTime() < qsimConfig.getEndTime().seconds()
308  // (we think that this only makes problems when the abort is not just because of mobsim end time. kai & theresa, jan'17)
309  ){
311  throw new IllegalStateException(ERROR_STUCK_AND_LINKTOLINK);
312  }
313  }
314 
315  // try to remove vehicle from set with filtered vehicles
316  if (filterAnalyzedModes) this.vehiclesToIgnore.remove(event.getVehicleId());
317  }
final Map< Id< Vehicle >, LinkEnterEvent > linkEnterEvents
TravelTimeDataArray getTravelTimeData(final Id< Link > linkId, final boolean createIfMissing)
Here is the call graph for this function:

◆ getTravelTimeData()

TravelTimeDataArray org.matsim.core.trafficmonitoring.TravelTimeCalculator.getTravelTimeData ( final Id< Link linkId,
final boolean  createIfMissing 
)
private

Definition at line 319 of file TravelTimeCalculator.java.

References org.matsim.core.trafficmonitoring.TravelTimeCalculator.createTravelTimeData(), org.matsim.api.core.v01.IdMap< T, V >.get(), and org.matsim.api.core.v01.IdMap< T, V >.put().

Referenced by org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkTravelTime(), and org.matsim.core.trafficmonitoring.TravelTimeCalculator.handleEvent().

319  {
320  TravelTimeDataArray data = this.linkData.get(linkId);
321  if ((null == data) && createIfMissing) {
322  data = this.createTravelTimeData(linkId);
323  this.linkData.put(linkId, data);
324  }
325  return data;
326  }
TravelTimeDataArray createTravelTimeData(Id< Link > linkId)
Here is the call graph for this function:

◆ getLinkToLinkTravelTimeData()

TravelTimeDataArray org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkToLinkTravelTimeData ( Tuple< Id< Link >, Id< Link >>  fromLinkToLink)
private

Definition at line 328 of file TravelTimeCalculator.java.

References org.matsim.core.trafficmonitoring.TravelTimeCalculator.createTravelTimeData().

Referenced by org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkToLinkTravelTime(), and org.matsim.core.trafficmonitoring.TravelTimeCalculator.handleEvent().

328  {
329  TravelTimeDataArray data = this.linkToLinkData.get(fromLinkToLink);
330  if ( null == data ) {
331  data = this.createTravelTimeData(fromLinkToLink.getFirst()) ;
332  this.linkToLinkData.put(fromLinkToLink, data);
333  }
334  return data;
335  }
TravelTimeDataArray createTravelTimeData(Id< Link > linkId)
Map< Tuple< Id< Link >, Id< Link > >, TravelTimeDataArray > linkToLinkData
Here is the call graph for this function:

◆ createTravelTimeData()

TravelTimeDataArray org.matsim.core.trafficmonitoring.TravelTimeCalculator.createTravelTimeData ( Id< Link linkId)
private

◆ getLinkTravelTime()

double org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkTravelTime ( final Id< Link linkId,
final double  time 
)
private

Definition at line 341 of file TravelTimeCalculator.java.

References org.matsim.core.trafficmonitoring.TravelTimeCalculator.consolidateData(), and org.matsim.core.trafficmonitoring.TravelTimeCalculator.getTravelTimeData().

Referenced by org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkTravelTimes().

341  {
342  if (this.calculateLinkTravelTimes) {
343 
344  TravelTimeData data = this.getTravelTimeData(linkId, true);
345  if ( data.isNeedingConsolidation() ) {
346  consolidateData(data);
347  }
348  return this.travelTimeGetter.getTravelTime( data, time );
349  }
350  throw new IllegalStateException("No link travel time is available " +
351  "if calculation is switched off by config option!");
352  }
TravelTimeDataArray getTravelTimeData(final Id< Link > linkId, final boolean createIfMissing)
Here is the call graph for this function:

◆ getLinkToLinkTravelTime()

double org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkToLinkTravelTime ( final Id< Link fromLinkId,
final Id< Link toLinkId,
double  time 
)
private

Definition at line 354 of file TravelTimeCalculator.java.

References org.matsim.core.trafficmonitoring.TravelTimeCalculator.consolidateData(), and org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkToLinkTravelTimeData().

Referenced by org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkToLinkTravelTimes().

354  {
355  if (!this.calculateLinkToLinkTravelTimes) {
356  throw new IllegalStateException("No link to link travel time is available " +
357  "if calculation is switched off by config option!");
358  }
359  TravelTimeData data = this.getLinkToLinkTravelTimeData(new Tuple<>(fromLinkId, toLinkId) );
360  if ( data.isNeedingConsolidation() ) {
361  consolidateData(data);
362  }
363  return this.travelTimeGetter.getTravelTime( data, time );
364  }
TravelTimeDataArray getLinkToLinkTravelTimeData(Tuple< Id< Link >, Id< Link >> fromLinkToLink)
Here is the call graph for this function:

◆ reset()

void org.matsim.core.trafficmonitoring.TravelTimeCalculator.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 367 of file TravelTimeCalculator.java.

References org.matsim.api.core.v01.IdMap< T, V >.values().

Referenced by org.matsim.core.trafficmonitoring.TravelTimeCalculator.TravelTimeCalculator().

367  {
368  if (this.calculateLinkTravelTimes) {
369  for (TravelTimeData data : this.linkData.values()){
370  data.resetTravelTimes();
371  data.setNeedsConsolidation( false );
372  }
373  }
375  for (TravelTimeData data : this.linkToLinkData.values()){
376  data.resetTravelTimes();
377  data.setNeedsConsolidation( false );
378  }
379  }
380  this.linkEnterEvents.clear();
381  this.vehiclesToIgnore.clear();
382  }
final Map< Id< Vehicle >, LinkEnterEvent > linkEnterEvents
Map< Tuple< Id< Link >, Id< Link > >, TravelTimeDataArray > linkToLinkData
Here is the call graph for this function:

◆ consolidateData()

void org.matsim.core.trafficmonitoring.TravelTimeCalculator.consolidateData ( final TravelTimeData  data)
private

Makes sure that the travel times "make sense".

Imagine short bin sizes (e.g. 5min), small links (e.g. 300 veh/hour) and small sample sizes (e.g. 2%). This would mean that effectively in the simulation only 6 vehicles can pass the link in one hour, one every 10min. So, the travel time in one time slot could be >= 10min if two cars enter the link at the same time. If no car enters in the next time bin, the travel time in that time bin should still be >=5 minutes (10min - binSize), and not freespeedTraveltime, because actually every car entering the link in this bin will be behind the car entered before, which still needs >=5min until it can leave.

This method ensures that the travel time in a time bin cannot be smaller than the travel time in the bin before minus the bin size.

Definition at line 402 of file TravelTimeCalculator.java.

References org.matsim.core.trafficmonitoring.TravelTimeCalculator.numSlots, and org.matsim.core.trafficmonitoring.TravelTimeCalculator.timeSlice.

Referenced by org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkToLinkTravelTime(), and org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkTravelTime().

402  {
403  synchronized(data) {
404  if ( data.isNeedingConsolidation() ) {
405 
406  // initialize prevTravelTime with ttime from time bin 0 and time 0. (The interface comment already states that
407  // having both as argument does not make sense.)
408  double prevTravelTime = data.getTravelTime(0, 0.0 );
409  // changed (1, 0.0) to (0, 0.0) since Michal has convinced me (by a test) that using "1" is wrong
410  // because you get the wrong result for time slot number 1. This change does not affect the existing
411  // unit tests. kai, oct'11
412 
413  // go from time slot 1 forward in time:
414  for (int i = 1; i < this.numSlots; i++) {
415 
416  // once more the getter is weird since it needs both the time slot and the time:
417  double travelTime = data.getTravelTime(i, i * this.timeSlice );
418 
419  // if the travel time in the previous time slice was X, then now it is X-S, where S is the time slice:
420  double minTravelTime = prevTravelTime - this.timeSlice;
421 
422  // if the travel time that has been measured so far is less than that minimum travel time, then do something:
423  if (travelTime < minTravelTime) {
424  // (set the travel time to the smallest possible travel time that makes sense according to the argument above)
425  travelTime = minTravelTime;
426  data.setTravelTime(i, travelTime);
427  }
428  prevTravelTime = travelTime;
429  }
430  data.setNeedsConsolidation( false );
431  }
432  }
433  }

◆ getLinkTravelTimes()

TravelTime org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkTravelTimes ( )

Definition at line 437 of file TravelTimeCalculator.java.

References org.matsim.api.core.v01.Identifiable< T >.getId(), org.matsim.api.core.v01.network.Link.getLength(), org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkTravelTime(), org.matsim.vehicles.VehicleType.getMaximumVelocity(), org.matsim.vehicles.Vehicle.getType(), and org.matsim.core.gbl.Gbl.ONLYONCE.

Referenced by org.matsim.utils.leastcostpathtree.LeastCostPathTree.main().

437  {
438  return new TravelTime() {
439 
440  @Override
441  public double getLinkTravelTime(Link link, double time, Person person, Vehicle vehicle) {
442  // right now, the link speed limit comes from the travel time calculator, and this here just overrides it. One might consider doing all of this here;
443  // possibly would make the code easier to read. kai/mads, feb'19
444 
445  double linkTtimeFromVehicle = 0. ;
446  if ( vehicle!=null ){
447  final VehicleType vehicleType = vehicle.getType();
448  if ( vehicleType==null ){
449  if( cnt < 1 ){
450  cnt++;
451  log.warn( "encountered vehicle where vehicle.getType() returns null. That should be repaired (whereever it comes from)." );
452  log.warn( Gbl.ONLYONCE );
453  }
454  } else{
455  linkTtimeFromVehicle = link.getLength() / vehicleType.getMaximumVelocity();
456  }
457  }
458  double linkTTimeFromObservation = TravelTimeCalculator.this.getLinkTravelTime(link.getId(), time);
459  return Math.max( linkTtimeFromVehicle, linkTTimeFromObservation) ;
460  // yyyyyy should this not be min? kai/janek, may'19
461  // No, it is correct. It is preventing the router to route with an empirical speed from
462  // the previous iteration that exceeds the maximum vehicle speed.
463  // Thus, the lowest speed (highest travel time) of the two should be used. Mads, Nov'19
464  }
465 
466  };
467 
468  }
double getLinkTravelTime(final Id< Link > linkId, final double time)
Here is the call graph for this function:

◆ getLinkToLinkTravelTimes()

LinkToLinkTravelTime org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkToLinkTravelTimes ( )

Definition at line 470 of file TravelTimeCalculator.java.

References org.matsim.api.core.v01.Identifiable< T >.getId(), org.matsim.api.core.v01.network.Link.getLength(), org.matsim.core.trafficmonitoring.TravelTimeCalculator.getLinkToLinkTravelTime(), org.matsim.vehicles.VehicleType.getMaximumVelocity(), org.matsim.vehicles.Vehicle.getType(), and org.matsim.core.gbl.Gbl.ONLYONCE.

470  {
471  return new LinkToLinkTravelTime() {
472 
473  @Override
474  public double getLinkToLinkTravelTime(Link fromLink, Link toLink, double time, Person person, Vehicle vehicle) {
475  double linkTtimeFromVehicle = 0. ;
476  if ( vehicle!=null ){
477  final VehicleType vehicleType = vehicle.getType();
478  if ( vehicleType==null ){
479  if( cnt < 1 ){
480  cnt++;
481  log.warn( "encountered vehicle where vehicle.getType() returns null. That should be repaired (whereever it comes from)." );
482  log.warn( Gbl.ONLYONCE );
483  }
484  } else{
485  linkTtimeFromVehicle = fromLink.getLength() / vehicleType.getMaximumVelocity();
486  }
487  }
488  double linkTTimeFromObservation = TravelTimeCalculator.this.getLinkToLinkTravelTime(fromLink.getId(), toLink.getId(), time);
489 
490  return Math.max(linkTTimeFromObservation, linkTtimeFromVehicle);
491  }
492  };
493  }
double getLinkToLinkTravelTime(final Id< Link > fromLinkId, final Id< Link > toLinkId, double time)
Here is the call graph for this function:

Member Data Documentation

◆ log

final Logger org.matsim.core.trafficmonitoring.TravelTimeCalculator.log = LogManager.getLogger(TravelTimeCalculator.class)
staticprivate

Definition at line 72 of file TravelTimeCalculator.java.

◆ ERROR_STUCK_AND_LINKTOLINK

final String org.matsim.core.trafficmonitoring.TravelTimeCalculator.ERROR_STUCK_AND_LINKTOLINK
staticprivate
Initial value:
= "Using the stuck feature with turning move travel times is not available. As the next link of a stucked" +
"agent is not known the turning move travel time cannot be calculated!"

Definition at line 74 of file TravelTimeCalculator.java.

◆ timeSlice

final double org.matsim.core.trafficmonitoring.TravelTimeCalculator.timeSlice
private

◆ numSlots

final int org.matsim.core.trafficmonitoring.TravelTimeCalculator.numSlots
private

◆ network

final Network org.matsim.core.trafficmonitoring.TravelTimeCalculator.network
private

◆ linkData

IdMap<Link, TravelTimeDataArray> org.matsim.core.trafficmonitoring.TravelTimeCalculator.linkData
private

Definition at line 82 of file TravelTimeCalculator.java.

◆ linkToLinkData

Map<Tuple<Id<Link>, Id<Link> >, TravelTimeDataArray> org.matsim.core.trafficmonitoring.TravelTimeCalculator.linkToLinkData
private

Definition at line 84 of file TravelTimeCalculator.java.

◆ linkEnterEvents

final Map<Id<Vehicle>, LinkEnterEvent> org.matsim.core.trafficmonitoring.TravelTimeCalculator.linkEnterEvents
private

Definition at line 86 of file TravelTimeCalculator.java.

◆ vehiclesToIgnore

final Set<Id<Vehicle> > org.matsim.core.trafficmonitoring.TravelTimeCalculator.vehiclesToIgnore
private

Definition at line 88 of file TravelTimeCalculator.java.

◆ analyzedModes

final Set<String> org.matsim.core.trafficmonitoring.TravelTimeCalculator.analyzedModes
private

Definition at line 89 of file TravelTimeCalculator.java.

◆ filterAnalyzedModes

final boolean org.matsim.core.trafficmonitoring.TravelTimeCalculator.filterAnalyzedModes
private

Definition at line 91 of file TravelTimeCalculator.java.

◆ calculateLinkTravelTimes

final boolean org.matsim.core.trafficmonitoring.TravelTimeCalculator.calculateLinkTravelTimes
private

Definition at line 93 of file TravelTimeCalculator.java.

◆ calculateLinkToLinkTravelTimes

final boolean org.matsim.core.trafficmonitoring.TravelTimeCalculator.calculateLinkToLinkTravelTimes
private

Definition at line 95 of file TravelTimeCalculator.java.

◆ qsimConfig

QSimConfigGroup org.matsim.core.trafficmonitoring.TravelTimeCalculator.qsimConfig
private

Definition at line 97 of file TravelTimeCalculator.java.

◆ cnt

int org.matsim.core.trafficmonitoring.TravelTimeCalculator.cnt = 0
staticprivate

Definition at line 435 of file TravelTimeCalculator.java.


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