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 80 : double getStimCox() {
50 80 : std::string key = getKeyPrefix() + "_STIM_COX";
51 160 : return getDouble(key, stimCoxDVal);
52 : }
53 : void setStimCoxDefVal(double defVal) {
54 : stimCoxDVal = defVal;
55 : }
56 80 : double getStimOffsetIn() {
57 80 : std::string key = getKeyPrefix() + "_STIM_OFFSET_IN";
58 160 : return getDouble(key, stimOffsetInDVal);
59 : }
60 : void setStimOffsetInDefVal(double defVal) {
61 : stimOffsetInDVal = defVal;
62 : }
63 80 : double getStimOffsetOut() {
64 80 : std::string key = getKeyPrefix() + "_STIM_OFFSET_OUT";
65 160 : return getDouble(key, stimOffsetOutDVal);
66 : }
67 :
68 : void setStimOffsetOutDefVal(double defVal) {
69 : stimOffsetOutDVal = defVal;
70 : }
71 :
72 80 : double getStimOffsetDispersionIn() {
73 80 : std::string key = getKeyPrefix() + "_STIM_OFFSET_DISPERSION_IN";
74 160 : return getDouble(key, stimOffsetDispersionInDVal);
75 : }
76 : void setStimOffsetDispersionInDefVal(double defVal) {
77 : stimOffsetDispersionInDVal = defVal;
78 : }
79 80 : double getStimOffsetDispersionOut() {
80 80 : std::string key = getKeyPrefix() + "_STIM_OFFSET_DISPERSION_OUT";
81 160 : return getDouble(key, stimOffsetDispersionOutDVal);
82 : }
83 : void setStimOffsetDispersionOutDefVal(double defVal) {
84 : stimOffsetDispersionOutDVal = defVal;
85 : }
86 160 : double getStimDivisorIn() {
87 160 : std::string key = getKeyPrefix() + "_STIM_DIVISOR_IN";
88 320 : return getDouble(key, stimDivInDVal);
89 : }
90 :
91 : void setStimDivisorInDefVal(double defVal) {
92 : stimDivInDVal = defVal;
93 : }
94 :
95 160 : double getStimDivisorOut() {
96 160 : std::string key = getKeyPrefix() + "_STIM_DIVISOR_OUT";
97 320 : return getDouble(key, stimDivOutDVal);
98 : }
99 :
100 : void setStimDivisorOutDefVal(double defVal) {
101 : stimDivOutDVal = defVal;
102 : }
103 :
104 80 : double getStimDivisorDispersionIn() {
105 80 : std::string key = getKeyPrefix() + "_STIM_DIVISOR_DISPERSION_IN";
106 160 : return getDouble(key, stimDivDispersionInDVal);
107 : }
108 :
109 : void setStimDivisorDispersionInDefVal(double defVal) {
110 : stimDivDispersionInDVal = defVal;
111 : }
112 80 : double getStimDivisorDispersionOut() {
113 80 : std::string key = getKeyPrefix() + "_STIM_DIVISOR_DISPERSION_OUT";
114 160 : return getDouble(key, stimDivDispersionOutDVal);
115 : }
116 :
117 : void setStimDivisorDispersionOutDefVal(double defVal) {
118 : stimDivDispersionOutDVal = defVal;
119 : }
120 80 : double getStimCoxExpIn() {
121 80 : std::string key = getKeyPrefix() + "_STIM_COX_EXP_IN";
122 160 : return getDouble(key, stimCoxExpInDVal);
123 : }
124 : void setStimCoxExpInDefVal(double defVal) {
125 : stimCoxExpInDVal = defVal;
126 : }
127 80 : double getStimCoxExpOut() {
128 80 : std::string key = getKeyPrefix() + "_STIM_COX_EXP_OUT";
129 160 : return getDouble(key, stimCoxExpOutDVal);
130 : }
131 : void setStimCoxExpOutDefVal(double defVal) {
132 : stimCoxExpOutDVal = defVal;
133 : }
134 :
135 80 : double getStimCoxExpDispersionIn() {
136 80 : std::string key = getKeyPrefix() + "_STIM_COX_EXP_DISPERSION_IN";
137 160 : return getDouble(key, stimCoxExpDispersionInDVal);
138 : }
139 : void setStimCoxExpDispersionInDefVal(double defVal) {
140 0 : stimCoxExpDispersionInDVal = defVal;
141 : }
142 80 : double getStimCoxExpDispersionOut() {
143 80 : std::string key = getKeyPrefix() + "_STIM_COX_EXP_DISPERSION_OUT";
144 160 : 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 : };
|