LCOV - code coverage report
Current view: top level - src/microsim/traffic_lights - MSSOTLPlatoonPolicy.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 20 26 76.9 %
Date: 2024-05-19 15:37:39 Functions: 4 5 80.0 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2010-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    MSSOTLPlatoonPolicy.cpp
      15             : /// @author  Gianfilippo Slager
      16             : /// @author  Federico Caselli
      17             : /// @date    Feb 2010
      18             : ///
      19             : // The class for SOTL Platoon logics
      20             : /****************************************************************************/
      21             : 
      22             : #include "MSSOTLPlatoonPolicy.h"
      23             : //#define SWARM_DEBUG
      24             : 
      25             : 
      26             : // ===========================================================================
      27             : // method definitions
      28             : // ===========================================================================
      29          32 : MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(const Parameterised::Map& parameters) :
      30          64 :     MSSOTLPolicy("Platoon", parameters) {
      31          32 :     init();
      32          32 : }
      33             : 
      34           0 : MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(MSSOTLPolicyDesirability* desirabilityAlgorithm) :
      35           0 :     MSSOTLPolicy("Platoon", desirabilityAlgorithm) {
      36           0 :     getDesirabilityAlgorithm()->setKeyPrefix("PLATOON");
      37           0 :     init();
      38           0 : }
      39             : 
      40          32 : MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(MSSOTLPolicyDesirability* desirabilityAlgorithm,
      41          32 :         const Parameterised::Map& parameters) :
      42          64 :     MSSOTLPolicy("Platoon", desirabilityAlgorithm, parameters) {
      43          32 :     getDesirabilityAlgorithm()->setKeyPrefix("PLATOON");
      44          32 :     init();
      45          32 : }
      46             : 
      47       58078 : bool MSSOTLPlatoonPolicy::canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed,
      48             :                                      const MSPhaseDefinition* stage, int vehicleCount) {
      49             : //  DBG(std::ostringstream str; str << "invoked MSTLPlatoonPolicy::canRelease()"; WRITE_MESSAGE(str.str()););
      50             : #ifdef SWARM_DEBUG
      51             :     std::ostringstream str;
      52             :     str << "MSSOTLPlatoonPolicy::canRelease elapsed " << elapsed << " threshold " << thresholdPassed << " pushbutton " << pushButtonPressed << " vcount " << vehicleCount
      53             :         << " minD " << stage->minDuration << " maxD " << stage->maxDuration;
      54             :     str << " will return " << ((thresholdPassed && ((vehicleCount == 0) || (elapsed >= stage->maxDuration))) ? "true" : "false");
      55             :     WRITE_MESSAGE(str.str());
      56             : #endif
      57       58078 :     if (elapsed >= stage->minDuration) {
      58       51016 :         if (pushButtonLogic(elapsed, pushButtonPressed, stage)) {
      59             :             return true;
      60             :         }
      61       51016 :         if (thresholdPassed) {
      62             :             //If there are no other vehicles approaching green lights
      63             :             //or the declared maximum duration has been reached
      64       43036 :             return ((vehicleCount == 0) || (elapsed >= stage->maxDuration));
      65             :         } else {
      66       29192 :             if (sigmoidLogic(elapsed, stage, vehicleCount)) {
      67           0 :                 return true;
      68             :             }
      69             :         }
      70             :     }
      71             :     return false;
      72             : }
      73             : 
      74          64 : void MSSOTLPlatoonPolicy::init() {
      75          64 :     SigmoidLogic::init("MSSOTLPlatoonPolicy", this);
      76          64 :     PushButtonLogic::init("MSSOTLPlatoonPolicy", this);
      77          64 : }

Generated by: LCOV version 1.14