1 package org.opentrafficsim.road.gtu.lane.tactical.following;
2
3 import org.opentrafficsim.base.parameters.ParameterException;
4 import org.opentrafficsim.base.parameters.ParameterSet;
5 import org.opentrafficsim.base.parameters.Parameters;
6
7 import nl.tudelft.simulation.jstats.distributions.DistContinuous;
8 import nl.tudelft.simulation.jstats.distributions.DistNormal;
9 import nl.tudelft.simulation.jstats.streams.StreamInterface;
10
11
12
13
14
15
16
17
18
19
20
21
22
23 public class AbstractIDMFactory<T extends AbstractIDM> implements CarFollowingModelFactory<T>
24 {
25
26
27 private final T idm;
28
29
30 private final DistContinuous fSpeed;
31
32
33
34
35
36
37 public AbstractIDMFactory(final T idm, final StreamInterface randomStream)
38 {
39 this.idm = idm;
40 this.fSpeed = new DistNormal(randomStream, 123.7 / 120.0, 0.1);
41 }
42
43
44 @Override
45 public final T generateCarFollowingModel()
46 {
47 return this.idm;
48 }
49
50
51 @Override
52 public Parameters getParameters() throws ParameterException
53 {
54 ParameterSet parameters = new ParameterSet();
55 parameters.setDefaultParameters(AbstractIDM.class);
56 parameters.setParameter(AbstractIDM.FSPEED, this.fSpeed.draw());
57 return parameters;
58 }
59
60 }