SUMO - Simulation of Urban MObility
MSSOTLCongestionPolicy.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2014-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 Congestion logics
19 /****************************************************************************/
20 
21 #include "MSSOTLCongestionPolicy.h"
22 
24  const std::map<std::string, std::string>& parameters) :
25  MSSOTLPolicy("Congestion", parameters) {
26 }
27 
29  MSSOTLPolicyDesirability* desirabilityAlgorithm) :
30  MSSOTLPolicy("Congestion", desirabilityAlgorithm) {
31  getDesirabilityAlgorithm()->setKeyPrefix("CONGESTION");
32 }
33 
35  MSSOTLPolicyDesirability* desirabilityAlgorithm,
36  const std::map<std::string, std::string>& parameters) :
37  MSSOTLPolicy("Congestion", desirabilityAlgorithm, parameters) {
38  getDesirabilityAlgorithm()->setKeyPrefix("CONGESTION");
39 
40 }
41 
43  const MSPhaseDefinition* stage, int currentPhaseIndex,
44  int /* phaseMaxCTS */, bool thresholdPassed, bool pushButtonPressed, int vehicleCount) {
45  if (stage->isCommit()) {
46  // decide which chain to activate. Gotta work on this
47  return currentPhaseIndex;
48  }
49  if (stage->isTransient()) {
50  //If the junction was in a transient step
51  //=> go to the next step and return computeReturnTime()
52  return currentPhaseIndex + 1;
53  }
54 
55  if (stage->isDecisional()) {
56  if (canRelease(elapsed, thresholdPassed, pushButtonPressed, stage, vehicleCount)) {
57  return currentPhaseIndex + 1;
58  }
59  }
60 
61  return currentPhaseIndex;
62 }
63 
64 bool MSSOTLCongestionPolicy::canRelease(SUMOTime elapsed, bool /* thresholdPassed */, bool /* pushButtonPressed */,
65  const MSPhaseDefinition* stage, int /* vehicleCount */) {
66  return (elapsed >= stage->minDuration);
67 }
int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
MSSOTLCongestionPolicy(const std::map< std::string, std::string > &parameters)
bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)
MSSOTLPolicyDesirability * getDesirabilityAlgorithm()
Definition: MSSOTLPolicy.h:127
bool isTransient() const
void setKeyPrefix(std::string val)
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
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
The definition of a single phase of a tls logic.
bool isDecisional() const