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 /****************************************************************************/
15 // The class for SOTL Congestion logics
16 /****************************************************************************/
17 
18 #include "MSSOTLCongestionPolicy.h"
19 
21  const std::map<std::string, std::string>& parameters) :
22  MSSOTLPolicy("Congestion", parameters) {
23 }
24 
26  MSSOTLPolicyDesirability* desirabilityAlgorithm) :
27  MSSOTLPolicy("Congestion", desirabilityAlgorithm) {
28  getDesirabilityAlgorithm()->setKeyPrefix("CONGESTION");
29 }
30 
32  MSSOTLPolicyDesirability* desirabilityAlgorithm,
33  const std::map<std::string, std::string>& parameters) :
34  MSSOTLPolicy("Congestion", desirabilityAlgorithm, parameters) {
35  getDesirabilityAlgorithm()->setKeyPrefix("CONGESTION");
36 
37 }
38 
40  const MSPhaseDefinition* stage, int currentPhaseIndex,
41  int /* phaseMaxCTS */, bool thresholdPassed, bool pushButtonPressed, int vehicleCount) {
42  if (stage->isCommit()) {
43  // decide which chain to activate. Gotta work on this
44  return currentPhaseIndex;
45  }
46  if (stage->isTransient()) {
47  //If the junction was in a transient step
48  //=> go to the next step and return computeReturnTime()
49  return currentPhaseIndex + 1;
50  }
51 
52  if (stage->isDecisional()) {
53  if (canRelease(elapsed, thresholdPassed, pushButtonPressed, stage, vehicleCount)) {
54  return currentPhaseIndex + 1;
55  }
56  }
57 
58  return currentPhaseIndex;
59 }
60 
61 bool MSSOTLCongestionPolicy::canRelease(SUMOTime elapsed, bool /* thresholdPassed */, bool /* pushButtonPressed */,
62  const MSPhaseDefinition* stage, int /* vehicleCount */) {
63  return (elapsed >= stage->minDuration);
64 }
MSSOTLPolicy
Class for a low-level policy.
Definition: MSSOTLPolicy.h:64
MSPhaseDefinition::isTransient
bool isTransient() const
Definition: MSPhaseDefinition.h:278
MSSOTLPolicyDesirability::setKeyPrefix
void setKeyPrefix(std::string val)
Definition: MSSOTLPolicyDesirability.h:58
MSSOTLCongestionPolicy::decideNextPhase
int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
Definition: MSSOTLCongestionPolicy.cpp:39
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSSOTLPolicy::getDesirabilityAlgorithm
MSSOTLPolicyDesirability * getDesirabilityAlgorithm()
Definition: MSSOTLPolicy.h:120
MSPhaseDefinition::isDecisional
bool isDecisional() const
Definition: MSPhaseDefinition.h:285
MSPhaseDefinition::isCommit
bool isCommit() const
Definition: MSPhaseDefinition.h:292
MSSOTLCongestionPolicy::canRelease
bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)
Definition: MSSOTLCongestionPolicy.cpp:61
MSSOTLCongestionPolicy::MSSOTLCongestionPolicy
MSSOTLCongestionPolicy(const std::map< std::string, std::string > &parameters)
Definition: MSSOTLCongestionPolicy.cpp:20
MSSOTLCongestionPolicy.h
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:51
MSSOTLPolicyDesirability
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
Definition: MSSOTLPolicyDesirability.h:35
MSPhaseDefinition::minDuration
SUMOTime minDuration
The minimum duration of the phase.
Definition: MSPhaseDefinition.h:76