 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
34 #define INVALID_POSITION std::numeric_limits<double>::max()
46 const std::string&
id,
const std::string& programID,
49 const std::map<std::string, std::string>& parameter,
50 const std::string& basePath) :
52 #ifdef DEBUG_TIMELOSS_CONTROL
53 std::cout <<
"Building delay based tls logic '" <<
id <<
"'" << std::endl;
61 #ifdef DEBUG_TIMELOSS_CONTROL
77 LaneVectorVector::const_iterator i2;
78 LaneVector::const_iterator i;
82 for (i = lanes.begin(); i != lanes.end(); i++) {
91 myLaneDetectors[lane] = nb.
createE2Detector(
id,
DU_TL_CONTROL, lane,
INVALID_POSITION, lane->
getLength(),
myDetectionRange, 0, 0, 0,
myVehicleTypes,
myShowDetectors);
107 #ifdef DEBUG_TIMELOSS_CONTROL
108 std::cout <<
"\n" <<
SIMTIME <<
" MSDelayBasedTrafficLightLogic::proposeProlongation() for TLS '" << this->
getID() <<
"' (current phase = " <<
myStep <<
")" << std::endl;
113 for (
int i = 0; i < (int) state.size(); i++) {
116 const std::vector<MSLane*>& lanes =
getLanesAt(i);
117 for (LaneVector::const_iterator j = lanes.begin(); j != lanes.end(); j++) {
120 #ifdef DEBUG_TIMELOSS_CONTROL
122 std::cout <<
"no detector on lane '" << (*j)->getID() << std::endl;
126 MSE2Collector* detector = static_cast<MSE2Collector* >(i->second);
127 const std::vector<MSE2Collector::VehicleInfo*> vehInfos = detector->
getCurrentVehicles();
128 #ifdef DEBUG_TIMELOSS_CONTROL
133 for (std::vector<MSE2Collector::VehicleInfo*>::const_iterator ivp = vehInfos.begin(); ivp != vehInfos.end(); ++ivp) {
137 if (actDuration + estimatedTimeToJunction <= maxDuration) {
139 prolongation =
MAX2(prolongation, estimatedTimeToJunction);
141 #ifdef DEBUG_TIMELOSS_CONTROL
145 #ifdef DEBUG_TIMELOSS_CONTROL
147 <<
"\nestimated passing time: " << estimatedTimeToJunction << std::endl;
150 std::cout <<
"disregarded: (vehicle '" << iv->
id <<
"' with accumulated timeloss " << iv->
accumulatedTimeLoss <<
")" << reason << std::endl;
156 if (vehInfos.size() > 0) {
160 #ifdef DEBUG_TIMELOSS_CONTROL
161 std::cout <<
"Actual duration exceeds maxDuration and a vehicle is on concurrent approach: " << nrVehs << std::endl;
168 #ifdef DEBUG_TIMELOSS_CONTROL
169 std::cout <<
"Number of current vehicles on detector: " << nrVehs << std::endl;
174 #ifdef DEBUG_TIMELOSS_CONTROL
175 std::cout <<
"Proposed prolongation (maximal estimated passing time): " << prolongation << std::endl;
188 #ifdef DEBUG_TIMELOSS_CONTROL
189 std::cout <<
"last switch = " << currentPhase.
myLastSwitch
190 <<
"\nactDuration = " << actDuration
197 bool othersEmpty =
true;
200 #ifdef DEBUG_TIMELOSS_CONTROL
201 std::cout <<
"othersEmpty = " << othersEmpty
206 bool prolong = othersEmpty || actDuration < currentPhase.
maxDuration;
211 proposedProlongation =
MAX2(proposedProlongation,
TIME2STEPS(1.));
217 #ifdef DEBUG_TIMELOSS_CONTROL
218 std::cout <<
"Proposed prolongation = " << proposedProlongation << std::endl;
221 prolong = proposedProlongation > 0;
225 return proposedProlongation;
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 ...
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()
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index.
SUMOTime myLastSwitch
Stores the timestep of the last on-switched of the phase.
MSDetectorControl & getDetectorControl()
Returns the detector control.
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
Representation of a lane in the micro simulation.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
SUMOTime trySwitch()
Switches to the next phase, if possible.
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
bool myShowDetectors
Whether the detectors shall be shown in the GUI.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
double myTimeLossThreshold
static OptionsCont & getOptions()
Retrieves the options.
The link has green light, has to brake.
An areal detector corresponding to a sequence of consecutive lanes.
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.
std::vector< VehicleInfo * > getCurrentVehicles() const
Returns the VehicleInfos for the vehicles currently on the detector.
The link has green light, may pass.
SUMOTime maxDuration
The maximum duration of the phase.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
~MSDelayBasedTrafficLightLogic()
Destructor.
std::string myFile
The output file for generated detectors.
std::string id
vehicle's ID
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
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 & getState() const
Returns the state within this phase.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
A VehicleInfo stores values that are tracked for the individual vehicles on the detector,...
double getLength() const
Returns the lane's length.
A fixed traffic light logic.
bool isGreenPhase() const
Returns whether this phase is a pure "green" phase.
SUMOTime myFreq
The frequency for aggregating detector output.
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...
double myDetectionRange
Range of the connected detector, which provides the information on approaching vehicles.
const std::string myProgramID
The id of the logic.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
void init(NLDetectorBuilder &nb)
Initializes the tls with information about incoming lanes.
std::string myVehicleTypes
Whether detector output separates by vType.
Phases myPhases
The list of phases this logic uses.
bool noVehicles(SVCPermissions permissions)
Returns whether an edge with the given permission forbids vehicles.
LaneDetectorMap myLaneDetectors
A map from lanes to the corresponding lane detectors.
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime splInterval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
A class that stores and controls tls and switching of their programs.
The definition of a single phase of a tls logic.
int myStep
The current step.
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
std::string myID
The name of the object.
const std::string & getID() const
Returns the id.
Builds detectors for microsim.
SUMOTime minDuration
The minimum duration of the phase.
const LaneVector & getLanesAt(int i) const
Returns the list of lanes that are controlled by the signals at the given position.