LCOV - code coverage report
Current view: top level - src/microsim - MSDriverState.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 97.9 % 47 46
Test Date: 2024-10-24 15:46:30 Functions: 50.0 % 2 1

            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    MSDriverState.h
      15              : /// @author  Michael Behrisch
      16              : /// @date    Tue, 21 Apr 2015
      17              : ///
      18              : // A class representing a vehicle driver's current mental state
      19              : /****************************************************************************/
      20              : 
      21              : 
      22              : /// @todo: check parameter admissibility in setter methods
      23              : 
      24              : 
      25              : #pragma once
      26              : #include <config.h>
      27              : 
      28              : #include <memory>
      29              : #include <utils/common/SUMOTime.h>
      30              : #include <utils/xml/SUMOXMLDefinitions.h>
      31              : 
      32              : 
      33              : // ===========================================================================
      34              : // class definitions
      35              : // ===========================================================================
      36              : /// @class OUProcess
      37              : /// @brief An Ornstein-Uhlenbeck stochastic process
      38              : class OUProcess {
      39              : public:
      40              :     /// @brief constructor
      41              :     OUProcess(double initialState, double timeScale, double noiseIntensity);
      42              :     /// @brief destructor
      43              :     ~OUProcess();
      44              : 
      45              :     /// @brief evolve for a time step of length dt.
      46              :     void step(double dt);
      47              :     /// @brief static version of the step()
      48              :     static double step(double state, double dt, double timeScale, double noiseIntensity);
      49              : 
      50              :     /// @brief set the process' timescale to a new value
      51              :     void setTimeScale(double timeScale) {
      52        59629 :         myTimeScale = timeScale;
      53              :     };
      54              : 
      55              :     /// @brief set the process' noise intensity to a new value
      56              :     void setNoiseIntensity(double noiseIntensity) {
      57        59629 :         myNoiseIntensity = noiseIntensity;
      58              :     };
      59              : 
      60              :     /// @brief set the process' state to a new value
      61              :     void setState(double state) {
      62       197464 :         myState = state;
      63       197463 :     };
      64              : 
      65              :     inline double getNoiseIntensity() const {
      66            4 :         return myNoiseIntensity;
      67              :     };
      68              : 
      69              :     inline double getTimeScale() const {
      70            4 :         return myTimeScale;
      71              :     };
      72              : 
      73              : 
      74              :     /// @brief Obtain the current state of the process
      75              :     double getState() const;
      76              : 
      77              : 
      78              :     static SumoRNG* getRNG() {
      79              :         return &myRNG;
      80              :     }
      81              : 
      82              : private:
      83              :     /** @brief The current state of the process
      84              :      */
      85              :     double myState;
      86              : 
      87              :     /** @brief The time scale of the process
      88              :      */
      89              :     double myTimeScale;
      90              : 
      91              :     /** @brief The noise intensity of the process
      92              :      */
      93              :     double myNoiseIntensity;
      94              : 
      95              :     /// @brief Random generator for OUProcesses
      96              :     static SumoRNG myRNG;
      97              : };
      98              : 
      99              : 
     100              : /// @class MSSimpleDriverState
     101              : /// @brief Provides an interface to an error whose fluctuation is controlled
     102              : ///        via the driver's 'awareness', which can be controlled externally, @see MSDevice_ToC
     103              : class MSSimpleDriverState {
     104              : 
     105              : public:
     106              :     MSSimpleDriverState(MSVehicle* veh);
     107          388 :     virtual ~MSSimpleDriverState() {};
     108              : 
     109              : 
     110              :     /// @name Getter methods
     111              :     ///@{
     112              :     inline double getMinAwareness() const {
     113            4 :         return myMinAwareness;
     114              :     }
     115              : 
     116              :     inline double getInitialAwareness() const {
     117            4 :         return myInitialAwareness;
     118              :     }
     119              : 
     120              :     inline double getErrorTimeScaleCoefficient() const {
     121            4 :         return myErrorTimeScaleCoefficient;
     122              :     }
     123              : 
     124              :     inline double getErrorNoiseIntensityCoefficient() const {
     125            4 :         return myErrorNoiseIntensityCoefficient;
     126              :     }
     127              : 
     128              :     inline double getErrorTimeScale() const {
     129              :         return myError.getTimeScale();
     130              :     }
     131              : 
     132              :     inline double getErrorNoiseIntensity() const {
     133              :         return myError.getNoiseIntensity();
     134              :     }
     135              : 
     136              :     inline double getSpeedDifferenceErrorCoefficient() const {
     137            4 :         return mySpeedDifferenceErrorCoefficient;
     138              :     }
     139              : 
     140              :     inline double getHeadwayErrorCoefficient() const {
     141            4 :         return myHeadwayErrorCoefficient;
     142              :     }
     143              : 
     144              :     inline double getFreeSpeedErrorCoefficient() const {
     145              :         return myFreeSpeedErrorCoefficient;
     146              :     }
     147              : 
     148              :     inline double getSpeedDifferenceChangePerceptionThreshold() const {
     149            4 :         return mySpeedDifferenceChangePerceptionThreshold;
     150              :     }
     151              : 
     152              :     inline double getHeadwayChangePerceptionThreshold() const {
     153            4 :         return myHeadwayChangePerceptionThreshold;
     154              :     }
     155              : 
     156              :     inline double getAwareness() const {
     157          126 :         return myAwareness;
     158              :     }
     159              : 
     160              :     inline double getMaximalReactionTime() const {
     161            3 :         return myMaximalReactionTime;
     162              :     }
     163              : 
     164              :     inline double getOriginalReactionTime() const {
     165            3 :         return myOriginalReactionTime;
     166              :     }
     167              : 
     168              :     inline double getActionStepLength() const {
     169       256656 :         return myActionStepLength;
     170              :     }
     171              : 
     172              :     inline double getErrorState() const {
     173          126 :         return myError.getState();
     174              :     };
     175              :     ///@}
     176              : 
     177              : 
     178              :     /// @name Setter methods
     179              :     ///@{
     180              :     inline void setMinAwareness(const double value)  {
     181          194 :         myMinAwareness = value;
     182            1 :     }
     183              : 
     184              :     inline void setInitialAwareness(const double value)  {
     185          194 :         myInitialAwareness = value;
     186            1 :     }
     187              : 
     188              :     inline void setErrorTimeScaleCoefficient(const double value)  {
     189          194 :         myErrorTimeScaleCoefficient = value;
     190            1 :     }
     191              : 
     192              :     inline void setErrorNoiseIntensityCoefficient(const double value)  {
     193          194 :         myErrorNoiseIntensityCoefficient = value;
     194            1 :     }
     195              : 
     196              :     inline void setSpeedDifferenceErrorCoefficient(const double value)  {
     197          194 :         mySpeedDifferenceErrorCoefficient = value;
     198            1 :     }
     199              : 
     200              :     inline void setHeadwayErrorCoefficient(const double value)  {
     201          194 :         myHeadwayErrorCoefficient = value;
     202            1 :     }
     203              : 
     204              :     inline void setFreeSpeedErrorCoefficient(const double value)  {
     205          194 :         myFreeSpeedErrorCoefficient = value;
     206            0 :     }
     207              : 
     208              :     inline void setSpeedDifferenceChangePerceptionThreshold(const double value)  {
     209          194 :         mySpeedDifferenceChangePerceptionThreshold = value;
     210            1 :     }
     211              : 
     212              :     inline void setHeadwayChangePerceptionThreshold(const double value)  {
     213          194 :         myHeadwayChangePerceptionThreshold = value;
     214            1 :     }
     215              : 
     216              :     inline void setMaximalReactionTime(const double value)  {
     217            2 :         myMaximalReactionTime = value;
     218            2 :         updateReactionTime();
     219            2 :     }
     220              : 
     221              :     inline void setOriginalReactionTime(const double value)  {
     222            1 :         myOriginalReactionTime = value;
     223            1 :         updateReactionTime();
     224            1 :     }
     225              : 
     226              :     void setAwareness(const double value);
     227              : 
     228              :     inline void setErrorState(const double state) {
     229              :         myError.setState(state);
     230            1 :     };
     231              : 
     232              :     inline void setErrorTimeScale(const double value)  {
     233              :         myError.setTimeScale(value);
     234            1 :     }
     235              : 
     236              :     inline void setErrorNoiseIntensity(const double value)  {
     237              :         myError.setNoiseIntensity(value);
     238            1 :     }
     239              :     ///@}
     240              : 
     241              :     /// @brief Trigger updates for the errorProcess, assumed gaps, etc
     242              :     void update();
     243              : 
     244              : 
     245              :     /// @brief Update the assumed gaps to the known objects according to
     246              :     ///        the corresponding perceived speed differences.
     247              :     void updateAssumedGaps();
     248              : 
     249              :     /// @name Methods to obtain the current error quantities to be used by the car-following model
     250              :     /// @see TCIModel
     251              :     /// @{
     252              : //    /// @see myAccelerationError
     253              : //    inline double getAppliedAcceleration(double desiredAccel) {
     254              : //        return desiredAccel + myError.getState();
     255              : //    };
     256              : 
     257              :     /// @brief apply perception error to own speed
     258              :     double getPerceivedOwnSpeed(double speed);
     259              : 
     260              :     /// @brief This method checks whether the errorneous speed difference that would be perceived for this step
     261              :     ///        differs sufficiently from the previously perceived to be actually perceived. If so, it sets the
     262              :     ///        flag myReactionFlag[objID]=true, which should be checked just after the call to this method because
     263              :     ///        it will be overwritten by subsequent calls.
     264              :     double getPerceivedSpeedDifference(const double trueSpeedDifference, const double trueGap, const void* objID = nullptr);
     265              :     /// @see myHeadwayPerceptionError
     266              :     double getPerceivedHeadway(const double trueGap, const void* objID = nullptr);
     267              :     /// @}
     268              : 
     269              :     inline void lockDebug() {
     270              :         myDebugLock = true;
     271              :     }
     272              : 
     273              :     inline void unlockDebug() {
     274              :         myDebugLock = false;
     275              :     }
     276              : 
     277              :     inline bool debugLocked() const {
     278              :         return myDebugLock;
     279              :     }
     280              : 
     281              : private:
     282              :     // @brief Update the current step duration
     283              :     void updateStepDuration();
     284              :     // Update the error process
     285              :     void updateError();
     286              :     // Update the reaction time (actionStepLength)
     287              :     void updateReactionTime();
     288              : 
     289              : private:
     290              : 
     291              :     /// @brief Vehicle corresponding to this driver state
     292              :     MSVehicle* myVehicle;
     293              : 
     294              :     /// @brief Driver's 'awareness' \in [0,1]
     295              :     double myAwareness;
     296              :     /// @brief Minimal value for 'awareness' \in [0,1]
     297              :     double myMinAwareness;
     298              :     /// @brief Initial value for 'awareness' \in [0,1]
     299              :     double myInitialAwareness;
     300              :     /// @brief Driver's 'error', @see TCI_Model
     301              :     OUProcess myError;
     302              :     /// @brief Coefficient controlling the impact of awareness on the time scale of the error process
     303              :     double myErrorTimeScaleCoefficient;
     304              :     /// @brief Coefficient controlling the impact of awareness on the noise intensity of the error process
     305              :     double myErrorNoiseIntensityCoefficient;
     306              : 
     307              :     /// @brief Scaling coefficients for the magnitude of errors
     308              :     double mySpeedDifferenceErrorCoefficient;
     309              :     double myHeadwayErrorCoefficient;
     310              :     double myFreeSpeedErrorCoefficient;
     311              :     /// @brief Thresholds above a change in the corresponding quantity is perceived.
     312              :     /// @note  In the comparison, we multiply the actual change amount by the current
     313              :     ///       gap to the object to reflect a more precise perception if the object is closer.
     314              :     double myHeadwayChangePerceptionThreshold;
     315              :     double mySpeedDifferenceChangePerceptionThreshold;
     316              : //    // @brief if a perception threshold is passed for some object, a flag is set to induce a reaction to the object
     317              : //    std::map<void*, bool> myReactionFlag;
     318              : 
     319              :     /// @brief Action step length (~current maximal reaction time) induced by awareness level
     320              :     /// @note  This interpolates linearly from myOriginalReactionTime for awareness==1
     321              :     ///        to myMaximalReactionTime for awareness==myMinAwareness
     322              :     double myActionStepLength;
     323              :     /// @brief Maximal reaction time (value set for the actionStepLength at awareness=1)
     324              :     double myOriginalReactionTime;
     325              :     /// @brief Maximal reaction time (value set for the actionStepLength at awareness=myMinAwareness)
     326              :     double myMaximalReactionTime;
     327              : 
     328              :     /// @name Variables for tracking update instants
     329              :     /// @see updateStepDuration()
     330              :     /// @{
     331              :     /// @brief Elapsed time since the last state update
     332              :     double myStepDuration;
     333              :     /// @brief Time point of the last state update
     334              :     double myLastUpdateTime;
     335              : 
     336              : 
     337              :     /// @brief The assumed gaps to different objects
     338              :     /// @todo: update each step to incorporate the assumed change given a specific speed difference
     339              :     std::map<const void*, double> myAssumedGap;
     340              :     /// @brief The last perceived speed differences to the corresponding objects
     341              :     std::map<const void*, double> myLastPerceivedSpeedDifference;
     342              :     /// @}
     343              : 
     344              :     /// @brief Used to prevent infinite loops in debugging outputs, @see followSpeed() and stopSpeed() (of MSCFModel_Krauss, e.g.)
     345              :     bool myDebugLock;
     346              : };
     347              : 
     348              : 
     349              : 
     350              : 
     351              : 
     352              : ///** @class MSDriverState
     353              : // * @brief  An object representing a traffic item. Used for influencing
     354              : // *         the task demand of the TCI car-following model.
     355              : // * @see MSCFModel_TCI
     356              : // */
     357              : //class MSDriverState {
     358              : //
     359              : //protected:
     360              : //    /// @brief base class for VehicleCharacteristics, TLSCharacteristics, PedestrianCharacteristics, SpeedLimitCharacteristics, Junction Characteristics...
     361              : //    /// @see TrafficItemType, @see MSCFModel_TCI
     362              : //    struct MSTrafficItemCharacteristics {
     363              : //        inline virtual ~MSTrafficItemCharacteristics() {};
     364              : //    };
     365              : //
     366              : //    // @brief Types of traffic items, @see TrafficItem
     367              : //    enum MSTrafficItemType {
     368              : //        TRAFFIC_ITEM_VEHICLE,
     369              : //        TRAFFIC_ITEM_PEDESTRIAN,
     370              : //        TRAFFIC_ITEM_SPEED_LIMIT,
     371              : //        TRAFFIC_ITEM_JUNCTION
     372              : //    };
     373              : //
     374              : //    /** @class MSTrafficItem
     375              : //     * @brief  An object representing a traffic item. Used for influencing
     376              : //     *         the task demand of the TCI car-following model.
     377              : //     * @see MSCFModel_TCI
     378              : //     */
     379              : //    struct MSTrafficItem {
     380              : //        MSTrafficItem(MSTrafficItemType type, const std::string& id, std::shared_ptr<MSTrafficItemCharacteristics> data);
     381              : //        static std::hash<std::string> hash;
     382              : //        MSTrafficItemType type;
     383              : //        size_t id_hash;
     384              : //        std::shared_ptr<MSTrafficItemCharacteristics> data;
     385              : //        double remainingIntegrationTime;
     386              : //        double integrationDemand;
     387              : //        double latentDemand;
     388              : //    };
     389              : //
     390              : //    struct JunctionCharacteristics : MSTrafficItemCharacteristics {
     391              : //        JunctionCharacteristics(const MSJunction* junction, const MSLink* egoLink, double dist) :
     392              : //            junction(junction), approachingLink(egoLink), dist(dist) {};
     393              : //        const MSJunction* junction;
     394              : //        const MSLink* approachingLink;
     395              : //        double dist;
     396              : //    };
     397              : //
     398              : //    struct PedestrianCharacteristics : MSTrafficItemCharacteristics {
     399              : //        PedestrianCharacteristics(const MSPerson* pedestrian, double dist) :
     400              : //            pedestrian(pedestrian), dist(dist) {};
     401              : //        const MSPerson* pedestrian;
     402              : //        double dist;
     403              : //    };
     404              : //
     405              : //    struct SpeedLimitCharacteristics : MSTrafficItemCharacteristics {
     406              : //        SpeedLimitCharacteristics(const MSLane* lane, double dist, double limit) :
     407              : //            dist(dist), limit(limit), lane(lane) {};
     408              : //        const MSLane* lane;
     409              : //        double dist;
     410              : //        double limit;
     411              : //    };
     412              : //
     413              : //    struct VehicleCharacteristics : MSTrafficItemCharacteristics {
     414              : //        VehicleCharacteristics(const MSVehicle* foe, double longitudinalDist, double lateralDist, double relativeSpeed) :
     415              : //            longitudinalDist(longitudinalDist), lateralDist(lateralDist), foe(foe), relativeSpeed(relativeSpeed) {};
     416              : //        const MSVehicle* foe;
     417              : //        double longitudinalDist;
     418              : //        double lateralDist;
     419              : //        double relativeSpeed;
     420              : //    };
     421              : //
     422              : //
     423              : //public:
     424              : //
     425              : //    MSDriverState(MSVehicle* veh);
     426              : //    virtual ~MSDriverState() {};
     427              : //
     428              : //    /// @name Interfaces to inform Driver Model about traffic items, which potentially
     429              : //    ///       influence the driving difficulty.
     430              : //    /// @{
     431              : //    /** @brief Informs about leader.
     432              : //    */
     433              : //    virtual void registerLeader(const MSVehicle* leader, double gap, double relativeSpeed, double latGap = -1.);
     434              : //
     435              : //    /** @brief Informs about pedestrian.
     436              : //    */
     437              : //    virtual void registerPedestrian(const MSPerson* pedestrian, double gap);
     438              : //
     439              : //    /** @brief Informs about upcoming speed limit reduction.
     440              : //    */
     441              : //    virtual void registerSpeedLimit(const MSLane* lane, double speedLimit, double dist);
     442              : //
     443              : //    /** @brief Informs about upcoming junction.
     444              : //    */
     445              : //    virtual void registerJunction(MSLink* link, double dist);
     446              : //
     447              : //    /** @brief Takes into account vehicle-specific factors for the driving demand
     448              : //    *          For instance, whether vehicle drives on an opposite direction lane, absolute speed, etc.
     449              : //    */
     450              : //    virtual void registerEgoVehicleState();
     451              : //
     452              : //    /** @brief Trigger updates for the state variables according to the traffic situation
     453              : //     *         (present traffic items)
     454              : //    */
     455              : //    virtual void update();
     456              : //    /// @}
     457              : //
     458              : //
     459              : //    /// @name Methods to obtain the current error quantities to be used by the car-following model
     460              : //    /// @see TCIModel
     461              : //    /// @{
     462              : //    /// @see myAccelerationError
     463              : //    inline double getAppliedAcceleration(double desiredAccel) {
     464              : //        return desiredAccel + myAccelerationError.getState();
     465              : //    };
     466              : //    /// @see mySpeedPerceptionError
     467              : //    inline double getPerceivedSpeedDifference(double trueSpeedDifference) {
     468              : //        return trueSpeedDifference + mySpeedPerceptionError.getState();
     469              : //    };
     470              : //    /// @see myHeadwayPerceptionError
     471              : //    inline double getPerceivedHeadway(double trueGap) {
     472              : //        return trueGap + myHeadwayPerceptionError.getState();
     473              : //    };
     474              : //    /// @see myActionStepLength
     475              : //    inline double getActionStepLength(){
     476              : //        return myActionStepLength;
     477              : //    };
     478              : //    /// @}
     479              : //
     480              : //
     481              : //private:
     482              : //
     483              : //    /** @brief Updates the internal variables to track the time between
     484              : //     *        two calls to the state update (i.e., two action points). Needed for a consistent
     485              : //     *        evolution of the error processes.
     486              : //     */
     487              : //    void updateStepDuration();
     488              : //
     489              : //    /** @brief Calculates a value for the task difficulty given the capability and the demand
     490              : //     *         and stores the result in myCurrentDrivingDifficulty.
     491              : //     *  @see difficultyFunction()
     492              : //     */
     493              : //    void calculateDrivingDifficulty();
     494              : //
     495              : //
     496              : //    /** @brief Transformation of the quotient demand/capability to obtain the actual
     497              : //     *         difficulty value used to control driving performance.
     498              : //     *  @note  The current implementation is a continuous piecewise affine function.
     499              : //     *         It has two regions with different slopes. A slight ascend, where the capability
     500              : //     *         is larger than the demand and a region of steeper ascend, where the demand
     501              : //     *         exceeds the capability.
     502              : //     */
     503              : //    double difficultyFunction(double demandCapabilityQuotient) const;
     504              : //
     505              : //
     506              : //    /** @brief Updates the myTaskCapability in dependence of the myTaskDifficulty to model a reactive
     507              : //     *         level of attention. The characteristics of the process are determined by myHomeostasisDifficulty
     508              : //     *         and myCapabilityTimeScale.
     509              : //     *  @todo Review the implementation as simple exponential process.
     510              : //     */
     511              : //    void adaptTaskCapability();
     512              : //
     513              : //
     514              : //    /// @name Updater for error processes.
     515              : //    /// @{
     516              : //    void updateAccelerationError();
     517              : //    void updateSpeedPerceptionError();
     518              : //    void updateHeadwayPerceptionError();
     519              : //    void updateActionStepLength();
     520              : //    /// @}
     521              : //
     522              : //
     523              : //    /// @brief Updates the given error process
     524              : //    void updateErrorProcess(OUProcess& errorProcess, double timeScaleCoefficient, double noiseIntensityCoefficient) const;
     525              : //
     526              : //    /// @brief Initialize newly appeared traffic item
     527              : //    void calculateLatentDemand(std::shared_ptr<MSTrafficItem> ti) const;
     528              : //
     529              : //    /// @brief Calculate demand induced by the given junction
     530              : //    double calculateLatentJunctionDemand(std::shared_ptr<JunctionCharacteristics> ch) const;
     531              : //    /// @brief Calculate demand induced by the given pedestrian
     532              : //    double calculateLatentPedestrianDemand(std::shared_ptr<PedestrianCharacteristics> ch) const;
     533              : //    /// @brief Calculate demand induced by the given pedestrian
     534              : //    double calculateLatentSpeedLimitDemand(std::shared_ptr<SpeedLimitCharacteristics> ch) const;
     535              : //    /// @brief Calculate demand induced by the given vehicle
     536              : //    double calculateLatentVehicleDemand(std::shared_ptr<VehicleCharacteristics> ch) const;
     537              : //
     538              : //    /// @brief Calculate integration demand induced by the given junction
     539              : //    double calculateJunctionIntegrationDemand(std::shared_ptr<JunctionCharacteristics> ch) const;
     540              : //    /// @brief Calculate integration demand induced by the given pedestrian
     541              : //    double calculatePedestrianIntegrationDemand(std::shared_ptr<PedestrianCharacteristics> ch) const;
     542              : //    /// @brief Calculate integration demand induced by the given pedestrian
     543              : //    double calculateSpeedLimitIntegrationDemand(std::shared_ptr<SpeedLimitCharacteristics> ch) const;
     544              : //    /// @brief Calculate integration demand induced by the given vehicle
     545              : //    double calculateVehicleIntegrationDemand(std::shared_ptr<VehicleCharacteristics> ch) const;
     546              : //
     547              : //    /// @brief Register known traffic item to persist
     548              : //    void updateItemIntegration(std::shared_ptr<MSTrafficItem> ti) const;
     549              : //
     550              : //    /// @brief Determine the integration demand and duration for a newly encountered traffic item (updated in place)
     551              : //    ///        The integration demand takes effect during a short period after the first appearance of the item.
     552              : //    void calculateIntegrationDemandAndTime(std::shared_ptr<MSTrafficItem> ti) const;
     553              : //
     554              : //    /// @brief Calculate the integration time for an item approached with the given speed at given dist
     555              : //    double calculateIntegrationTime(double dist, double speed) const;
     556              : //
     557              : //    /// @brief Incorporate the item's demand into the total task demand.
     558              : //    void integrateDemand(std::shared_ptr<MSTrafficItem> ti);
     559              : //
     560              : //    /// @brief Called whenever the vehicle is notified about a traffic item encounter.
     561              : //    void registerTrafficItem(std::shared_ptr<MSTrafficItem> ti);
     562              : //
     563              : //private:
     564              : //
     565              : //    MSVehicle* myVehicle;
     566              : //
     567              : //    /// @name Variables for tracking update instants
     568              : //    /// @see updateStepDuration()
     569              : //    /// @{
     570              : //
     571              : //    /// @brief Elapsed time since the last state update
     572              : //    double myStepDuration;
     573              : //    /// @brief Time point of the last state update
     574              : //    double myLastUpdateTime;
     575              : //
     576              : //    /// @}
     577              : //
     578              : //
     579              : //    /// @name Dynamical quantities for the driving performance
     580              : //    /// @{
     581              : //
     582              : //    /** @brief Task capability (combines static and dynamic factors specific to the driver and the situation,
     583              : //     *         total capability, attention, etc.). Follows myTaskDemand with some inertia (task-difficulty-homeostasis).
     584              : //     */
     585              : //    double myTaskCapability;
     586              : //    double myMinTaskCapability, myMaxTaskCapability;
     587              : //
     588              : //    /** @brief Task Demand (dynamic variable representing the total demand imposed on the driver by the driving situation and environment.
     589              : //     *         For instance, number, novelty and type of traffic participants in neighborhood, speed differences, road curvature,
     590              : //     *         headway to leader, number of lanes, traffic density, street signs, traffic lights)
     591              : //     */
     592              : //    double myTaskDemand;
     593              : //    double myMaxTaskDemand;
     594              : //
     595              : //    /** @brief Cached current value of the difficulty resulting from the combination of task capability and demand.
     596              : //     *  @see calculateDrivingDifficulty()
     597              : //     */
     598              : //    double myCurrentDrivingDifficulty;
     599              : //    /// @brief Upper bound for myCurrentDrivingDifficulty
     600              : //    double myMaxDifficulty;
     601              : //    /** @brief Slopes for the dependence of the difficulty on the quotient of demand and capability.
     602              : //     *  @see   difficultyFunction();
     603              : //     */
     604              : //    double mySubCriticalDifficultyCoefficient, mySuperCriticalDifficultyCoefficient;
     605              : //
     606              : //    /// @}
     607              : //
     608              : //    /// @name Field that reflect the current driving situation
     609              : //    /// @{
     610              : //    /// @brief Whether vehicle is driving on an opposite direction lane
     611              : //    bool myAmOpposite;
     612              : //    double myCurrentSpeed;
     613              : //    double myCurrentAcceleration;
     614              : //    /// @}
     615              : //
     616              : //    /// @name Parameters for the dynamic adaptation of capability (attention) and demand
     617              : //    /// @{
     618              : //
     619              : //    /** @brief The desired value of the quotient myTaskDemand/myTaskCapability. Influences the fixed point of the
     620              : //     *         process myTaskCapability -> myTaskDemand, @see adaptTaskCapability()
     621              : //     */
     622              : //    double myHomeostasisDifficulty;
     623              : //
     624              : //    /** @brief Determines the time scale for the adaptation process of task capability towards the
     625              : //     *         task difficulty.
     626              : //     */
     627              : //    double myCapabilityTimeScale;
     628              : //
     629              : //    /** @brief Factor for the demand if driving on an opposite direction lane
     630              : //     */
     631              : //    double myOppositeDirectionDrivingDemandFactor;
     632              : //
     633              : //    /// @}
     634              : //
     635              : //
     636              : //
     637              : //    /** @brief Traffic items in the current neighborhood of the vehicle.
     638              : //     */
     639              : //    std::map<size_t, std::shared_ptr<MSTrafficItem> > myTrafficItems;
     640              : //    std::map<size_t, std::shared_ptr<MSTrafficItem> > myNewTrafficItems;
     641              : //
     642              : //    /// @name Actuation errors
     643              : //    /// @{
     644              : //
     645              : //    /** @brief Acceleration error. Modelled as an Ornstein-Uhlenbeck process.
     646              : //     *  @see updateAccelerationError()
     647              : //     */
     648              : //    OUProcess myAccelerationError;
     649              : //    /// @brief Coefficient controlling the impact of driving difficulty on the time scale of the acceleration error process
     650              : //    double myAccelerationErrorTimeScaleCoefficient;
     651              : //    /// @brief Coefficient controlling the impact of driving difficulty on the noise intensity of the acceleration error process
     652              : //    double myAccelerationErrorNoiseIntensityCoefficient;
     653              : //
     654              : //    /// @brief Action step length (increases with task difficulty, is similar to reaction time)
     655              : //    double myActionStepLength;
     656              : //    /// @brief Proportionality factor of myActionStepLength and driving difficulty
     657              : //    double myActionStepLengthCoefficient;
     658              : //    /// @brief Bounds for the action step length
     659              : //    double myMinActionStepLength, myMaxActionStepLength;
     660              : //
     661              : //    /// @}
     662              : //
     663              : //
     664              : //    /// @name Perception errors
     665              : //    /// @{
     666              : //
     667              : //    /** @brief Error of estimation of the relative speeds of neighboring vehicles
     668              : //     */
     669              : //    OUProcess mySpeedPerceptionError;
     670              : //    /// @brief Coefficient controlling the impact of driving difficulty on the time scale of the relative speed error process
     671              : //    double mySpeedPerceptionErrorTimeScaleCoefficient;
     672              : //    /// @brief Coefficient controlling the impact of driving difficulty on the noise intensity of the relative speed error process
     673              : //    double mySpeedPerceptionErrorNoiseIntensityCoefficient;
     674              : //
     675              : //    /** @brief Error of estimation of the distance/headways of neighboring vehicles
     676              : //     */
     677              : //    OUProcess myHeadwayPerceptionError;
     678              : //    /// @brief Coefficient controlling the impact of driving difficulty on the time scale of the headway error process
     679              : //    double myHeadwayPerceptionErrorTimeScaleCoefficient;
     680              : //    /// @brief Coefficient controlling the impact of driving difficulty on the noise intensity of the headway error process
     681              : //    double myHeadwayPerceptionErrorNoiseIntensityCoefficient;
     682              : //
     683              : //    /// @}
     684              : //};
     685              : 
     686              : 
     687              : 
     688              : /// @brief Default values for the MSDriverState parameters
     689              : struct DriverStateDefaults {
     690              : //    static double myMinTaskCapability;
     691              : //    static double myMaxTaskCapability;
     692              : //    static double myMaxTaskDemand;
     693              : //    static double myMaxDifficulty;
     694              : //    static double mySubCriticalDifficultyCoefficient;
     695              : //    static double mySuperCriticalDifficultyCoefficient;
     696              : //    static double myHomeostasisDifficulty;
     697              : //    static double myCapabilityTimeScale;
     698              : //    static double myAccelerationErrorTimeScaleCoefficient;
     699              : //    static double myAccelerationErrorNoiseIntensityCoefficient;
     700              : //    static double myActionStepLengthCoefficient;
     701              : //    static double myMinActionStepLength;
     702              : //    static double myMaxActionStepLength;
     703              : //    static double mySpeedPerceptionErrorTimeScaleCoefficient;
     704              : //    static double mySpeedPerceptionErrorNoiseIntensityCoefficient;
     705              : //    static double myHeadwayPerceptionErrorTimeScaleCoefficient;
     706              : //    static double myHeadwayPerceptionErrorNoiseIntensityCoefficient;
     707              : //    static double myOppositeDirectionDrivingFactor;
     708              : 
     709              :     // for MSSimpleDriverState
     710              :     static double minAwareness;
     711              :     static double initialAwareness;
     712              :     static double errorTimeScaleCoefficient;
     713              :     static double errorNoiseIntensityCoefficient;
     714              :     static double speedDifferenceErrorCoefficient;
     715              :     static double speedDifferenceChangePerceptionThreshold;
     716              :     static double headwayChangePerceptionThreshold;
     717              :     static double headwayErrorCoefficient;
     718              :     static double freeSpeedErrorCoefficient;
     719              :     static double maximalReactionTimeFactor;
     720              : };
        

Generated by: LCOV version 2.0-1