1 package org.opentrafficsim.core.dsol;
2
3 import org.djunits.value.vdouble.scalar.Duration;
4 import org.djutils.exceptions.Throw;
5
6 import nl.tudelft.simulation.dsol.experiment.StreamInformation;
7 import nl.tudelft.simulation.dsol.model.AbstractDsolModel;
8 import nl.tudelft.simulation.jstats.streams.MersenneTwister;
9
10
11
12
13
14
15
16
17
18 public abstract class AbstractOtsModel extends AbstractDsolModel<Duration, OtsSimulatorInterface> implements OtsModelInterface
19 {
20
21 private static final long serialVersionUID = 1L;
22
23
24 private String shortName;
25
26
27 private String description;
28
29
30
31
32
33 public AbstractOtsModel(final OtsSimulatorInterface simulator)
34 {
35 this(simulator, "", "");
36 this.shortName = getClass().getSimpleName();
37 this.description = getClass().getSimpleName();
38 }
39
40
41
42
43
44
45
46 public AbstractOtsModel(final OtsSimulatorInterface simulator, final String shortName, final String description)
47 {
48 this(simulator, shortName, description, setInitialStreams());
49 }
50
51
52
53
54
55
56
57
58 public AbstractOtsModel(final OtsSimulatorInterface simulator, final String shortName, final String description,
59 final StreamInformation streamInformation)
60 {
61 super(simulator, streamInformation);
62 Throw.whenNull(shortName, "shortname cannot be null");
63 Throw.whenNull(description, "description cannot be null");
64 this.shortName = shortName;
65 this.description = description;
66 }
67
68
69
70
71
72 public static StreamInformation setInitialStreams()
73 {
74 StreamInformation streamInformation = new StreamInformation();
75 streamInformation.addStream("default", new MersenneTwister(10L));
76 streamInformation.addStream("generation", new MersenneTwister(11L));
77 return streamInformation;
78 }
79
80
81 @Override
82 public final String getShortName()
83 {
84 return this.shortName;
85 }
86
87
88
89
90 public final void setShortName(final String shortName)
91 {
92 this.shortName = shortName;
93 }
94
95
96 @Override
97 public final String getDescription()
98 {
99 return this.description;
100 }
101
102
103
104
105 public final void setDescription(final String description)
106 {
107 this.description = description;
108 }
109
110 }