LCOV - code coverage report
Current view: top level - src/microsim/cfmodels - MSCFModel_KraussOrig1.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 86.7 % 15 13
Test Date: 2024-11-21 15:56:26 Functions: 80.0 % 5 4

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-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_KraussOrig1.h
      15              : /// @author  Tobias Mayer
      16              : /// @author  Daniel Krajzewicz
      17              : /// @author  Jakob Erdmann
      18              : /// @author  Michael Behrisch
      19              : /// @date    Tue, 28 Jul 2009
      20              : ///
      21              : // The original Krauss (1998) car-following model and parameter
      22              : /****************************************************************************/
      23              : #pragma once
      24              : #include <config.h>
      25              : 
      26              : #include "MSCFModel.h"
      27              : #include <utils/xml/SUMOXMLDefinitions.h>
      28              : 
      29              : 
      30              : // ===========================================================================
      31              : // class definitions
      32              : // ===========================================================================
      33              : /** @class MSCFModel_KraussOrig1
      34              :  * @brief The original Krauss (1998) car-following model and parameter
      35              :  * @see MSCFModel
      36              :  */
      37              : class MSCFModel_KraussOrig1 : public MSCFModel {
      38              : public:
      39              :     /** @brief Constructor
      40              :      *  @param[in] vtype the type for which this model is built and also the parameter object to configure this model
      41              :      */
      42              :     MSCFModel_KraussOrig1(const MSVehicleType* vtype);
      43              : 
      44              : 
      45              :     /// @brief Destructor
      46              :     ~MSCFModel_KraussOrig1();
      47              : 
      48              : 
      49              :     /// @name Implementations of the MSCFModel interface
      50              :     /// @{
      51              :     /// @brief apply dawdling
      52              :     double patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const;
      53              : 
      54              :     /** @brief Computes the vehicle's safe speed (no dawdling)
      55              :      * @param[in] veh The vehicle (EGO)
      56              :      * @param[in] speed The vehicle's speed
      57              :      * @param[in] gap2pred The (net) distance to the LEADER
      58              :      * @param[in] predSpeed The speed of LEADER
      59              :      * @return EGO's safe speed
      60              :      * @see MSCFModel::ffeV
      61              :      */
      62              :     double followSpeed(const MSVehicle* const veh, double speed, double gap2pred,
      63              :                        double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0, const CalcReason usage = CalcReason::CURRENT) const;
      64              : 
      65              : 
      66              :     /** @brief Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
      67              :      * @param[in] veh The vehicle (EGO)
      68              :      * @param[in] gap2pred The (net) distance to the obstacle
      69              :      * @return EGO's safe speed for approaching a non-moving obstacle
      70              :      * @see MSCFModel::ffeS
      71              :      * @todo generic Interface, models can call for the values they need
      72              :      */
      73              :     virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred, double decel, const CalcReason usage = CalcReason::CURRENT) const;
      74              : 
      75              : 
      76              :     /** @brief Returns the model's name
      77              :      * @return The model's name
      78              :      * @see MSCFModel::getModelName
      79              :      */
      80            0 :     virtual int getModelID() const {
      81            0 :         return SUMO_TAG_CF_KRAUSS_ORIG1;
      82              :     }
      83              : 
      84              : 
      85              :     /** @brief Get the driver's imperfection
      86              :      * @return The imperfection of drivers of this class
      87              :      */
      88          125 :     double getImperfection() const {
      89          125 :         return myDawdle;
      90              :     }
      91              :     /// @}
      92              : 
      93              : 
      94              : 
      95              :     /// @name Setter methods
      96              :     /// @{
      97              :     /** @brief Sets a new value for maximum deceleration [m/s^2]
      98              :      * @param[in] accel The new deceleration in m/s^2
      99              :      */
     100       696499 :     void setMaxDecel(double decel) {
     101       696499 :         myDecel = decel;
     102       696499 :         myTauDecel = myDecel * myHeadwayTime;
     103       696499 :     }
     104              : 
     105              : 
     106              :     /** @brief Sets a new value for driver imperfection
     107              :      * @param[in] accel The new driver imperfection
     108              :      */
     109           32 :     void setImperfection(double imperfection) {
     110           32 :         myDawdle = imperfection;
     111           32 :     }
     112              : 
     113              : 
     114              :     /** @brief Sets a new value for desired headway [s]
     115              :      * @param[in] headwayTime The new desired headway (in s)
     116              :      */
     117         5851 :     void setHeadwayTime(double headwayTime) {
     118         5851 :         myHeadwayTime = headwayTime;
     119         5851 :         myTauDecel = myDecel * headwayTime;
     120         5851 :     }
     121              :     /// @}
     122              : 
     123              : 
     124              :     /** @brief Duplicates the car-following model
     125              :      * @param[in] vtype The vehicle type this model belongs to (1:1)
     126              :      * @return A duplicate of this car-following model
     127              :      */
     128              :     virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
     129              : 
     130              : protected:
     131              :     /** @brief Returns the "safe" velocity
     132              :      * @param[in] gap2pred The (net) distance to the LEADER
     133              :      * @param[in] predSpeed The LEADER's speed
     134              :      * @param[in] predMaxDecel The LEADER's maximum deceleration
     135              :      * @return the safe velocity
     136              :      */
     137              :     virtual double vsafe(double gap, double predSpeed, double predMaxDecel) const;
     138              : 
     139              : 
     140              :     /** @brief Applies driver imperfection (dawdling / sigma)
     141              :      * @param[in] speed The speed with no dawdling
     142              :      * @return The speed after dawdling
     143              :      */
     144              :     virtual double dawdle(double speed, SumoRNG* rng) const;
     145              : 
     146              : protected:
     147              :     /// @brief The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
     148              :     double myDawdle;
     149              : 
     150              :     /// @brief The precomputed value for myDecel*myTau
     151              :     double myTauDecel;
     152              : };
        

Generated by: LCOV version 2.0-1