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 /****************************************************************************/
16 // The class for SOTL Platoon logics
17 /****************************************************************************/
18 
19 #include "MSSOTLPlatoonPolicy.h"
20 
21 
22 MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(const std::map<std::string, std::string>& parameters) :
23  MSSOTLPolicy("Platoon", parameters) {
24  init();
25 }
26 
28  MSSOTLPolicy("Platoon", desirabilityAlgorithm) {
30  init();
31 }
32 
34  const std::map<std::string, std::string>& parameters) :
35  MSSOTLPolicy("Platoon", desirabilityAlgorithm, parameters) {
37  init();
38 }
39 
40 bool MSSOTLPlatoonPolicy::canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed,
41  const MSPhaseDefinition* stage, int vehicleCount) {
42 // DBG(std::ostringstream str; str << "invoked MSTLPlatoonPolicy::canRelease()"; WRITE_MESSAGE(str.str()););
43  DBG(
44  std::ostringstream str;
45  str << "MSSOTLPlatoonPolicy::canRelease elapsed " << elapsed << " threshold " << thresholdPassed << " pushbutton " << pushButtonPressed << " vcount " << vehicleCount
46  << " minD " << stage->minDuration << " maxD " << stage->maxDuration; str << " will return " << ((thresholdPassed && ((vehicleCount == 0) || (elapsed >= stage->maxDuration))) ? "true" : "false");
47  WRITE_MESSAGE(str.str());
48  );
49  if (elapsed >= stage->minDuration) {
50  if (pushButtonLogic(elapsed, pushButtonPressed, stage)) {
51  return true;
52  }
53  if (thresholdPassed) {
54  //If there are no other vehicles approaching green lights
55  //or the declared maximum duration has been reached
56  return ((vehicleCount == 0) || (elapsed >= stage->maxDuration));
57  } else {
58  if (sigmoidLogic(elapsed, stage, vehicleCount)) {
59  return true;
60  }
61  }
62  }
63  return false;
64 }
65 
67  SigmoidLogic::init("MSSOTLPlatoonPolicy", this);
68  PushButtonLogic::init("MSSOTLPlatoonPolicy", this);
69 }
MSSOTLPolicy
Class for a low-level policy.
Definition: MSSOTLPolicy.h:65
SigmoidLogic::init
void init(std::string prefix, const Parameterised *parameterised)
Definition: MSSOTLPolicy.cpp:45
MSSOTLPlatoonPolicy.h
SigmoidLogic::sigmoidLogic
bool sigmoidLogic(SUMOTime elapsed, const MSPhaseDefinition *stage, int vehicleCount)
Definition: MSSOTLPolicy.cpp:61
MSSOTLPolicyDesirability::setKeyPrefix
void setKeyPrefix(std::string val)
Definition: MSSOTLPolicyDesirability.h:59
DBG
#define DBG(X)
Definition: SwarmDebug.h:27
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
PushButtonLogic::init
void init(std::string prefix, const Parameterised *parameterised)
Definition: MSSOTLPolicy.cpp:25
MSPhaseDefinition::maxDuration
SUMOTime maxDuration
The maximum duration of the phase.
Definition: MSPhaseDefinition.h:80
MSSOTLPolicy::getDesirabilityAlgorithm
MSSOTLPolicyDesirability * getDesirabilityAlgorithm()
Definition: MSSOTLPolicy.h:121
MSSOTLPlatoonPolicy::init
void init()
Definition: MSSOTLPlatoonPolicy.cpp:66
MSSOTLPlatoonPolicy::canRelease
bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)
Definition: MSSOTLPlatoonPolicy.cpp:40
PushButtonLogic::pushButtonLogic
bool pushButtonLogic(SUMOTime elapsed, bool pushButtonPressed, const MSPhaseDefinition *stage)
Definition: MSSOTLPolicy.cpp:31
MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy
MSSOTLPlatoonPolicy(const std::map< std::string, std::string > &parameters)
Definition: MSSOTLPlatoonPolicy.cpp:22
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:52
MSSOTLPolicyDesirability
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
Definition: MSSOTLPolicyDesirability.h:36
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:240
MSPhaseDefinition::minDuration
SUMOTime minDuration
The minimum duration of the phase.
Definition: MSPhaseDefinition.h:77