Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSVehicleType.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
22// The car-following model and parameter
23/****************************************************************************/
24#include <config.h>
25
26#include <cassert>
27#include <memory>
35#include "MSNet.h"
50#include "MSInsertionControl.h"
51#include "MSVehicleControl.h"
53#include "MSVehicleType.h"
54
55
56// ===========================================================================
57// static members
58// ===========================================================================
60
61
62// ===========================================================================
63// method definitions
64// ===========================================================================
66 myParameter(parameter),
67 myEnergyParams(&parameter),
72 myCarFollowModel(nullptr),
73 myOriginalType(nullptr) {
74 assert(getLength() > 0);
75 assert(getMaxSpeed() > 0);
76
77 // Check if actionStepLength was set by user, if not init to global default
80 }
82}
83
84
88
89
90double
91MSVehicleType::computeChosenSpeedDeviation(double speedFactorOverride, SumoRNG* rng, const double minDev) const {
92 return speedFactorOverride < 0
93 ? roundDecimal(MAX2(minDev, myParameter.speedFactor.sample(rng)), gPrecisionRandom)
94 : speedFactorOverride;
95}
96
97
98// ------------ Setter methods
99void
100MSVehicleType::setLength(const double& length) {
101 if (myOriginalType != nullptr && length < 0) {
102 myParameter.length = myOriginalType->getLength();
103 } else {
104 myParameter.length = length;
105 }
106 myParameter.parametersSet |= VTYPEPARS_LENGTH_SET;
107}
108
109
110void
111MSVehicleType::setHeight(const double& height) {
112 if (myOriginalType != nullptr && height < 0) {
113 myParameter.height = myOriginalType->getHeight();
114 } else {
115 myParameter.height = height;
116 }
117 myParameter.parametersSet |= VTYPEPARS_HEIGHT_SET;
118}
119
120
121void
122MSVehicleType::setMinGap(const double& minGap) {
123 if (myOriginalType != nullptr && minGap < 0) {
124 myParameter.minGap = myOriginalType->getMinGap();
125 } else {
126 myParameter.minGap = minGap;
127 }
128 myParameter.parametersSet |= VTYPEPARS_MINGAP_SET;
129}
130
131
132void
133MSVehicleType::setMinGapLat(const double& minGapLat) {
134 if (myOriginalType != nullptr && minGapLat < 0) {
135 myParameter.minGapLat = myOriginalType->getMinGapLat();
136 } else {
137 myParameter.minGapLat = minGapLat;
138 }
139 myParameter.parametersSet |= VTYPEPARS_MINGAP_LAT_SET;
140}
141
142
143void
144MSVehicleType::setMaxSpeed(const double& maxSpeed) {
145 if (myOriginalType != nullptr && maxSpeed < 0) {
146 myParameter.maxSpeed = myOriginalType->getMaxSpeed();
147 } else {
148 myParameter.maxSpeed = maxSpeed;
149 }
150 myParameter.parametersSet |= VTYPEPARS_MAXSPEED_SET;
151}
152
153
154void
155MSVehicleType::setMaxSpeedLat(const double& maxSpeedLat) {
156 if (myOriginalType != nullptr && maxSpeedLat < 0) {
157 myParameter.maxSpeedLat = myOriginalType->getMaxSpeedLat();
158 } else {
159 myParameter.maxSpeedLat = maxSpeedLat;
160 }
162}
163
164
165void
167 myParameter.vehicleClass = vclass;
169}
170
171
172void
174 myParameter.shape = shape;
175 myParameter.parametersSet |= VTYPEPARS_SHAPE_SET;
176}
177
178void
179MSVehicleType::setPreferredLateralAlignment(const LatAlignmentDefinition& latAlignment, double latAlignmentOffset) {
180 myParameter.latAlignmentProcedure = latAlignment;
181 myParameter.latAlignmentOffset = latAlignmentOffset;
183}
184
185void
187 myParameter.scale = value;
189 insertControl.updateScale(getID());
190}
191
192void
195}
196
197void
199 if (myOriginalType != nullptr && prob < 0) {
200 myParameter.defaultProbability = myOriginalType->getDefaultProbability();
201 } else {
202 myParameter.defaultProbability = prob;
203 }
204 myParameter.parametersSet |= VTYPEPARS_PROBABILITY_SET;
205}
206
207
208void
209MSVehicleType::setSpeedFactor(const double& factor) {
210 if (myOriginalType != nullptr && factor < 0) {
211 myParameter.speedFactor.setParameter(0, myOriginalType->myParameter.speedFactor.getParameter(0));
212 } else {
213 myParameter.speedFactor.setParameter(0, factor);
214 }
215 myParameter.parametersSet |= VTYPEPARS_SPEEDFACTOR_SET;
216}
217
218
219void
221 if (myOriginalType != nullptr && dev < 0) {
222 myParameter.speedFactor.setParameter(1, myOriginalType->myParameter.speedFactor.getParameter(1));
223 } else {
224 myParameter.speedFactor.setParameter(1, dev);
225 }
226 myParameter.parametersSet |= VTYPEPARS_SPEEDFACTOR_SET;
227}
228
229
230void
231MSVehicleType::setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset) {
232 assert(actionStepLength >= 0);
234
235 if (myParameter.actionStepLength == actionStepLength) {
236 return;
237 }
238
239 SUMOTime previousActionStepLength = myParameter.actionStepLength;
240 myParameter.actionStepLength = actionStepLength;
242 check();
243
244 if (isVehicleSpecific()) {
245 // don't perform vehicle lookup for singular vtype
246 return;
247 }
248
249 // For non-singular vType reset all vehicle's actionOffsets
250 // Iterate through vehicles
252 for (auto vehIt = vc.loadedVehBegin(); vehIt != vc.loadedVehEnd(); ++vehIt) {
253 MSVehicle* veh = static_cast<MSVehicle*>(vehIt->second);
254 if (&veh->getVehicleType() == this) {
255 // Found vehicle of this type. Perform requested actionOffsetReset
256 if (resetActionOffset) {
257 veh->resetActionOffset();
258 } else {
259 veh->updateActionOffset(previousActionStepLength, actionStepLength);
260 }
261 }
262 }
263}
264
265
266void
268 myParameter.emissionClass = eclass;
270}
271
272
273void
275 myParameter.mass = mass;
276 myParameter.parametersSet |= VTYPEPARS_MASS_SET;
277 const_cast<EnergyParams&>(myEnergyParams).setMass(mass);
278}
279
280
281void
283 myParameter.color = color;
284 myParameter.parametersSet |= VTYPEPARS_COLOR_SET;
285}
286
287
288void
289MSVehicleType::setParkingBadges(const std::vector<std::string>& badges) {
290 myParameter.parkingBadges.assign(badges.begin(), badges.end());
292}
293
294
295void
296MSVehicleType::setWidth(const double& width) {
297 if (myOriginalType != nullptr && width < 0) {
298 myParameter.width = myOriginalType->getWidth();
299 } else {
300 myParameter.width = width;
301 }
302 myParameter.parametersSet |= VTYPEPARS_WIDTH_SET;
303}
304
305void
306MSVehicleType::setImpatience(const double impatience) {
307 myParameter.impatience = impatience;
308 myParameter.parametersSet |= VTYPEPARS_IMPATIENCE_SET;
309}
310
311
312void
314 if (myOriginalType != nullptr && duration < 0) {
315 myParameter.boardingDuration = myOriginalType->getBoardingDuration(isPerson);
316 } else {
317 if (isPerson) {
318 myParameter.boardingDuration = duration;
319 } else {
320 myParameter.loadingDuration = duration;
321 }
322 }
324}
325
326void
328 myParameter.shape = shape;
329 myParameter.parametersSet |= VTYPEPARS_SHAPE_SET;
330}
331
332
333
334// ------------ Static methods for building vehicle types
336MSVehicleType::build(SUMOVTypeParameter& from, const std::string& fileName) {
337 if (from.hasParameter("vehicleMass")) {
338 if (from.wasSet(VTYPEPARS_MASS_SET)) {
339 WRITE_WARNINGF(TL("The vType '%' has a 'mass' attribute and a 'vehicleMass' parameter. The 'mass' attribute will take precedence."), from.id);
340 } else {
341 WRITE_WARNINGF(TL("The vType '%' has a 'vehicleMass' parameter, which is deprecated. Please use the 'mass' attribute (for the empty mass) and the 'loading' parameter, if needed."), from.id);
342 from.mass = from.getDouble("vehicleMass", from.mass);
344 }
345 }
346 // the unique_ptr ensures the type is deleted if an exception occurs
347 std::unique_ptr<MSVehicleType> vtypeOwner(new MSVehicleType(from));
348 MSVehicleType* vtype = vtypeOwner.get();
351 // by default decel and apparentDecel are identical
352 const double apparentDecel = from.getCFParam(SUMO_ATTR_APPARENTDECEL, decel);
353
354 if (emergencyDecel < decel) {
355 WRITE_WARNINGF(TL("Value of 'emergencyDecel' (%) should be higher than 'decel' (%) for vType '%'."), toString(emergencyDecel), toString(decel), from.id);
356 }
357 if (emergencyDecel < apparentDecel) {
358 WRITE_WARNINGF(TL("Value of 'emergencyDecel' (%) is lower than 'apparentDecel' (%) for vType '%' may cause collisions."), toString(emergencyDecel), toString(apparentDecel), from.id);
359 }
360
361 switch (from.cfModel) {
362 case SUMO_TAG_CF_IDM:
363 vtype->myCarFollowModel = new MSCFModel_IDM(vtype, false);
364 break;
365 case SUMO_TAG_CF_IDMM:
366 vtype->myCarFollowModel = new MSCFModel_IDM(vtype, true);
367 break;
369 vtype->myCarFollowModel = new MSCFModel_Kerner(vtype);
370 break;
372 vtype->myCarFollowModel = new MSCFModel_KraussOrig1(vtype);
373 break;
375 vtype->myCarFollowModel = new MSCFModel_KraussPS(vtype);
376 break;
378 vtype->myCarFollowModel = new MSCFModel_KraussX(vtype);
379 break;
380 case SUMO_TAG_CF_EIDM:
381 vtype->myCarFollowModel = new MSCFModel_EIDM(vtype);
382 break;
384 vtype->myCarFollowModel = new MSCFModel_SmartSK(vtype);
385 break;
387 vtype->myCarFollowModel = new MSCFModel_Daniel1(vtype);
388 break;
390 vtype->myCarFollowModel = new MSCFModel_PWag2009(vtype);
391 break;
393 vtype->myCarFollowModel = new MSCFModel_Wiedemann(vtype);
394 break;
395 case SUMO_TAG_CF_W99:
396 vtype->myCarFollowModel = new MSCFModel_W99(vtype);
397 break;
398 case SUMO_TAG_CF_RAIL:
399 vtype->myCarFollowModel = new MSCFModel_Rail(vtype);
400 break;
401 case SUMO_TAG_CF_ACC:
402 vtype->myCarFollowModel = new MSCFModel_ACC(vtype);
403 break;
404 case SUMO_TAG_CF_CACC:
405 vtype->myCarFollowModel = new MSCFModel_CACC(vtype);
406 break;
407 case SUMO_TAG_CF_CC:
408 vtype->myCarFollowModel = new MSCFModel_CC(vtype);
409 break;
411 default:
412 vtype->myCarFollowModel = new MSCFModel_Krauss(vtype);
413 break;
414 }
415 // init Rail visualization parameters
417 return vtypeOwner.release();
418}
419
422 return (getParameter().getEntryManoeuvreTime(angle));
423}
424
427 return (getParameter().getExitManoeuvreTime(angle));
428}
429
431MSVehicleType::buildSingularType(const std::string& id) const {
432 return duplicateType(id, false);
433}
434
435
437MSVehicleType::duplicateType(const std::string& id, bool persistent) const {
439 vtype->myParameter.id = id;
440 vtype->myCarFollowModel = myCarFollowModel->duplicate(vtype);
441 if (!persistent) {
442 vtype->myOriginalType = this;
443 }
444 if (!MSNet::getInstance()->getVehicleControl().addVType(vtype)) {
445 std::string singular = persistent ? "" : TL("singular ");
446 throw ProcessError(TLF("could not add %type %", singular, vtype->getID()));
447 }
448 return vtype;
449}
450
451void
454 && myParameter.actionStepLength != DELTA_T
455 && STEPS2TIME(myParameter.actionStepLength) > getCarFollowModel().getHeadwayTime()) {
457 std::stringstream s;
458 s << "Given action step length " << STEPS2TIME(myParameter.actionStepLength) << " for vehicle type '" << getID()
459 << "' is larger than its parameter tau (=" << getCarFollowModel().getHeadwayTime() << ")!"
460 << " This may lead to collisions. (This warning is only issued once per vehicle type).";
461 WRITE_WARNING(s.str());
462 }
464 && myParameter.actionStepLength != DELTA_T
467 std::string warning2;
468 if (OptionsCont::getOptions().isDefault("step-method.ballistic")) {
469 warning2 = " Setting it now to avoid collisions.";
471 } else {
472 warning2 = " This may cause collisions.";
473 }
474 WRITE_WARNINGF("Action step length '%' is used for vehicle type '%' but step-method.ballistic was not set." + warning2
475 , STEPS2TIME(myParameter.actionStepLength), getID())
476 }
477 if (!myWarnedStepLengthTauOnce && TS > getCarFollowModel().getHeadwayTime()
480 WRITE_WARNINGF(TL("Value of tau=% in vehicle type '%' lower than simulation step size may cause collisions."),
481 getCarFollowModel().getHeadwayTime(), getID());
482 }
483 if (MSGlobals::gUseMesoSim && getVehicleClass() != SVC_PEDESTRIAN && !OptionsCont::getOptions().getBool("meso-lane-queue")) {
484 SVCPermissions ignoreVClasses = parseVehicleClasses(OptionsCont::getOptions().getStringVector("meso-ignore-lanes-by-vclass"));
485 if ((ignoreVClasses & getVehicleClass()) != 0) {
486 WRITE_WARNINGF(TL("Vehicle class '%' of vType '%' is set as ignored by option --meso-ignore-lanes-by-vclass to ensure default vehicle capacity. Set option --meso-lane-queue for multi-modal meso simulation"),
488 }
489 }
490 if (!myParameter.wasSet(VTYPEPARS_EMISSIONCLASS_SET) && !OptionsCont::getOptions().getBool("device.battery.track-fuel")
491 && (OptionsCont::getOptions().getFloat("device.battery.probability") == 1.
492 || myParameter.getDouble("device.battery.probability", -1.) == 1.
493 || StringUtils::toBool(myParameter.getParameter("has.battery.device", "false")))) {
494 myParameter.emissionClass = PollutantsInterface::getClassByName("Energy");
496 WRITE_MESSAGEF(TL("The battery device is active for vType '%' but no emission class is set. The emission class Energy/unknown will be used, please consider setting an explicit emission class!"),
497 getID());
498 }
499}
500
501
502void
504 if (myOriginalType != nullptr && accel < 0) {
505 accel = myOriginalType->getCarFollowModel().getMaxAccel();
506 }
507 myCarFollowModel->setMaxAccel(accel);
508 myParameter.cfParameter[SUMO_ATTR_ACCEL] = toString(accel);
509}
510
511void
513 if (myOriginalType != nullptr && decel < 0) {
514 decel = myOriginalType->getCarFollowModel().getMaxDecel();
515 }
516 myCarFollowModel->setMaxDecel(decel);
517 myParameter.cfParameter[SUMO_ATTR_DECEL] = toString(decel);
518}
519
520void
521MSVehicleType::setEmergencyDecel(double emergencyDecel) {
522 if (myOriginalType != nullptr && emergencyDecel < 0) {
523 emergencyDecel = myOriginalType->getCarFollowModel().getEmergencyDecel();
524 }
525 myCarFollowModel->setEmergencyDecel(emergencyDecel);
526 myParameter.cfParameter[SUMO_ATTR_EMERGENCYDECEL] = toString(emergencyDecel);
527}
528
529void
530MSVehicleType::setApparentDecel(double apparentDecel) {
531 if (myOriginalType != nullptr && apparentDecel < 0) {
532 apparentDecel = myOriginalType->getCarFollowModel().getApparentDecel();
533 }
534 myCarFollowModel->setApparentDecel(apparentDecel);
535 myParameter.cfParameter[SUMO_ATTR_APPARENTDECEL] = toString(apparentDecel);
536}
537
538void
539MSVehicleType::setMaxAccelProfile(std::vector<std::pair<double, double> > /* accelProfile */) {
540 /*
541 if (myOriginalType != nullptr) {
542 accelProfile = myOriginalType->getCarFollowModel().getMaxAccelProfile();
543 } else {
544 if (accelProfile[0].first > 0.) {
545 accelProfile.insert(accelProfile.begin(), std::make_pair(0.0, accelProfile[0].second));
546 }
547 if (accelProfile.back().first < (10000 / 3.6)) {
548 accelProfile.push_back(std::make_pair((10000 / 3.6), accelProfile.back().second));
549 }
550 double prevSpeed = 0.0;
551 for (const auto& accelPair : accelProfile) {
552 if (accelPair.first < 0.) {
553 accelProfile = myOriginalType->getCarFollowModel().getMaxAccelProfile();
554 break;
555 } else if (accelPair.second < 0.) {
556 accelProfile = myOriginalType->getCarFollowModel().getMaxAccelProfile();
557 break;
558 } else if (accelPair.first < prevSpeed) {
559 accelProfile = myOriginalType->getCarFollowModel().getMaxAccelProfile();
560 break;
561 }
562 prevSpeed = accelPair.first;
563 }
564 }
565 myCarFollowModel->setMaxAccelProfile(accelProfile);
566
567 std::stringstream accelProfileString;
568 accelProfileString << std::fixed << std::setprecision(2);
569 int count = 0;
570 for (const auto& accelPair : accelProfile) {
571 if (count > 0) {
572 accelProfileString << " ";
573 }
574 accelProfileString << toString(accelPair.first) + "," << accelPair.second;
575 count++;
576 }
577 myParameter.cfParameter[SUMO_ATTR_MAXACCEL_PROFILE] = accelProfileString.str();
578 */
579}
580
581void
582MSVehicleType::setDesAccelProfile(std::vector<std::pair<double, double> > /* accelProfile */) {
583 /*
584 if (myOriginalType != nullptr) {
585 accelProfile = myOriginalType->getCarFollowModel().getDesAccelProfile();
586 } else {
587 if (accelProfile[0].first > 0.) {
588 accelProfile.insert(accelProfile.begin(), std::make_pair(0.0, accelProfile[0].second));
589 }
590 if (accelProfile.back().first < (10000 / 3.6)) {
591 accelProfile.push_back(std::make_pair((10000 / 3.6), accelProfile.back().second));
592 }
593 double prevSpeed = 0.0;
594 for (const auto& accelPair : accelProfile) {
595 if (accelPair.first < 0.) {
596 accelProfile = myOriginalType->getCarFollowModel().getDesAccelProfile();
597 break;
598 } else if (accelPair.second < 0.) {
599 accelProfile = myOriginalType->getCarFollowModel().getDesAccelProfile();
600 break;
601 } else if (accelPair.first < prevSpeed) {
602 accelProfile = myOriginalType->getCarFollowModel().getDesAccelProfile();
603 break;
604 }
605 prevSpeed = accelPair.first;
606 }
607 }
608 myCarFollowModel->setDesAccelProfile(accelProfile);
609
610 std::stringstream accelProfileString;
611 accelProfileString << std::fixed << std::setprecision(2);
612 int count = 0;
613 for (const auto& accelPair : accelProfile) {
614 if (count > 0) {
615 accelProfileString << " ";
616 }
617 accelProfileString << toString(accelPair.first) + "," << accelPair.second;
618 count++;
619 }
620 myParameter.cfParameter[SUMO_ATTR_DESACCEL_PROFILE] = accelProfileString.str();
621 */
622}
623
624void
625MSVehicleType::setImperfection(double imperfection) {
626 if (myOriginalType != nullptr && imperfection < 0) {
627 imperfection = myOriginalType->getCarFollowModel().getImperfection();
628 }
629 myCarFollowModel->setImperfection(imperfection);
630 myParameter.cfParameter[SUMO_ATTR_SIGMA] = toString(imperfection);
631}
632
633void
635 if (myOriginalType != nullptr && tau < 0) {
636 tau = myOriginalType->getCarFollowModel().getHeadwayTime();
637 }
638 myCarFollowModel->setHeadwayTime(tau);
639 myParameter.cfParameter[SUMO_ATTR_TAU] = toString(tau);
640}
641
642
643/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_MESSAGEF(...)
Definition MsgHandler.h:289
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
const std::string invalid_return< std::string >::value
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
#define STEPS2TIME(x)
Definition SUMOTime.h:58
#define TS
Definition SUMOTime.h:45
const long long int VTYPEPARS_SHAPE_SET
const long long int VTYPEPARS_WIDTH_SET
const long long int VTYPEPARS_ACTIONSTEPLENGTH_SET
const long long int VTYPEPARS_MAXSPEED_LAT_SET
const long long int VTYPEPARS_MAXSPEED_SET
const long long int VTYPEPARS_EMISSIONCLASS_SET
const long long int VTYPEPARS_LATALIGNMENT_SET
const long long int VTYPEPARS_COLOR_SET
const long long int VTYPEPARS_SPEEDFACTOR_SET
const long long int VTYPEPARS_MINGAP_SET
const long long int VTYPEPARS_PROBABILITY_SET
const long long int VTYPEPARS_HEIGHT_SET
const long long int VTYPEPARS_PARKING_BADGES_SET
const long long int VTYPEPARS_MASS_SET
const long long int VTYPEPARS_BOARDING_DURATION
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
const long long int VTYPEPARS_VEHICLECLASS_SET
const long long int VTYPEPARS_IMPATIENCE_SET
const long long int VTYPEPARS_LENGTH_SET
const long long int VTYPEPARS_MINGAP_LAT_SET
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
int SUMOEmissionClass
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PEDESTRIAN
pedestrian
@ SUMO_TAG_CF_KRAUSS
@ SUMO_TAG_CF_BKERNER
@ SUMO_TAG_CF_KRAUSSX
@ SUMO_TAG_CF_CACC
@ SUMO_TAG_CF_CC
@ SUMO_TAG_CF_KRAUSS_PLUS_SLOPE
@ SUMO_TAG_CF_IDM
@ SUMO_TAG_CF_W99
@ SUMO_TAG_CF_RAIL
@ SUMO_TAG_CF_SMART_SK
@ SUMO_TAG_CF_EIDM
@ SUMO_TAG_CF_PWAGNER2009
@ SUMO_TAG_CF_KRAUSS_ORIG1
@ SUMO_TAG_CF_WIEDEMANN
@ SUMO_TAG_CF_IDMM
@ SUMO_TAG_CF_DANIEL1
@ SUMO_TAG_CF_ACC
@ SUMO_ATTR_APPARENTDECEL
@ SUMO_ATTR_DECEL
@ SUMO_ATTR_LCA_CONTRIGHT
@ SUMO_ATTR_EMERGENCYDECEL
@ SUMO_ATTR_ACCEL
@ SUMO_ATTR_SIGMA
@ SUMO_ATTR_TAU
int gPrecisionRandom
Definition StdDefs.cpp:30
double roundDecimal(double x, int precision)
round to the given number of decimal digits
Definition StdDefs.cpp:61
T MAX2(T a, T b)
Definition StdDefs.h:86
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
An upper class for objects with additional parameters.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
The ACC car-following model.
The CACC car-following model.
A set of automatic Cruise Controllers, including classic Cruise Control (CC), Adaptive Cruise Control...
The original Krauss (1998) car-following model and parameter.
The Extended Intelligent Driver Model (EIDM) car-following model.
The Intelligent Driver Model (IDM) car-following model.
car-following model by B. Kerner
Krauss car-following model, with acceleration decrease and faster start.
The original Krauss (1998) car-following model and parameter.
Krauss car-following model, changing accel and speed by slope.
Krauss car-following model, changing accel and speed by slope.
Scalable model based on Krauss by Peter Wagner.
The original Krauss (1998) car-following model and parameter.
The W99 Model car-following model.
The Wiedemann Model car-following model.
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
Definition MSCFModel.h:355
static bool gUseMesoSim
Definition MSGlobals.h:106
static double gDefaultEmergencyDecel
encoding of the string-option default.emergencydecel
Definition MSGlobals.h:130
static bool gSemiImplicitEulerUpdate
Definition MSGlobals.h:53
static SUMOTime gActionStepLength
default value for the interval between two action points for MSVehicle (defaults to DELTA_T)
Definition MSGlobals.h:121
Inserts vehicles into the network when their departure time is reached.
void updateScale(const std::string vtypeid)
updates the flow scale value to keep track of TraCI-induced change
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:199
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:455
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:402
The class responsible for building and deletion of vehicles.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
void updateActionOffset(const SUMOTime oldActionStepLength, const SUMOTime newActionStepLength)
Process an updated action step length value (only affects the vehicle's action offset,...
The car-following model and parameter.
void setHeight(const double &height)
Set a new value for this type's height.
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type's maximum lateral speed.
double myCachedActionStepLengthSecs
the vtypes actionsStepLength in seconds (cached because needed very often)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void setSpeedFactor(const double &factor)
Set a new value for this type's speed factor.
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
const int myIndex
the running index
void setGUIShape(SUMOVehicleShape shape)
Set a new value for this type's gui shape.
MSVehicleType(const SUMOVTypeParameter &parameter)
Constructor.
void setDefaultProbability(const double &prob)
Set a new value for this type's default probability.
void setEmergencyDecel(double emergencyDecel)
Set a new value for this type's emergency deceleration.
void setSpeedDeviation(const double &dev)
Set a new value for this type's speed deviation.
bool myWarnedActionStepLengthTauOnce
Indicator whether the user was already warned once about an action step length larger than the desire...
const std::string & getID() const
Returns the name of the vehicle type.
void setParkingBadges(const std::vector< std::string > &badges)
Set a new value for parking access rights of this type.
MSCFModel * myCarFollowModel
instance of the car following model.
void setDesAccelProfile(std::vector< std::pair< double, double > > accelProfile)
Set a new value for this type's desired acceleration profile.
void setMinGapLat(const double &minGapLat)
Set a new value for this type's minimum lataral gap.
MSVehicleType * duplicateType(const std::string &id, bool persistent) const
Duplicates the microsim vehicle type giving the newly created type the given id.
SUMOVTypeParameter myParameter
the parameter container
bool myWarnedStepLengthTauOnce
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
void setBoardingDuration(SUMOTime duration, bool isPerson=true)
Set a new value for this type's boardingDuration.
const MSVehicleType * myOriginalType
The original type.
void setLength(const double &length)
Set a new value for this type's length.
void setDecel(double decel)
Set a new value for this type's deceleration.
SUMOTime getExitManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning exit time for a specific manoeuver angle.
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
void setAccel(double accel)
Set a new value for this type's acceleration.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version).
void setWidth(const double &width)
Set a new value for this type's width.
void setLcContRight(const std::string &value)
Set lcContRight (which is the only lc-attribute not used within the laneChange model).
void setColor(const RGBColor &color)
Set a new value for this type's color.
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified).
void setImpatience(const double impatience)
Set a new value for this type's impatience.
void setImperfection(double imperfection)
Set a new value for this type's imperfection.
static MSVehicleType * build(SUMOVTypeParameter &from, const std::string &fileName="")
Builds the microsim vehicle type described by the given parameter.
void setPreferredLateralAlignment(const LatAlignmentDefinition &latAlignment, double latAlignmentOffset=0.0)
Set vehicle's preferred lateral alignment.
static int myNextIndex
next value for the running index
void setTau(double tau)
Set a new value for this type's headway.
void setMaxAccelProfile(std::vector< std::pair< double, double > > accelProfile)
Set a new value for this type's maximum acceleration profile.
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type's action step length.
double getLength() const
Get vehicle's length [m].
void setMass(double mass)
Set a new value for this type's mass.
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
SUMOTime getEntryManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning entry time for a specific manoeuver angle.
double computeChosenSpeedDeviation(double speedFactorOverride, SumoRNG *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
const SUMOVTypeParameter & getParameter() const
virtual ~MSVehicleType()
Destructor.
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
const EnergyParams myEnergyParams
void check()
Checks whether vehicle type parameters may be problematic (Currently, only the value for the action s...
bool myWarnedActionStepLengthBallisticOnce
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
void setScale(double value)
Set traffic scaling factor.
static OptionsCont & getOptions()
Retrieves the options.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
double getDouble(const std::string &key, const double defaultValue) const
Returns the value for a given key converted to a double.
Structure representing possible vehicle parameter.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
static double getDefaultDecel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default deceleration for the given vehicle class This needs to be a function because the ...
void initRailVisualizationParameters(const std::string fileName="")
init Rail Visualization Parameters
long long int parametersSet
Information for the router which parameter were set.
static double getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption)
Returns the default emergency deceleration for the given vehicle class This needs to be a function be...
double getCFParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
SUMOVehicleClass vehicleClass
The vehicle's class.
std::string id
The vehicle type's id.
SumoXMLTag cfModel
The enum-representation of the car-following model to use.
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter