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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // The class for Swarm-based low-level policy
19 /****************************************************************************/
20 
21 #include "MSSOTLPolicy5DStimulus.h"
22 
24  const std::map<std::string, std::string>& parameters) :
25  MSSOTLPolicyDesirability(keyPrefix, parameters) {
26 
27  stimCoxDVal = 1;
28  stimOffsetInDVal = 1;
32  stimDivInDVal = 1;
33  stimDivOutDVal = 1;
36  stimCoxExpInDVal = 0;
40 }
41 
42 double MSSOTLPolicy5DStimulus::computeDesirability(double vehInMeasure, double vehOutMeasure, double vehInDispersionMeasure, double vehOutDispersionMeasure) {
43  DBG(
44  std::ostringstream str;
45  str << "cox=" << getStimCox() << ", cox_exp_in=" << getStimCoxExpIn() << ", cox_exp_out=" << getStimCoxExpOut()
46  << ", off_in=" << getStimOffsetIn() << ", off_out=" << getStimOffsetOut() << ", div_in=" << getStimDivisorIn() << ", div_out=" << getStimDivisorOut(); WRITE_MESSAGE(str.str());)
47 
48  // it seems to be not enough, a strange segmentation fault appears...
49  // if((getStimCoxExpIn()!=0.0 && getStimDivisorIn()==0.0)||(getStimCoxExpOut()!=0.0 && getStimDivisorOut()==0.0)){
50  if (getStimDivisorIn() == 0 || getStimDivisorOut() == 0) {
51  std::ostringstream errorMessage;
52  errorMessage << "INCORRECT VALUES" << "\nStimCoxExpIn="
53  << getStimCoxExpIn() << ", StimDivisorIn=" << getStimDivisorIn()
54  << ", StimCoxExpOut=" << getStimCoxExpOut()
55  << ", StimDivisorOut=" << getStimDivisorOut();
56  WRITE_ERROR(errorMessage.str());
57  assert(-1);
58  return -1;
59  } else {
60  double stimulus = getStimCox()
61  * exp(
63  * pow(vehInMeasure - getStimOffsetIn(), 2)
66  * pow(vehOutMeasure - getStimOffsetOut(), 2)
69  * pow(vehInDispersionMeasure - getStimOffsetDispersionIn(), 2)
72  * pow(vehOutDispersionMeasure - getStimOffsetDispersionOut(), 2)
74 
75  );
76  return stimulus;
77  }
78 }
79 
80 double MSSOTLPolicy5DStimulus::computeDesirability(double vehInMeasure, double vehOutMeasure) {
81 
82  return computeDesirability(vehInMeasure, vehOutMeasure, 0, 0);
83 }
85  std::ostringstream _str;
86  _str << " stimCox " << getStimCox()
87  << " StimOffsetIn " << getStimOffsetIn()
88  << " StimOffsetOut " << getStimOffsetOut()
89  << " StimDivisorIn " << getStimDivisorIn()
90  << " StimDivisorOut " << getStimDivisorOut()
91  << " StimCoxExpIn " << getStimCoxExpIn()
92  << " StimCoxExpOut " << getStimCoxExpOut()
93  << " .";
94  return _str.str();
95 }
#define DBG(X)
Definition: SwarmDebug.h:29
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:200
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...