51 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, nullptr, nullptr, pos, aXMLFilename, outputFilename, freq, length, probe, invalidJamThreshold, vTypes, false, false),
59 mySegment(edge == nullptr ? nullptr :
MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos)) {
83 throw ProcessError(
"Emission of vehicle '" + vehicle->
getID() +
"' in calibrator '" +
getID() +
"'failed!");
125 bool hadInvalidJam =
false;
126 while ((calibrateFlow || calibrateSpeed) &&
invalidJam()) {
127 hadInvalidJam =
true;
150 if (!hadInvalidJam) {
158 const int insertionSlack =
MAX2(0, adaptedNum + relaxedInsertion - totalWishedNum);
165 if (route ==
nullptr) {
168 if (route ==
nullptr) {
172 if (!route->contains(
myEdge)) {
177 assert(route != 0 && vtype != 0);
183 newPars->
routeid = route->getID();
200 const bool duplicate = vc.
getVehicle(newPars->
id) !=
nullptr;
211 while (vehicle->
getEdge() != myedge) {
228 while (totalWishedNum < adaptedNum) {
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::shared_ptr< const MSRoute > ConstMSRoutePtr
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
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 addDetector(MSMoveReminder *data, int queueIndex=-1)
Adds a data collector for a detector to this segment.
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
SUMOTime getNextInsertionTime(SUMOTime earliestEntry) const
return a time after earliestEntry at which a vehicle may be inserted at full speed
void prepareDetectorForWriting(MSMoveReminder &data, int queueIndex=-1)
Removes a data collector for a detector from this segment.
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
MESegment * mySegment
mesoscopic edge segment the calibrator lies on
bool tryEmit(MESegment *s, MEVehicle *vehicle)
METriggeredCalibrator(const std::string &id, 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)
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 its current segment.
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.
virtual bool hasValidRouteStart(std::string &msg)
checks wether the vehicle can depart on the first edge
Calibrates the flow on a segment to a specified one.
double myInvalidJamThreshold
relative speed threshold for detecting and clearing invalid jam
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.
void setMaxSpeed(double val, double jamThreshold=-1)
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
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, ConstMSRoutePtr route)
Adds a route to the dictionary.
Writes routes of vehicles passing a certain edge.
ConstMSRoutePtr sampleRoute(bool last=true) const
The class responsible for building and deletion of vehicles.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
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.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const VehicleDefinitionSource source=ROUTEFILE, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false)
Deletes the vehicle.
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.