Eclipse 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-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 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 }
MSSOTLPolicy
Class for a low-level policy.
Definition: MSSOTLPolicy.h:65
MSPhaseDefinition::isTransient
bool isTransient() const
Definition: MSPhaseDefinition.h:279
MSSOTLPolicyDesirability::setKeyPrefix
void setKeyPrefix(std::string val)
Definition: MSSOTLPolicyDesirability.h:59
MSSOTLCongestionPolicy::decideNextPhase
int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
Definition: MSSOTLCongestionPolicy.cpp:40
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSSOTLPolicy::getDesirabilityAlgorithm
MSSOTLPolicyDesirability * getDesirabilityAlgorithm()
Definition: MSSOTLPolicy.h:121
MSPhaseDefinition::isDecisional
bool isDecisional() const
Definition: MSPhaseDefinition.h:286
MSPhaseDefinition::isCommit
bool isCommit() const
Definition: MSPhaseDefinition.h:293
MSSOTLCongestionPolicy::canRelease
bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)
Definition: MSSOTLCongestionPolicy.cpp:62
MSSOTLCongestionPolicy::MSSOTLCongestionPolicy
MSSOTLCongestionPolicy(const std::map< std::string, std::string > &parameters)
Definition: MSSOTLCongestionPolicy.cpp:21
MSSOTLCongestionPolicy.h
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
MSPhaseDefinition::minDuration
SUMOTime minDuration
The minimum duration of the phase.
Definition: MSPhaseDefinition.h:77