SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSSOTLPlatoonPolicy.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // The class for SOTL Platoon logics
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright 2001-2009 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 "MSSOTLPlatoonPolicy.h"
23 
24 
25 MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(const std::map<std::string, std::string>& parameters) :
26  MSSOTLPolicy("Platoon", parameters) {
27  init();
28 }
29 
31  MSSOTLPolicy("Platoon", desirabilityAlgorithm) {
33  init();
34 }
35 
37  const std::map<std::string, std::string>& parameters) :
38  MSSOTLPolicy("Platoon", desirabilityAlgorithm, parameters) {
40  init();
41 }
42 
43 bool MSSOTLPlatoonPolicy::canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed,
44  const MSPhaseDefinition* stage, int vehicleCount) {
45 // DBG(std::ostringstream str; str << "invoked MSTLPlatoonPolicy::canRelease()"; WRITE_MESSAGE(str.str()););
46  DBG(
47  std::ostringstream str;
48  str << "MSSOTLPlatoonPolicy::canRelease elapsed " << elapsed << " threshold " << thresholdPassed << " pushbutton " << pushButtonPressed << " vcount " << vehicleCount
49  << " minD " << stage->minDuration << " maxD " << stage->maxDuration; str << " will return " << ((thresholdPassed && ((vehicleCount == 0) || (elapsed >= stage->maxDuration))) ? "true" : "false");
50  WRITE_MESSAGE(str.str());
51  );
52  if (elapsed >= stage->minDuration) {
53  if (pushButtonLogic(elapsed, pushButtonPressed, stage)) {
54  return true;
55  }
56  if (thresholdPassed) {
57  //If there are no other vehicles approaching green lights
58  //or the declared maximum duration has been reached
59  return ((vehicleCount == 0) || (elapsed >= stage->maxDuration));
60  } else {
61  if (sigmoidLogic(elapsed, stage, vehicleCount)) {
62  return true;
63  }
64  }
65  }
66  return false;
67 }
68 
70  SigmoidLogic::init("MSSOTLPlatoonPolicy", this);
71  PushButtonLogic::init("MSSOTLPlatoonPolicy", this);
72 }
long long int SUMOTime
Definition: SUMOTime.h:43
void init(std::string prefix, const Parameterised *parameterised)
bool pushButtonLogic(SUMOTime elapsed, bool pushButtonPressed, const MSPhaseDefinition *stage)
bool sigmoidLogic(SUMOTime elapsed, const MSPhaseDefinition *stage, int vehicleCount)
MSSOTLPolicyDesirability * getDesirabilityAlgorithm()
Definition: MSSOTLPolicy.h:128
bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)
void setKeyPrefix(std::string val)
#define DBG(X)
Definition: SwarmDebug.h:30
void init(std::string prefix, const Parameterised *parameterised)
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
SUMOTime maxDuration
The maximum duration of the phase.
Class for a low-level policy.
Definition: MSSOTLPolicy.h:72
SUMOTime minDuration
The minimum duration of the phase.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
The definition of a single phase of a tls logic.
MSSOTLPlatoonPolicy(const std::map< std::string, std::string > &parameters)