1 package org.opentrafficsim.core.dsol;
2
3 import javax.naming.NamingException;
4
5 import org.djunits.value.vdouble.scalar.Duration;
6 import org.djunits.value.vdouble.scalar.Time;
7 import org.opentrafficsim.core.perception.HistoryManager;
8 import org.opentrafficsim.core.perception.HistoryManagerDEVS;
9
10 import nl.tudelft.simulation.dsol.experiment.Experiment;
11 import nl.tudelft.simulation.dsol.experiment.Replication;
12 import nl.tudelft.simulation.dsol.experiment.Treatment;
13
14
15
16
17
18
19
20
21
22
23 public class OTSReplication extends Replication.TimeDoubleUnit<OTSSimulatorInterface>
24 {
25
26
27 private HistoryManager historyManager;
28
29
30
31
32
33
34 public OTSReplication(final String id, final Experiment.TimeDoubleUnit<OTSSimulatorInterface> experiment)
35 throws NamingException
36 {
37 super(id, experiment);
38 }
39
40
41
42
43
44
45
46
47
48
49
50 public static OTSReplication create(final String id, final Time startTime, final Duration warmupPeriod,
51 final Duration runLength, final OTSModelInterface model) throws NamingException
52 {
53 Experiment.TimeDoubleUnit<OTSSimulatorInterface> experiment = new Experiment.TimeDoubleUnit<>();
54 experiment.setModel(model);
55 Treatment.TimeDoubleUnit treatment =
56 new Treatment.TimeDoubleUnit(experiment, "Treatment for " + id, startTime, warmupPeriod, runLength);
57 experiment.setTreatment(treatment);
58 return new OTSReplication(id, experiment);
59
60 }
61
62
63
64
65
66
67
68 public HistoryManager getHistoryManager(final OTSSimulatorInterface simulator)
69 {
70 if (this.historyManager == null)
71 {
72 this.historyManager = new HistoryManagerDEVS(simulator, Duration.ZERO, Duration.createSI(10.0));
73 }
74 return this.historyManager;
75 }
76
77
78
79
80
81 public void setHistoryManager(final HistoryManager historyManager)
82 {
83 this.historyManager = historyManager;
84 }
85
86
87 private static final long serialVersionUID = 20140815L;
88
89
90 @Override
91 public final String toString()
92 {
93 return "OTSReplication []";
94 }
95 }