33 #define INVALID_POSITION std::numeric_limits<double>::max()
45 const std::string&
id,
const std::string& programID,
48 const std::map<std::string, std::string>& parameter,
49 const std::string& basePath) :
51 #ifdef DEBUG_TIMELOSS_CONTROL
52 std::cout <<
"Building delay based tls logic '" <<
id <<
"'" << std::endl;
60 #ifdef DEBUG_TIMELOSS_CONTROL
76 LaneVectorVector::const_iterator i2;
77 LaneVector::const_iterator i;
81 for (i = lanes.begin(); i != lanes.end(); i++) {
94 WRITE_ERROR(
"Unknown laneAreaDetector '" + customID +
"' given as custom detector for delay_based tlLogic '" +
getID() +
"', program '" +
getProgramID() +
".");
100 det = nb.
createE2Detector(
id,
DU_TL_CONTROL, lane,
INVALID_POSITION, lane->
getLength(),
myDetectionRange, 0, 0, 0,
myVehicleTypes,
myShowDetectors);
118 #ifdef DEBUG_TIMELOSS_CONTROL
119 std::cout <<
"\n" <<
SIMTIME <<
" MSDelayBasedTrafficLightLogic::proposeProlongation() for TLS '" << this->
getID() <<
"' (current phase = " <<
myStep <<
")" << std::endl;
124 for (
int i = 0; i < (int) state.size(); i++) {
127 const std::vector<MSLane*>& lanes =
getLanesAt(i);
128 for (LaneVector::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
131 #ifdef DEBUG_TIMELOSS_CONTROL
133 std::cout <<
"no detector on lane '" << (*j)->getID() << std::endl;
138 const std::vector<MSE2Collector::VehicleInfo*> vehInfos = detector->
getCurrentVehicles();
139 #ifdef DEBUG_TIMELOSS_CONTROL
144 for (std::vector<MSE2Collector::VehicleInfo*>::const_iterator ivp = vehInfos.begin(); ivp != vehInfos.end(); ++ivp) {
148 if (actDuration + estimatedTimeToJunction <= maxDuration) {
150 prolongation =
MAX2(prolongation, estimatedTimeToJunction);
152 #ifdef DEBUG_TIMELOSS_CONTROL
156 #ifdef DEBUG_TIMELOSS_CONTROL
158 <<
"\nestimated passing time: " << estimatedTimeToJunction << std::endl;
161 std::cout <<
"disregarded: (vehicle '" << iv->
id <<
"' with accumulated timeloss " << iv->
accumulatedTimeLoss <<
")" << reason << std::endl;
167 if (vehInfos.size() > 0) {
171 #ifdef DEBUG_TIMELOSS_CONTROL
172 std::cout <<
"Actual duration exceeds maxDuration and a vehicle is on concurrent approach: " << nrVehs << std::endl;
179 #ifdef DEBUG_TIMELOSS_CONTROL
180 std::cout <<
"Number of current vehicles on detector: " << nrVehs << std::endl;
185 #ifdef DEBUG_TIMELOSS_CONTROL
186 std::cout <<
"Proposed prolongation (maximal estimated passing time): " << prolongation << std::endl;
199 #ifdef DEBUG_TIMELOSS_CONTROL
200 std::cout <<
"last switch = " << currentPhase.
myLastSwitch
201 <<
"\nactDuration = " << actDuration
208 bool othersEmpty =
true;
211 #ifdef DEBUG_TIMELOSS_CONTROL
212 std::cout <<
"othersEmpty = " << othersEmpty
217 bool prolong = othersEmpty || actDuration < currentPhase.
maxDuration;
222 proposedProlongation =
MAX2(proposedProlongation,
TIME2STEPS(1.));
228 #ifdef DEBUG_TIMELOSS_CONTROL
229 std::cout <<
"Proposed prolongation = " << proposedProlongation << std::endl;
232 prolong = proposedProlongation > 0;
236 return proposedProlongation;
bool noVehicles(SVCPermissions permissions)
Returns whether an edge with the given permission forbids vehicles.
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ LINKSTATE_TL_GREEN_MAJOR
The link has green light, may pass.
@ LINKSTATE_TL_GREEN_MINOR
The link has green light, has to brake.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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.
double myDetectionRange
Range of the connected detector, which provides the information on approaching vehicles.
void setShowDetectors(bool show)
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.
std::string myVehicleTypes
Whether detector output separates by vType.
void init(NLDetectorBuilder &nb)
Initializes the tls with information about incoming lanes.
SUMOTime myFreq
The frequency for aggregating detector output.
LaneDetectorMap myLaneDetectors
A map from lanes to the corresponding lane detectors.
bool myShowDetectors
Whether the detectors shall be shown in the GUI.
double myTimeLossThreshold
std::string myFile
The output file for generated detectors.
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 ...
~MSDelayBasedTrafficLightLogic()
Destructor.
SUMOTime trySwitch()
Switches to the next phase, if possible.
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime splInterval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
An areal detector corresponding to a sequence of consecutive lanes.
std::vector< VehicleInfo * > getCurrentVehicles() const
Returns the VehicleInfos for the vehicles currently on the detector.
virtual void setVisible(bool)
Representation of a lane in the micro simulation.
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
double getLength() const
Returns the lane's length.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSDetectorControl & getDetectorControl()
Returns the detector control.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
The definition of a single phase of a tls logic.
const std::string & getState() const
Returns the state within this phase.
SUMOTime maxDuration
The maximum duration of the phase.
SUMOTime minDuration
The minimum duration of the phase.
SUMOTime myLastSwitch
Stores the timestep of the last on-switched of the phase.
bool isGreenPhase() const
Returns whether this phase is a pure "green" phase.
A fixed traffic light logic.
Phases myPhases
The list of phases this logic uses.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
int myStep
The current step.
A class that stores and controls tls and switching of their programs.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
const std::string myProgramID
The id of the 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.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
const std::string & getProgramID() const
Returns this tl-logic's id.
Builds detectors for microsim.
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()
std::string myID
The name of the object.
const std::string & getID() const
Returns the id.
T get(const std::string &id) const
Retrieves an item.
static OptionsCont & getOptions()
Retrieves the options.
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
A VehicleInfo stores values that are tracked for the individual vehicles on the detector,...
double accumulatedTimeLoss
Accumulated time loss that this vehicle suffered since it entered the detector.
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
std::string id
vehicle's ID