54 #ifdef CHECK_MEMORY_LEAKS
56 #endif // CHECK_MEMORY_LEAKS
64 const std::string& aXMLFilename,
65 const std::string& outputFilename,
68 :
MSCalibrator(id, edge, pos, aXMLFilename, outputFilename, freq, length, probe, false),
69 mySegment(
MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos)) {
88 throw ProcessError(
"Emission of vehicle '" + vehicle->
getID() +
"' in calibrator '" +
getID() +
"'failed!");
136 bool hadInvalidJam =
false;
138 hadInvalidJam =
true;
161 if (!hadInvalidJam) {
169 const int insertionSlack =
MAX2(0, adaptedNum + relaxedInsertion - totalWishedNum);
187 assert(route != 0 && vtype != 0);
195 newPars, route, vtype,
false,
false));
201 while (vehicle->
getEdge() != myedge) {
218 while (totalWishedNum < adaptedNum) {
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
SUMOTime execute(SUMOTime currentTime)
A vehicle from the mesoscopic point of view.
std::string vtypeid
The vehicle's type id.
METriggeredCalibrator(const std::string &id, const MSEdge *const edge, const SUMOReal pos, const std::string &aXMLFilename, const std::string &outputFilename, const SUMOTime freq, const SUMOReal length, const MSRouteProbe *probe)
bool initialise(MEVehicle *veh, SUMOTime time)
Inserts (emits) vehicle into the segment.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
bool invalidJam() const
returns whether the segment is jammed although it should not be
Writes routes of vehicles passing a certain edge.
bool myDidSpeedAdaption
The information whether speed was adapted in the current interval.
std::string time2string(SUMOTime t)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
SUMOTime myFrequency
The frequeny with which to check for calibration.
bool tryEmit(MESegment *s, MEVehicle *vehicle)
int myRemoved
The number of vehicles that were removed in the current interval.
int myClearedInJam
The number of vehicles that were removed when clearin a jam.
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
const MSEdge *const myEdge
the edge on which this calibrator lies
#define WRITE_WARNING(msg)
The car-following model and parameter.
static OptionsCont & getOptions()
Retrieves the options.
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
std::vector< AspiredState >::const_iterator myCurrentStateInterval
Iterator pointing to the current interval.
std::string routeid
The vehicle's route id.
MESegment * mySegment
mesoscopic edge segment the calibrator lies on
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
bool contains(const MSEdge *const edge) const
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
SUMOTime depart
The vehicle's departure time.
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
bool mySpeedIsDefault
The information whether the speed adaption has been reset.
std::vector< AspiredState > myIntervals
List of adaptation intervals.
bool vaporizeAnyCar(SUMOTime currentTime)
tries to remove any car from this segment
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
SUMOReal getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
bool myHaveWarnedAboutClearingJam
The default (maximum) speed on the segment.
void removeDetector(MSMoveReminder *data)
Removes a data collector for a detector from this segment.
void setDescription(const std::string &description)
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
const MSRoute * getRoute() const
void setSpeed(SUMOReal newSpeed, SUMOTime currentTime, SUMOReal jamThresh=DO_NOT_PATCH_JAM_THRESHOLD)
reset mySpeed and patch the speed of all vehicles in it. Also set/recompute myJamThreshold ...
std::string myID
The name of the object.
Structure representing possible vehicle parameter.
SUMOReal getMeanSpeed(bool useCache) const
Returns the average speed of vehicles on the segment in meters per second. If there is no vehicle on ...
A single mesoscopic segment (cell)
MESegment * getSegmentForEdge(const MSEdge &e, SUMOReal pos=0)
Get the segment for a given edge at a given position.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
const MSRouteProbe *const myProbe
the route probe to retrieve routes from
void setEventTime(SUMOTime t, bool hasDelay=true)
Sets the (planned) time at which the vehicle leaves his current cell.
Calibrates the flow on a segment to a specified one.
SUMOReal getBruttoOccupancy() const
Returns the occupany of the segment (the sum of the vehicle lengths + minGaps)
SUMOTime getNextInsertionTime(SUMOTime earliestEntry) const
return a time after earliestEntry at which a vehicle may be inserted at full speed ...
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
virtual ~METriggeredCalibrator()
MSMeanData_Net::MSLaneMeanDataValues myEdgeMeanData
accumlated data for the whole edge
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
void prepareDetectorForWriting(MSMoveReminder &data)
Updates data of a detector for all vehicle queues.
bool isCurrentStateActive(SUMOTime time)
int remainingVehicleCapacity() const
returns the number of vehicles (of the current type) that still fit onto the segment ...
int maximumInflow() const
returns the maximum number of vehicles that could enter from upstream until the calibrator is activat...
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, MTRand *rng=0)
Returns the named vehicle type or a sample from the named distribution.
int remainingVehicleCapacity(const SUMOReal vehLength) const
return the remaining physical space on this segment
void reset()
reset collected vehicle data
SUMOReal myDefaultSpeed
The default (maximum) speed on the segment.
int myInserted
The number of vehicles that were inserted in the current interval.
std::string id
The vehicle's id.
void setMaxSpeed(SUMOReal val) const
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
const std::string & getID() const
Returns the name of the vehicle.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.