MSVehicleType Class Reference

#include <MSVehicleType.h>


Detailed Description

The car-following model and parameter.

MSVehicleType stores the parameter of a single vehicle type and methods that use these for computing the vehicle's car-following behavior

It is assumed that within the simulation many vehicles are using the same vehicle type, quite common is using only one vehicle type for all vehicles.

You can think of it like of having a vehicle type for each VW Golf or Ford Mustang in your simulation while the car instances just refer to it.

Definition at line 68 of file MSVehicleType.h.


Public Member Functions

 MSVehicleType (const std::string &id, SUMOReal length, SUMOReal maxSpeed, SUMOReal prob, SUMOReal speedFactor, SUMOReal speedDev, SUMOVehicleClass vclass, SUMOEmissionClass emissionClass, SUMOVehicleShape shape, SUMOReal guiWidth, SUMOReal guiOffset, int cfModel, const std::string &lcModel, const RGBColor &c) throw ()
 Constructor.
void saveState (std::ostream &os)
 Saves the states of a vehicle.
virtual ~MSVehicleType () throw ()
 Destructor.
Atomar getter for simulation
const MSCFModelgetCarFollowModel () const throw ()
 Returns the vehicle type's car following model definition.
const RGBColorgetColor () const throw ()
 Returns this type's color.
SUMOReal getDefaultProbability () const throw ()
 Get the default probability of this vehicle type.
SUMOEmissionClass getEmissionClass () const throw ()
 Get this vehicle type's emission class.
const std::string & getID () const throw ()
 Returns the name of the vehicle type.
SUMOReal getLength () const throw ()
 Get vehicle's length [m].
SUMOReal getMaxSpeed () const throw ()
 Get vehicle's maximum speed [m/s].
SUMOReal getMaxSpeedWithDeviation (SUMOReal referenceSpeed) const throw ()
 Get vehicle's maximum speed [m/s] drawn from a normal distribution.
SUMOVehicleClass getVehicleClass () const throw ()
 Get this vehicle type's vehicle class.
SUMOReal hasSpeedDeviation () const throw ()
 Get vehicle's maximum speed [m/s].
Atomar getter for visualization
SUMOReal getGuiOffset () const throw ()
 Get the free space (not drawn) in front of vehicles of this class.
SUMOVehicleShape getGuiShape () const throw ()
 Get this vehicle type's shape.
SUMOReal getGuiWidth () const throw ()
 Get the width which vehicles of this class shall have when being drawn.

Static Public Member Functions

Static methods for building vehicle types from descriptions
static MSVehicleTypebuild (SUMOVTypeParameter &from) throw (ProcessError)
 Builds the microsim vehicle type described by the given parameter.
static SUMOReal get (const std::map< std::string, SUMOReal > &from, const std::string &name, SUMOReal defaultValue) throw ()
 Returns the named value from the map, or the default if it is ot contained there.

Private Member Functions

 MSVehicleType (const MSVehicleType &)
 Invalidated copy constructor.
MSVehicleTypeoperator= (const MSVehicleType &)
 Invalidated assignment operator.

Private Attributes

MSCFModelmyCarFollowModel
 ID of the car following model.
RGBColor myColor
 The color.
SUMOReal myDefaultProbability
 The probability when being added to a distribution without an explicit probability.
SUMOEmissionClass myEmissionClass
 The emission class of such vehicles.
std::string myID
 Unique ID.
std::string myLaneChangeModel
 ID of the lane change model.
SUMOReal myLength
 Vehicles' length [m].
SUMOReal myMaxSpeed
 Vehicles' maximum speed [m/s].
SUMOReal mySpeedDev
 The standard deviation for speed variations.
SUMOReal mySpeedFactor
 The factor by which the maximum speed may deviate from the allowed max speed on the street.
SUMOVehicleClass myVehicleClass
 The vehicles' class.
Values for drawing this class' vehicles
SUMOReal myOffset
 This class' free space in front of the vehicle itself.
SUMOVehicleShape myShape
 This class' shape.
SUMOReal myWidth
 This class' width.

Constructor & Destructor Documentation

MSVehicleType::MSVehicleType ( const std::string &  id,
SUMOReal  length,
SUMOReal  maxSpeed,
SUMOReal  prob,
SUMOReal  speedFactor,
SUMOReal  speedDev,
SUMOVehicleClass  vclass,
SUMOEmissionClass  emissionClass,
SUMOVehicleShape  shape,
SUMOReal  guiWidth,
SUMOReal  guiOffset,
int  cfModel,
const std::string &  lcModel,
const RGBColor c 
) throw ()

Constructor.

