View Javadoc
1   package org.opentrafficsim.core.dsol;
2   
3   import javax.naming.NamingException;
4   
5   import org.djunits.value.vdouble.scalar.Duration;
6   import org.djutils.exceptions.Throw;
7   import org.opentrafficsim.core.perception.HistoryManager;
8   
9   import nl.tudelft.simulation.dsol.experiment.SingleReplication;
10  
11  /**
12   * Simulation replication with history manager.
13   * <p>
14   * Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * </p>
17   * @author Alexander Verbraeck
18   */
19  public class OtsReplication extends SingleReplication<Duration>
20  {
21      /** History manager. */
22      private final HistoryManager historyManager;
23  
24      /** Start time of day. */
25      private final Duration startTimeOfDay;
26  
27      /**
28       * Create a new OtsReplication.
29       * @param id id of the new OtsReplication
30       * @param startTimeOfDay the start time of the new OtsReplication
31       * @param warmupPeriod the warm-up period of the new OtsReplication
32       * @param runLength the run length of the new OtsReplication
33       * @param historyManager history manager
34       * @throws NamingException when the context for the replication cannot be created
35       */
36      public OtsReplication(final String id, final Duration startTimeOfDay, final Duration warmupPeriod, final Duration runLength,
37              final HistoryManager historyManager) throws NamingException
38      {
39          super(id, Duration.ZERO, warmupPeriod, runLength);
40          Throw.whenNull(historyManager, "historyManager");
41          Throw.whenNull(startTimeOfDay, "startTimeOfDay");
42          this.historyManager = historyManager;
43          this.startTimeOfDay = startTimeOfDay;
44      }
45  
46      /**
47       * Returns the history manager.
48       * @param simulator simulator
49       * @return history manager
50       */
51      public HistoryManager getHistoryManager(final OtsSimulatorInterface simulator)
52      {
53          return this.historyManager;
54      }
55  
56      /**
57       * Returns the start time-of-day.
58       * @return start time-of-day
59       */
60      public Duration getStartTimeOfDay()
61      {
62          return this.startTimeOfDay;
63      }
64  
65      @Override
66      public final String toString()
67      {
68          return "OtsReplication []";
69      }
70  
71  }