View Javadoc
1   package org.opentrafficsim.road.gtu.lane.perception.mental.sdm;
2   
3   import org.djunits.value.vdouble.scalar.Duration;
4   import org.djunits.value.vdouble.scalar.Frequency;
5   
6   /**
7    * Set of default distractions as derived by the research of Manuel Lindorfer. These only describe the statistics. Actual
8    * {@code Distraction}s are linked to the simulation. {@code DistractionFactory} can be used to create those.
9    * <p>
10   * Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
12   * <p>
13   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 29 jun. 2018 <br>
14   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
16   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
17   */
18  public enum DefaultDistraction
19  {
20      /** Talking on cell phone. */
21      TALKING_CELL_PHONE("1", "Talking on cell phone", freq(100, 0.329), 0.329, dur(92.65), dur(176.29)),
22  
23      /** Answering cell phone. */
24      ANSWERING_CELL_PHONE("2", "Answering cell phone", freq(15, 0.157), 0.157, dur(7.86), dur(4.24)),
25  
26      /** Dialing cell phone. */
27      DIALING_CELL_PHONE("3", "Dialing cell phone", freq(122, 0.357), 0.357, dur(12.85), dur(13.41)),
28  
29      /** Drinking. */
30      DRINKING("4", "Drinking", freq(1028, 0.729), 0.729, dur(5.23), dur(7.4)),
31  
32      /** Manipulating audio controls. */
33      MANIPULATING_AUDIO_CONTROLS("5", "Manipulating audio controls", freq(1539, 0.943), 0.943, dur(5.46), dur(8.63)),
34  
35      /** Smoking. */
36      SMOKING("6", "Smoking", freq(45, 0.071), 0.071, dur(245.81), dur(162.95)),
37  
38      /** Reading or writing. */
39      READING_WRITING("7", "Reading or writing", freq(303, 0.643), 0.643, dur(18.43), dur(29.7)),
40  
41      /** Grooming. */
42      GROOMING("8", "Grooming", freq(229, 0.571), 0.571, dur(11.82), dur(29.77)),
43  
44      /** Baby distracting. */
45      BABY_DISTRACTING("9", "Baby distracting", freq(114, 0.086), 0.086, dur(23.49), dur(28.39)),
46  
47      /** Child distracting. */
48      CHILD_DISTRACTING("10", "Child distracting", freq(81, 0.143), 0.143, dur(25.76), dur(124.72)),
49  
50      /** Adult distracting. */
51      ADULT_DISTRACTING("11", "Adult distracting", freq(48, 0.257), 0.257, dur(46.32), dur(108.49)),
52  
53      /** Conversing. */
54      CONVERSING("12", "Conversing", freq(1558, 0.8), 0.8, dur(74.04), dur(234.5)),
55  
56      /** Reaching. */
57      REACHING("13", "Reaching", freq(2246, 1.0), 1.0, dur(7.58), dur(36.7)),
58  
59      /** Manipulating vehicle controls. */
60      MANIPULATING_VEHICLE_CONTROLS("14", "Manipulating vehicle controls", freq(2095, 1.0), 1.0, dur(4.82), dur(11.53)),
61  
62      /** Internal distraction. */
63      INTERNAL_DISTRACTION("15", "Internal distraction", freq(481, 0.814), 0.814, dur(21.55), dur(46.38)),
64  
65      /** External distraction. */
66      EXTERNAL_DISTRACTION("16", "External distraction", freq(659, 0.9), 0.9, dur(26.55), dur(58.78)),
67  
68      /** Preparing to eat / drink. */
69      PREPARING_EAT_DRINK("17", "Preparing to eat / drink", freq(1503, 0.614), 0.614, dur(15.4), dur(34.7));
70  
71      /** Total time of data with which frequencies are determined. */
72      private static final double BASELINE_DURATION_SECONDS = 207.14 * 3600.0;
73  
74      /** Id. */
75      private final String id;
76  
77      /** Description. */
78      private final String description;
79  
80      /** Frequency. */
81      private final Frequency frequency;
82  
83      /** Exposure (value in range [0...1]). */
84      private final double exposure;
85  
86      /** Average duration. */
87      private final Duration averageDuration;
88  
89      /** Standard deviation of duration. */
90      private final Duration stdDuration;
91  
92      /**
93       * Constructor.
94       * @param id String; id
95       * @param description String; description
96       * @param frequency Frequency; frequency per exposed driver
97       * @param exposure double; exposure (value in range [0...1])
98       * @param averageDuration Duration; average duration
99       * @param stdDuration Duration; standard deviation of duration
100      */
101     DefaultDistraction(final String id, final String description, final Frequency frequency, final double exposure,
102             final Duration averageDuration, final Duration stdDuration)
103     {
104         this.id = id;
105         this.description = description;
106         this.frequency = frequency;
107         this.exposure = exposure;
108         this.averageDuration = averageDuration;
109         this.stdDuration = stdDuration;
110     }
111 
112     /**
113      * Helper method to return a {@code Frequency} with little code.
114      * @param occurrences int; number of occurrences in data
115      * @param exposure double; exposure
116      * @return Frequency; frequency
117      */
118     private static Frequency freq(final int occurrences, final double exposure)
119     {
120         return Frequency.instantiateSI(occurrences / (BASELINE_DURATION_SECONDS * exposure));
121     }
122 
123     /**
124      * Helper method to return a {@code Duration} with little code.
125      * @param duration double; SI value of duration
126      * @return Duration; duration
127      */
128     private static Duration dur(final double duration)
129     {
130         return Duration.instantiateSI(duration);
131     }
132 
133     /**
134      * Returns the id.
135      * @return String; id
136      */
137     public String getId()
138     {
139         return this.id;
140     }
141 
142     /**
143      * Returns the description.
144      * @return String; description
145      */
146     public String getDescription()
147     {
148         return this.description;
149     }
150 
151     /**
152      * Returns the frequency per exposed driver.
153      * @return Frequency; frequency per exposed driver
154      */
155     public Frequency getFrequency()
156     {
157         return this.frequency;
158     }
159 
160     /**
161      * Returns the exposure.
162      * @return double; exposure
163      */
164     public double getExposure()
165     {
166         return this.exposure;
167     }
168 
169     /**
170      * Returns the average duration.
171      * @return Duration; average duration
172      */
173     public Duration getAverageDuration()
174     {
175         return this.averageDuration;
176     }
177 
178     /**
179      * Returns the standard deviation of duration.
180      * @return Duration; standard deviation of duration
181      */
182     public Duration getStdDuration()
183     {
184         return this.stdDuration;
185     }
186 
187     /**
188      * Returns a default distraction from the id.
189      * @param id String; id
190      * @return DefaultDistraction; default distraction from id
191      */
192     public static DefaultDistraction getFromId(final String id)
193     {
194         return values()[Integer.parseInt(id) - 1];
195     }
196 
197 }