45 #ifdef CHECK_MEMORY_LEAKS
47 #endif // CHECK_MEMORY_LEAKS
66 myTotalDepartureDelay(0),
68 myDefaultVTypeMayBeDeleted(true),
69 myWaitingForPerson(0),
74 if (oc.
isSet(
"incremental-dua-step")) {
77 if (oc.
isSet(
"scale")) {
116 for (std::vector<MSDevice*>::const_iterator i = veh->
getDevices().begin(); i != veh->
getDevices().end(); ++i) {
117 (*i)->generateOutput();
172 it->second->getParameter().write(out);
181 (*it).second->saveState(out);
296 into.push_back((*i).first);
299 into.push_back((*i).first);
307 myWaiting[edge] = std::vector<SUMOVehicle*>();
316 std::vector<SUMOVehicle*>::iterator it = std::find(
myWaiting[edge].begin(),
myWaiting[edge].end(), vehicle);
327 for (std::vector<SUMOVehicle*>::const_iterator it =
myWaiting[edge].begin(); it !=
myWaiting[edge].end(); ++it) {
328 const std::string& line = (*it)->
getParameter().
line ==
"" ? (*it)->getParameter().id : (*it)->getParameter().line;
329 if (lines.count(line)) {
341 WRITE_WARNING(
"Vehicle " + i->first +
" aborted waiting for a person that will never come.");
348 frac = frac < 0 ?
myScale : frac;
352 const unsigned int resolution = 1000;
353 const unsigned int intFrac = (
unsigned int)floor(frac * resolution + 0.5);
356 return (((
myLoadedVehNo - 1) % resolution) * intFrac) % resolution < intFrac;
The vehicle has departed (was inserted into the network)
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
bool addVTypeDistribution(const std::string &id, RandomDistributor< MSVehicleType * > *vehTypeDistribution)
Adds a vehicle type distribution.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Representation of a vehicle in the micro simulation.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
SUMOReal myTotalDepartureDelay
The aggregated time vehicles had to wait for departure (in seconds)
unsigned int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
unsigned int myDiscarded
The number of vehicles which were discarded while loading.
SUMOReal myTotalTravelTime
The aggregated time vehicles needed to aacomplish their route (in seconds)
Structure representing possible vehicle parameter.
std::map< const MSEdge *const, std::vector< SUMOVehicle * > > myWaiting
the lists of waiting vehicles
SUMOReal computeChosenSpeedDeviation(MTRand &rng) const
Computes and returns the speed deviation.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID)
Returns the named vehicle type or a sample from the named distribution.
MSVehicleControl()
Constructor.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
VehicleDictType myVehicleDict
Dictionary of vehicles.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
VTypeDictType myVTypeDict
Dictionary of vehicle types.
void removeWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector...
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type was loaded.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
const std::string DEFAULT_VTYPE_ID
void printMeanTravelTime(OutputDevice &od) const
Returns the mean travel time of vehicles The mean travel time of ended vehicles (-1 if no vehicle has...
void printMeanWaitingTime(OutputDevice &od) const
Prints the mean waiting time of vehicles. The mean time vehicles had to wait for being inserted (-1 i...
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
#define WRITE_WARNING(msg)
The car-following model and parameter.
static OptionsCont & getOptions()
Retrieves the options.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type)
Builds a vehicle, increases the number of built vehicles.
SUMOVehicle * getWaitingVehicle(const MSEdge *const edge, const std::set< std::string > &lines)
A road/street connecting two junctions.
virtual const std::vector< MSDevice * > & getDevices() const =0
Returns this vehicle's devices.
The vehicle arrived at his destination (is deleted)
void setState(int runningVehNo, int endedVehNo, SUMOReal totalDepartureDelay, SUMOReal totalTravelTime)
Sets the current state variables as loaded from the stream.
Representation of a vehicle.
SUMOReal myScale
The scaling factor (especially for inc-dua)
SUMOTime depart
The vehicle's departure time.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
static MTRand myVehicleParamsRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
unsigned int myEndedVehNo
The number of removed vehicles.
std::string line
The vehicle's line (mainly for public transport)
void abortWaiting()
removes any vehicles that are still waiting
The vehicle was built, but has not yet departed.
bool addVType(MSVehicleType *vehType)
Adds a vehicle type.
void scheduleVehicleRemoval(SUMOVehicle *veh)
Removes a vehicle after it has ended.
Structure representing possible vehicle parameter.
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual ~MSVehicleControl()
Destructor.
A storage for options typed value containers)
const std::string & getID() const
Returns the name of the vehicle type.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to)
Informs all added listeners about a vehicle's state change.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
bool isInQuota(SUMOReal frac=-1) const
Returns the information whether the currently vehicle number shall be emitted considering that only f...
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
unsigned int myLoadedVehNo
The number of build vehicles.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
virtual const std::string & getID() const =0
Get the vehicle's ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
unsigned int myRunningVehNo
The number of vehicles within the network (build and inserted but not removed)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.