LCOV - code coverage report
Current view: top level - src/microsim/traffic_lights - MSDelayBasedTrafficLightLogic.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 1 0.0 %
Date: 2024-05-19 15:37:39 Functions: 0 0 -

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2002-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    MSDelayBasedTrafficLightLogic.h
      15             : /// @author  Leonhard Luecken
      16             : /// @date    Feb 2017
      17             : ///
      18             : // An actuated traffic light logic based on time delay of approaching vehicles
      19             : /****************************************************************************/
      20             : #pragma once
      21             : #include <config.h>
      22             : 
      23             : #include <map>
      24             : #include "MSSimpleTrafficLightLogic.h"
      25             : 
      26             : 
      27             : // ===========================================================================
      28             : // class declarations
      29             : // ===========================================================================
      30             : class NLDetectorBuilder;
      31             : class MSE2Collector;
      32             : 
      33             : 
      34             : // ===========================================================================
      35             : // class definitions
      36             : // ===========================================================================
      37             : /**
      38             :  * @class MSDelayBasedTrafficLightLogic
      39             :  * @brief An actuated traffic light logic based on time delay of approaching vehicles
      40             :  * @todo Validate against the original algorithm's details.
      41             :  * @note The current phase is not prolonged if the passing time of the next approaching vehicle
      42             :  * is larger than the remaining greentime (in contrast to the original algorithm)
      43             :  * @note The maximal green time can be exceeded if no vehicles are present on other approaches;
      44             :  */
      45             : class MSDelayBasedTrafficLightLogic : public MSSimpleTrafficLightLogic {
      46             : public:
      47             :     /** @brief Constructor
      48             :      * @param[in] tlcontrol The tls control responsible for this tls
      49             :      * @param[in] id This tls' id
      50             :      * @param[in] programID This tls' sub-id (program id)
      51             :      * @param[in] phases Definitions of the phases
      52             :      * @param[in] step The initial phase index
      53             :      * @param[in] delay The time to wait before the first switch
      54             :      * @param[in] parameter The parameter to use for tls set-up
      55             :      */
      56             :     MSDelayBasedTrafficLightLogic(MSTLLogicControl& tlcontrol,
      57             :                                   const std::string& id, const std::string& programID,
      58             :                                   const SUMOTime offset,
      59             :                                   const MSSimpleTrafficLightLogic::Phases& phases,
      60             :                                   int step, SUMOTime delay,
      61             :                                   const Parameterised::Map& parameter,
      62             :                                   const std::string& basePath);
      63             : 
      64             : 
      65             :     /** @brief Initializes the tls with information about incoming lanes
      66             :      * @param[in] nb The detector builder
      67             :      * @exception ProcessError If something fails on initialization
      68             :      */
      69             :     void init(NLDetectorBuilder& nb);
      70             : 
      71             : 
      72             :     /// @brief Destructor
      73             :     ~MSDelayBasedTrafficLightLogic();
      74             : 
      75             : 
      76             : 
      77             :     /// @name Switching and setting current rows
      78             :     /// @{
      79             : 
      80             :     /** @brief Switches to the next phase, if possible
      81             :      * @return The time of the next switch
      82             :      * @see MSTrafficLightLogic::trySwitch
      83             :      */
      84             :     SUMOTime trySwitch();
      85             :     /// @}
      86             : 
      87             :     bool showDetectors() const {
      88           0 :         return myShowDetectors;
      89             :     }
      90             : 
      91             :     void setShowDetectors(bool show);
      92             : 
      93             : 
      94             : protected:
      95             :     /// @name "actuated" algorithm methods
      96             :     /// @{
      97             : 
      98             :     /**
      99             :      * @brief Checks for approaching vehicles on the lanes associated with green signals
     100             :      *        and returns the minimal time to keep the green phase going.
     101             :      *        This is zero if no vehicle on the lane has gathered any waiting time
     102             :      *        or if the green time is exhausted (maximal green time has passed since switch).
     103             :      * @return Minimal remaining green time.
     104             :      */
     105             :     SUMOTime checkForWaitingTime();
     106             : 
     107             :     /**
     108             :      * @brief The returned, proposed prolongation for the green phase is oriented on the
     109             :      *        largest estimated passing time among the vehicles with waiting time.
     110             :      * @param actDuration Duration of the current phase
     111             :      * @param maxDuration Maximal duration of the current phase
     112             :      * @param[in/out] othersEmpty Whether there are vehicles on another approach, which is not part of a green signal group for the current phase
     113             :      * @return The proposed prolongation time for the current phase
     114             :      */
     115             :     SUMOTime proposeProlongation(const SUMOTime actDuration, const SUMOTime maxDuration, bool& othersEmpty);
     116             : 
     117             : protected:
     118             :     /// A map from lanes to the corresponding lane detectors
     119             :     std::map<const MSLane*, MSE2Collector*> myLaneDetectors;
     120             : 
     121             :     /// Range of the connected detector, which provides the information on approaching vehicles
     122             :     double myDetectionRange;
     123             : 
     124             :     /// If a vehicle's timeloss is below myTimeLossThreshold, this is counted as insignificant,
     125             :     /// since this may stem from dawdling, or driving only slightly slower than the maximal velocity on the lane.
     126             :     // (Idea: this might be adapted to the detector-length and the vehicle's maximal speed)
     127             :     double myTimeLossThreshold;
     128             : 
     129             :     /// Whether the detectors shall be shown in the GUI
     130             :     bool myShowDetectors;
     131             : 
     132             :     /// The output file for generated detectors
     133             :     std::string myFile;
     134             : 
     135             :     /// The frequency for aggregating detector output
     136             :     SUMOTime myFreq;
     137             : 
     138             :     /// Whether detector output separates by vType
     139             :     std::string myVehicleTypes;
     140             : 
     141             :     /// Whether phases may be extended beyond maxDur in the absence of traffic
     142             :     bool myExtendMaxDur;
     143             : };

Generated by: LCOV version 1.14