SUMO - Simulation of Urban MObility
MSSOTLPlatoonPolicy.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2010-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 SOTL Platoon logics
19 /****************************************************************************/
20 
21 #include "MSSOTLPlatoonPolicy.h"
22 
23 
24 MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(const std::map<std::string, std::string>& parameters) :
25  MSSOTLPolicy("Platoon", parameters) {
26  init();
27 }
28 
30  MSSOTLPolicy("Platoon", desirabilityAlgorithm) {
32  init();
33 }
34 
36  const std::map<std::string, std::string>& parameters) :
37  MSSOTLPolicy("Platoon", desirabilityAlgorithm, parameters) {
39  init();
40 }
41 
42 bool MSSOTLPlatoonPolicy::canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed,
43  const MSPhaseDefinition* stage, int vehicleCount) {
44 // DBG(std::ostringstream str; str << "invoked MSTLPlatoonPolicy::canRelease()"; WRITE_MESSAGE(str.str()););
45  DBG(
46  std::ostringstream str;
47  str << "MSSOTLPlatoonPolicy::canRelease elapsed " << elapsed << " threshold " << thresholdPassed << " pushbutton " << pushButtonPressed << " vcount " << vehicleCount
48  << " minD " << stage->minDuration << " maxD " << stage->maxDuration; str << " will return " << ((thresholdPassed && ((vehicleCount == 0) || (elapsed >= stage->maxDuration))) ? "true" : "false");
49  WRITE_MESSAGE(str.str());
50  );
51  if (elapsed >= stage->minDuration) {
52  if (pushButtonLogic(elapsed, pushButtonPressed, stage)) {
53  return true;
54  }
55  if (thresholdPassed) {
56  //If there are no other vehicles approaching green lights
57  //or the declared maximum duration has been reached
58  return ((vehicleCount == 0) || (elapsed >= stage->maxDuration));
59  } else {
60  if (sigmoidLogic(elapsed, stage, vehicleCount)) {
61  return true;
62  }
63  }
64  }
65  return false;
66 }
67 
69  SigmoidLogic::init("MSSOTLPlatoonPolicy", this);
70  PushButtonLogic::init("MSSOTLPlatoonPolicy", this);
71 }
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:127
bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)
void setKeyPrefix(std::string val)
#define DBG(X)
Definition: SwarmDebug.h:29
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:71
SUMOTime minDuration
The minimum duration of the phase.
long long int SUMOTime
Definition: TraCIDefs.h:51
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:200
The definition of a single phase of a tls logic.
MSSOTLPlatoonPolicy(const std::map< std::string, std::string > &parameters)