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 }
long long int SUMOTime
Definition: SUMOTime.h:35
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:121
bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)
void setKeyPrefix(std::string val)
#define DBG(X)
Definition: SwarmDebug.h:27
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:65
SUMOTime minDuration
The minimum duration of the phase.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:240
The definition of a single phase of a tls logic.
MSSOTLPlatoonPolicy(const std::map< std::string, std::string > &parameters)