35 #define INVALID_POSITION std::numeric_limits<double>::max() 47 const std::string&
id,
const std::string& programID,
50 const std::map<std::string, std::string>& parameter,
51 const std::string& basePath) :
53 #ifdef DEBUG_TIMELOSS_CONTROL 54 std::cout <<
"Building delay based tls logic '" <<
id <<
"'" << std::endl;
62 #ifdef DEBUG_TIMELOSS_CONTROL 78 LaneVectorVector::const_iterator i2;
79 LaneVector::const_iterator i;
83 for (i = lanes.begin(); i != lanes.end(); i++) {
92 myLaneDetectors[lane] = nb.
createE2Detector(
id,
DU_TL_CONTROL, lane,
INVALID_POSITION, lane->
getLength(),
myDetectionRange, 0, 0, 0,
myVehicleTypes,
myShowDetectors);
108 #ifdef DEBUG_TIMELOSS_CONTROL 109 std::cout <<
"\n" <<
SIMTIME <<
" MSDelayBasedTrafficLightLogic::proposeProlongation() for TLS '" << this->
getID() <<
"' (current phase = " <<
myStep <<
")" << std::endl;
114 for (
int i = 0; i < (int) state.size(); i++) {
117 const std::vector<MSLane*>& lanes =
getLanesAt(i);
118 for (LaneVector::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
121 #ifdef DEBUG_TIMELOSS_CONTROL 123 std::cout <<
"no detector on lane '" << (*j)->getID() << std::endl;
128 const std::vector<MSE2Collector::VehicleInfo*> vehInfos = detector->
getCurrentVehicles();
129 #ifdef DEBUG_TIMELOSS_CONTROL 134 for (std::vector<MSE2Collector::VehicleInfo*>::const_iterator ivp = vehInfos.begin(); ivp != vehInfos.end(); ++ivp) {
138 if (actDuration + estimatedTimeToJunction <= maxDuration) {
140 prolongation =
MAX2(prolongation, estimatedTimeToJunction);
142 #ifdef DEBUG_TIMELOSS_CONTROL 146 #ifdef DEBUG_TIMELOSS_CONTROL 148 <<
"\nestimated passing time: " << estimatedTimeToJunction << std::endl;
151 std::cout <<
"disregarded: (vehicle '" << iv->
id <<
"' with accumulated timeloss " << iv->
accumulatedTimeLoss <<
")" << reason << std::endl;
157 if (vehInfos.size() > 0) {
161 #ifdef DEBUG_TIMELOSS_CONTROL 162 std::cout <<
"Actual duration exceeds maxDuration and a vehicle is on concurrent approach: " << nrVehs << std::endl;
169 #ifdef DEBUG_TIMELOSS_CONTROL 170 std::cout <<
"Number of current vehicles on detector: " << nrVehs << std::endl;
175 #ifdef DEBUG_TIMELOSS_CONTROL 176 std::cout <<
"Proposed prolongation (maximal estimated passing time): " << prolongation << std::endl;
189 #ifdef DEBUG_TIMELOSS_CONTROL 190 std::cout <<
"last switch = " << currentPhase.
myLastSwitch 191 <<
"\nactDuration = " << actDuration
198 bool othersEmpty =
true;
201 #ifdef DEBUG_TIMELOSS_CONTROL 202 std::cout <<
"othersEmpty = " << othersEmpty
207 bool prolong = othersEmpty || actDuration < currentPhase.
maxDuration;
212 proposedProlongation =
MAX2(proposedProlongation,
TIME2STEPS(1.));
218 #ifdef DEBUG_TIMELOSS_CONTROL 219 std::cout <<
"Proposed prolongation = " << proposedProlongation << std::endl;
222 prolong = proposedProlongation > 0;
226 return proposedProlongation;
The link has green light, may pass.
~MSDelayBasedTrafficLightLogic()
Destructor.
const std::string & getState() const
Returns the state within this phase.
Builds detectors for microsim.
double myTimeLossThreshold
An areal detector corresponding to a sequence of consecutive lanes.
The link has green light, has to brake.
Phases myPhases
The list of phases this logic uses.
int myStep
The current step.
SUMOTime trySwitch()
Switches to the next phase, if possible.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getLength() const
Returns the lane's length.
const std::string & getID() const
Returns the id.
std::vector< VehicleInfo * > getCurrentVehicles() const
Returns the VehicleInfos for the vehicles currently on the detector.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
A fixed traffic light logic.
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index...
const LaneVector & getLanesAt(int i) const
Returns the list of lanes that are controlled by the signals at the given position.
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter ...
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.
A VehicleInfo stores values that are tracked for the individual vehicles on the detector, e.g., accumulated timeloss. These infos are stored in myVehicles. If a vehicle leaves the detector (may it be temporarily), the entry in myVehicles is discarded, i.e. all information on the vehicle is reset.
std::string myFile
The output file for generated detectors.
SUMOTime myLastSwitch
Stores the timestep of the last on-switched of the phase.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
std::string id
vehicle's ID
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
LaneDetectorMap myLaneDetectors
A map from lanes to the corresponding lane detectors.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
SUMOTime proposeProlongation(const SUMOTime actDuration, const SUMOTime maxDuration, bool &othersEmpty)
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.
virtual MSE2Collector * createE2Detector(const std::string &id, DetectorUsage usage, MSLane *lane, double pos, double endPos, double length, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string &vTypes, bool showDetector=true)
Creates a MSE2Collector instance, overridden by GUIE2Collector::createE2Detector() ...
const std::string myProgramID
The id of the logic.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
double accumulatedTimeLoss
Accumulated time loss that this vehicle suffered since it entered the detector.
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...
bool noVehicles(SVCPermissions permissions)
Returns whether an edge with the given permission forbids vehicles.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
SUMOTime minDuration
The minimum duration of the phase.
bool isGreenPhase() const
Returns whether this phase is a pure "green" phase.
void init(NLDetectorBuilder &nb)
Initializes the tls with information about incoming lanes.
bool myShowDetectors
Whether the detectors shall be shown in the GUI.
SUMOTime myFreq
The frequency for aggregating detector output.
double myDetectionRange
Range of the connected detector, which provides the information on approaching vehicles.
The definition of a single phase of a tls logic.
Representation of a lane in the micro simulation.