Parameters:
[in] id The vehicle type's id
[in] length The length of vehicles that are of this type
[in] maxSpeed The maximum velocity vehicles of this type may drive with
[in] prob The probability of this vehicle type
[in] speedFactor The speed factor to scale maximum speed with
[in] speedDev The speed deviation
[in] vclass The class vehicles of this type belong to
[in] emissionClass The emission class vehicles of this type belong to
[in] shape How vehicles of this class shall be drawn
[in] guiWidth The width of the vehicles when being drawn
[in] guiOffset The free space in front of the vehicles of this class
[in] cfModel Enumeration of the car-following model to use
[in] lcModel Name of the lane-change model to use
[in] c Color of this vehicle type

Definition at line 51 of file MSVehicleType.cpp.

Referenced by build().

00060         : myID(id), myLength(length), myMaxSpeed(maxSpeed),
00061         myDefaultProbability(prob), mySpeedFactor(speedFactor),
00062         mySpeedDev(speedDev), myVehicleClass(vclass),
00063         myLaneChangeModel(lcModel),
00064         myEmissionClass(emissionClass), myColor(c),
00065         myWidth(guiWidth), myOffset(guiOffset), myShape(shape) {
00066     assert(myLength > 0);
00067     assert(getMaxSpeed() > 0);
00068 }

MSVehicleType::~MSVehicleType (  )  throw () [virtual]

Destructor.

Definition at line 71 of file MSVehicleType.cpp.

00071 {}

MSVehicleType::MSVehicleType ( const MSVehicleType  )  [private]

Invalidated copy constructor.


Member Function Documentation

MSVehicleType * MSVehicleType::build ( SUMOVTypeParameter from  )  throw (ProcessError) [static]

Builds the microsim vehicle type described by the given parameter.

Parameters:
[in] from The vehicle type description
Returns:
The built vehicle type
Exceptions:
ProcessError on false values (not et used)

Definition at line 107 of file MSVehicleType.cpp.

References DEFAULT_VEH_ACCEL, DEFAULT_VEH_DECEL, DEFAULT_VEH_SIGMA, DEFAULT_VEH_TAU, MSVehicleType(), myCarFollowModel, SUMO_TAG_CF_BKERNER, SUMO_TAG_CF_IDM, SUMO_TAG_CF_KRAUSS, SUMO_TAG_CF_KRAUSS_ORIG1, and SUMO_TAG_CF_PWAGNER2009.

Referenced by MSVehicleControl::MSVehicleControl(), and MSRouteHandler::myEndElement().

00107                                                                  {
00108     MSVehicleType *vtype = new MSVehicleType(
00109         from.id, from.length, from.maxSpeed,
00110         from.defaultProbability, from.speedFactor, from.speedDev, from.vehicleClass, from.emissionClass,
00111         from.shape, from.width, from.offset, from.cfModel, from.lcModel, from.color);
00112     MSCFModel *model = 0;
00113     switch (from.cfModel) {
00114     case SUMO_TAG_CF_IDM:
00115         model = new MSCFModel_IDM(vtype,
00116                                   get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL),
00117                                   get(from.cfParameter, "decel", DEFAULT_VEH_DECEL),
00118                                   get(from.cfParameter, "timeHeadWay", 1.5),
00119                                   get(from.cfParameter, "minGap", 5.),
00120                                   get(from.cfParameter, "tau", DEFAULT_VEH_TAU));
00121         break;
00122     case SUMO_TAG_CF_BKERNER:
00123         model = new MSCFModel_Kerner(vtype,
00124                                      get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL),
00125                                      get(from.cfParameter, "decel", DEFAULT_VEH_DECEL),
00126                                      get(from.cfParameter, "tau", DEFAULT_VEH_TAU),
00127                                      get(from.cfParameter, "k", .5),
00128                                      get(from.cfParameter, "phi", 5.));
00129         break;
00130     case SUMO_TAG_CF_KRAUSS_ORIG1:
00131         model = new MSCFModel_KraussOrig1(vtype,
00132                                           get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL),
00133                                           get(from.cfParameter, "decel", DEFAULT_VEH_DECEL),
00134                                           get(from.cfParameter, "sigma", DEFAULT_VEH_SIGMA),
00135                                           get(from.cfParameter, "tau", DEFAULT_VEH_TAU));
00136         break;
00137     case SUMO_TAG_CF_PWAGNER2009:
00138         model = new MSCFModel_PWag2009(vtype,
00139                                        get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL),
00140                                        get(from.cfParameter, "decel", DEFAULT_VEH_DECEL),
00141                                        get(from.cfParameter, "sigma", DEFAULT_VEH_SIGMA),
00142                                        get(from.cfParameter, "tau", DEFAULT_VEH_TAU));
00143         break;
00144     case SUMO_TAG_CF_KRAUSS:
00145     default:
00146         model = new MSCFModel_Krauss(vtype,
00147                                      get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL),
00148                                      get(from.cfParameter, "decel", DEFAULT_VEH_DECEL),
00149                                      get(from.cfParameter, "sigma", DEFAULT_VEH_SIGMA),
00150                                      get(from.cfParameter, "tau", DEFAULT_VEH_TAU));
00151         break;
00152     }
00153     vtype->myCarFollowModel = model;
00154     return vtype;
00155 }

