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
34
35
36 public AbstractOtsModel(final OtsSimulatorInterface simulator)
37 {
38 this(simulator, "", "");
39 this.shortName = getClass().getSimpleName();
40 this.description = getClass().getSimpleName();
41 }
42
43
44
45
46
47
48
49 public AbstractOtsModel(final OtsSimulatorInterface simulator, final String shortName, final String description)
50 {
51 this(simulator, shortName, description, setInitialStreams());
52 }
53
54
55
56
57
58
59
60
61 public AbstractOtsModel(final OtsSimulatorInterface simulator, final String shortName, final String description,
62 final StreamInformation streamInformation)
63 {
64 super(simulator, streamInformation);
65 Throw.whenNull(shortName, "shortname cannot be null");
66 Throw.whenNull(description, "description cannot be null");
67 this.shortName = shortName;
68 this.description = description;
69 }
70
71
72
73
74
75 public static StreamInformation setInitialStreams()
76 {
77 StreamInformation streamInformation = new StreamInformation();
78 streamInformation.addStream("default", new MersenneTwister(10L));
79 streamInformation.addStream("generation", new MersenneTwister(11L));
80 return streamInformation;
81 }
82
83 @Override
84 public final String getShortName()
85 {
86 return this.shortName;
87 }
88
89
90
91
92 public final void setShortName(final String shortName)
93 {
94 this.shortName = shortName;
95 }
96
97 @Override
98 public final String getDescription()
99 {
100 return this.description;
101 }
102
103
104
105
106 public final void setDescription(final String description)
107 {
108 this.description = description;
109 }
110
111 }