LCOV - code coverage report
Current view: top level - src/microsim/traffic_lights - MSSOTLPhasePolicy.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 80.0 % 30 24
Test Date: 2024-11-22 15:46:21 Functions: 80.0 % 5 4

            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    MSSOTLPhasePolicy.cpp
      15              : /// @author  Gianfilippo Slager
      16              : /// @author  Federico Caselli
      17              : /// @date    Feb 2010
      18              : ///
      19              : // The class for SOTL Phase logics
      20              : /****************************************************************************/
      21              : 
      22              : #include "MSSOTLPhasePolicy.h"
      23              : #include <cmath>
      24              : #include "utils/common/RandHelper.h"
      25              : 
      26              : 
      27           16 : MSSOTLPhasePolicy::MSSOTLPhasePolicy(const Parameterised::Map& parameters) :
      28           32 :     MSSOTLPolicy("Phase", parameters) {
      29           16 :     init();
      30           16 : }
      31              : 
      32            0 : MSSOTLPhasePolicy::MSSOTLPhasePolicy(MSSOTLPolicyDesirability* desirabilityAlgorithm) :
      33            0 :     MSSOTLPolicy("Phase", desirabilityAlgorithm) {
      34            0 :     getDesirabilityAlgorithm()->setKeyPrefix("PHASE");
      35            0 :     init();
      36            0 : }
      37              : 
      38           16 : MSSOTLPhasePolicy::MSSOTLPhasePolicy(MSSOTLPolicyDesirability* desirabilityAlgorithm,
      39           16 :                                      const Parameterised::Map& parameters) :
      40           32 :     MSSOTLPolicy("Phase", desirabilityAlgorithm, parameters) {
      41           16 :     getDesirabilityAlgorithm()->setKeyPrefix("PHASE");
      42           16 :     init();
      43           16 : }
      44              : 
      45        14858 : bool MSSOTLPhasePolicy::canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed,
      46              :                                    const MSPhaseDefinition* stage, int vehicleCount) {
      47              : //  DBG(
      48        14858 :     std::ostringstream str;
      49        29716 :     str << "MSSOTLPhasePolicy::canRelease threshold " << thresholdPassed << " vehicle " << vehicleCount << " elapsed " << elapsed << " min " << stage->minDuration;
      50        14858 :     WRITE_MESSAGE(str.str());
      51              : //          );
      52        14858 :     if (elapsed >= stage->minDuration) {
      53         8302 :         if (pushButtonLogic(elapsed, pushButtonPressed, stage)) {
      54              :             return true;
      55              :         }
      56         8302 :         if (thresholdPassed) {
      57              :             return thresholdPassed;
      58         7706 :         } else if (m_useVehicleTypesWeights) {
      59            0 :             if (sigmoidLogic(elapsed, stage, vehicleCount)) {
      60              :                 return true;
      61              :             }
      62              :         }
      63              :     }
      64              :     return false;
      65        14858 : }
      66              : 
      67           32 : void MSSOTLPhasePolicy::init() {
      68           32 :     PushButtonLogic::init("MSSOTLPhasePolicy", this);
      69           32 :     SigmoidLogic::init("MSSOTLPhasePolicy", this);
      70           64 :     m_useVehicleTypesWeights = getParameter("USE_VEHICLE_TYPES_WEIGHTS", "0") == "1";
      71           32 : }
        

Generated by: LCOV version 2.0-1