LCOV - code coverage report
Current view: top level - src/microsim/lcmodels - MSLCM_DK2008.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 40.0 % 5 2
Test Date: 2024-11-20 15:55:46 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2005-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    MSLCM_DK2008.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Friedemann Wesner
      17              : /// @author  Sascha Krieg
      18              : /// @author  Michael Behrisch
      19              : /// @author  Jakob Erdmann
      20              : /// @date    Fri, 29.04.2005
      21              : ///
      22              : // A lane change model developed by D. Krajzewicz between 2004 and 2010
      23              : /****************************************************************************/
      24              : #pragma once
      25              : #include <config.h>
      26              : 
      27              : #include "MSAbstractLaneChangeModel.h"
      28              : #include <vector>
      29              : 
      30              : // ===========================================================================
      31              : // class definitions
      32              : // ===========================================================================
      33              : /**
      34              :  * @class MSLCM_DK2008
      35              :  * @brief A lane change model developed by D. Krajzewicz between 2004 and 2010
      36              :  */
      37              : class MSLCM_DK2008 : public MSAbstractLaneChangeModel {
      38              : public:
      39              : 
      40              :     MSLCM_DK2008(MSVehicle& v);
      41              : 
      42              :     virtual ~MSLCM_DK2008();
      43              : 
      44              :     /// @brief Returns the model's id
      45            0 :     LaneChangeModel getModelID() const {
      46            0 :         return LaneChangeModel::DK2008;
      47              :     }
      48              : 
      49              :     /** @brief Called to examine whether the vehicle wants to change
      50              :      * using the given laneOffset.
      51              :      * This method gets the information about the surrounding vehicles
      52              :      * and whether another lane may be more preferable */
      53              :     int wantsChange(
      54              :         int laneOffset,
      55              :         MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
      56              :         const std::pair<MSVehicle*, double>& leader,
      57              :         const std::pair<MSVehicle*, double>& follower,
      58              :         const std::pair<MSVehicle*, double>& neighLead,
      59              :         const std::pair<MSVehicle*, double>& neighFollow,
      60              :         const MSLane& neighLane,
      61              :         const std::vector<MSVehicle::LaneQ>& preb,
      62              :         MSVehicle** lastBlocked,
      63              :         MSVehicle** firstBlocked);
      64              : 
      65              :     virtual void* inform(void* info, MSVehicle* sender);
      66              : 
      67              :     /** @brief Called to adapt the speed in order to allow a lane change.
      68              :      *
      69              :      * @param min The minimum resulting speed
      70              :      * @param wanted The aspired speed of the car following model
      71              :      * @param max The maximum resulting speed
      72              :      * @param cfModel The model used
      73              :      * @return the new speed of the vehicle as proposed by the lane changer
      74              :      */
      75              :     virtual double patchSpeed(const double min, const double wanted, const double max,
      76              :                               const MSCFModel& cfModel);
      77              : 
      78              :     virtual void changed();
      79              : 
      80              :     virtual void prepareStep();
      81              : 
      82              : 
      83              : protected:
      84              :     /** @brief Called to examine whether the vehicle wants to change to right
      85              :         This method gets the information about the surrounding vehicles
      86              :         and whether another lane may be more preferable */
      87              :     virtual int wantsChangeToRight(
      88              :         MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
      89              :         const std::pair<MSVehicle*, double>& leader,
      90              :         const std::pair<MSVehicle*, double>& neighLead,
      91              :         const std::pair<MSVehicle*, double>& neighFollow,
      92              :         const MSLane& neighLane,
      93              :         const std::vector<MSVehicle::LaneQ>& preb,
      94              :         MSVehicle** lastBlocked,
      95              :         MSVehicle** firstBlocked);
      96              : 
      97              :     /** @brief Called to examine whether the vehicle wants to change to left
      98              :         This method gets the information about the surrounding vehicles
      99              :         and whether another lane may be more preferable */
     100              :     virtual int wantsChangeToLeft(
     101              :         MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
     102              :         const std::pair<MSVehicle*, double>& leader,
     103              :         const std::pair<MSVehicle*, double>& neighLead,
     104              :         const std::pair<MSVehicle*, double>& neighFollow,
     105              :         const MSLane& neighLane,
     106              :         const std::vector<MSVehicle::LaneQ>& preb,
     107              :         MSVehicle** lastBlocked,
     108              :         MSVehicle** firstBlocked);
     109              : 
     110              :     void informBlocker(MSAbstractLaneChangeModel::MSLCMessager& msgPass,
     111              :                        int& blocked, int dir,
     112              :                        const std::pair<MSVehicle*, double>& neighLead,
     113              :                        const std::pair<MSVehicle*, double>& neighFollow);
     114              : 
     115              :     inline bool amBlockingLeader() {
     116              :         return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
     117              :     }
     118              :     inline bool amBlockingFollower() {
     119              :         return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
     120              :     }
     121              :     inline bool amBlockingFollowerNB() {
     122              :         return (myOwnState & LCA_AMBLOCKINGFOLLOWER_DONTBRAKE) != 0;
     123              :     }
     124              :     inline bool amBlockingFollowerPlusNB() {
     125          109 :         return (myOwnState & (LCA_AMBLOCKINGFOLLOWER | LCA_AMBLOCKINGFOLLOWER_DONTBRAKE)) != 0;
     126              :     }
     127              :     inline bool currentDistDisallows(double dist, int laneOffset, double lookForwardDist) {
     128          167 :         return dist / (abs(laneOffset)) < lookForwardDist;
     129              :     }
     130              :     inline bool currentDistAllows(double dist, int laneOffset, double lookForwardDist) {
     131            0 :         return dist / abs(laneOffset) > lookForwardDist;
     132              :     }
     133              : 
     134              :     typedef std::pair<double, int> Info;
     135              : 
     136              : 
     137              : 
     138              : protected:
     139              :     double myChangeProbability;
     140              : 
     141              :     double myLeadingBlockerLength;
     142              :     double myLeftSpace;
     143              : 
     144              :     std::vector<double> myVSafes;
     145              :     bool myDontBrake;
     146              : 
     147              : };
        

Generated by: LCOV version 2.0-1