SUMO - Simulation of Urban MObility
GNECalibratorVehicleType.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 //
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #include <string>
31 #include <iostream>
32 #include <utility>
37 #include <utils/common/ToString.h>
38 #include <utils/geom/GeomHelper.h>
45 #include <utils/gui/div/GLHelper.h>
49 
51 #include "GNECalibrator.h"
52 #include "GNEViewNet.h"
53 #include "GNENet.h"
54 
55 
56 // ===========================================================================
57 // member method definitions
58 // ===========================================================================
59 
60 
62  myCalibratorParent(calibratorParent), myVehicleTypeID(calibratorParent->generateVehicleTypeID()) {
63  // setset default parameters
64  setAccel();
65  setDecel();
66  setSigma();
67  setTau();
68  setLength();
69  setMinGap();
70  setMaxSpeed();
72  setSpeedDev();
73  setColor();
74  setVClass();
76  setShape();
77  setWidth();
78  setFilename();
79  setImpatience();
87  setMinGapLat();
89 }
90 
91 
92 GNECalibratorVehicleType::GNECalibratorVehicleType(GNECalibrator* calibratorParent, std::string vehicleTypeID,
93  double accel, double decel, double sigma, double tau, double length, double minGap, double maxSpeed,
94  double speedFactor, double speedDev, const RGBColor& color, SUMOVehicleClass vClass, const std::string& emissionClass,
95  SUMOVehicleShape shape, double width, const std::string& filename, double impatience, const std::string& laneChangeModel,
96  const std::string& carFollowModel, int personCapacity, int containerCapacity, double boardingDuration,
97  double loadingDuration, const std::string& latAlignment, double minGapLat, double maxSpeedLat) :
98  myCalibratorParent(calibratorParent), myVehicleTypeID(calibratorParent->generateVehicleTypeID()) {
99  // set parameters using the set functions, to avoid non valid values
100  setVehicleTypeID(vehicleTypeID);
101  setAccel(accel);
102  setDecel(decel);
103  setSigma(sigma);
104  setTau(tau);
105  setLength(length);
106  setMinGap(minGap);
107  setMaxSpeed(maxSpeed);
108  setSpeedFactor(speedFactor);
109  setSpeedDev(speedDev);
110  setColor(color);
111  setVClass(vClass);
112  setEmissionClass(emissionClass);
113  setShape(shape);
114  setWidth(width);
115  setFilename(filename);
116  setImpatience(impatience);
117  setLaneChangeModel(laneChangeModel);
118  setCarFollowModel(carFollowModel);
119  setPersonCapacity(personCapacity);
120  setContainerCapacity(containerCapacity);
121  setBoardingDuration(boardingDuration);
122  setLoadingDuration(loadingDuration);
123  setLatAlignment(latAlignment);
124  setMinGapLat(minGapLat);
125  setMaxSpeedLat(maxSpeedLat);
126 }
127 
128 
130 
131 
134  return myCalibratorParent;
135 }
136 
137 
140  return SUMO_TAG_VTYPE;
141 }
142 
143 
144 std::string
146  return myVehicleTypeID;
147 }
148 
149 
150 double
152  return myAccel;
153 }
154 
155 
156 double
158  return myDecel;
159 }
160 
161 
162 double
164  return mySigma;
165 }
166 
167 
168 double
170  return myTau;
171 }
172 
173 
174 double
176  return myLength;
177 }
178 
179 
180 double
182  return myMinGap;
183 }
184 
185 
186 double
188  return myMaxSpeed;
189 }
190 
191 
192 double
194  return mySpeedFactor;
195 }
196 
197 
198 double
200  return mySpeedDev;
201 }
202 
203 
204 const RGBColor&
206  return myColor;
207 }
208 
209 
212  return myVClass;
213 }
214 
215 
216 std::string
218  return myEmissionClass;
219 }
220 
221 
224  return myShape;
225 }
226 
227 
228 double
230  return myWidth;
231 }
232 
233 
234 std::string
236  return myFilename;
237 }
238 
239 
240 double
242  return myImpatience;
243 }
244 
245 
246 std::string
248  return myLaneChangeModel;
249 }
250 
251 
252 std::string
254  return myCarFollowModel;
255 }
256 
257 
258 int
260  return myPersonCapacity;
261 }
262 
263 
264 int
266  return myContainerCapacity;
267 }
268 
269 
270 double
272  return myBoardingDuration;
273 }
274 
275 
276 double
278  return myLoadingDuration;
279 }
280 
281 
282 std::string
284  return myLatAlignment;
285 }
286 
287 
288 double
290  return myMinGapLat;
291 }
292 
293 
294 double
296  return myMaxSpeedLat;
297 }
298 
299 bool
300 GNECalibratorVehicleType::setVehicleTypeID(std::string vehicleTypeID) {
301  if (vehicleTypeID.empty()) {
302  return false;
303  } else if (myCalibratorParent->getViewNet()->getNet()->vehicleTypeExists(vehicleTypeID)) {
304  return false;
305  } else {
306  myVehicleTypeID = vehicleTypeID;
307  return true;
308  }
309 }
310 
311 
312 bool
314  if (accel < 0) {
315  return false;
316  } else {
317  myAccel = accel;
318  return true;
319  }
320 }
321 
322 
323 bool
325  if (GNEAttributeCarrier::canParse<double>(accel)) {
326  return setAccel(GNEAttributeCarrier::parse<double>(accel));
327  } else {
328  return false;
329  }
330 }
331 
332 
333 bool
335  if (decel < 0) {
336  return false;
337  } else {
338  myDecel = decel;
339  return true;
340  }
341 }
342 
343 
344 bool
346  if (GNEAttributeCarrier::canParse<double>(decel)) {
347  return setDecel(GNEAttributeCarrier::parse<double>(decel));
348  } else {
349  return false;
350  }
351 }
352 
353 
354 bool
356  if (sigma < 0) {
357  return false;
358  } else {
359  mySigma = sigma;
360  return true;
361  }
362 }
363 
364 
365 bool
367  if (GNEAttributeCarrier::canParse<double>(sigma)) {
368  return setSigma(GNEAttributeCarrier::parse<double>(sigma));
369  } else {
370  return false;
371  }
372 }
373 
374 
375 bool
377  if (tau < 0) {
378  return false;
379  } else {
380  myTau = tau;
381  return true;
382  }
383 }
384 
385 
386 bool
388  if (GNEAttributeCarrier::canParse<double>(tau)) {
389  return setTau(GNEAttributeCarrier::parse<double>(tau));
390  } else {
391  return false;
392  }
393 }
394 
395 
396 bool
398  if (length < 0) {
399  return false;
400  } else {
401  myLength = length;
402  return true;
403  }
404 }
405 
406 
407 bool
409  if (GNEAttributeCarrier::canParse<double>(length)) {
410  return setLength(GNEAttributeCarrier::parse<double>(length));
411  } else {
412  return false;
413  }
414 }
415 
416 
417 bool
419  if (minGap < 0) {
420  return false;
421  } else {
422  myMinGap = minGap;
423  return true;
424  }
425 }
426 
427 
428 bool
430  if (GNEAttributeCarrier::canParse<double>(minGap)) {
431  return setMinGap(GNEAttributeCarrier::parse<double>(minGap));
432  } else {
433  return false;
434  }
435 }
436 
437 
438 bool
440  if (maxSpeed < 0) {
441  return false;
442  } else {
443  myMaxSpeed = maxSpeed;
444  return true;
445  }
446 }
447 
448 
449 bool
451  if (GNEAttributeCarrier::canParse<double>(maxSpeed)) {
452  return setMaxSpeed(GNEAttributeCarrier::parse<double>(maxSpeed));
453  } else {
454  return false;
455  }
456 }
457 
458 
459 bool
461  if (speedFactor < 0) {
462  return false;
463  } else {
464  mySpeedFactor = speedFactor;
465  return true;
466  }
467 }
468 
469 
470 bool
472  if (GNEAttributeCarrier::canParse<double>(speedFactor)) {
473  return setSpeedFactor(GNEAttributeCarrier::parse<double>(speedFactor));
474  } else {
475  return false;
476  }
477 }
478 
479 
480 bool
482  if (speedDev < 0) {
483  return false;
484  } else {
485  mySpeedDev = speedDev;
486  return true;
487  }
488 }
489 
490 
491 bool
493  if (GNEAttributeCarrier::canParse<double>(speedDev)) {
494  return setSpeedDev(GNEAttributeCarrier::parse<double>(speedDev));
495  } else {
496  return false;
497  }
498 }
499 
501  myColor = color;
502  return false;
503 }
504 
505 
506 bool
508  if (GNEAttributeCarrier::canParse<RGBColor>(color)) {
509  return setColor(GNEAttributeCarrier::parse<RGBColor>(color));
510  } else {
511  return false;
512  }
513 }
514 
515 
516 bool
518  myVClass = vClass;
519  return true;
520 }
521 
522 
523 bool
525  if (canParseVehicleClasses(vClass)) {
526  return setVClass(getVehicleClassID(vClass));
527  } else {
528  return false;
529  }
530 }
531 
532 
533 bool
534 GNECalibratorVehicleType::setEmissionClass(std::string emissionClass) {
535  myEmissionClass = emissionClass;
536  return true;
537 }
538 
539 
540 bool
542  myShape = shape;
543  return true;
544 }
545 
546 
547 bool
549  if (canParseVehicleShape(shape)) {
550  return setShape(getVehicleShapeID(shape));
551  } else {
552  return false;
553  }
554 }
555 
556 
557 bool
559  if (width < 0) {
560  return false;
561  } else {
562  myWidth = width;
563  return true;
564  }
565 }
566 
567 
568 bool
570  if (GNEAttributeCarrier::canParse<double>(width)) {
571  return setWidth(GNEAttributeCarrier::parse<double>(width));
572  } else {
573  return false;
574  }
575 }
576 
577 
578 bool
580  myFilename = filename;
581  return true;
582 }
583 
584 
585 bool
587  if (impatience < 0) {
588  return false;
589  } else {
590  myImpatience = impatience;
591  return true;
592  }
593 }
594 
595 
596 bool
598  if (GNEAttributeCarrier::canParse<double>(impatience)) {
599  return setImpatience(GNEAttributeCarrier::parse<double>(impatience));
600  } else {
601  return false;
602  }
603 }
604 
605 
606 bool
607 GNECalibratorVehicleType::setLaneChangeModel(std::string laneChangeModel) {
608  myLaneChangeModel = laneChangeModel;
609  return true;
610 }
611 
612 
613 bool
614 GNECalibratorVehicleType::setCarFollowModel(std::string carFollowModel) {
615  myCarFollowModel = carFollowModel;
616  return true;
617 }
618 
619 
620 bool
622  if (personCapacity < 0) {
623  return false;
624  } else {
625  myPersonCapacity = personCapacity;
626  return true;
627  }
628 }
629 
630 
631 bool
632 GNECalibratorVehicleType::setPersonCapacity(std::string personCapacity) {
633  if (GNEAttributeCarrier::canParse<double>(personCapacity)) {
634  double personCapacityD = GNEAttributeCarrier::parse<double>(personCapacity);
635  // Check that double doesn't have decimals
636  if (fmod(personCapacityD, 1) == 0) {
637  return setPersonCapacity((int)personCapacityD);
638  } else {
639  return false;
640  }
641  } else {
642  return false;
643  }
644 }
645 
646 
647 bool
649  if (containerCapacity < 0) {
650  return false;
651  } else {
652  myContainerCapacity = containerCapacity;
653  return true;
654  }
655 }
656 
657 
658 bool
659 GNECalibratorVehicleType::setContainerCapacity(std::string containerCapacity) {
660  if (GNEAttributeCarrier::canParse<double>(containerCapacity)) {
661  double containerCapacityD = GNEAttributeCarrier::parse<double>(containerCapacity);
662  // Check that double doesn't have decimals
663  if (fmod(containerCapacityD, 1) == 0) {
664  return setContainerCapacity((int)containerCapacityD);
665  } else {
666  return false;
667  }
668  } else {
669  return false;
670  }
671 }
672 
673 
674 bool
676  if (boardingDuration < 0) {
677  return false;
678  } else {
679  myBoardingDuration = boardingDuration;
680  return true;
681  }
682 }
683 
684 
685 bool
686 GNECalibratorVehicleType::setBoardingDuration(std::string boardingDuration) {
687  if (GNEAttributeCarrier::canParse<double>(boardingDuration)) {
688  return setBoardingDuration(GNEAttributeCarrier::parse<double>(boardingDuration));
689  } else {
690  return false;
691  }
692 }
693 
694 
695 bool
697  if (loadingDuration < 0) {
698  return false;
699  } else {
700  myLoadingDuration = loadingDuration;
701  return true;
702  }
703 }
704 
705 
706 bool
707 GNECalibratorVehicleType::setLoadingDuration(std::string loadingDuration) {
708  if (GNEAttributeCarrier::canParse<double>(loadingDuration)) {
709  return setLoadingDuration(GNEAttributeCarrier::parse<double>(loadingDuration));
710  } else {
711  return false;
712  }
713 }
714 
715 
716 bool
717 GNECalibratorVehicleType::setLatAlignment(std::string latAlignment) {
718  if ((latAlignment == "left") || (latAlignment == "right") || (latAlignment == "center") ||
719  (latAlignment == "compact") || (latAlignment == "nice") || (latAlignment == "arbitrary")) {
720  myLatAlignment = latAlignment;
721  return true;
722  } else {
723  return false;
724  }
725 }
726 
727 
728 bool
730  if (minGapLat < 0) {
731  return false;
732  } else {
733  myMinGapLat = minGapLat;
734  return true;
735  }
736 }
737 
738 
739 bool
741  if (GNEAttributeCarrier::canParse<double>(minGapLat)) {
742  return setMinGapLat(GNEAttributeCarrier::parse<double>(minGapLat));
743  } else {
744  return false;
745  }
746 }
747 
748 
749 bool
751  if (maxSpeedLat < 0) {
752  return false;
753  } else {
754  myMaxSpeedLat = maxSpeedLat;
755  return true;
756  }
757 }
758 
759 
760 bool
762  if (GNEAttributeCarrier::canParse<double>(maxSpeedLat)) {
763  return setMaxSpeedLat(GNEAttributeCarrier::parse<double>(maxSpeedLat));
764  } else {
765  return false;
766  }
767 }
768 
769 
770 bool
772  return (myVehicleTypeID == calibratorVehicleType.getVehicleTypeID());
773 }
774 
775 /****************************************************************************/
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
double myTau
Car-following model parameter.
double myMinGap
Empty space after leader [m].
double myMaxSpeedLat
The maximum lateral speed when using the sublane-model.
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool setTau(double tau=1.0)
set tau
description of a vehicle type
std::string getVehicleTypeID() const
get VehicleTypeID
bool setDecel(double decel=4.5)
set decel
std::string getLatAlignment() const
get lateral lat
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
bool setLength(double length=5.0)
set length
double getWidth() const
get width
bool setImpatience(double impatience=0.0)
set impatience
double getLoadingDuration() const
get loading duration
double getImpatience() const
get impatience
bool vehicleTypeExists(const std::string &vehicleTypeID) const
Check if exist a vehicle type with these ID.
Definition: GNENet.cpp:1779
bool setAccel(double accel=2.6)
set accel
double myImpatience
Willingess of drivers to impede vehicles with higher priority. See below for semantics.
bool setMinGapLat(double minGapLat=0.12)
set min gap lat
bool setEmissionClass(std::string emissionClass="P_7_7")
set emission class
bool setShape(std::string shape)
set shape (string version)
double getMinGapLat() const
get min gap lat
double myWidth
The vehicle&#39;s width [m] (only used for drawing)
double myAccel
The acceleration ability of vehicles of this type (in m/s^2)
SumoXMLTag getTag() const
get tag
bool setFilename(std::string filename="")
set filename
GNECalibrator * myCalibratorParent
pointer to calibrator parent
double myDecel
The deceleration ability of vehicles of this type (in m/s^2)
int getPersonCapacity() const
get person capacity
SUMOVehicleShape getShape() const
get shape
bool setMaxSpeed(double maxSpeed=70.0)
set max speed
std::string getLaneChangeModel() const
get lane change model
std::string myLatAlignment
The preferred lateral alignment when using the sublane-model. One of (left, right, center, compact, nice, arbitrary).
double myLength
The vehicle&#39;s netto-length (length) (in m)
double getDecel() const
get decel
std::string getFilename() const
get filename
bool canParseVehicleShape(const std::string &shape)
Checks whether the given string contains only known vehicle shape.
double mySigma
Car-following model parameter.
double getLength() const
get length
double getMinGap() const
get min gap
std::string getEmissionClass() const
get emission class
std::string myCarFollowModel
The model used for car following.
bool setWidth(double width=2.0)
set width
std::string myVehicleTypeID
vehicleType ID
double getAccel() const
get accel
GNEViewNet * getViewNet() const
Returns a pointer to GNEViewNet in which additional element is located.
RGBColor myColor
This vehicle type&#39;s color.
int myPersonCapacity
The number of persons (excluding an autonomous driver) the vehicle can transport. ...
double mySpeedDev
The deviation of the speedFactor; see below for details.
bool setPersonCapacity(int personCapacity=4)
set person capacity
SUMOVehicleClass myVClass
An abstract vehicle class.
GNECalibratorVehicleType(GNECalibrator *calibratorParent)
constructor
GNECalibrator * getCalibratorParent() const
get pointer to calibrator parent
SUMOVehicleShape myShape
How this vehicle is rendered.
std::string myEmissionClass
An abstract emission class.
bool setSigma(double sigma=0.5)
set sigma
std::string myFilename
Image file for rendering vehicles of this type (should be grayscale to allow functional coloring) ...
bool setSpeedDev(double speedDev=0.0)
set speed dev
double getBoardingDuration() const
get boarding duration
bool setBoardingDuration(double boardingDuration=0.5)
set boarding duration
bool setMaxSpeedLat(double maxSpeedLat=1.0)
set max speed lat
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
int getContainerCapacity() const
get container capacity
bool setLaneChangeModel(std::string laneChangeModel="LC2013")
set lane change model
double myBoardingDuration
The time required by a person to board the vehicle.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
bool setCarFollowModel(std::string carFollowModel="Krauss")
set car follow model
bool setMinGap(double minGap=2.5)
set min gap
bool setSpeedFactor(double speedFactor=1.0)
set speed factor
double getSpeedDev() const
get speed dev
GNENet * getNet() const
get the net object
SUMOVehicleClass getVClass() const
get VClass
const RGBColor & getColor() const
get color
double myLoadingDuration
The time required to load a container onto the vehicle.
double getMaxSpeed() const
get max speed
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
bool setColor(const RGBColor &color)
set color
double getSigma() const
get sigma
std::string getCarFollowModel() const
get car follow model
double myMinGapLat
The minimum lateral gap at a speed difference of 100km/h when using the sublane-model.
bool setVClass(SUMOVehicleClass vClass=SVC_PRIVATE)
set VClass
double getSpeedFactor() const
get speed factor
bool setLoadingDuration(double loadingDuration=90.0)
set loading duration
bool setContainerCapacity(int containerCapacity=0)
set container capacity
double myMaxSpeed
The vehicle&#39;s maximum velocity (in m/s)
double mySpeedFactor
The vehicles expected multiplicator for lane speed limits.
std::string myLaneChangeModel
The model used for changing lanes.
int myContainerCapacity
The number of containers the vehicle can transport.
bool setVehicleTypeID(std::string vehicleTypeID)
set vehicleType ID
bool setLatAlignment(std::string latAlignment="center")
set lateral lat
bool operator==(const GNECalibratorVehicleType &calibratorVehicleType) const
overload operator ==
double getMaxSpeedLat() const
get max speed lat