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-2025 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>
34#include "MSNet.h"
49#include "MSInsertionControl.h"
50#include "MSVehicleControl.h"
52#include "MSVehicleType.h"
53
54
55// ===========================================================================
56// static members
57// ===========================================================================
59
60
61// ===========================================================================
62// method definitions
63// ===========================================================================
65 myParameter(parameter),
66 myEnergyParams(&parameter),
71 myCarFollowModel(nullptr),
72 myOriginalType(nullptr) {
73 assert(getLength() > 0);
74 assert(getMaxSpeed() > 0);
75
76 // Check if actionStepLength was set by user, if not init to global default
79 }
81}
82
83
87
88
89double
90MSVehicleType::computeChosenSpeedDeviation(SumoRNG* rng, const double minDev) const {
91 return roundDecimal(MAX2(minDev, myParameter.speedFactor.sample(rng)), gPrecisionRandom);
92}
93
94
95// ------------ Setter methods
96void
97MSVehicleType::setLength(const double& length) {
98 if (myOriginalType != nullptr && length < 0) {
99 myParameter.length = myOriginalType->getLength();
100 } else {
101 myParameter.length = length;
102 }
103 myParameter.parametersSet |= VTYPEPARS_LENGTH_SET;
104}
105
106
107void
108MSVehicleType::setHeight(const double& height) {
109 if (myOriginalType != nullptr && height < 0) {
110 myParameter.height = myOriginalType->getHeight();
111 } else {
112 myParameter.height = height;
113 }
114 myParameter.parametersSet |= VTYPEPARS_HEIGHT_SET;
115}
116
117
118void
119MSVehicleType::setMinGap(const double& minGap) {
120 if (myOriginalType != nullptr && minGap < 0) {
121 myParameter.minGap = myOriginalType->getMinGap();
122 } else {
123 myParameter.minGap = minGap;
124 }
125 myParameter.parametersSet |= VTYPEPARS_MINGAP_SET;
126}
127
128
129void
130MSVehicleType::setMinGapLat(const double& minGapLat) {
131 if (myOriginalType != nullptr && minGapLat < 0) {
132 myParameter.minGapLat = myOriginalType->getMinGapLat();
133 } else {
134 myParameter.minGapLat = minGapLat;
135 }
136 myParameter.parametersSet |= VTYPEPARS_MINGAP_LAT_SET;
137}
138
139
140void
141MSVehicleType::setMaxSpeed(const double& maxSpeed) {
142 if (myOriginalType != nullptr && maxSpeed < 0) {
143 myParameter.maxSpeed = myOriginalType->getMaxSpeed();
144 } else {
145 myParameter.maxSpeed = maxSpeed;
146 }
147 myParameter.parametersSet |= VTYPEPARS_MAXSPEED_SET;
148}
149
150
151void
152MSVehicleType::setMaxSpeedLat(const double& maxSpeedLat) {
153 if (myOriginalType != nullptr && maxSpeedLat < 0) {
154 myParameter.maxSpeedLat = myOriginalType->getMaxSpeedLat();
155 } else {
156 myParameter.maxSpeedLat = maxSpeedLat;
157 }
159}
160
161
162void
164 myParameter.vehicleClass = vclass;
166}
167
168
169void
171 myParameter.shape = shape;
172 myParameter.parametersSet |= VTYPEPARS_SHAPE_SET;
173}
174
175void
176MSVehicleType::setPreferredLateralAlignment(const LatAlignmentDefinition& latAlignment, double latAlignmentOffset) {
177 myParameter.latAlignmentProcedure = latAlignment;
178 myParameter.latAlignmentOffset = latAlignmentOffset;
180}
181
182void
184 myParameter.scale = value;
186 insertControl.updateScale(getID());
187}
188
189void
192}
193
194void
196 if (myOriginalType != nullptr && prob < 0) {
197 myParameter.defaultProbability = myOriginalType->getDefaultProbability();
198 } else {
199 myParameter.defaultProbability = prob;
200 }
201 myParameter.parametersSet |= VTYPEPARS_PROBABILITY_SET;
202}
203
204
205void
206MSVehicleType::setSpeedFactor(const double& factor) {
207 if (myOriginalType != nullptr && factor < 0) {
208 myParameter.speedFactor.setParameter(0, myOriginalType->myParameter.speedFactor.getParameter(0));
209 } else {
210 myParameter.speedFactor.setParameter(0, factor);
211 }
212 myParameter.parametersSet |= VTYPEPARS_SPEEDFACTOR_SET;
213}
214
215
216void
218 if (myOriginalType != nullptr && dev < 0) {
219 myParameter.speedFactor.setParameter(1, myOriginalType->myParameter.speedFactor.getParameter(1));
220 } else {
221 myParameter.speedFactor.setParameter(1, dev);
222 }
223 myParameter.parametersSet |= VTYPEPARS_SPEEDFACTOR_SET;
224}
225
226
227void
228MSVehicleType::setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset) {
229 assert(actionStepLength >= 0);
231
232 if (myParameter.actionStepLength == actionStepLength) {
233 return;
234 }
235
236 SUMOTime previousActionStepLength = myParameter.actionStepLength;
237 myParameter.actionStepLength = actionStepLength;
239 check();
240
241 if (isVehicleSpecific()) {
242 // don't perform vehicle lookup for singular vtype
243 return;
244 }
245
246 // For non-singular vType reset all vehicle's actionOffsets
247 // Iterate through vehicles
249 for (auto vehIt = vc.loadedVehBegin(); vehIt != vc.loadedVehEnd(); ++vehIt) {
250 MSVehicle* veh = static_cast<MSVehicle*>(vehIt->second);
251 if (&veh->getVehicleType() == this) {
252 // Found vehicle of this type. Perform requested actionOffsetReset
253 if (resetActionOffset) {
254 veh->resetActionOffset();
255 } else {
256 veh->updateActionOffset(previousActionStepLength, actionStepLength);
257 }
258 }
259 }
260}
261
262
263void
265 myParameter.emissionClass = eclass;
267}
268
269
270void
272 myParameter.mass = mass;
273 myParameter.parametersSet |= VTYPEPARS_MASS_SET;
274 const_cast<EnergyParams&>(myEnergyParams).setMass(mass);
275}
276
277
278void
280 myParameter.color = color;
281 myParameter.parametersSet |= VTYPEPARS_COLOR_SET;
282}
283
284
285void
286MSVehicleType::setParkingBadges(const std::vector<std::string>& badges) {
287 myParameter.parkingBadges.assign(badges.begin(), badges.end());
289}
290
291
292void
293MSVehicleType::setWidth(const double& width) {
294 if (myOriginalType != nullptr && width < 0) {
295 myParameter.width = myOriginalType->getWidth();
296 } else {
297 myParameter.width = width;
298 }
299 myParameter.parametersSet |= VTYPEPARS_WIDTH_SET;
300}
301
302void
303MSVehicleType::setImpatience(const double impatience) {
304 myParameter.impatience = impatience;
305 myParameter.parametersSet |= VTYPEPARS_IMPATIENCE_SET;
306}
307
308
309void
311 if (myOriginalType != nullptr && duration < 0) {
312 myParameter.boardingDuration = myOriginalType->getBoardingDuration(isPerson);
313 } else {
314 if (isPerson) {
315 myParameter.boardingDuration = duration;
316 } else {
317 myParameter.loadingDuration = duration;
318 }
319 }
321}
322
323void
325 myParameter.shape = shape;
326 myParameter.parametersSet |= VTYPEPARS_SHAPE_SET;
327}
328
329
330
331// ------------ Static methods for building vehicle types
333MSVehicleType::build(SUMOVTypeParameter& from, const std::string& fileName) {
334 if (from.hasParameter("vehicleMass")) {
335 if (from.wasSet(VTYPEPARS_MASS_SET)) {
336 WRITE_WARNINGF(TL("The vType '%' has a 'mass' attribute and a 'vehicleMass' parameter. The 'mass' attribute will take precedence."), from.id);
337 } else {
338 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);
339 from.mass = from.getDouble("vehicleMass", from.mass);
341 }
342 }
343 MSVehicleType* vtype = new MSVehicleType(from);
346 // by default decel and apparentDecel are identical
347 const double apparentDecel = from.getCFParam(SUMO_ATTR_APPARENTDECEL, decel);
348
349 if (emergencyDecel < decel) {
350 WRITE_WARNINGF(TL("Value of 'emergencyDecel' (%) should be higher than 'decel' (%) for vType '%'."), toString(emergencyDecel), toString(decel), from.id);
351 }
352 if (emergencyDecel < apparentDecel) {
353 WRITE_WARNINGF(TL("Value of 'emergencyDecel' (%) is lower than 'apparentDecel' (%) for vType '%' may cause collisions."), toString(emergencyDecel), toString(apparentDecel), from.id);
354 }
355
356 switch (from.cfModel) {
357 case SUMO_TAG_CF_IDM:
358 vtype->myCarFollowModel = new MSCFModel_IDM(vtype, false);
359 break;
360 case SUMO_TAG_CF_IDMM:
361 vtype->myCarFollowModel = new MSCFModel_IDM(vtype, true);
362 break;
364 vtype->myCarFollowModel = new MSCFModel_Kerner(vtype);
365 break;
367 vtype->myCarFollowModel = new MSCFModel_KraussOrig1(vtype);
368 break;
370 vtype->myCarFollowModel = new MSCFModel_KraussPS(vtype);
371 break;
373 vtype->myCarFollowModel = new MSCFModel_KraussX(vtype);
374 break;
375 case SUMO_TAG_CF_EIDM:
376 vtype->myCarFollowModel = new MSCFModel_EIDM(vtype);
377 break;
379 vtype->myCarFollowModel = new MSCFModel_SmartSK(vtype);
380 break;
382 vtype->myCarFollowModel = new MSCFModel_Daniel1(vtype);
383 break;
385 vtype->myCarFollowModel = new MSCFModel_PWag2009(vtype);
386 break;
388 vtype->myCarFollowModel = new MSCFModel_Wiedemann(vtype);
389 break;
390 case SUMO_TAG_CF_W99:
391 vtype->myCarFollowModel = new MSCFModel_W99(vtype);
392 break;
393 case SUMO_TAG_CF_RAIL:
394 vtype->myCarFollowModel = new MSCFModel_Rail(vtype);
395 break;
396 case SUMO_TAG_CF_ACC:
397 vtype->myCarFollowModel = new MSCFModel_ACC(vtype);
398 break;
399 case SUMO_TAG_CF_CACC:
400 vtype->myCarFollowModel = new MSCFModel_CACC(vtype);
401 break;
402 case SUMO_TAG_CF_CC:
403 vtype->myCarFollowModel = new MSCFModel_CC(vtype);
404 break;
406 default:
407 vtype->myCarFollowModel = new MSCFModel_Krauss(vtype);
408 break;
409 }
410 // init Rail visualization parameters
412 return vtype;
413}
414
417 return (getParameter().getEntryManoeuvreTime(angle));
418}
419
422 return (getParameter().getExitManoeuvreTime(angle));
423}
424
426MSVehicleType::buildSingularType(const std::string& id) const {
427 return duplicateType(id, false);
428}
429
430
432MSVehicleType::duplicateType(const std::string& id, bool persistent) const {
434 vtype->myParameter.id = id;
435 vtype->myCarFollowModel = myCarFollowModel->duplicate(vtype);
436 if (!persistent) {
437 vtype->myOriginalType = this;
438 }
439 if (!MSNet::getInstance()->getVehicleControl().addVType(vtype)) {
440 std::string singular = persistent ? "" : TL("singular ");
441 throw ProcessError(TLF("could not add %type %", singular, vtype->getID()));
442 }
443 return vtype;
444}
445
446void
449 && myParameter.actionStepLength != DELTA_T
450 && STEPS2TIME(myParameter.actionStepLength) > getCarFollowModel().getHeadwayTime()) {
452 std::stringstream s;
453 s << "Given action step length " << STEPS2TIME(myParameter.actionStepLength) << " for vehicle type '" << getID()
454 << "' is larger than its parameter tau (=" << getCarFollowModel().getHeadwayTime() << ")!"
455 << " This may lead to collisions. (This warning is only issued once per vehicle type).";
456 WRITE_WARNING(s.str());
457 }
459 && myParameter.actionStepLength != DELTA_T
462 std::string warning2;
463 if (OptionsCont::getOptions().isDefault("step-method.ballistic")) {
464 warning2 = " Setting it now to avoid collisions.";
466 } else {
467 warning2 = " This may cause collisions.";
468 }
469 WRITE_WARNINGF("Action step length '%' is used for vehicle type '%' but step-method.ballistic was not set." + warning2
470 , STEPS2TIME(myParameter.actionStepLength), getID())
471 }
472 if (!myWarnedStepLengthTauOnce && TS > getCarFollowModel().getHeadwayTime()
475 WRITE_WARNINGF(TL("Value of tau=% in vehicle type '%' lower than simulation step size may cause collisions."),
476 getCarFollowModel().getHeadwayTime(), getID());
477 }
478 if (MSGlobals::gUseMesoSim && getVehicleClass() != SVC_PEDESTRIAN && !OptionsCont::getOptions().getBool("meso-lane-queue")) {
479 SVCPermissions ignoreVClasses = parseVehicleClasses(OptionsCont::getOptions().getStringVector("meso-ignore-lanes-by-vclass"));
480 if ((ignoreVClasses & getVehicleClass()) != 0) {
481 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"),
483 }
484 }
485 if (!myParameter.wasSet(VTYPEPARS_EMISSIONCLASS_SET) && !OptionsCont::getOptions().getBool("device.battery.track-fuel")
486 && (OptionsCont::getOptions().getFloat("device.battery.probability") == 1.
487 || myParameter.getDouble("device.battery.probability", -1.) == 1.
488 || StringUtils::toBool(myParameter.getParameter("has.battery.device", "false")))) {
489 myParameter.emissionClass = PollutantsInterface::getClassByName("Energy");
491 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!"),
492 getID());
493 }
494}
495
496
497void
499 if (myOriginalType != nullptr && accel < 0) {
500 accel = myOriginalType->getCarFollowModel().getMaxAccel();
501 }
502 myCarFollowModel->setMaxAccel(accel);
503 myParameter.cfParameter[SUMO_ATTR_ACCEL] = toString(accel);
504}
505
506void
508 if (myOriginalType != nullptr && decel < 0) {
509 decel = myOriginalType->getCarFollowModel().getMaxDecel();
510 }
511 myCarFollowModel->setMaxDecel(decel);
512 myParameter.cfParameter[SUMO_ATTR_DECEL] = toString(decel);
513}
514
515void
516MSVehicleType::setEmergencyDecel(double emergencyDecel) {
517 if (myOriginalType != nullptr && emergencyDecel < 0) {
518 emergencyDecel = myOriginalType->getCarFollowModel().getEmergencyDecel();
519 }
520 myCarFollowModel->setEmergencyDecel(emergencyDecel);
521 myParameter.cfParameter[SUMO_ATTR_EMERGENCYDECEL] = toString(emergencyDecel);
522}
523
524void
525MSVehicleType::setApparentDecel(double apparentDecel) {
526 if (myOriginalType != nullptr && apparentDecel < 0) {
527 apparentDecel = myOriginalType->getCarFollowModel().getApparentDecel();
528 }
529 myCarFollowModel->setApparentDecel(apparentDecel);
530 myParameter.cfParameter[SUMO_ATTR_APPARENTDECEL] = toString(apparentDecel);
531}
532
533void
534MSVehicleType::setMaxAccelProfile(std::vector<std::pair<double, double> > /* accelProfile */) {
535 /*
536 if (myOriginalType != nullptr) {
537 accelProfile = myOriginalType->getCarFollowModel().getMaxAccelProfile();
538 } else {
539 if (accelProfile[0].first > 0.) {
540 accelProfile.insert(accelProfile.begin(), std::make_pair(0.0, accelProfile[0].second));
541 }
542 if (accelProfile.back().first < (10000 / 3.6)) {
543 accelProfile.push_back(std::make_pair((10000 / 3.6), accelProfile.back().second));
544 }
545 double prevSpeed = 0.0;
546 for (const auto& accelPair : accelProfile) {
547 if (accelPair.first < 0.) {
548 accelProfile = myOriginalType->getCarFollowModel().getMaxAccelProfile();
549 break;
550 } else if (accelPair.second < 0.) {
551 accelProfile = myOriginalType->getCarFollowModel().getMaxAccelProfile();
552 break;
553 } else if (accelPair.first < prevSpeed) {
554 accelProfile = myOriginalType->getCarFollowModel().getMaxAccelProfile();
555 break;
556 }
557 prevSpeed = accelPair.first;
558 }
559 }
560 myCarFollowModel->setMaxAccelProfile(accelProfile);
561
562 std::stringstream accelProfileString;
563 accelProfileString << std::fixed << std::setprecision(2);
564 int count = 0;
565 for (const auto& accelPair : accelProfile) {
566 if (count > 0) {
567 accelProfileString << " ";
568 }
569 accelProfileString << toString(accelPair.first) + "," << accelPair.second;
570 count++;
571 }
572 myParameter.cfParameter[SUMO_ATTR_MAXACCEL_PROFILE] = accelProfileString.str();
573 */
574}
575
576void
577MSVehicleType::setDesAccelProfile(std::vector<std::pair<double, double> > /* accelProfile */) {
578 /*
579 if (myOriginalType != nullptr) {
580 accelProfile = myOriginalType->getCarFollowModel().getDesAccelProfile();
581 } else {
582 if (accelProfile[0].first > 0.) {
583 accelProfile.insert(accelProfile.begin(), std::make_pair(0.0, accelProfile[0].second));
584 }
585 if (accelProfile.back().first < (10000 / 3.6)) {
586 accelProfile.push_back(std::make_pair((10000 / 3.6), accelProfile.back().second));
587 }
588 double prevSpeed = 0.0;
589 for (const auto& accelPair : accelProfile) {
590 if (accelPair.first < 0.) {
591 accelProfile = myOriginalType->getCarFollowModel().getDesAccelProfile();
592 break;
593 } else if (accelPair.second < 0.) {
594 accelProfile = myOriginalType->getCarFollowModel().getDesAccelProfile();
595 break;
596 } else if (accelPair.first < prevSpeed) {
597 accelProfile = myOriginalType->getCarFollowModel().getDesAccelProfile();
598 break;
599 }
600 prevSpeed = accelPair.first;
601 }
602 }
603 myCarFollowModel->setDesAccelProfile(accelProfile);
604
605 std::stringstream accelProfileString;
606 accelProfileString << std::fixed << std::setprecision(2);
607 int count = 0;
608 for (const auto& accelPair : accelProfile) {
609 if (count > 0) {
610 accelProfileString << " ";
611 }
612 accelProfileString << toString(accelPair.first) + "," << accelPair.second;
613 count++;
614 }
615 myParameter.cfParameter[SUMO_ATTR_DESACCEL_PROFILE] = accelProfileString.str();
616 */
617}
618
619void
620MSVehicleType::setImperfection(double imperfection) {
621 if (myOriginalType != nullptr && imperfection < 0) {
622 imperfection = myOriginalType->getCarFollowModel().getImperfection();
623 }
624 myCarFollowModel->setImperfection(imperfection);
625 myParameter.cfParameter[SUMO_ATTR_SIGMA] = toString(imperfection);
626}
627
628void
630 if (myOriginalType != nullptr && tau < 0) {
631 tau = myOriginalType->getCarFollowModel().getHeadwayTime();
632 }
633 myCarFollowModel->setHeadwayTime(tau);
634 myParameter.cfParameter[SUMO_ATTR_TAU] = toString(tau);
635}
636
637
638/****************************************************************************/
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:55
#define TS
Definition SUMOTime.h:42
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:60
T MAX2(T a, T b)
Definition StdDefs.h:86
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
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:339
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:118
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:186
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:445
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:392
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.
const SUMOVTypeParameter & getParameter() const
double computeChosenSpeedDeviation(SumoRNG *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
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