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

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2013-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    MSSOTLPolicy5DStimulus.h
      15             : /// @author  Riccardo Belletti
      16             : /// @author  Simone Bacchilega
      17             : /// @date    2014-09-30
      18             : ///
      19             : // The class the low-level policy stimulus
      20             : /****************************************************************************/
      21             : #pragma once
      22             : #include <config.h>
      23             : 
      24             : #include <utils/common/MsgHandler.h>
      25             : #include <sstream>
      26             : #include <cmath>
      27             : #include "MSSOTLPolicyDesirability.h"
      28             : 
      29             : /**
      30             :  * \class MSSOTLPolicyStimulus
      31             :  * \brief This class determines the stimulus of a MSSOTLPolicy when
      32             :  * used in combination with a high level policy.\n
      33             :  * The stimulus function is calculated as follows:\n
      34             :  * stimulus = cox * exp(-pow(pheroIn - offsetIn, 2)/divisor -pow(pheroOut - offsetOut, 2)/divisor)
      35             :  */
      36             : class MSSOTLPolicy5DStimulus: public MSSOTLPolicyDesirability {
      37             : 
      38             : private:
      39             : 
      40             :     double stimCoxDVal,
      41             :            stimOffsetInDVal, stimOffsetOutDVal, stimOffsetDispersionInDVal, stimOffsetDispersionOutDVal,
      42             :            stimDivInDVal, stimDivOutDVal, stimDivDispersionInDVal, stimDivDispersionOutDVal,
      43             :            stimCoxExpInDVal, stimCoxExpOutDVal, stimCoxExpDispersionInDVal, stimCoxExpDispersionOutDVal;
      44             : 
      45             : public:
      46             : 
      47             :     MSSOTLPolicy5DStimulus(std::string keyPrefix, const Parameterised::Map& parameters);
      48             : 
      49         160 :     double getStimCox() {
      50         160 :         std::string key = getKeyPrefix() + "_STIM_COX";
      51         320 :         return getDouble(key, stimCoxDVal);
      52             :     }
      53             :     void setStimCoxDefVal(double defVal) {
      54             :         stimCoxDVal = defVal;
      55             :     }
      56         160 :     double getStimOffsetIn() {
      57         160 :         std::string key = getKeyPrefix() + "_STIM_OFFSET_IN";
      58         320 :         return getDouble(key, stimOffsetInDVal);
      59             :     }
      60             :     void setStimOffsetInDefVal(double defVal) {
      61             :         stimOffsetInDVal = defVal;
      62             :     }
      63         160 :     double getStimOffsetOut() {
      64         160 :         std::string key = getKeyPrefix() + "_STIM_OFFSET_OUT";
      65         320 :         return getDouble(key, stimOffsetOutDVal);
      66             :     }
      67             : 
      68             :     void setStimOffsetOutDefVal(double defVal) {
      69             :         stimOffsetOutDVal = defVal;
      70             :     }
      71             : 
      72         160 :     double getStimOffsetDispersionIn() {
      73         160 :         std::string key = getKeyPrefix() + "_STIM_OFFSET_DISPERSION_IN";
      74         320 :         return getDouble(key, stimOffsetDispersionInDVal);
      75             :     }
      76             :     void setStimOffsetDispersionInDefVal(double defVal) {
      77             :         stimOffsetDispersionInDVal = defVal;
      78             :     }
      79         160 :     double getStimOffsetDispersionOut() {
      80         160 :         std::string key = getKeyPrefix() + "_STIM_OFFSET_DISPERSION_OUT";
      81         320 :         return getDouble(key, stimOffsetDispersionOutDVal);
      82             :     }
      83             :     void setStimOffsetDispersionOutDefVal(double defVal) {
      84             :         stimOffsetDispersionOutDVal = defVal;
      85             :     }
      86         320 :     double getStimDivisorIn() {
      87         320 :         std::string key = getKeyPrefix() + "_STIM_DIVISOR_IN";
      88         640 :         return getDouble(key, stimDivInDVal);
      89             :     }
      90             : 
      91             :     void setStimDivisorInDefVal(double defVal) {
      92             :         stimDivInDVal = defVal;
      93             :     }
      94             : 
      95         320 :     double getStimDivisorOut() {
      96         320 :         std::string key = getKeyPrefix() + "_STIM_DIVISOR_OUT";
      97         640 :         return getDouble(key, stimDivOutDVal);
      98             :     }
      99             : 
     100             :     void setStimDivisorOutDefVal(double defVal) {
     101             :         stimDivOutDVal = defVal;
     102             :     }
     103             : 
     104         160 :     double getStimDivisorDispersionIn() {
     105         160 :         std::string key = getKeyPrefix() + "_STIM_DIVISOR_DISPERSION_IN";
     106         320 :         return getDouble(key, stimDivDispersionInDVal);
     107             :     }
     108             : 
     109             :     void setStimDivisorDispersionInDefVal(double defVal) {
     110             :         stimDivDispersionInDVal = defVal;
     111             :     }
     112         160 :     double getStimDivisorDispersionOut() {
     113         160 :         std::string key = getKeyPrefix() + "_STIM_DIVISOR_DISPERSION_OUT";
     114         320 :         return getDouble(key, stimDivDispersionOutDVal);
     115             :     }
     116             : 
     117             :     void setStimDivisorDispersionOutDefVal(double defVal) {
     118             :         stimDivDispersionOutDVal = defVal;
     119             :     }
     120         160 :     double getStimCoxExpIn() {
     121         160 :         std::string key = getKeyPrefix() + "_STIM_COX_EXP_IN";
     122         320 :         return getDouble(key, stimCoxExpInDVal);
     123             :     }
     124             :     void setStimCoxExpInDefVal(double defVal) {
     125             :         stimCoxExpInDVal = defVal;
     126             :     }
     127         160 :     double getStimCoxExpOut() {
     128         160 :         std::string key = getKeyPrefix() + "_STIM_COX_EXP_OUT";
     129         320 :         return getDouble(key, stimCoxExpOutDVal);
     130             :     }
     131             :     void setStimCoxExpOutDefVal(double defVal) {
     132             :         stimCoxExpOutDVal = defVal;
     133             :     }
     134             : 
     135         160 :     double getStimCoxExpDispersionIn() {
     136         160 :         std::string key = getKeyPrefix() + "_STIM_COX_EXP_DISPERSION_IN";
     137         320 :         return getDouble(key, stimCoxExpDispersionInDVal);
     138             :     }
     139             :     void setStimCoxExpDispersionInDefVal(double defVal) {
     140           0 :         stimCoxExpDispersionInDVal = defVal;
     141             :     }
     142         160 :     double getStimCoxExpDispersionOut() {
     143         160 :         std::string key = getKeyPrefix() + "_STIM_COX_EXP_DISPERSION_OUT";
     144         320 :         return getDouble(key, stimCoxExpDispersionOutDVal);
     145             :     }
     146             :     void setStimCoxExpDispersionOutDefVal(double defVal) {
     147           0 :         stimCoxExpDispersionOutDVal = defVal;
     148             :     }
     149             :     std::string getMessage();
     150             :     /**
     151             :      *  @brief Computes stimulus function
     152             :      *  stimulus = cox * exp(-pow(pheroIn - offsetIn, 2)/divisor -pow(pheroOut - offsetOut, 2)/divisor);
     153             :      */
     154             :     virtual double computeDesirability(double vehInMeasure,
     155             :                                        double vehOutMeasure);
     156             : 
     157             :     virtual double computeDesirability(double vehInMeasure, double vehOutMeasure, double vehInDispersionMeasure, double vehOutDispersionMeasure);
     158             : };

Generated by: LCOV version 1.14