Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2012-2024 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file MSCFModel_Daniel1.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Michael Behrisch
17 : /// @date Tue, 05 Jun 2012
18 : ///
19 : // The original Krauss (1998) car-following model and parameter
20 : /****************************************************************************/
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include "MSCFModel.h"
25 : #include <utils/xml/SUMOXMLDefinitions.h>
26 :
27 :
28 : // ===========================================================================
29 : // class definitions
30 : // ===========================================================================
31 : /** @class MSCFModel_Daniel1
32 : * @brief The original Krauss (1998) car-following model and parameter
33 : * @see MSCFModel
34 : */
35 : class MSCFModel_Daniel1 : public MSCFModel {
36 : public:
37 : /** @brief Constructor
38 : * @param[in] vtype the type for which this model is built and also the parameter object to configure this model
39 : */
40 : MSCFModel_Daniel1(const MSVehicleType* vtype);
41 :
42 :
43 : /// @brief Destructor
44 : ~MSCFModel_Daniel1();
45 :
46 :
47 : /// @name Implementations of the MSCFModel interface
48 : /// @{
49 :
50 : /** @brief Applies interaction with stops and lane changing model influences
51 : * @param[in] veh The ego vehicle
52 : * @param[in] vPos The possible velocity
53 : * @return The velocity after applying interactions with stops and lane change model influences
54 : */
55 : double finalizeSpeed(MSVehicle* const veh, double vPos) const;
56 :
57 :
58 : /** @brief Computes the vehicle's safe speed (no dawdling)
59 : * @param[in] veh The vehicle (EGO)
60 : * @param[in] speed The vehicle's speed
61 : * @param[in] gap2pred The (net) distance to the LEADER
62 : * @param[in] predSpeed The speed of LEADER
63 : * @return EGO's safe speed
64 : * @see MSCFModel::ffeV
65 : */
66 : virtual double followSpeed(const MSVehicle* const veh, double speed, double gap2pred,
67 : double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0, const CalcReason usage = CalcReason::CURRENT) const;
68 :
69 :
70 : /** @brief Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
71 : * @param[in] veh The vehicle (EGO)
72 : * @param[in] gap2pred The (net) distance to the obstacle
73 : * @return EGO's safe speed for approaching a non-moving obstacle
74 : * @see MSCFModel::ffeS
75 : * @todo generic Interface, models can call for the values they need
76 : */
77 : virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred, double decel, const CalcReason usage = CalcReason::CURRENT) const;
78 :
79 :
80 : /** @brief Returns the model's name
81 : * @return The model's name
82 : * @see MSCFModel::getModelName
83 : */
84 0 : virtual int getModelID() const {
85 0 : return SUMO_TAG_CF_DANIEL1;
86 : }
87 :
88 :
89 : /** @brief Get the driver's imperfection
90 : * @return The imperfection of drivers of this class
91 : */
92 0 : double getImperfection() const {
93 0 : return myDawdle;
94 : }
95 : /// @}
96 :
97 :
98 :
99 : /// @name Setter methods
100 : /// @{
101 : /** @brief Sets a new value for maximum deceleration [m/s^2]
102 : * @param[in] accel The new deceleration in m/s^2
103 : */
104 0 : void setMaxDecel(double decel) {
105 0 : myDecel = decel;
106 0 : myTauDecel = myDecel * myHeadwayTime;
107 0 : }
108 :
109 :
110 : /** @brief Sets a new value for driver imperfection
111 : * @param[in] accel The new driver imperfection
112 : */
113 0 : void setImperfection(double imperfection) {
114 0 : myDawdle = imperfection;
115 0 : }
116 :
117 :
118 : /** @brief Sets a new value for driver reaction time [s]
119 : * @param[in] headwayTime The new driver reaction time (in s)
120 : */
121 0 : void setHeadwayTime(double headwayTime) {
122 0 : myHeadwayTime = headwayTime;
123 0 : myTauDecel = myDecel * headwayTime;
124 0 : }
125 : /// @}
126 :
127 :
128 : /** @brief Duplicates the car-following model
129 : * @param[in] vtype The vehicle type this model belongs to (1:1)
130 : * @return A duplicate of this car-following model
131 : */
132 : virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
133 :
134 : private:
135 : /** @brief Returns the "safe" velocity
136 : * @param[in] gap2pred The (net) distance to the LEADER
137 : * @param[in] predSpeed The LEADER's speed
138 : * @return the safe velocity
139 : */
140 : virtual double _vsafe(double gap, double predSpeed) const;
141 :
142 :
143 : /** @brief Applies driver imperfection (dawdling / sigma)
144 : * @param[in] speed The speed with no dawdling
145 : * @return The speed after dawdling
146 : */
147 : virtual double dawdle(double speed, SumoRNG* rng) const;
148 :
149 : protected:
150 : /// @brief The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
151 : double myDawdle;
152 :
153 : /// @brief The precomputed value for myDecel*myTau
154 : double myTauDecel;
155 :
156 : /// @brief temporary (testing) parameter
157 : double myTmp1, myTmp2, myTmp3, myTmp4, myTmp5;
158 :
159 : };
|