51 const MSEdge*
const edge,
const double pos,
52 const std::string& aXMLFilename,
53 const std::string& outputFilename,
54 const SUMOTime freq,
const double length,
56 const double invalidJamThreshold,
57 const std::string& vTypes) :
58 MSCalibrator(id, edge, (
MSLane*)nullptr, pos, aXMLFilename, outputFilename, freq, length, probe, invalidJamThreshold, vTypes, false),
59 mySegment(
MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos)) {
81 throw ProcessError(
"Emission of vehicle '" + vehicle->
getID() +
"' in calibrator '" +
getID() +
"'failed!");
107 while (first !=
nullptr) {
125 while (first !=
nullptr) {
133 bool hadInvalidJam =
false;
134 while ((calibrateFlow || calibrateSpeed) &&
invalidJam()) {
135 hadInvalidJam =
true;
158 if (!hadInvalidJam) {
166 const int insertionSlack =
MAX2(0, adaptedNum + relaxedInsertion - totalWishedNum);
173 if (route ==
nullptr) {
176 if (route ==
nullptr) {
185 assert(route != 0 && vtype != 0);
204 const bool duplicate = vc.
getVehicle(newPars->
id) !=
nullptr;
215 while (vehicle->
getEdge() != myedge) {
232 while (totalWishedNum < adaptedNum) {
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
A single mesoscopic segment (cell)
bool initialise(MEVehicle *veh, SUMOTime time)
Inserts (emits) vehicle into the segment.
double getBruttoOccupancy() const
Returns the occupany of the segment (the sum of the vehicle lengths + minGaps)
void prepareDetectorForWriting(MSMoveReminder &data)
Updates data of a detector for all vehicle queues.
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
double getMeanSpeed(bool useCache) const
Returns the average speed of vehicles on the segment in meters per second. If there is no vehicle on ...
int remainingVehicleCapacity(const double vehLength) const
return the remaining physical space on this segment
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
void setSpeed(double newSpeed, SUMOTime currentTime, double jamThresh=DO_NOT_PATCH_JAM_THRESHOLD)
reset mySpeed and patch the speed of all vehicles in it. Also set/recompute myJamThreshold
SUMOTime getNextInsertionTime(SUMOTime earliestEntry) const
return a time after earliestEntry at which a vehicle may be inserted at full speed
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
bool vaporizeAnyCar(SUMOTime currentTime, const MSDetectorFileOutput *filter)
tries to remove any car from this segment
void reset()
reset collected vehicle data
int maximumInflow() const
returns the maximum number of vehicles that could enter from upstream until the calibrator is activat...
virtual ~METriggeredCalibrator()
SUMOTime execute(SUMOTime currentTime)
int remainingVehicleCapacity() const
returns the number of vehicles (of the current type) that still fit onto the segment
bool invalidJam() const
returns whether the segment is jammed although it should not be
METriggeredCalibrator(const std::string &id, const MSEdge *const edge, const double pos, const std::string &aXMLFilename, const std::string &outputFilename, const SUMOTime freq, const double length, const MSRouteProbe *probe, const double invalidJamThreshold, const std::string &vTypes)
MESegment * mySegment
mesoscopic edge segment the calibrator lies on
bool tryEmit(MESegment *s, MEVehicle *vehicle)
A vehicle from the mesoscopic point of view.
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
void setEventTime(SUMOTime t, bool hasDelay=true)
Sets the (planned) time at which the vehicle leaves his current cell.
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
Calibrates the flow on a segment to a specified one.
double myInvalidJamThreshold
relative speed threshold for detecting and clearing invalid jam
const MSEdge *const myEdge
the edge on which this calibrator lies
bool mySpeedIsDefault
The information whether the speed adaption has been reset.
int myRemoved
The number of vehicles that were removed in the current interval.
const MSRouteProbe *const myProbe
the route probe to retrieve routes from
bool myAmActive
whether the calibrator was active when last checking
std::vector< AspiredState >::const_iterator myCurrentStateInterval
Iterator pointing to the current interval.
int myInserted
The number of vehicles that were inserted in the current interval.
bool myHaveWarnedAboutClearingJam
The default (maximum) speed on the segment.
std::vector< AspiredState > myIntervals
List of adaptation intervals.
std::string getNewVehicleID()
determine id of new vehicle from calibrator state
MSMeanData_Net::MSLaneMeanDataValues myEdgeMeanData
accumlated data for the whole edge
int myClearedInJam
The number of vehicles that were removed when clearin a jam.
double myDefaultSpeed
The default (maximum) speed on the segment.
bool isCurrentStateActive(SUMOTime time)
SUMOTime myFrequency
The frequeny with which to check for calibration.
bool myDidSpeedAdaption
The information whether speed was adapted in the current interval.
A road/street connecting two junctions.
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
void setMaxSpeed(double val) const
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Representation of a lane in the micro simulation.
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
void setDescription(const std::string &description)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
bool contains(const MSEdge *const edge) const
Writes routes of vehicles passing a certain edge.
const MSRoute * sampleRoute(bool last=true) const
The class responsible for building and deletion of vehicles.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
The car-following model and parameter.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
const std::string & getID() const
Returns the id.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static OptionsCont & getOptions()
Retrieves the options.
Structure representing possible vehicle parameter.
std::string vtypeid
The vehicle's type id.
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.