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