41 #define INVALID_POSITION std::numeric_limits<double>::max() 53 const std::string&
id,
const std::string& programID,
56 const std::map<std::string, std::string>& parameter,
57 const std::string& basePath) :
59 #ifdef DEBUG_TIMELOSS_CONTROL 60 std::cout <<
"Building delay based tls logic '" <<
id <<
"'" << std::endl;
68 #ifdef DEBUG_TIMELOSS_CONTROL 84 LaneVectorVector::const_iterator i2;
85 LaneVector::const_iterator i;
89 for (i = lanes.begin(); i != lanes.end(); i++) {
94 myLaneDetectors[lane] = nb.
createE2Detector(
id,
DU_TL_CONTROL, lane,
INVALID_POSITION, lane->
getLength(),
myDetectionRange, 0, 0, 0,
myVehicleTypes,
myShowDetectors);
110 #ifdef DEBUG_TIMELOSS_CONTROL 111 std::cout <<
"\n" <<
SIMTIME <<
" MSDelayBasedTrafficLightLogic::proposeProlongation() for TLS '" << this->
getID() <<
"' (current phase = " <<
myStep <<
")" << std::endl;
116 for (
int i = 0; i < (int) state.size(); i++) {
119 const std::vector<MSLane*>& lanes =
getLanesAt(i);
120 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();
131 #ifdef DEBUG_TIMELOSS_CONTROL 136 for (std::vector<MSE2Collector::VehicleInfo*>::const_iterator ivp = vehInfos.begin(); ivp != vehInfos.end(); ++ivp) {
140 if (actDuration + estimatedTimeToJunction <= maxDuration) {
142 prolongation =
MAX2(prolongation, estimatedTimeToJunction);
144 #ifdef DEBUG_TIMELOSS_CONTROL 148 #ifdef DEBUG_TIMELOSS_CONTROL 150 <<
"\nestimated passing time: " << estimatedTimeToJunction << std::endl;
153 std::cout <<
"disregarded: (vehicle '" << iv->
id <<
"' with accumulated timeloss " << iv->
accumulatedTimeLoss <<
")" << reason << std::endl;
159 if (vehInfos.size() > 0) {
163 #ifdef DEBUG_TIMELOSS_CONTROL 164 std::cout <<
"Actual duration exceeds maxDuration and a vehicle is on concurrent approach: " << nrVehs << std::endl;
171 #ifdef DEBUG_TIMELOSS_CONTROL 172 std::cout <<
"Number of current vehicles on detector: " << nrVehs << std::endl;
177 #ifdef DEBUG_TIMELOSS_CONTROL 178 std::cout <<
"Proposed prolongation (maximal estimated passing time): " << prolongation << std::endl;
191 #ifdef DEBUG_TIMELOSS_CONTROL 192 std::cout <<
"last switch = " << currentPhase.
myLastSwitch 193 <<
"\nactDuration = " << actDuration
200 bool othersEmpty =
true;
203 #ifdef DEBUG_TIMELOSS_CONTROL 204 std::cout <<
"othersEmpty = " << othersEmpty
209 bool prolong = othersEmpty || actDuration < currentPhase.
maxDuration;
214 proposedProlongation =
MAX2(proposedProlongation,
TIME2STEPS(1.));
220 #ifdef DEBUG_TIMELOSS_CONTROL 221 std::cout <<
"Proposed prolongation = " << proposedProlongation << std::endl;
224 prolong = proposedProlongation > 0;
228 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.
std::string myProgramID
The id of the logic.
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.
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.
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.
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
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() ...
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...
static double _2double(const E *const data)
converts a char-type array into the double value described by it
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.