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-2018 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 Congestion logics
17 /****************************************************************************/
18 
19 #include "MSSOTLCongestionPolicy.h"
20 
22  const std::map<std::string, std::string>& parameters) :
23  MSSOTLPolicy("Congestion", parameters) {
24 }
25 
27  MSSOTLPolicyDesirability* desirabilityAlgorithm) :
28  MSSOTLPolicy("Congestion", desirabilityAlgorithm) {
29  getDesirabilityAlgorithm()->setKeyPrefix("CONGESTION");
30 }
31 
33  MSSOTLPolicyDesirability* desirabilityAlgorithm,
34  const std::map<std::string, std::string>& parameters) :
35  MSSOTLPolicy("Congestion", desirabilityAlgorithm, parameters) {
36  getDesirabilityAlgorithm()->setKeyPrefix("CONGESTION");
37 
38 }
39 
41  const MSPhaseDefinition* stage, int currentPhaseIndex,
42  int /* phaseMaxCTS */, bool thresholdPassed, bool pushButtonPressed, int vehicleCount) {
43  if (stage->isCommit()) {
44  // decide which chain to activate. Gotta work on this
45  return currentPhaseIndex;
46  }
47  if (stage->isTransient()) {
48  //If the junction was in a transient step
49  //=> go to the next step and return computeReturnTime()
50  return currentPhaseIndex + 1;
51  }
52 
53  if (stage->isDecisional()) {
54  if (canRelease(elapsed, thresholdPassed, pushButtonPressed, stage, vehicleCount)) {
55  return currentPhaseIndex + 1;
56  }
57  }
58 
59  return currentPhaseIndex;
60 }
61 
62 bool MSSOTLCongestionPolicy::canRelease(SUMOTime elapsed, bool /* thresholdPassed */, bool /* pushButtonPressed */,
63  const MSPhaseDefinition* stage, int /* vehicleCount */) {
64  return (elapsed >= stage->minDuration);
65 }
long long int SUMOTime
Definition: SUMOTime.h:36
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:121
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:65
SUMOTime minDuration
The minimum duration of the phase.
The definition of a single phase of a tls logic.
bool isDecisional() const