Eclipse SUMO - Simulation of Urban MObility
MSSOTLPolicy5DStimulus.cpp
Go to the documentation of this file.
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 /****************************************************************************/
19 // The class for Swarm-based low-level policy
20 /****************************************************************************/
21 
22 #include "MSSOTLPolicy5DStimulus.h"
23 //#define SWARM_DEBUG
24 
25 
26 // ===========================================================================
27 // method definitions
28 // ===========================================================================
30  const Parameterised::Map& parameters) :
31  MSSOTLPolicyDesirability(keyPrefix, parameters) {
32 
33  stimCoxDVal = 1;
34  stimOffsetInDVal = 1;
38  stimDivInDVal = 1;
39  stimDivOutDVal = 1;
42  stimCoxExpInDVal = 0;
46 }
47 
48 double MSSOTLPolicy5DStimulus::computeDesirability(double vehInMeasure, double vehOutMeasure, double vehInDispersionMeasure, double vehOutDispersionMeasure) {
49 #ifdef SWARM_DEBUG
50  std::ostringstream str;
51  str << "cox=" << getStimCox() << ", cox_exp_in=" << getStimCoxExpIn() << ", cox_exp_out=" << getStimCoxExpOut()
52  << ", off_in=" << getStimOffsetIn() << ", off_out=" << getStimOffsetOut() << ", div_in=" << getStimDivisorIn() << ", div_out=" << getStimDivisorOut();
53  WRITE_MESSAGE(str.str());
54 #endif
55  // it seems to be not enough, a strange segmentation fault appears...
56  // if((getStimCoxExpIn()!=0.0 && getStimDivisorIn()==0.0)||(getStimCoxExpOut()!=0.0 && getStimDivisorOut()==0.0)){
57  if (getStimDivisorIn() == 0 || getStimDivisorOut() == 0) {
58  std::ostringstream errorMessage;
59  errorMessage << "INCORRECT VALUES" << "\nStimCoxExpIn="
60  << getStimCoxExpIn() << ", StimDivisorIn=" << getStimDivisorIn()
61  << ", StimCoxExpOut=" << getStimCoxExpOut()
62  << ", StimDivisorOut=" << getStimDivisorOut();
63  WRITE_ERROR(errorMessage.str());
64  assert(-1);
65  return -1;
66  } else {
67  double stimulus = getStimCox()
68  * exp(
70  * pow(vehInMeasure - getStimOffsetIn(), 2)
73  * pow(vehOutMeasure - getStimOffsetOut(), 2)
76  * pow(vehInDispersionMeasure - getStimOffsetDispersionIn(), 2)
79  * pow(vehOutDispersionMeasure - getStimOffsetDispersionOut(), 2)
81 
82  );
83  return stimulus;
84  }
85 }
86 
87 double MSSOTLPolicy5DStimulus::computeDesirability(double vehInMeasure, double vehOutMeasure) {
88 
89  return computeDesirability(vehInMeasure, vehOutMeasure, 0, 0);
90 }
92  std::ostringstream _str;
93  _str << " stimCox " << getStimCox()
94  << " StimOffsetIn " << getStimOffsetIn()
95  << " StimOffsetOut " << getStimOffsetOut()
96  << " StimDivisorIn " << getStimDivisorIn()
97  << " StimDivisorOut " << getStimDivisorOut()
98  << " StimCoxExpIn " << getStimCoxExpIn()
99  << " StimCoxExpOut " << getStimCoxExpOut()
100  << " .";
101  return _str.str();
102 }
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:297
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:304
virtual double computeDesirability(double vehInMeasure, double vehOutMeasure)
Computes stimulus function stimulus = cox * exp(-pow(pheroIn - offsetIn, 2)/divisor -pow(pheroOut - o...
MSSOTLPolicy5DStimulus(std::string keyPrefix, const Parameterised::Map &parameters)
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45