49 return MIN2(maxPower / speed, maxTraction);
63 if (trainType.compare(
"RB425") == 0) {
65 }
else if (trainType.compare(
"RB628") == 0) {
67 }
else if (trainType.compare(
"NGT400") == 0) {
69 }
else if (trainType.compare(
"NGT400_16") == 0) {
71 }
else if (trainType.compare(
"ICE1") == 0) {
73 }
else if (trainType.compare(
"REDosto7") == 0) {
75 }
else if (trainType.compare(
"Freight") == 0) {
77 }
else if (trainType.compare(
"ICE3") == 0) {
79 }
else if (trainType.compare(
"MireoPlusB") == 0) {
81 }
else if (trainType.compare(
"MireoPlusH") == 0) {
83 }
else if (trainType.compare(
"custom") == 0) {
112 if (speedTable.size() > 0 || tractionTable.size() > 0 || resistanceTable.size() > 0) {
113 if (speedTable.size() == 1) {
114 throw ProcessError(
TLF(
"Invalid size of speedTable for vType '%' (at least 2 values are required).", vtype->
getID()));
115 }
else if (speedTable.size() != tractionTable.size()) {
116 throw ProcessError(
TLF(
"Mismatching size of speedTable and tractionTable for vType '%'.", vtype->
getID()));
117 }
else if (speedTable.size() != resistanceTable.size()) {
118 throw ProcessError(
TLF(
"Mismatching size of speedTable and resistanceTable for vType '%'.", vtype->
getID()));
122 for (
int i = 0; i < (int)speedTable.size(); i++) {
141 WRITE_WARNING(
TLF(
"Ignoring tractionTable because maxPower and maxTraction are set for vType '%'.", vtype->
getID()));
149 if (hasSomeResCoef && !hasAllResCoef) {
150 throw ProcessError(
TLF(
"Some undefined resistance coefficients for vType '%' (requires resCoef_constant, resCoef_linear and resCoef_quadratic)", vtype->
getID()));
153 WRITE_WARNING(
TLF(
"Ignoring resistanceTable because resistance coefficients are set for vType '%'.", vtype->
getID()));
157 throw ProcessError(
TLF(
"Either tractionTable or maxPower must be defined for vType '%' with Rail model type '%'.", vtype->
getID(), trainType));
160 throw ProcessError(
TLF(
"Either resistanceTable or resCoef_constant must be defined for vType '%' with Rail model type '%'.", vtype->
getID(), trainType));
170 std::vector<double> result;
172 if (!values.empty()) {
189 if (speed >= 30 / 3.6) {
199 return MIN2(vsafe, vmax);
203 return MAX2(
MIN2(vsafe, vmax), vmin);
233 double totalRes = res + gr;
238 if (speed < targetSpeed) {
242 if (totalRes > trac) {
256 const double slope = veh->
getSlope();
259 const double totalRes = res + gr;
263 return MAX2(vMin, 0.);
294 WRITE_ERROR(
"function call not allowed for rail model. Exiting!");
311 const bool onInsertion,
const CalcReason )
const {
331 const double y =
MAX2(0.0, ((sqrt((b + 2.0 * v) * (b + 2.0 * v) + 8.0 * b * dist) - b) * 0.5 - v) / b);
332 const double yFull = floor(y);
333 const double exactGap = (yFull * yFull + yFull) * 0.5 * b + yFull * v + (y > yFull ? v : 0.0);
335 return DIST2SPEED(
MAX2(0.0, dist - exactGap) / (yFull + 1)) + fullSpeedGain + targetSpeed;
337 WRITE_ERROR(
TL(
"Anything else than semi implicit euler update is not yet implemented. Exiting!"));
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
const long long int VTYPEPARS_MAXSPEED_SET
const long long int VTYPEPARS_MASS_SET
const long long int VTYPEPARS_LENGTH_SET
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_RESISTANCE_COEFFICIENT_CONSTANT
@ SUMO_ATTR_RESISTANCE_TABLE
@ SUMO_ATTR_RESISTANCE_COEFFICIENT_QUADRATIC
@ SUMO_ATTR_EMERGENCYDECEL
@ SUMO_ATTR_RESISTANCE_COEFFICIENT_LINEAR
@ SUMO_ATTR_TRACTION_TABLE
const double INVALID_DOUBLE
invalid double
static double getInterpolatedValue(const LinearApproxMap &map, double axisValue)
Get interpolated value.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
TrainParams initICE3Params() const
TrainParams initNGT400_16Params() const
virtual ~MSCFModel_Rail()
TrainParams initREDosto7Params() const
MSCFModel::VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
virtual double minNextSpeedEmergency(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed after emergency braking, given the current speed (depends on the numerical ...
TrainParams initCustomParams() const
TrainParams initICE1Params() const
MSCFModel_Rail(const MSVehicleType *vtype)
Constructor.
TrainParams initMireoPlusB2TParams() const
double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed without a leader.
TrainParams initRB628Params() const
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
virtual int getModelID() const
Returns the model's ID; the XML-Tag number is used.
double getSpeedAfterMaxDecel(double v) const
Returns the velocity after maximum deceleration.
TrainParams myTrainParams
virtual double minNextSpeed(double speed, const MSVehicle *const veh) const
Returns the minimum speed given the current speed (depends on the numerical update scheme and its ste...
std::vector< double > getValueTable(const MSVehicleType *vtype, SumoXMLAttr attr)
double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's follow speed (no dawdling)
TrainParams initRB425Params() const
TrainParams initFreightParams() const
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
TrainParams initNGT400Params() const
TrainParams initMireoPlusH2TParams() const
double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences. Called at most once per simulation...
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, double decel, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
The car-following model abstraction.
virtual void setEmergencyDecel(double decel)
Sets a new value for maximal physically possible deceleration [m/s^2].
virtual double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences. Called at most once per simulation...
virtual void setMaxDecel(double decel)
Sets a new value for maximal comfortable deceleration [m/s^2].
CalcReason
What the return value of stop/follow/free-Speed is used for.
double myDecel
The vehicle's maximum deceleration [m/s^2].
double maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion=false, double headway=-1, bool relaxEmergency=true) const
Returns the maximum next velocity for stopping within gap.
static bool gSemiImplicitEulerUpdate
Representation of a vehicle in the micro simulation.
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
The car-following model and parameter.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
const std::string & getID() const
Returns the name of the vehicle type.
double getMinGap() const
Get the free space in front of vehicles of this class.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double getLength() const
Get vehicle's length [m].
double getMass() const
Get this vehicle type's mass.
const SUMOVTypeParameter & getParameter() const
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.
std::string getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
std::vector< std::string > getVector()
return vector of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
LinearApproxHelpers::LinearApproxMap traction
double getRotWeight() const
LinearApproxHelpers::LinearApproxMap resistance
double getTraction(double speed) const
double getResistance(double speed) const