MATSIM
QSim.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * QSim.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2007, 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 
21 package org.matsim.core.mobsim.qsim;
22 
23 import com.google.inject.Injector;
24 import org.apache.logging.log4j.LogManager;
25 import org.apache.logging.log4j.Logger;
26 import org.matsim.api.core.v01.Id;
27 import org.matsim.api.core.v01.IdMap;
28 import org.matsim.api.core.v01.Scenario;
39 import org.matsim.core.gbl.Gbl;
54 import org.matsim.core.utils.misc.Time;
55 import org.matsim.vehicles.Vehicle;
64 
65 import jakarta.inject.Inject;
66 import java.util.*;
67 import java.util.Map.Entry;
68 import java.util.concurrent.atomic.AtomicLong;
69 
98 public final class QSim implements VisMobsim, Netsim, ActivityEndRescheduler {
99 
100  final private static Logger log = LogManager.getLogger(QSim.class);
101 
105  private double infoTime = 0;
106 
107  private static final int INFO_PERIOD = 3600;
108 
109  private final EventsManager events;
110 
112 
113  private final Collection<MobsimEngine> mobsimEngines = new ArrayList<>();
114 
115  private final MobsimTimer simTimer;
116 
118 
120 
121  private final Date realWorldStarttime = new Date();
122  private double stopTime; // initialised in initSimTimer()
123  private final MobsimListenerManager listenerManager;
124  private final Scenario scenario;
125  private final List<ActivityHandler> activityHandlers = new ArrayList<>();
126  private final List<DepartureHandler> departureHandlers = new ArrayList<>();
128  private final Map<Id<Person>, MobsimAgent> agents = new LinkedHashMap<>();
130  private final List<AgentSource> agentSources = new ArrayList<>();
131 
132  // for detailed run time analysis
133  public static boolean analyzeRunTimes = false;
134  private long startClockTime = 0;
135  private long qSimInternalTime = 0;
136  private final Map<MobsimEngine, AtomicLong> mobsimEngineRunTimes;
138 
139  {
140  if (analyzeRunTimes) this.mobsimEngineRunTimes = new HashMap<>();
141  else this.mobsimEngineRunTimes = null;
142  }
143 
144  /*package (for tests)*/ final InternalInterface internalInterface = new InternalInterface() {
145 
146  // These methods must be synchronized, because they are called back
147  // from possibly multi-threaded engines, and they access
148  // global mutable data.
149 
150  @Override
151  public synchronized void arrangeNextAgentState(MobsimAgent agent) {
152  QSim.this.arrangeNextAgentAction(agent);
153  }
154 
155  @Override
156  public QSim getMobsim() {
157  return QSim.this;
158  }
159 
160  @Override
161  public synchronized void registerAdditionalAgentOnLink(final MobsimAgent planAgent) {
162  if (QSim.this.netEngine != null) {
164  }
165  }
166 
167  @Override
168  public synchronized MobsimAgent unregisterAdditionalAgentOnLink(Id<Person> agentId, Id<Link> linkId) {
169  if (QSim.this.netEngine != null) {
170  return QSim.this.netEngine.unregisterAdditionalAgentOnLink(agentId, linkId);
171  }
172  return null;
173  }
174 
175  @Override public final List<DepartureHandler> getDepartureHandlers() {
176  return departureHandlers ;
177  }
178  };
179 
180  private final Collection<AgentTracker> agentTrackers = new ArrayList<>() ;
181 
182  private final Injector childInjector;
183 
184  @Override
185  public final void rescheduleActivityEnd(MobsimAgent agent) {
186  for( ActivityHandler activityHandler : this.activityHandlers ){
187  Gbl.assertNotNull( activityHandler );
188  activityHandler.rescheduleActivityEnd( agent );
189  }
190  }
191 
200  @Inject
201  private QSim( final Scenario sc, EventsManager events, Injector childInjector ) {
202  this.scenario = sc;
203  if ( sc.getConfig().qsim().getNumberOfThreads() > 1) {
204  this.events = EventsUtils.getParallelFeedableInstance( events );
205  } else {
206  this.events = events;
207  }
208  this.listenerManager = new MobsimListenerManager( this );
210  this.simTimer = new MobsimTimer( sc.getConfig().qsim().getTimeStepSize());
211 
212  this.childInjector = childInjector ;
213  }
214 
215  // ============================================================================================================================
216  // "run" method:
217 
218  @Override
219  public void run() {
220  boolean tryBlockWithException = false;
221  try {
222  // Teleportation must be last (default) departure handler, so add it only before running:
223  this.departureHandlers.add(this.teleportationEngine);
224 
225  // ActivityEngine must be last (=default) activity handler, so add it only before running:
226  this.activityHandlers.add(this.activityEngine);
227 
228  prepareSim();
229  this.listenerManager.fireQueueSimulationInitializedEvent();
230 
231  // Put agents into the handler for their first ("overnight") action,
232  // probably the ActivityEngine. This is done before the first
233  // beforeSimStepEvent, because the expectation seems to be
234  // (e.g. in OTFVis), that agents are doing something
235  // (can be located somewhere) before you execute a sim step.
236  // Agents can abort in this loop already, so we iterate over
237  // a defensive copy of the agent collection.
238  for (MobsimAgent agent : new ArrayList<>(this.agents.values())) {
239  arrangeNextAgentAction(agent);
240  }
241 
242  // do iterations
243  boolean doContinue = true;
244  while (doContinue) {
245  doContinue = doSimStep();
246  }
247  } catch (RuntimeException tryBlockException) {
248  tryBlockWithException = true;
249  throw tryBlockException;
250  } finally {
251  // We really want to perform that. For instance, with QNetsimEngine, threads are cleaned up in this method.
252  // Without this finally, in case of a crash, threads are not closed, which lead to process hanging forever
253  // at least on the eth euler cluster (but not on our local machines at ivt!?) td oct 15
254  try {
255  cleanupSim();
256  } catch (RuntimeException cleanupException) {
257  if (tryBlockWithException) {
258  // we want to log this exception thrown during the cleanup, but not to throw it
259  // since there is another (earlier) exception thrown in the try block
260  log.warn("exception in finally block - "
261  + "this may be a follow-up exception of an exception thrown in the try block.",
262  cleanupException);
263  } else {
264  // no exception thrown in the try block, let's re-throw the exception from the cleanup step
265  throw cleanupException;
266  }
267  }
268  }
269  }
270 
271  // ============================================================================================================================
272  // prepareSim and related:
273 
277  /*package*/ void prepareSim() {
278  events.initProcessing();
279 
280  createAgents();
281  this.initSimTimer();
282  this.infoTime = Math.floor(this.simTimer.getSimStartTime()
283  / INFO_PERIOD)
284  * INFO_PERIOD; // infoTime may be < simStartTime, this ensures
285  // to print out the info at the very first
286  // timestep already
287 
288  for (MobsimEngine mobsimEngine : this.mobsimEngines) {
289  mobsimEngine.onPrepareSim();
290  }
291  }
292 
293  private void createAgents() {
294  for (AgentSource agentSource : this.agentSources) {
295  agentSource.insertAgentsIntoMobsim();
296  }
297  }
298 
299 // public void createAndParkVehicleOnLink(Vehicle vehicle, Id<Link> linkId) {
300 // QVehicle qveh = this.qVehicleFactory.createQVehicle( vehicle ) ;
301 // addParkedVehicle ( qveh, linkId ) ;
302 // }
303 
304  private static int wrnCnt2 = 0;
305  public void addParkedVehicle(MobsimVehicle veh, Id<Link> startLinkId) {
306  if (this.netEngine != null) {
307  this.netEngine.addParkedVehicle(veh, startLinkId);
308  } else {
309  if (wrnCnt2 < 1) {
310  log.warn( "not able to add parked vehicle since there is no netsim engine. continuing anyway, but it may "
311  + "not be clear what this means ...") ;
312  log.warn(Gbl.ONLYONCE);
313  wrnCnt2++;
314  }
315  }
316  if ( this.vehicles.containsKey( veh.getId() ) ) {
317  throw new RuntimeException( "vehicle with ID " + veh.getId() + " exists twice. Aborting ..." ) ;
318  }
319  this.vehicles.put( veh.getId(), veh ) ;
320 
321  final Vehicles allvehicles = VehicleUtils.getOrCreateAllvehicles( scenario );
322  VehicleType vehType = veh.getVehicle().getType();
323  if ( !allvehicles.getVehicleTypes().containsKey( vehType.getId() ) ) {
324  allvehicles.addVehicleType( veh.getVehicle().getType() );
325  }
326  if ( !allvehicles.getVehicles().containsKey( veh.getVehicle().getId() ) ) {
327  allvehicles.addVehicle( veh.getVehicle() );
328  }
329  // yy one might want to check if the types/vehicles here are the same as in previous iterations. kai/kai, jan'20
330  }
331 
332  public Map<Id<Vehicle>,MobsimVehicle> getVehicles() {
333  return Collections.unmodifiableMap( this.vehicles ) ;
334  }
335 
336  private void cleanupSim() {
337  this.listenerManager.fireQueueSimulationBeforeCleanupEvent();
338 
339  boolean gotException = false;
340  for (MobsimEngine mobsimEngine : mobsimEngines) {
341  try {
342  // make sure all engines are cleaned up
343  mobsimEngine.afterSim();
344  }
345  catch (Exception e) {
346  log.error("got exception while cleaning up", e);
347  gotException=true;
348  }
349  }
350 
351  if (gotException) throw new RuntimeException( "got exception while cleaning up the QSim. Please check the error messages above for details.");
352  events.finishProcessing();
353  if (analyzeRunTimes) {
354  log.info("qsim internal cpu time (nanos): " + qSimInternalTime);
355  for (Entry<MobsimEngine, AtomicLong> entry : this.mobsimEngineRunTimes.entrySet()) {
356  log.info(entry.getKey().getClass().toString() + " cpu time (nanos): " + entry.getValue().get());
357  }
358  log.info("");
359  if ( this.netEngine instanceof QNetsimEngineI ) {
360  ((QNetsimEngineI)this.netEngine).printEngineRunTimes();
361  // (yy should somehow be in afterSim()).
362  }
363  }
364  }
365 
371  /*package*/ boolean doSimStep() {
372  if (analyzeRunTimes) this.startClockTime = System.nanoTime();
373 
374  final double now = this.getSimTimer().getTimeOfDay();
375 
376  this.listenerManager.fireQueueSimulationBeforeSimStepEvent(now);
377 
378  if (analyzeRunTimes) this.qSimInternalTime += System.nanoTime() - this.startClockTime;
379 
380  /*
381  * The WithinDayEngine has to perform its replannings before
382  * the other engines simulate the sim step.
383  */
384  if (this.withindayEngine != null) {
385  if (analyzeRunTimes) startClockTime = System.nanoTime();
386  this.withindayEngine.doSimStep(now);
387  if (analyzeRunTimes) this.mobsimEngineRunTimes.get(this.withindayEngine).addAndGet(System.nanoTime() - this.startClockTime);
388  }
389 
390  // "added" engines
391  for (MobsimEngine mobsimEngine : this.mobsimEngines) {
392  if (analyzeRunTimes) this.startClockTime = System.nanoTime();
393 
394  // withindayEngine.doSimStep(time) has already been called
395  if (mobsimEngine == this.withindayEngine) continue;
396 
397  mobsimEngine.doSimStep(now);
398 
399  if (analyzeRunTimes)
400  this.mobsimEngineRunTimes.get(mobsimEngine).addAndGet(System.nanoTime() - this.startClockTime);
401  }
402 
403  if (analyzeRunTimes) this.startClockTime = System.nanoTime();
404 
405  // console printout:
406  this.printSimLog(now);
407 
408  // trigger the after sim step listeners before finishing the events processing of this sim step.
409  // this gives after sim step listeners like snapshot generator the opportunity to generate events
410  // for the current time step.
411  this.events.afterSimStep(now);
412  this.listenerManager.fireQueueSimulationAfterSimStepEvent(now);
413 
414 
415  final QSimConfigGroup qsimConfigGroup = this.scenario.getConfig().qsim();
416  boolean doContinue = (this.agentCounter.isLiving() && (this.stopTime > now));
418  doContinue = now <= qsimConfigGroup.getEndTime().seconds();
419  }
420 
421  if (doContinue) {
422  this.simTimer.incrementTime();
423  }
424 
425  if (analyzeRunTimes) this.qSimInternalTime += System.nanoTime() - this.startClockTime;
426 
427  return doContinue;
428  }
429 
430  public void insertAgentIntoMobsim(final MobsimAgent agent) {
431  if (this.agents.containsKey(agent.getId())) {
432  throw new RuntimeException("Agent with same Id (" + agent.getId().toString() + ") already in mobsim; aborting ... ") ;
433  }
434  this.agents.put(agent.getId(), agent);
435  this.agentCounter.incLiving();
436  if ( agent instanceof HasPerson ){
437  final Population allpersons = PopulationUtils.getOrCreateAllpersons( scenario );
438  if ( !allpersons.getPersons().containsKey( ((HasPerson) agent).getPerson().getId() ) ){
439  allpersons.addPerson( ((HasPerson) agent).getPerson() );
440  }
441  }
442  }
443 
444  private void arrangeNextAgentAction(final MobsimAgent agent) {
445  switch( agent.getState() ) {
446  case ACTIVITY:
447  arrangeAgentActivity(agent);
448  break ;
449  case LEG:
450  this.arrangeAgentDeparture(agent);
451  break ;
452  case ABORT:
453  this.events.processEvent( new PersonStuckEvent(this.simTimer.getTimeOfDay(), agent.getId(), agent.getCurrentLinkId(), agent.getMode()));
454 
455  // NOTE: in the same way as one can register departure handler or activity handler, we could allow to
456  // register abort handlers. If someone ever comes to this place here and needs this. kai, nov'17
457 
458  this.agents.remove(agent.getId()) ;
459  this.agentCounter.decLiving();
460  this.agentCounter.incLost();
461  break ;
462  default:
463  throw new RuntimeException("agent with unknown state (possibly null)") ;
464  }
465  }
466 
467  private void arrangeAgentActivity(final MobsimAgent agent) {
468  for (ActivityHandler activityHandler : this.activityHandlers) {
469  if (activityHandler.handleActivity(agent)) {
470  return;
471  }
472  }
473  }
474 
481  private void arrangeAgentDeparture(final MobsimAgent agent) {
482  double now = this.getSimTimer().getTimeOfDay();
483  Id<Link> linkId = agent.getCurrentLinkId();
484  Gbl.assertIf( linkId!=null );
485 
486  String routingMode = null;
487 
488  if (agent instanceof PlanAgent) {
489  Leg currentLeg = (Leg) ((PlanAgent) agent).getCurrentPlanElement();
490  routingMode = TripStructureUtils.getRoutingMode(currentLeg);
491  }
492 
493  events.processEvent(new PersonDepartureEvent(now, agent.getId(), linkId, agent.getMode(), routingMode));
494 
495  for (DepartureHandler departureHandler : this.departureHandlers) {
496  if (departureHandler.handleDeparture(now, agent, linkId)) {
497  return;
498  }
499  }
500  log.warn("no departure handler wanted to handle the departure of agent " + agent.getId());
501  // yy my intuition is that this should be followed by setting the agent state to abort. kai, nov'14
502 
503  }
504 
505  // ############################################################################################################################
506  // private methods
507  // ############################################################################################################################
508 
509  private void initSimTimer() {
510  QSimConfigGroup qSimConfigGroup = this.scenario.getConfig().qsim();
511  double configuredStartTime = qSimConfigGroup.getStartTime().orElse(0);
512  this.stopTime = qSimConfigGroup.getEndTime().orElse(Double.MAX_VALUE);
513  if (this.stopTime == 0) {
514  this.stopTime = Double.MAX_VALUE;
515  }
516 
517  double simStartTime;
519  double firstAgentStartTime = calculateFirstAgentStartTime();
520  simStartTime = Math.floor(Math.max(configuredStartTime, firstAgentStartTime));
522  simStartTime = configuredStartTime;
523  } else {
524  throw new RuntimeException("unkonwn starttimeInterpretation; aborting ...");
525  }
526 
527  this.simTimer.setSimStartTime(simStartTime);
528  this.simTimer.setTime(simStartTime);
529 
530  }
531 
532  private double calculateFirstAgentStartTime() {
533  double firstAgentStartTime = Double.POSITIVE_INFINITY;
534  for (MobsimAgent agent : agents.values()) {
535  firstAgentStartTime = Math.min(firstAgentStartTime, agent.getActivityEndTime());
536  }
537  return firstAgentStartTime;
538  }
539 
540  // ############################################################################################################################
541  // utility methods (presumably no state change)
542  // ############################################################################################################################
543 
544  private void printSimLog(final double time) {
545  if (time >= this.infoTime) {
546  // if(true){
547  this.infoTime += INFO_PERIOD;
548  Date endtime = new Date();
549  long diffreal = (endtime.getTime() - this.realWorldStarttime
550  .getTime()) / 1000;
551  double diffsim = time - this.simTimer.getSimStartTime();
552  log.info("SIMULATION (NEW QSim) AT " + Time.writeTime(time)
553  + " : #Veh=" + this.agentCounter.getLiving() + " lost="
554  + this.agentCounter.getLost() + " simT=" + diffsim
555  + "s realT=" + (diffreal) + "s; (s/r): "
556  + (diffsim / (diffreal + Double.MIN_VALUE)));
557  }
558  }
559 
560  // ############################################################################################################################
561  // no real functionality beyond this point
562  // ############################################################################################################################
563 
564  @Override
566  return events;
567  }
568 
569  @Override
571  return this.netEngine.getNetsimNetwork();
572  }
573 
574  @Override
576  return this.netEngine.getNetsimNetwork();
577  }
578 
579  @Override
581  return this.scenario;
582  }
583 
584  @Override
586  return this.simTimer;
587  }
588 
589  public void addMobsimEngine(MobsimEngine mobsimEngine) {
590  // yy in all of the instanceof expressions below, the implementation class needs to be replaced
591  // by a meaningful interface. kai, oct'17
592 
593 // if (mobsimEngine instanceof TransitQSimEngine) {
594 // if (this.transitEngine != null) {
595 // log.warn("pre-existing transitEngine != null; will be overwritten; with the current design, " +
596 // "there can only be one TransitQSimEngine") ;
597 // }
598 // this.transitEngine = (TransitQSimEngine) mobsimEngine;
599 // }
600 
601  // yy note that what follows here somewhat interacts with the QSimProvider, which is doing similar things. I just fixed a resulting misunderstanding re
602  // ActivityEngine, but presumably more thinking should be invested here. kai, mar'19
603 
604  if ( mobsimEngine instanceof AgentTracker ) {
605  agentTrackers.add((AgentTracker) mobsimEngine);
606  }
607  if (mobsimEngine instanceof ActivityEngine){
608  this.activityEngine = (ActivityEngine) mobsimEngine;
609  }
610  if ( mobsimEngine instanceof HasAgentTracker ) {
611  agentTrackers.add(((HasAgentTracker) mobsimEngine).getAgentTracker());
612  }
613  if (mobsimEngine instanceof NetsimEngine) {
614  this.netEngine = (NetsimEngine) mobsimEngine;
615  }
616  if (mobsimEngine instanceof TeleportationEngine) {
617  this.teleportationEngine = (TeleportationEngine) mobsimEngine;
618  }
619  if (mobsimEngine instanceof WithinDayEngine) {
620  this.withindayEngine = (WithinDayEngine) mobsimEngine;
621  }
622  mobsimEngine.setInternalInterface(this.internalInterface);
623  this.mobsimEngines.add(mobsimEngine);
624 
625  if (analyzeRunTimes) this.mobsimEngineRunTimes.put(mobsimEngine, new AtomicLong());
626  }
627 
628  @Override
629  public AgentCounter getAgentCounter() {
630  return this.agentCounter;
631  }
632 
633  public void addDepartureHandler(DepartureHandler departureHandler) {
634  if (!(departureHandler instanceof TeleportationEngine)) {
635  // We add the teleportation handler manually later
636  this.departureHandlers.add(departureHandler);
637  }
638  }
639 
640  public void addActivityHandler(ActivityHandler activityHandler) {
641  if ( ! ( activityHandler instanceof ActivityEngine ) ){
642  // We add the ActivityEngine manually later
643  Gbl.assertNotNull( activityHandler );
644  this.activityHandlers.add( activityHandler );
645  }
646  }
647 
652  @Override
654  this.listenerManager.addQueueSimulationListener(listener);
655  }
656 
657  @Inject void addQueueSimulationListeners(Set<MobsimListener> listeners) {
658  // I think that "injecting a method" means that the method is called at some point, pulling the method arguments out of injection. In
659  // consequence, it is assumed that a "Set<MobsimListener>" was bound before, and is used here. I think that the results of
660  // multibinding will be provided in several ways, one of them as this kind of set. Thus, the working assumption is that the
661  // <MobsimListener> multibinder that is constructed in AbstractModule is retrieved here. kai, sep'20
662 
663  for (MobsimListener listener : listeners) {
664  this.listenerManager.addQueueSimulationListener(listener);
665  }
666  }
667 
668 // /**
669 // * Only OTFVis is allowed to use this. If you want access to the TransitQSimEngine,
670 // * just "inline" the factory method of this class to plug together your own QSim, and you've got it!
671 // * This getter will disappear very soon. michaz 11/11
672 // */
673 // @Deprecated
674 // public TransitQSimEngine getTransitEngine() {
675 // return this.transitEngine;
676 // }
677  // see new getAgentTrackers method. kai, nov'17
678 
679  @Override
680  public Map<Id<Person>, MobsimAgent> getAgents() {
681  return Collections.unmodifiableMap(this.agents);
682  }
683 
684  public void addAgentSource(AgentSource agentSource) {
685  this.agentSources.add(agentSource);
686  }
687 
688  @Override
690  return new VisData() {
691 
692  @Override
693  public Collection<AgentSnapshotInfo> addAgentSnapshotInfo(Collection<AgentSnapshotInfo> positions) {
694  for (MobsimEngine mobsimEngine : mobsimEngines) {
695  if (mobsimEngine instanceof VisData) {
696  VisData visData = (VisData) mobsimEngine;
697  positions = visData.addAgentSnapshotInfo(positions);
698  }
699  }
700  return positions;
701  }
702  };
703  }
704 
705  public Collection<AgentTracker> getAgentTrackers() {
706  return Collections.unmodifiableCollection(agentTrackers) ;
707  }
708 
709  public Injector getChildInjector() {
710  return this.childInjector ;
711  }
712 
713  public final void addNetworkChangeEvent( NetworkChangeEvent event ) {
714  // used (and thus implicitly tested) by bdi-abm-integration project. A separate core test would be good. kai, feb'18
715 
716  boolean processed = false ;
717  for ( MobsimEngine engine : this.mobsimEngines ) {
718  if ( engine instanceof NetworkChangeEventsEngineI ) {
719  ((NetworkChangeEventsEngineI) engine).addNetworkChangeEvent( event );
720  processed = true ;
721  }
722  }
723  if ( !processed ) {
724  throw new RuntimeException("received a network change event, but did not process it. Maybe " +
725  "the network change events engine was not set up for the qsim? Aborting ...") ;
726  }
727  }
728 
729 }
final Collection< MobsimEngine > mobsimEngines
Definition: QSim.java:113
final List< AgentSource > agentSources
Definition: QSim.java:130
static final String ONLYONCE
Definition: Gbl.java:42
static boolean analyzeRunTimes
Definition: QSim.java:133
void arrangeNextAgentAction(final MobsimAgent agent)
Definition: QSim.java:444
void addMobsimEngine(MobsimEngine mobsimEngine)
Definition: QSim.java:589
MobsimAgent unregisterAdditionalAgentOnLink(Id< Person > agentId, Id< Link > linkId)
void addAgentSource(AgentSource agentSource)
Definition: QSim.java:684
static void assertIf(boolean flag)
Definition: Gbl.java:207
final List< ActivityHandler > activityHandlers
Definition: QSim.java:125
final List< DepartureHandler > departureHandlers
Definition: QSim.java:126
void addQueueSimulationListeners(MobsimListener listener)
Definition: QSim.java:653
void arrangeAgentActivity(final MobsimAgent agent)
Definition: QSim.java:467
Map< Id< Person >, MobsimAgent > getAgents()
Definition: QSim.java:680
final static Logger log
Definition: QSim.java:100
boolean containsKey(Object key)
Definition: IdMap.java:44
final MobsimTimer simTimer
Definition: QSim.java:115
Map< Id< VehicleType >, VehicleType > getVehicleTypes()
NetsimNetwork getNetsimNetwork()
Definition: QSim.java:570
QSim(final Scenario sc, EventsManager events, Injector childInjector)
Definition: QSim.java:201
void registerAdditionalAgentOnLink(MobsimAgent planAgent)
static Vehicles getOrCreateAllvehicles(Scenario scenario)
void addVehicleType(final VehicleType type)
Map< Id< Vehicle >, MobsimVehicle > getVehicles()
Definition: QSim.java:332
Map< Id< Person >,? extends Person > getPersons()
void setInternalInterface(InternalInterface internalInterface)
void insertAgentIntoMobsim(final MobsimAgent agent)
Definition: QSim.java:430
final Map< Id< Person >, MobsimAgent > agents
Definition: QSim.java:128
Collection< AgentTracker > getAgentTrackers()
Definition: QSim.java:705
final Injector childInjector
Definition: QSim.java:182
StarttimeInterpretation getSimStarttimeInterpretation()
void arrangeAgentDeparture(final MobsimAgent agent)
Definition: QSim.java:481
void addVehicle(final Vehicle v)
TeleportationEngine teleportationEngine
Definition: QSim.java:117
VisData getNonNetworkAgentSnapshots()
Definition: QSim.java:689
static Population getOrCreateAllpersons(Scenario scenario)
ActivityEngine activityEngine
Definition: QSim.java:137
final Map< MobsimEngine, AtomicLong > mobsimEngineRunTimes
Definition: QSim.java:136
void setSimStartTime(double startTimeSec)
QSimConfigGroup qsim()
Definition: Config.java:447
static final String writeTime(final double seconds, final String timeformat)
Definition: Time.java:80
static void assertNotNull(Object obj)
Definition: Gbl.java:212
void addDepartureHandler(DepartureHandler departureHandler)
Definition: QSim.java:633
EventsManager getEventsManager()
Definition: QSim.java:565
void addActivityHandler(ActivityHandler activityHandler)
Definition: QSim.java:640
final Collection< AgentTracker > agentTrackers
Definition: QSim.java:180
AgentCounter getAgentCounter()
Definition: QSim.java:629
final Id< VehicleType > getId()
void printSimLog(final double time)
Definition: QSim.java:544
Map< Id< Vehicle >, Vehicle > getVehicles()
final void rescheduleActivityEnd(MobsimAgent agent)
Definition: QSim.java:185
WithinDayEngine withindayEngine
Definition: QSim.java:119
final IdMap< Vehicle, MobsimVehicle > vehicles
Definition: QSim.java:129
Collection< AgentSnapshotInfo > addAgentSnapshotInfo(final Collection< AgentSnapshotInfo > positions)
V put(Id< T > key, V value)
Definition: IdMap.java:141
void addParkedVehicle(MobsimVehicle veh, Id< Link > linkId)
final void addNetworkChangeEvent(NetworkChangeEvent event)
Definition: QSim.java:713
static EventsManager getParallelFeedableInstance(EventsManager events)
final MobsimListenerManager listenerManager
Definition: QSim.java:123
final EventsManager events
Definition: QSim.java:109
final org.matsim.core.mobsim.qsim.AgentCounter agentCounter
Definition: QSim.java:127
void addParkedVehicle(MobsimVehicle veh, Id< Link > startLinkId)
Definition: QSim.java:305
static final int INFO_PERIOD
Definition: QSim.java:107