SUMOReal MSVehicleType::get ( const std::map< std::string, SUMOReal > &  from,
const std::string &  name,
SUMOReal  defaultValue 
) throw () [static]

Returns the named value from the map, or the default if it is ot contained there.

Parameters:
[in] from The map to retrieve values from
[in] name The name of variable
[in] defaultValue The value to return if the given map does not contain the named variable
Returns:
The named value from the map or the default if it does not exist there

Definition at line 97 of file MSVehicleType.cpp.

00097                                                                                                                 {
00098     std::map<std::string, SUMOReal>::const_iterator i = from.find(name);
00099     if (i==from.end()) {
00100         return defaultValue;
00101     }
00102     return (*i).second;
00103 }

const MSCFModel& MSVehicleType::getCarFollowModel (  )  const throw () [inline]

Returns the vehicle type's car following model definition.

Returns:
The vehicle type's car following model definition

Definition at line 123 of file MSVehicleType.h.

References myCarFollowModel.

Referenced by MSVehicle::checkRewindLinkLanes(), MSVehicle::getCarFollowModel(), and TraCIServerAPI_VehicleType::processGet().

00123                                                               {
00124         return *myCarFollowModel;
00125     }

const RGBColor& MSVehicleType::getColor (  )  const throw () [inline]

Returns this type's color.

Returns:
The color of this type

Definition at line 186 of file MSVehicleType.h.

References myColor.

Referenced by TraCIServerAPI_VehicleType::processGet(), and GUIVehicle::setOwnTypeColor().

00186                                              {
00187         return myColor;
00188     }

SUMOReal MSVehicleType::getDefaultProbability (  )  const throw () [inline]

Get the default probability of this vehicle type.

Returns:
The probability to use this type

Definition at line 160 of file MSVehicleType.h.

References myDefaultProbability.

Referenced by MSRouteHandler::myEndElement(), and MSRouteHandler::openVehicleTypeDistribution().

00160                                                    {
00161         return myDefaultProbability;
00162     }

SUMOEmissionClass MSVehicleType::getEmissionClass (  )  const throw () [inline]

SUMOReal MSVehicleType::getGuiOffset (  )  const throw () [inline]

Get the free space (not drawn) in front of vehicles of this class.

Returns:
The place before the vehicle

Definition at line 216 of file MSVehicleType.h.

References myOffset.

Referenced by drawAction_drawVehicleAsBoxPlus(), drawAction_drawVehicleAsPoly(), drawAction_drawVehicleBlinker(), and TraCIServerAPI_VehicleType::processGet().

00216                                           {
00217         return myOffset;
00218     }

SUMOVehicleShape MSVehicleType::getGuiShape (  )  const throw () [inline]

Get this vehicle type's shape.

Returns:
The shape of this vehicle type
See also:
SUMOVehicleShape

Definition at line 200 of file MSVehicleType.h.

References myShape.

Referenced by drawAction_drawVehicleAsPoly(), and TraCIServerAPI_VehicleType::processGet().

00200                                                  {
00201         return myShape;
00202     }

SUMOReal MSVehicleType::getGuiWidth (  )  const throw () [inline]

Get the width which vehicles of this class shall have when being drawn.

Returns:
The width of this type's vehicles

Definition at line 208 of file MSVehicleType.h.

References myWidth.

Referenced by drawAction_drawVehicleAsBoxPlus(), drawAction_drawVehicleAsPoly(), drawAction_drawVehicleBlinker(), and TraCIServerAPI_VehicleType::processGet().

00208                                          {
00209         return myWidth;
00210     }

const std::string& MSVehicleType::getID (  )  const throw () [inline]

Returns the name of the vehicle type.

Returns:
This type's id

Definition at line 107 of file MSVehicleType.h.

References myID.

Referenced by MSVTypeProbe::execute(), MSCalibrator::execute(), GUIVehicle::getParameterWindow(), MSRouteHandler::myEndElement(), TraCIServerAPI_Vehicle::processGet(), and MSVehicle::saveState().

00107                                            {
00108         return myID;
00109     }

SUMOReal MSVehicleType::getLength (  )  const throw () [inline]

SUMOReal MSVehicleType::getMaxSpeed (  )  const throw () [inline]

SUMOReal MSVehicleType::getMaxSpeedWithDeviation ( SUMOReal  referenceSpeed  )  const throw () [inline]

