Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSCFModel_NaSch.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2026-2026 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/****************************************************************************/
18// The Nagel-Schreckenberg (1992) cellular automaton car-following model
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include "MSCFModel.h"
25
26
27// ===========================================================================
28// class definitions
29// ===========================================================================
46class MSCFModel_NaSch : public MSCFModel {
47public:
52 MSCFModel_NaSch(const MSVehicleType* vtype, double dawdle);
53
54
57
58
61
72 double followSpeed(const MSVehicle* const veh, double speed, double gap2pred,
73 double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0, const CalcReason usage = CalcReason::CURRENT) const;
74
87 double insertionFollowSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0) const;
88
96 double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred, double decel, const CalcReason usage = CalcReason::CURRENT) const;
97
98
100 double patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const;
101
102
107 double minNextSpeedEmergency(double speed, const MSVehicle* const veh = 0) const;
108
109
113 int getModelID() const {
114 return SUMO_TAG_CF_NASCH;
115 }
116
117
121 double getImperfection() const {
122 return myDawdle;
123 }
125
126
130 void setImperfection(double imperfection) {
131 myDawdle = imperfection;
132 }
133
134
139 MSCFModel* duplicate(const MSVehicleType* vtype) const;
140
141protected:
148 double roundToCell(double speed) const;
149
151 double vsafe(const MSVehicle* const veh, double speed, double gap) const;
152
153protected:
155 double myDawdle;
156
159};
@ SUMO_TAG_CF_NASCH
The Nagel-Schreckenberg (1992) cellular automaton car-following model.
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)
int getModelID() const
Returns the model's name.
double getImperfection() const
Get the driver's imperfection.
double myDawdle
The probability of randomized deceleration by one cell per step ("sigma")
double patchSpeedBeforeLC(const MSVehicle *veh, double vMin, double vMax) const
NaSch rule 3 ("randomization"): dawdle by exactly one cell with probability sigma.
double vsafe(const MSVehicle *const veh, double speed, double gap) const
the safe speed considering only the gap to the leader/obstacle (NaSch rule 1+2)
double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage....
~MSCFModel_NaSch()
Destructor.
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)
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
double minNextSpeedEmergency(double speed, const MSVehicle *const veh=0) const
NaSch does not impose an extra bound on emergency braking: a vehicle may always come to a full (Euler...
void setImperfection(double imperfection)
Sets a new value for driver imperfection.
double myCellSpeed
The speed gained per step by accelerating at myAccel, i.e. one cell's worth of speed.
double roundToCell(double speed) const
Rounds a speed down to the nearest multiple of the cell speed (the speed gained by accelerating for e...
The car-following model abstraction.
Definition MSCFModel.h:59
CalcReason
What the return value of stop/follow/free-Speed is used for.
Definition MSCFModel.h:95
@ CURRENT
the return value is used for calculating the next speed
Definition MSCFModel.h:97
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
The car-following model and parameter.