41 if (trainType.compare(
"RB425") == 0) {
43 }
else if (trainType.compare(
"RB628") == 0) {
45 }
else if (trainType.compare(
"NGT400") == 0) {
47 }
else if (trainType.compare(
"NGT400_16") == 0) {
49 }
else if (trainType.compare(
"ICE1") == 0) {
51 }
else if (trainType.compare(
"REDosto7") == 0) {
53 }
else if (trainType.compare(
"Freight") == 0) {
55 }
else if (trainType.compare(
"ICE3") == 0) {
58 WRITE_ERROR(
"Unknown train type: " + trainType +
". Exiting!");
69 double ,
double )
const {
97 double totalRes = res + gr;
102 if (speed < targetSpeed) {
106 if (totalRes > trac) {
123 double totalRes = res + gr;
127 return speed - a *
DELTA_T / 1000.;
132 std::map<double, double>::const_iterator low, prev;
133 low = lookUpMap->lower_bound(speed);
135 if (low == lookUpMap->end()) {
136 return (lookUpMap->rbegin())->second;
139 if (low == lookUpMap->begin()) {
146 double range = low->first - prev->first;
147 double dist = speed - prev->first;
151 double weight = dist / range;
153 double res = (1 - weight) * prev->second + weight * low->second;
176 WRITE_ERROR(
"function call not allowd for rail model. Exiting!");
187 const double oldV = veh->
getSpeed();
209 vNext =
MAX2(vNext, vMin);
216 const bool onInsertion)
const {
236 const double y =
MAX2(0.0, ((sqrt((b + 2.0 * v) * (b + 2.0 * v) + 8.0 * b * dist) - b) * 0.5 - v) / b);
237 const double yFull = floor(y);
238 const double exactGap = (yFull * yFull + yFull) * 0.5 * b + yFull * v + (y > yFull ? v : 0.0);
240 return DIST2SPEED(
MAX2(0.0, dist - exactGap) / (yFull + 1)) + fullSpeedGain + targetSpeed;
242 WRITE_ERROR(
"Anything else then semi implicit euler update is not yet implemented. Exiting!");
Representation of a vehicle in the micro simulation.
TrainParams initRB425Params() const
TrainParams initICE1Params() const
double stopSpeed(const MSVehicle *const veh, const double speed, double gap) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) ...
MSCFModel::VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting...
The car-following model abstraction.
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
std::map< double, double > LookUpMap
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...
TrainParams initICE3Params() const
TrainParams initNGT400_16Params() const
double getSpeedAfterMaxDecel(double v) const
Returns the velocity after maximum deceleration.
The car-following model and parameter.
MSAbstractLaneChangeModel & getLaneChangeModel()
double getMaxSpeedOnLane() const
Returns the maximal speed for the vehicle on its current lane (including speed factor and deviation...
virtual double patchSpeed(const double min, const double wanted, const double max, const MSCFModel &cfModel)=0
Called to adapt the speed in order to allow a lane change.
double moveHelper(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
TrainParams initREDosto7Params() const
TrainParams initNGT400Params() const
double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion) const
Computes the vehicle's safe speed without a leader.
double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const
Computes the vehicle's follow speed (no dawdling)
TrainParams initRB628Params() const
double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
double myDecel
The vehicle's maximum deceleration [m/s^2].
virtual ~MSCFModel_Rail()
virtual void setMaxDecel(double decel)
Sets a new value for maximum deceleration [m/s^2].
double processNextStop(double currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
TrainParams myTrainParams
static bool gSemiImplicitEulerUpdate
double getSlope() const
Returns the slope of the road at vehicle's position.
TrainParams initFreightParams() const
MSCFModel_Rail(const MSVehicleType *vtype, std::string trainType)
Constructor.
virtual int getModelID() const
Returns the model's ID; the XML-Tag number is used.
double getSpeed() const
Returns the vehicle's current speed.
double getInterpolatedValueFromLookUpMap(double speed, const LookUpMap *lookUpMap) const