Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSCFModel_SmartSK.h
Go to the documentation of this file.
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/****************************************************************************/
20// A smarter SK
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include "MSCFModel.h"
27
28
29// ===========================================================================
30// class definitions
31// ===========================================================================
37public:
41 MSCFModel_SmartSK(const MSVehicleType* vtype);
42
43
46
47
50
56 double finalizeSpeed(MSVehicle* const veh, double vPos) const;
57
58
67 virtual double followSpeed(const MSVehicle* const veh, double speed, double gap2pred,
68 double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0, const CalcReason usage = CalcReason::CURRENT) const;
69
70
78 virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred, double decel, const CalcReason usage = CalcReason::CURRENT) const;
79
80
85 virtual int getModelID() const {
87 }
88
89
93 double getImperfection() const {
94 return myDawdle;
95 }
97
98
99
102
105 void setMaxDecel(double decel) {
106 myDecel = decel;
108 }
109
110
114 void setImperfection(double imperfection) {
115 myDawdle = imperfection;
116 }
117
118
122 void setHeadwayTime(double headwayTime) {
123 myHeadwayTime = headwayTime;
124 myTauDecel = myDecel * headwayTime;
125 }
127
129 double patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const;
130
135 virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
136
137private:
143 virtual double _vsafe(const MSVehicle* const veh, double gap, double predSpeed) const;
144
145
150 virtual double dawdle(double speed, SumoRNG* rng) const;
151
152 virtual void updateMyHeadway(const MSVehicle* const veh) const {
153 // this is the point were the preferred headway changes slowly:
155 double tTau = vars->myHeadway;
156 tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(double(-1.0), double(1.0), veh->getRNG());
157 if (tTau < TS) { // this ensures the SK safety condition
158 tTau = TS;
159 }
160 vars->myHeadway = tTau;
161 }
162
165 ret->gOld = 0.0;
167 return ret;
168 }
169
170#include <map>
171
172private:
174 public:
176 std::map<int, double> ggOld;
177 };
178
179protected:
181 double myDawdle;
182
185
188
193
194};
#define TS
Definition SUMOTime.h:42
@ SUMO_TAG_CF_SMART_SK
SumoRNG * getRNG() const
The original Krauss (1998) car-following model and parameter.
double patchSpeedBeforeLC(const MSVehicle *veh, double vMin, double vMax) const
apply dawdling
double myTauDecel
The precomputed value for myDecel*myTau.
double myDawdle
The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
virtual double _vsafe(const MSVehicle *const veh, double gap, double predSpeed) const
Returns the "safe" velocity.
void setMaxDecel(double decel)
Sets a new value for maximum deceleration [m/s^2].
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed (no dawdling)
double myS2Sspeed
new variables needed in this model; myS2Sspeed is the speed below which the vehicle does not move whe...
virtual int getModelID() const
Returns the model's name.
double myTmp1
temporary (testing) parameter
virtual void updateMyHeadway(const MSVehicle *const veh) const
~MSCFModel_SmartSK()
Destructor.
void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
virtual MSCFModel::VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
virtual double dawdle(double speed, SumoRNG *rng) const
Applies driver imperfection (dawdling / sigma)
double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
double getImperfection() const
Get the driver's imperfection.
virtual double stopSpeed(const MSVehicle *const veh, const double speed, double gap2pred, double decel, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
void setImperfection(double imperfection)
Sets a new value for driver imperfection.
The car-following model abstraction.
Definition MSCFModel.h:55
CalcReason
What the return value of stop/follow/free-Speed is used for.
Definition MSCFModel.h:77
@ CURRENT
the return value is used for calculating the next speed
Definition MSCFModel.h:79
double myDecel
The vehicle's maximum deceleration [m/s^2].
Definition MSCFModel.h:701
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
Definition MSCFModel.h:710
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
Definition MSVehicle.h:986
The car-following model and parameter.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)