SUMO - Simulation of Urban MObility
MSSOTLPhasePolicy.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // The class for SOTL Phase logics
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2010-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 #include "MSSOTLPhasePolicy.h"
23 #include <math.h>
25 
26 
27 MSSOTLPhasePolicy::MSSOTLPhasePolicy(const std::map<std::string, std::string>& parameters) :
28  MSSOTLPolicy("Phase", parameters) {
29  init();
30 }
31 
33  MSSOTLPolicy("Phase", desirabilityAlgorithm) {
35  init();
36 }
37 
39  const std::map<std::string, std::string>& parameters) :
40  MSSOTLPolicy("Phase", desirabilityAlgorithm, parameters) {
42  init();
43 }
44 
45 bool MSSOTLPhasePolicy::canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed,
46  const MSPhaseDefinition* stage, int vehicleCount) {
47 // DBG(
48  std::ostringstream str;
49  str << "MSSOTLPhasePolicy::canRelease threshold " << thresholdPassed << " vehicle " << vehicleCount << " elapsed " << elapsed << " min " << stage->minDuration;
50  WRITE_MESSAGE(str.str());
51 // );
52  if (elapsed >= stage->minDuration) {
53  if (pushButtonLogic(elapsed, pushButtonPressed, stage)) {
54  return true;
55  }
56  if (thresholdPassed) {
57  return thresholdPassed;
58  } else if (m_useVehicleTypesWeights) {
59  if (sigmoidLogic(elapsed, stage, vehicleCount)) {
60  return true;
61  }
62  }
63  }
64  return false;
65 }
66 
68  PushButtonLogic::init("MSSOTLPhasePolicy", this);
69  SigmoidLogic::init("MSSOTLPhasePolicy", this);
70  m_useVehicleTypesWeights = getParameter("USE_VEHICLE_TYPES_WEIGHTS", "0") == "1";
71 }
MSSOTLPhasePolicy(const std::map< std::string, std::string > &parameters)
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:128
void setKeyPrefix(std::string val)
void init(std::string prefix, const Parameterised *parameterised)
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
Class for a low-level policy.
Definition: MSSOTLPolicy.h:72
SUMOTime minDuration
The minimum duration of the phase.
long long int SUMOTime
Definition: TraCIDefs.h:52
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
The definition of a single phase of a tls logic.
bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)