Get vehicle's maximum speed [m/s] drawn from a normal distribution.

The speed is calculated relative to the reference speed (which is usually the maximum allowed speed on a lane or edge).

Returns:
The maximum speed (in m/s) of vehicles of this class

Definition at line 149 of file MSVehicleType.h.

References MAX3(), MIN3(), myMaxSpeed, mySpeedDev, mySpeedFactor, RandHelper::randNorm(), and SUMOReal.

Referenced by MSVehicle::adaptMaxSpeed().

00149                                                                              {
00150         SUMOReal meanSpeed = mySpeedFactor * referenceSpeed;
00151         SUMOReal speedDev = mySpeedDev * meanSpeed;
00152         SUMOReal speed = MIN3(RandHelper::randNorm(meanSpeed, speedDev), meanSpeed + 2*speedDev, myMaxSpeed);
00153         return MAX3((SUMOReal)0.0, speed, meanSpeed - 2*speedDev);
00154     }

SUMOVehicleClass MSVehicleType::getVehicleClass (  )  const throw () [inline]

Get this vehicle type's vehicle class.

Returns:
The class of this vehicle type
See also:
SUMOVehicleClass

Definition at line 169 of file MSVehicleType.h.

References myVehicleClass.

Referenced by MSVehicleTransfer::checkEmissions(), MSVehicle::getBestLanes(), MSVehicle::hasValidRoute(), TraCIServerAPI_VehicleType::processGet(), MSVehicle::rebuildContinuationsFor(), and MSLane::succLinkSec().

00169                                                      {
00170         return myVehicleClass;
00171     }

SUMOReal MSVehicleType::hasSpeedDeviation (  )  const throw () [inline]

Get vehicle's maximum speed [m/s].

Returns:
The maximum speed (in m/s) of vehicles of this class

Definition at line 138 of file MSVehicleType.h.

References mySpeedDev, and mySpeedFactor.

Referenced by MSVehicle::adaptMaxSpeed().

00138                                                {
00139         return mySpeedDev != 0.0 || mySpeedFactor != 1.0;
00140     }

MSVehicleType& MSVehicleType::operator= ( const MSVehicleType  )  [private]

Invalidated assignment operator.

void MSVehicleType::saveState ( std::ostream &  os  ) 


Field Documentation

ID of the car following model.

Definition at line 275 of file MSVehicleType.h.

Referenced by build(), getCarFollowModel(), and saveState().

The color.

Definition at line 284 of file MSVehicleType.h.

Referenced by getColor(), and saveState().

The probability when being added to a distribution without an explicit probability.

Definition at line 266 of file MSVehicleType.h.

Referenced by getDefaultProbability(), and saveState().

The emission class of such vehicles.

Definition at line 281 of file MSVehicleType.h.

Referenced by getEmissionClass(), and saveState().

std::string MSVehicleType::myID [private]

Unique ID.

Definition at line 254 of file MSVehicleType.h.

Referenced by getID(), and saveState().

std::string MSVehicleType::myLaneChangeModel [private]

ID of the lane change model.

Definition at line 278 of file MSVehicleType.h.

Referenced by saveState().

SUMOReal MSVehicleType::myLength [private]

Vehicles' length [m].

Definition at line 257 of file MSVehicleType.h.

Referenced by getLength(), and saveState().

SUMOReal MSVehicleType::myMaxSpeed [private]

Vehicles' maximum speed [m/s].

Definition at line 260 of file MSVehicleType.h.

Referenced by getMaxSpeed(), and getMaxSpeedWithDeviation().

SUMOReal MSVehicleType::myOffset [private]

This class' free space in front of the vehicle itself.

Definition at line 294 of file MSVehicleType.h.

Referenced by getGuiOffset(), and saveState().

This class' shape.

Definition at line 297 of file MSVehicleType.h.

Referenced by getGuiShape(), and saveState().

SUMOReal MSVehicleType::mySpeedDev [private]

The standard deviation for speed variations.

Definition at line 272 of file MSVehicleType.h.

Referenced by getMaxSpeedWithDeviation(), hasSpeedDeviation(), and saveState().

SUMOReal MSVehicleType::mySpeedFactor [private]

The factor by which the maximum speed may deviate from the allowed max speed on the street.

Definition at line 269 of file MSVehicleType.h.

Referenced by getMaxSpeedWithDeviation(), hasSpeedDeviation(), and saveState().

The vehicles' class.

Definition at line 263 of file MSVehicleType.h.

Referenced by getVehicleClass(), and saveState().

SUMOReal MSVehicleType::myWidth [private]

This class' width.

Definition at line 291 of file MSVehicleType.h.

Referenced by getGuiWidth(), and saveState().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:50 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6