|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // The car-following model and parameter 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef MSVehicleType_h 00024 #define MSVehicleType_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <cassert> 00037 #include <map> 00038 #include <string> 00039 #include "MSCFModel.h" 00040 #include <utils/common/SUMOTime.h> 00041 #include <utils/common/StdDefs.h> 00042 #include <utils/common/SUMOVehicleClass.h> 00043 #include <utils/common/RandHelper.h> 00044 #include <utils/common/SUMOVTypeParameter.h> 00045 #include <utils/common/RGBColor.h> 00046 00047 00048 // =========================================================================== 00049 // class declarations 00050 // =========================================================================== 00051 class MSLane; 00052 class BinaryInputDevice; 00053 class MSCFModel; 00054 class SUMOVTypeParameter; 00055 00056 00057 // =========================================================================== 00058 // class definitions 00059 // =========================================================================== 00073 class MSVehicleType { 00074 public: 00091 MSVehicleType(const std::string& id, SUMOReal lengthWithGap, 00092 SUMOReal minGap, SUMOReal maxSpeed, 00093 SUMOReal prob, SUMOReal speedFactor, 00094 SUMOReal speedDev, SUMOVehicleClass vclass, 00095 SUMOEmissionClass emissionClass, 00096 SUMOReal guiWidth, SUMOVehicleShape shape, 00097 const std::string& lcModel, 00098 const RGBColor& c) ; 00099 00100 00102 virtual ~MSVehicleType() ; 00103 00104 00105 00108 00112 const std::string& getID() const { 00113 return myID; 00114 } 00115 00116 00120 SUMOReal getLength() const { 00121 return myLength; 00122 } 00123 00124 00128 SUMOReal getLengthWithGap() const { 00129 return myLength + myMinGap; 00130 } 00131 00132 00136 SUMOReal getMinGap() const { 00137 return myMinGap; 00138 } 00139 00140 00144 inline const MSCFModel& getCarFollowModel() const { 00145 return *myCarFollowModel; 00146 } 00147 00148 00152 inline MSCFModel& getCarFollowModel() { 00153 return *myCarFollowModel; 00154 } 00155 00156 00160 SUMOReal getMaxSpeed() const { 00161 return myMaxSpeed; 00162 } 00163 00167 SUMOReal hasSpeedDeviation() const { 00168 return mySpeedDev != 0.0 || mySpeedFactor != 1.0; 00169 } 00170 00171 00178 SUMOReal getMaxSpeedWithDeviation(SUMOReal referenceSpeed) const { 00179 SUMOReal meanSpeed = mySpeedFactor * referenceSpeed; 00180 SUMOReal speedDev = mySpeedDev * meanSpeed; 00181 SUMOReal speed = MIN3(RandHelper::randNorm(meanSpeed, speedDev), meanSpeed + 2 * speedDev, myMaxSpeed); 00182 return MAX3((SUMOReal)0.0, speed, meanSpeed - 2 * speedDev); 00183 } 00184 00185 00189 SUMOReal getDefaultProbability() const { 00190 return myDefaultProbability; 00191 } 00192 00193 00198 SUMOVehicleClass getVehicleClass() const { 00199 return myVehicleClass; 00200 } 00201 00202 00207 SUMOEmissionClass getEmissionClass() const { 00208 return myEmissionClass; 00209 } 00210 00211 00215 const RGBColor& getColor() const { 00216 return myColor; 00217 } 00218 00219 00223 SUMOReal getSpeedFactor() const { 00224 return mySpeedFactor; 00225 } 00226 00227 00231 SUMOReal getSpeedDeviation() const { 00232 return mySpeedDev; 00233 } 00235 00236 00237 00240 00244 SUMOReal getGuiWidth() const { 00245 return myWidth; 00246 } 00247 00252 SUMOVehicleShape getGuiShape() const { 00253 return myShape; 00254 } 00255 00257 00258 00259 00260 00261 00263 void saveState(std::ostream& os); 00264 00265 00266 00269 00277 void setLength(const SUMOReal& length) ; 00278 00279 00287 void setMinGap(const SUMOReal& minGap) ; 00288 00289 00297 void setMaxSpeed(const SUMOReal& maxSpeed) ; 00298 00299 00303 void setVClass(SUMOVehicleClass vclass) ; 00304 00305 00313 void setDefaultProbability(const SUMOReal& prob) ; 00314 00315 00323 void setSpeedFactor(const SUMOReal& factor) ; 00324 00325 00333 void setSpeedDeviation(const SUMOReal& dev) ; 00334 00335 00339 void setEmissionClass(SUMOEmissionClass eclass) ; 00340 00341 00345 void setColor(const RGBColor& color) ; 00346 00347 00355 void setWidth(const SUMOReal& width) ; 00356 00357 00361 void setShape(SUMOVehicleShape shape) ; 00363 00364 00365 00368 00374 static MSVehicleType* build(SUMOVTypeParameter& from) ; 00375 00376 00382 static MSVehicleType* build(const std::string& id, const MSVehicleType* from) ; 00383 00384 00391 static SUMOReal get(const SUMOVTypeParameter::CFParams& from, SumoXMLAttr attr, SUMOReal defaultValue); 00393 00394 00398 bool amVehicleSpecific() const { 00399 return myOriginalType != 0; 00400 } 00401 00402 00403 private: 00405 std::string myID; 00406 00408 SUMOReal myLength; 00409 00411 SUMOReal myMinGap; 00412 00414 SUMOReal myMaxSpeed; 00415 00417 SUMOReal myDefaultProbability; 00418 00420 SUMOReal mySpeedFactor; 00421 00423 SUMOReal mySpeedDev; 00424 00426 MSCFModel* myCarFollowModel; 00427 00429 std::string myLaneChangeModel; 00430 00432 SUMOEmissionClass myEmissionClass; 00433 00435 RGBColor myColor; 00436 00438 SUMOVehicleClass myVehicleClass; 00439 00440 00443 00445 SUMOReal myWidth; 00446 00448 SUMOVehicleShape myShape; 00450 00451 00453 const MSVehicleType* myOriginalType; 00454 00455 00456 private: 00458 MSVehicleType(const MSVehicleType&); 00459 00461 MSVehicleType& operator=(const MSVehicleType&); 00462 00463 }; 00464 00465 00466 #endif 00467 00468 /****************************************************************************/ 00469