43 #ifdef CHECK_MEMORY_LEAKS 45 #endif // CHECK_MEMORY_LEAKS 55 #define TIMELOSS_THRESHOLD 1.0 63 const std::string&
id,
const std::string& programID,
66 const std::map<std::string, std::string>& parameter,
67 const std::string& basePath) :
83 LaneVectorVector::const_iterator i2;
84 LaneVector::const_iterator i;
88 for (i = lanes.begin(); i != lanes.end(); i++) {
110 #ifdef DEBUG_TIMELOSS_CONTROL 111 std::cout <<
"\n" <<
SIMTIME <<
" MSDelayBasedTrafficLightLogic::proposeProlongation() for TLS '" << this->
getID() <<
"'" << std::endl;
116 for (
int i = 0; i < (int) state.size(); i++) {
118 const std::vector<MSLane*>& lanes =
getLanesAt(i);
119 for (LaneVector::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
122 #ifdef DEBUG_TIMELOSS_CONTROL 125 std::cout <<
"no detector on lane '" << (*j)->getID() << std::endl;
130 const std::vector<MSE2Collector::VehicleInfo>& vehInfos = detector->
getCurrentVehicles();
132 #ifdef DEBUG_TIMELOSS_CONTROL 133 std::cout <<
"Number of current vehicles on detector: " << vehInfos.size() << std::endl;
136 for (std::vector<MSE2Collector::VehicleInfo>::const_iterator iv = vehInfos.begin(); iv != vehInfos.end(); ++iv) {
138 SUMOReal estimatedTimeToJunction = ((*j)->getLength() - iv->position) / (*j)->getSpeedLimit();
139 prolongationTime =
MAX2(prolongationTime, estimatedTimeToJunction);
140 #ifdef DEBUG_TIMELOSS_CONTROL 141 std::cout <<
"vehicle '" << iv->id <<
"' with accumulated timeloss: " << iv->accumulatedTimeLoss
142 <<
"\nestimated passing time: " << estimatedTimeToJunction << std::endl;
144 std::cout <<
"disregarded: (vehicle '" << iv->id <<
"' with accumulated timeloss " << iv->accumulatedTimeLoss <<
")" << std::endl;
151 #ifdef DEBUG_TIMELOSS_CONTROL 152 std::cout <<
"Proposed prolongation (maximal estimated passing time): " << prolongationTime << std::endl;
165 #ifdef DEBUG_TIMELOSS_CONTROL 166 std::cout <<
"last switch = " << currentPhase.
myLastSwitch 167 <<
"\nactDuration = " << actDuration << std::endl;
177 #ifdef DEBUG_TIMELOSS_CONTROL 178 std::cout <<
"Proposed prolongation = " << proposedProlongation << std::endl;
181 prolong = proposedProlongation > 0;
185 return proposedProlongation;
The link has green light, may pass.
~MSDelayBasedTrafficLightLogic()
Destructor.
Builds detectors for microsim.
const std::string & getState() const
Returns the state within this phase.
const LaneVector & getLanesAt(int i) const
Returns the list of lanes that are controlled by the signals at the given position.
An areal (along a single lane) detector.
std::string myProgramID
The id of the logic.
static SUMOReal _2SUMOReal(const E *const data)
converts a char-type array into the SUMOReal value described by it
static bool _2bool(const E *const data)
converts a 0-terminated char-type array into the boolean value described by it
The link has green light, has to brake.
SUMOReal getLength() const
Returns the lane's length.
Phases myPhases
The list of phases this logic uses.
int myStep
The current step.
SUMOTime trySwitch()
Switches to the next phase, if possible.
#define TIMELOSS_THRESHOLD
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
A fixed traffic light logic.
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index...
A class that stores and controls tls and switching of their programs.
MSDelayBasedTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const MSSimpleTrafficLightLogic::Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > ¶meter, const std::string &basePath)
Constructor.
const std::string & getID() const
Returns the id.
std::string myFile
The output file for generated detectors.
SUMOTime myLastSwitch
Stores the timestep of the last on-switched of the phase.
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
LaneDetectorMap myLaneDetectors
A map from lanes to the corresponding lane detectors.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
bool isGreenPhase() const
Returns whether this phase is a pure "green" phase.
SUMOTime proposeProlongation()
The returned, proposed prolongation for the green phase is oriented on the largest estimated passing ...
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime splInterval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
MSDetectorControl & getDetectorControl()
Returns the detector control.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
std::string myID
The name of the object.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
SUMOTime maxDuration
The maximum duration of the phase.
std::string myVehicleTypes
Whether detector output separates by vType.
static std::string checkForRelativity(const std::string &filename, const std::string &basePath)
Returns the path from a configuration so that it is accessable from the current working directory...
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
virtual MSE2Collector * createSingleLaneE2Detector(const std::string &id, DetectorUsage usage, MSLane *lane, SUMOReal pos, SUMOReal length, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, const std::string &vTypes)
Creates an instance of an e2 detector using the given values.
SUMOTime minDuration
The minimum duration of the phase.
void init(NLDetectorBuilder &nb)
Initializes the tls with information about incoming lanes.
const std::vector< VehicleInfo > & getCurrentVehicles() const
Returns the vehicles within the area.
bool myShowDetectors
Whether the detectors shall be shown in the GUI.
SUMOTime myFreq
The frequency for aggregating detector output.
The definition of a single phase of a tls logic.
Representation of a lane in the micro simulation.