SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSSOTLPolicy5DStimulus.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // The class for Swarm-based low-level policy
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright 2001-2013 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
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 SUMOReal MSSOTLPolicy5DStimulus::computeDesirability(SUMOReal vehInMeasure, SUMOReal vehOutMeasure, SUMOReal vehInDispersionMeasure, SUMOReal 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  SUMOReal 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 
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 DBG(X)
Definition: SwarmDebug.h:30
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
virtual SUMOReal computeDesirability(SUMOReal vehInMeasure, SUMOReal vehOutMeasure)
Computes stimulus function stimulus = cox * exp(-pow(pheroIn - offsetIn, 2)/divisor -pow(pheroOut - o...
#define SUMOReal
Definition: config.h:214
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
MSSOTLPolicy5DStimulus(std::string keyPrefix, const std::map< std::string, std::string > &parameters)