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.org/sumo
3 // Copyright (C) 2013-2020 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 
25  const std::map<std::string, std::string>& parameters) :
26  MSSOTLPolicyDesirability(keyPrefix, parameters) {
27 
28  stimCoxDVal = 1;
29  stimOffsetInDVal = 1;
33  stimDivInDVal = 1;
34  stimDivOutDVal = 1;
37  stimCoxExpInDVal = 0;
41 }
42 
43 double MSSOTLPolicy5DStimulus::computeDesirability(double vehInMeasure, double vehOutMeasure, double vehInDispersionMeasure, double vehOutDispersionMeasure) {
44  DBG(
45  std::ostringstream str;
46  str << "cox=" << getStimCox() << ", cox_exp_in=" << getStimCoxExpIn() << ", cox_exp_out=" << getStimCoxExpOut()
47  << ", off_in=" << getStimOffsetIn() << ", off_out=" << getStimOffsetOut() << ", div_in=" << getStimDivisorIn() << ", div_out=" << getStimDivisorOut(); WRITE_MESSAGE(str.str());)
48 
49  // it seems to be not enough, a strange segmentation fault appears...
50  // if((getStimCoxExpIn()!=0.0 && getStimDivisorIn()==0.0)||(getStimCoxExpOut()!=0.0 && getStimDivisorOut()==0.0)){
51  if (getStimDivisorIn() == 0 || getStimDivisorOut() == 0) {
52  std::ostringstream errorMessage;
53  errorMessage << "INCORRECT VALUES" << "\nStimCoxExpIn="
54  << getStimCoxExpIn() << ", StimDivisorIn=" << getStimDivisorIn()
55  << ", StimCoxExpOut=" << getStimCoxExpOut()
56  << ", StimDivisorOut=" << getStimDivisorOut();
57  WRITE_ERROR(errorMessage.str());
58  assert(-1);
59  return -1;
60  } else {
61  double stimulus = getStimCox()
62  * exp(
64  * pow(vehInMeasure - getStimOffsetIn(), 2)
67  * pow(vehOutMeasure - getStimOffsetOut(), 2)
70  * pow(vehInDispersionMeasure - getStimOffsetDispersionIn(), 2)
73  * pow(vehOutDispersionMeasure - getStimOffsetDispersionOut(), 2)
75 
76  );
77  return stimulus;
78  }
79 }
80 
81 double MSSOTLPolicy5DStimulus::computeDesirability(double vehInMeasure, double vehOutMeasure) {
82 
83  return computeDesirability(vehInMeasure, vehOutMeasure, 0, 0);
84 }
86  std::ostringstream _str;
87  _str << " stimCox " << getStimCox()
88  << " StimOffsetIn " << getStimOffsetIn()
89  << " StimOffsetOut " << getStimOffsetOut()
90  << " StimDivisorIn " << getStimDivisorIn()
91  << " StimDivisorOut " << getStimDivisorOut()
92  << " StimCoxExpIn " << getStimCoxExpIn()
93  << " StimCoxExpOut " << getStimCoxExpOut()
94  << " .";
95  return _str.str();
96 }
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
#define DBG(X)
Definition: SwarmDebug.h:30
MSSOTLPolicy5DStimulus(std::string keyPrefix, const std::map< std::string, std::string > &parameters)
virtual double computeDesirability(double vehInMeasure, double vehOutMeasure)
Computes stimulus function stimulus = cox * exp(-pow(pheroIn - offsetIn, 2)/divisor -pow(pheroOut - o...
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...