Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // The class for SOTL Platoon logics
16 /****************************************************************************/
17 
18 #include "MSSOTLPlatoonPolicy.h"
19 
20 
21 MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(const std::map<std::string, std::string>& parameters) :
22  MSSOTLPolicy("Platoon", parameters) {
23  init();
24 }
25 
27  MSSOTLPolicy("Platoon", desirabilityAlgorithm) {
29  init();
30 }
31 
33  const std::map<std::string, std::string>& parameters) :
34  MSSOTLPolicy("Platoon", desirabilityAlgorithm, parameters) {
36  init();
37 }
38 
39 bool MSSOTLPlatoonPolicy::canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed,
40  const MSPhaseDefinition* stage, int vehicleCount) {
41 // DBG(std::ostringstream str; str << "invoked MSTLPlatoonPolicy::canRelease()"; WRITE_MESSAGE(str.str()););
42  DBG(
43  std::ostringstream str;
44  str << "MSSOTLPlatoonPolicy::canRelease elapsed " << elapsed << " threshold " << thresholdPassed << " pushbutton " << pushButtonPressed << " vcount " << vehicleCount
45  << " minD " << stage->minDuration << " maxD " << stage->maxDuration; str << " will return " << ((thresholdPassed && ((vehicleCount == 0) || (elapsed >= stage->maxDuration))) ? "true" : "false");
46  WRITE_MESSAGE(str.str());
47  );
48  if (elapsed >= stage->minDuration) {
49  if (pushButtonLogic(elapsed, pushButtonPressed, stage)) {
50  return true;
51  }
52  if (thresholdPassed) {
53  //If there are no other vehicles approaching green lights
54  //or the declared maximum duration has been reached
55  return ((vehicleCount == 0) || (elapsed >= stage->maxDuration));
56  } else {
57  if (sigmoidLogic(elapsed, stage, vehicleCount)) {
58  return true;
59  }
60  }
61  }
62  return false;
63 }
64 
66  SigmoidLogic::init("MSSOTLPlatoonPolicy", this);
67  PushButtonLogic::init("MSSOTLPlatoonPolicy", this);
68 }
MSSOTLPolicy
Class for a low-level policy.
Definition: MSSOTLPolicy.h:64
SigmoidLogic::init
void init(std::string prefix, const Parameterised *parameterised)
Definition: MSSOTLPolicy.cpp:44
MSSOTLPlatoonPolicy.h
SigmoidLogic::sigmoidLogic
bool sigmoidLogic(SUMOTime elapsed, const MSPhaseDefinition *stage, int vehicleCount)
Definition: MSSOTLPolicy.cpp:60
MSSOTLPolicyDesirability::setKeyPrefix
void setKeyPrefix(std::string val)
Definition: MSSOTLPolicyDesirability.h:58
DBG
#define DBG(X)
Definition: SwarmDebug.h:26
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
PushButtonLogic::init
void init(std::string prefix, const Parameterised *parameterised)
Definition: MSSOTLPolicy.cpp:24
MSPhaseDefinition::maxDuration
SUMOTime maxDuration
The maximum duration of the phase.
Definition: MSPhaseDefinition.h:79
MSSOTLPolicy::getDesirabilityAlgorithm
MSSOTLPolicyDesirability * getDesirabilityAlgorithm()
Definition: MSSOTLPolicy.h:120
MSSOTLPlatoonPolicy::init
void init()
Definition: MSSOTLPlatoonPolicy.cpp:65
MSSOTLPlatoonPolicy::canRelease
bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)
Definition: MSSOTLPlatoonPolicy.cpp:39
PushButtonLogic::pushButtonLogic
bool pushButtonLogic(SUMOTime elapsed, bool pushButtonPressed, const MSPhaseDefinition *stage)
Definition: MSSOTLPolicy.cpp:30
MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy
MSSOTLPlatoonPolicy(const std::map< std::string, std::string > &parameters)
Definition: MSSOTLPlatoonPolicy.cpp:21
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:51
MSSOTLPolicyDesirability
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
Definition: MSSOTLPolicyDesirability.h:35
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
MSPhaseDefinition::minDuration
SUMOTime minDuration
The minimum duration of the phase.
Definition: MSPhaseDefinition.h:76