LCOV - code coverage report
Current view: top level - src/microsim/cfmodels - MSCFModel_SmartSK.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 0.0 % 26 0
Test Date: 2024-12-21 15:45:41 Functions: 0.0 % 7 0

            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_SmartSK.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @author  Peter Wagner
      18              : /// @date    Tue, 05 Jun 2012
      19              : ///
      20              : // A smarter SK
      21              : /****************************************************************************/
      22              : #pragma once
      23              : #include <config.h>
      24              : 
      25              : #include "MSCFModel.h"
      26              : #include <utils/xml/SUMOXMLDefinitions.h>
      27              : 
      28              : 
      29              : // ===========================================================================
      30              : // class definitions
      31              : // ===========================================================================
      32              : /** @class MSCFModel_SmartSK
      33              :  * @brief The original Krauss (1998) car-following model and parameter
      34              :  * @see MSCFModel
      35              :  */
      36              : class MSCFModel_SmartSK : public MSCFModel {
      37              : public:
      38              :     /** @brief Constructor
      39              :      *  @param[in] vtype the type for which this model is built and also the parameter object to configure this model
      40              :      */
      41              :     MSCFModel_SmartSK(const MSVehicleType* vtype);
      42              : 
      43              : 
      44              :     /// @brief Destructor
      45              :     ~MSCFModel_SmartSK();
      46              : 
      47              : 
      48              :     /// @name Implementations of the MSCFModel interface
      49              :     /// @{
      50              : 
      51              :     /** @brief Applies interaction with stops and lane changing model influences
      52              :      * @param[in] veh The ego vehicle
      53              :      * @param[in] vPos The possible velocity
      54              :      * @return The velocity after applying interactions with stops and lane change model influences
      55              :      */
      56              :     double finalizeSpeed(MSVehicle* const veh, double vPos) const;
      57              : 
      58              : 
      59              :     /** @brief Computes the vehicle's safe speed (no dawdling)
      60              :      * @param[in] veh The vehicle (EGO)
      61              :      * @param[in] speed The vehicle's speed
      62              :      * @param[in] gap2pred The (net) distance to the LEADER
      63              :      * @param[in] predSpeed The speed of LEADER
      64              :      * @return EGO's safe speed
      65              :      * @see MSCFModel::ffeV
      66              :      */
      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              : 
      71              :     /** @brief Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
      72              :      * @param[in] veh The vehicle (EGO)
      73              :      * @param[in] gap2pred The (net) distance to the obstacle
      74              :      * @return EGO's safe speed for approaching a non-moving obstacle
      75              :      * @see MSCFModel::ffeS
      76              :      * @todo generic Interface, models can call for the values they need
      77              :      */
      78              :     virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred, double decel, const CalcReason usage = CalcReason::CURRENT) const;
      79              : 
      80              : 
      81              :     /** @brief Returns the model's name
      82              :      * @return The model's name
      83              :      * @see MSCFModel::getModelName
      84              :      */
      85            0 :     virtual int getModelID() const {
      86            0 :         return SUMO_TAG_CF_SMART_SK;
      87              :     }
      88              : 
      89              : 
      90              :     /** @brief Get the driver's imperfection
      91              :      * @return The imperfection of drivers of this class
      92              :      */
      93            0 :     double getImperfection() const {
      94            0 :         return myDawdle;
      95              :     }
      96              :     /// @}
      97              : 
      98              : 
      99              : 
     100              :     /// @name Setter methods
     101              :     /// @{
     102              :     /** @brief Sets a new value for maximum deceleration [m/s^2]
     103              :      * @param[in] accel The new deceleration in m/s^2
     104              :      */
     105            0 :     void setMaxDecel(double decel) {
     106            0 :         myDecel = decel;
     107            0 :         myTauDecel = myDecel * myHeadwayTime;
     108            0 :     }
     109              : 
     110              : 
     111              :     /** @brief Sets a new value for driver imperfection
     112              :      * @param[in] accel The new driver imperfection
     113              :      */
     114            0 :     void setImperfection(double imperfection) {
     115            0 :         myDawdle = imperfection;
     116            0 :     }
     117              : 
     118              : 
     119              :     /** @brief Sets a new value for desired headway [s]
     120              :      * @param[in] headwayTime The new desired headway (in s)
     121              :      */
     122            0 :     void setHeadwayTime(double headwayTime) {
     123            0 :         myHeadwayTime = headwayTime;
     124            0 :         myTauDecel = myDecel * headwayTime;
     125            0 :     }
     126              :     /// @}
     127              : 
     128              :     /// @brief apply dawdling
     129              :     double patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const;
     130              : 
     131              :     /** @brief Duplicates the car-following model
     132              :      * @param[in] vtype The vehicle type this model belongs to (1:1)
     133              :      * @return A duplicate of this car-following model
     134              :      */
     135              :     virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
     136              : 
     137              : private:
     138              :     /** @brief Returns the "safe" velocity
     139              :      * @param[in] gap2pred The (net) distance to the LEADER
     140              :      * @param[in] predSpeed The LEADER's speed
     141              :      * @return the safe velocity
     142              :      */
     143              :     virtual double _vsafe(const MSVehicle* const veh, double gap, double predSpeed) const;
     144              : 
     145              : 
     146              :     /** @brief Applies driver imperfection (dawdling / sigma)
     147              :      * @param[in] speed The speed with no dawdling
     148              :      * @return The speed after dawdling
     149              :      */
     150              :     virtual double dawdle(double speed, SumoRNG* rng) const;
     151              : 
     152            0 :     virtual void updateMyHeadway(const MSVehicle* const veh) const {
     153              :         // this is the point were the preferred headway changes slowly:
     154              :         SSKVehicleVariables* vars = (SSKVehicleVariables*)veh->getCarFollowVariables();
     155            0 :         double tTau = vars->myHeadway;
     156            0 :         tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(double(-1.0), double(1.0), veh->getRNG());
     157            0 :         if (tTau < TS) { // this ensures the SK safety condition
     158              :             tTau = TS;
     159              :         }
     160            0 :         vars->myHeadway = tTau;
     161            0 :     }
     162              : 
     163            0 :     virtual MSCFModel::VehicleVariables* createVehicleVariables() const {
     164            0 :         SSKVehicleVariables* ret = new SSKVehicleVariables();
     165              :         ret->gOld = 0.0;
     166            0 :         ret->myHeadway = myHeadwayTime;
     167            0 :         return ret;
     168              :     }
     169              : 
     170              : #include <map>
     171              : 
     172              : private:
     173            0 :     class SSKVehicleVariables : public MSCFModel::VehicleVariables {
     174              :     public:
     175              :         double gOld, myHeadway;
     176              :         std::map<int, double> ggOld;
     177              :     };
     178              : 
     179              : protected:
     180              :     /// @brief The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
     181              :     double myDawdle;
     182              : 
     183              :     /// @brief The precomputed value for myDecel*myTau
     184              :     double myTauDecel;
     185              : 
     186              :     /// @brief temporary (testing) parameter
     187              :     double myTmp1, myTmp2, myTmp3, myTmp4, myTmp5;
     188              : 
     189              :     /** @brief new variables needed in this model; myS2Sspeed is the speed below which the vehicle does not move when stopped
     190              :      * @brief maxDeltaGap is the theoretical maximum change in gap that can happen in one time step
     191              :     */
     192              :     double myS2Sspeed, maxDeltaGap;
     193              : 
     194              : };
        

Generated by: LCOV version 2.0-1