NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
train.h
Go to the documentation of this file.
1//
2// Created by Ahmed Aredah
3// Version 0.1
4//
5
6#ifndef NeTrainSim_Train_h
7#define NeTrainSim_Train_h
8
9
10#include <iostream>
11#include "../util/vector.h"
12#include "car.h"
13#include "locomotive.h"
14#include "../util/map.h"
15#include "qobject.h"
16#include <utility>
17#include <variant>
18
25class NetNode;
26
33class NetLink;
34using namespace std;
35
42class Train : public QObject {
43 Q_OBJECT
44 /***********************************************
45 * variables declaration *
46 ************************************************/
47
48private:
50 static unsigned int NumberOfTrainsInSimulator;
52 static constexpr double DefaultDesiredDecelerationRate = 0.2;
54 static constexpr double DefaultOperatorReactionTime = 1.0;
56 static constexpr bool DefaultStopIfNoEnergy = false;
58 static constexpr double DefaultMaxAllowedJerk = 2.0;
60 static constexpr double DefaultMinFollowingGap = 2.0;
62 static constexpr int DefaultLookAheadCounterToUpdate = 1;
64 static constexpr int DefaultLookAheadCounter = 1;
65
66public:
67
72 static constexpr double speedOfSound = 343.0;
74 const double g = 9.8066;
76 double d_des;
82 double totalMass;
84 double totalEmptyMass = 0;
85
89 double maxJerk = 2.0;
91 double T_s;
95 double tripTime;
149
151 pair<double, double> currentCoordinates;
152
153
155 std::shared_ptr<NetLink> currentFirstLink;
166
167
191 Vector < std::shared_ptr<TrainComponent>> trainVehicles;
198
201
204
205
207 int nCars = 0;
209 int nlocs = 0;
211 int id;
225
226
230 bool isOn;
232 bool offloaded = false;
234 bool reachedDestination = false;
236 bool outOfEnergy = false;
238 bool loaded = false;
241
242
263 Train(int simulatorID, string id, Vector<int> trainPath, double trainStartTime_sec, double frictionCoeff,
264 Vector<std::shared_ptr<Locomotive>> locomotives, Vector<std::shared_ptr<Car>> cars, bool optimize,
265 double desiredDecelerationRate_mPs = DefaultDesiredDecelerationRate,
266 double operatorReactionTime_s = DefaultOperatorReactionTime,
267 bool stopIfNoEnergy = DefaultStopIfNoEnergy,
268 double maxAllowedJerk_mPcs = DefaultMaxAllowedJerk);
269
270 ~Train();
271
272 void setTrainSimulatorID(int newID);
273
279 bool rechargeCarsBatteries(double timeStep, double EC_kwh, std::shared_ptr<Locomotive> &loco);
280
286
291 void setTrainPath(Vector<int> path);
300 static unsigned int getNumberOfTrainsInSimulator();
301
302
312
317 void setTrainsCurrentLinks(Vector<std::shared_ptr<NetLink> > newLinks);
326 double getCargoNetWeight();
327
337
355 Map < std::shared_ptr<TrainComponent>, double> getTrainCentroids();
356
366
388
400
410
420
430
440
441
450 double getTrainTotalTorque();
451
461 //void setCars(Vector<Car> cars);
462 //void setLocomotives(Vector<Locomotive> locomotives);
463
470 void setTrainLength();
471
478 void setTrainWeight();
479
486 void resetTrain();
487
494 void rearrangeTrain();
495
507 void updateGradesCurvatures(Vector<double> &LocsCurvature, Vector<double> &LocsGrade,
508 Vector<double> &CarsCurvature, Vector<double> &CarsGrade);
509
519 void updateGradesCurvatures(const Vector<double> &trainGrade, const Vector<double> &trainCurvature);
520
534 double getTotalTractiveForce(double speed, double acceleration, bool optimize, double optimumThrottleLevel);
535
546 double getTotalResistance(double speed);
547
562 double getAccelerationUpperBound(double speed, double acceleration, double freeFlowSpeed,
563 bool optimize, double optimumThrottleLevel);
564
579 double getSafeGap(double initialGap, double speed, double freeFlowSpeed, double T_s, bool estimate);
580
597 double getNextTimeStepSpeed(double gap, double minGap, double speed, double freeFlowSpeed,
598 double aMax, double T_s, double deltaT);
599
613 double getTimeToCollision(double gap, double minGap, double speed, double leaderSpeed);
614
633 double accelerate(double gap, double mingap, double speed, double acceleration, double leaderSpeed,
634 double freeFlowSpeed, double deltaT, bool optimize, double throttleLevel = -1);
635
649 double accelerateConsideringJerk(double acceleration, double previousAcceleration, double jerk, double deltaT);
650
663 double smoothAccelerate(double acceleration, double previousAccelerationValue, double alpha = 0.2);
664
678 double speedUpDown(double previousSpeed, double acceleration, double deltaT, double freeFlowSpeed);
679
692 double adjustAcceleration(double speed, double previousSpeed, double deltaT);
693
704 void checkSuddenAccChange(double previousAcceleration, double currentAcceleration, double deltaT);
705
715 double getStepAcceleration(double timeStep, double freeFlowSpeed, Vector<double>& gapToNextCriticalPoint,
716 Vector<bool> &gapToNextCriticalPointType, Vector<double>& leaderSpeed);
717
730 void moveTrain(double timeStep, double freeFlowSpeed, Vector<double>& gapToNextCriticalPoint,
731 Vector<bool>& gapToNextCriticalPointType, Vector<double>& leaderSpeed);
732
745 pair<Vector<double>, double> getTractivePower(double speed, double acceleration, double resistanceForces);
746
753 void updateLocNotch();
754
763 void immediateStop(double timeStep);
764
773 void kickForwardADistance(double& distance);
774
785 double getEnergyConsumption(double timeStep);
786
796 void calculateEnergyConsumption(double timeStep, std::string currentRegion);
797
809 double getTotalEnergyConsumption(double& timeStep, Vector<double>& usedTractivePower);
810
822 bool consumeEnergy(double& timeStep, double trainSpeed, Vector<double>& usedTractivePower);
823
831
846 std::pair<bool, double> consumeTendersEnergy(double timeStep, double trainSpeed, double EC_kwh, TrainTypes::PowerType powerType,
847 double dieselConversionFactor = EC::DefaultDieselConversionFactor,
848 double hydrogenConversionFactor = EC::DefaultHydrogenConversionFactor,
849 double dieselDensity = EC::DefaultDieselDensity);
850
862
872
882
902 tuple<double, double, double> AStarOptimization(double prevSpeed, double currentSpeed, double currentAcceleration,
903 double prevThrottle, Vector<double> vector_grade,
904 Vector<double> vector_curvature, double freeSpeed_ms,
905 double timeStep, Vector<double> u_leader,
906 Vector<double> gapToNextCriticalPoint);
907
923 double heuristicFunction(double distanceToEnd, double stepAcceleration, double stepSpeed,
924 double timeStep, double resistance, double currentSpeed);
925
938
939// ##################################################################
940// # start: statistics calculations #
941// ##################################################################
942
954 void calcTrainStats(Vector<double> listOfLinksFreeFlowSpeeds, double MinFreeFlow, double timeStep, std::string currentRegion);
955
968 double calculateAverage(double previousAverage, double currentTimeStepData, double timeStep);
969
981 double getDelayTimeStat(double freeflowSpeed, double timeStep);
982
994 double getMaxDelayTimeStat(Vector<double> listOfLinksFreeFlowSpeeds, double timeStep);
995
1006 double getStoppingTimeStat(Vector<double> listOfLinksFreeFlowSpeeds);
1007
1011 void resetTrainLookAhead();
1012
1018 std::pair<double, Map<TrainTypes::PowerType, double>> getMaxProvidedEnergy(double &timeStep);
1019
1026 bool canProvideEnergy(double &EC, double &timeStep);
1027
1032 void reducePower(double &reductionFactor);
1033
1037 void resetPowerRestriction();
1038
1039// ##################################################################
1040// # end: statistics calculations #
1041// ##################################################################
1042
1054 friend ostream& operator<<(ostream& ostr, Train& train);
1055
1056 private:
1057
1071 double get_acceleration_an11(double u_hat, double speed, double TTC_s, double frictionCoef);
1072
1086 double get_acceleration_an12(double u_hat, double speed, double T_s, double amax);
1087
1098 double get_beta1(double an11);
1099
1112 double get_acceleration_an13(double beta1, double an11, double an12);
1113
1128 double get_acceleration_an14(double speed, double leaderSpeed, double T_s, double amax, double frictionCoef);
1129
1138 double get_beta2();
1139
1152 double get_acceleration_an1(double beta2, double an13, double an14);
1153
1164 double get_gamma(double speedDiff);
1165
1171 Map<TrainTypes::PowerType, double> getMaxProvidedEnergyFromLocomotivesOnly(double &timeStep);
1172
1180 double &timeStep);
1187 Map<TrainTypes::CarType, double> canProvideEnergyFromLocomotivesOnly(double &EC, double &timeStep);
1188
1195 bool canProvideEnergyFromTendersOnly(Map<TrainTypes::CarType, double> &EC, double &timeStep);
1196
1212 double get_acceleration_an2(double gap, double minGap, double speed, double leaderSpeed, double T_s, double frictionCoef);
1213
1214 public:
1215 signals:
1216
1223 void suddenAccelerationOccurred(std::string msg);
1224
1232 void slowSpeedOrStopped(std::string msg);
1233
1234};
1235
1236#endif // !NeTrainSim_Train_h
A map.
Definition map.h:26
The NetNode class represents a network node in a simulation.
Definition netnode.h:35
A train.
Definition train.h:42
double totalEConsumed
Total energy consumpted only of the train till time t.
Definition train.h:132
Vector< std::shared_ptr< Car > > cars
Holds all cars in the train.
Definition train.h:169
Map< string, double > getTrainConsumedTank()
getTrainConsumedTank
Definition train.cpp:185
void calculateEnergyConsumption(double timeStep, std::string currentRegion)
Calculates the energy consumption.
Definition train.cpp:1033
double getDelayTimeStat(double freeflowSpeed, double timeStep)
Gets delay time stat.
Definition train.cpp:717
int lookAheadStepCounter
The number of steps ahead the train is looking aheaf for optimization.
Definition train.h:222
double stoppedStat
Statistic of the stoppings at time t.
Definition train.h:144
std::pair< bool, double > consumeTendersEnergy(double timeStep, double trainSpeed, double EC_kwh, TrainTypes::PowerType powerType, double dieselConversionFactor=EC::DefaultDieselConversionFactor, double hydrogenConversionFactor=EC::DefaultHydrogenConversionFactor, double dieselDensity=EC::DefaultDieselDensity)
Consume tenders energy.
Definition train.cpp:975
int nCars
Number of cars in the train.
Definition train.h:207
double trainStartTime
Start time of the train to enter the network retrative to the beginning of the simulator.
Definition train.h:93
double getCargoNetWeight()
Gets cargo net weight.
Definition train.cpp:236
double currentUsedTractivePower
The current used tractive power that the locomotives provides in kw.
Definition train.h:122
double averageSpeed
The average journey speed of the train from t = 0 to t.
Definition train.h:110
double getAverageLocomotivesBatteryStatus()
Gets average locomotives battery status.
Definition train.cpp:135
Vector< double > linksCumLengths
Holds the cummulative distance from the start of the train's path to each and every node in the path.
Definition train.h:183
double maxDelayTimeStat
The time the train is delayed at time step t, relative to max free flow speed of all spanned links.
Definition train.h:140
void resetTrainEnergyConsumption()
Resets the train energy consumption.
Definition train.cpp:876
double getAverageTendersBatteryStatus()
Gets average tenders battery status.
Definition train.cpp:166
void resetTrain()
Resets the train parameters.
Definition train.cpp:1154
void moveTrain(double timeStep, double freeFlowSpeed, Vector< double > &gapToNextCriticalPoint, Vector< bool > &gapToNextCriticalPointType, Vector< double > &leaderSpeed)
Move train forward.
Definition train.cpp:641
Vector< bool > trainStoppingStations
The train stopping stations.
Definition train.h:203
double getTrainTotalTorque()
Gets train total torque in tons x meters.
Definition train.cpp:181
Map< string, double > cumRegionalConsumedEnergyStat
Total energy consumed till time step t mapped by region.
Definition train.h:165
string trainUserID
The name of the train.
Definition train.h:200
void immediateStop(double timeStep)
Immediate stop.
Definition train.cpp:658
double accelerate(double gap, double mingap, double speed, double acceleration, double leaderSpeed, double freeFlowSpeed, double deltaT, bool optimize, double throttleLevel=-1)
Gets the acceleration of the train.
Definition train.cpp:513
Vector< Vector< Map< int, double > > > LowerSpeedNodeIDs
Holds the lower speed node ID's the train will have to reduce its speed at.
Definition train.h:185
Map< TrainTypes::CarType, Vector< std::shared_ptr< Car > > > carsTypes
Maps the train cars types.
Definition train.h:161
~Train()
Definition train.cpp:75
double getBatteryNetEnergyConsumed()
Gets the battery energy consumed in kWh.
Definition train.cpp:127
double cumMaxDelayTimeStat
Total time delayed untill time step t, relative to max free flow speed of all spanned links.
Definition train.h:142
double energyStat
Total energy consumption (consumed + regenerated) at time step t.
Definition train.h:128
void setTrainPath(Vector< int > path)
set the train path.
Definition train.cpp:83
void checkSuddenAccChange(double previousAcceleration, double currentAcceleration, double deltaT)
Check sudden accumulate change.
Definition train.cpp:564
bool offloaded
If the train is on the network, it is true, false otherwise.
Definition train.h:232
void setTrainLength()
Sets train length.
Definition train.cpp:316
std::pair< double, Map< TrainTypes::PowerType, double > > getMaxProvidedEnergy(double &timeStep)
getMaxProvidedEnergy
Definition train.cpp:1079
Vector< std::shared_ptr< TrainComponent > > trainVehicles
holds the arrangement of the train and how locomotives and cars are arranged in that train.
Definition train.h:191
bool loaded
True if the train is loaded to the simulator, false otherwise.
Definition train.h:238
double heuristicFunction(double distanceToEnd, double stepAcceleration, double stepSpeed, double timeStep, double resistance, double currentSpeed)
The heuristic function for the A-Star algorithm.
Definition train.cpp:825
Map< int, double > LinkGradeDirection
Grade of the links the train is taking and it is mapped by the link ID.
Definition train.h:159
double getTotalResistance(double speed)
Gets total resistance.
Definition train.cpp:388
void kickForwardADistance(double &distance)
Kick forward a distance.
Definition train.cpp:666
static unsigned int getNumberOfTrainsInSimulator()
this function returns how many trains are loaded in the simulator
Definition train.cpp:204
Vector< pair< double, double > > startEndPoints
Holds both the start and end tips' coordinates of the train.
Definition train.h:187
int nextNodeID
The next node the train is targetting.
Definition train.h:217
void calcTrainStats(Vector< double > listOfLinksFreeFlowSpeeds, double MinFreeFlow, double timeStep, std::string currentRegion)
Calculates the train statistics.
Definition train.cpp:682
double maxJerk
Max allowable jerk (m/s^3) for the train.
Definition train.h:89
double accelerateConsideringJerk(double acceleration, double previousAcceleration, double jerk, double deltaT)
Accelerate considering jerk.
Definition train.cpp:546
Vector< double > throttleLevels
The throttle levels that the train will go by.
Definition train.h:197
double cumEnergyStat
Cumulative total energy consumed till time step t.
Definition train.h:130
double getBatteryEnergyRegenerated()
Gets the battery energy regenerated in kWh.
Definition train.cpp:119
int lookAheadCounterToUpdate
The number of steps ahead the train should update its optimization at.
Definition train.h:224
Vector< std::shared_ptr< NetLink > > previousLinks
The previous links the train spanned before.
Definition train.h:189
Map< TrainTypes::PowerType, int > LocTypeCount()
Locomotive type count.
Definition train.cpp:244
double totalLength
Total length of the train.
Definition train.h:80
void resetPowerRestriction()
resetPowerRestriction
Definition train.cpp:899
Vector< std::shared_ptr< NetNode > > trainPathNodes
The predefined path of the train by the node reference.
Definition train.h:176
void suddenAccelerationOccurred(std::string msg)
report a sudden acceleration.
double cumStoppedStat
Statistic of stoppings untill time t.
Definition train.h:146
double getStoppingTimeStat(Vector< double > listOfLinksFreeFlowSpeeds)
Gets stopping time stat.
Definition train.cpp:723
bool reachedDestination
True if the simulator reached its destination, false otherwise.
Definition train.h:234
double optimumThrottleLevel
The optimum throttle level that the train should go by to minimize its energy use.
Definition train.h:126
void slowSpeedOrStopped(std::string msg)
report the trains is very slow or stopped
Vector< Vector< double > > betweenNodesLengths
Holds the computed distances between two nodes along the train's path.
Definition train.h:180
bool consumeEnergy(double &timeStep, double trainSpeed, Vector< double > &usedTractivePower)
Consume energy.
Definition train.cpp:924
double tripTime
Total time spent between the train entering and leaving the network.
Definition train.h:95
void setTrainSimulatorID(int newID)
Definition train.cpp:79
int previousNodeID
The previous node ID the tip of the train just passed.
Definition train.h:213
double getAccelerationUpperBound(double speed, double acceleration, double freeFlowSpeed, bool optimize, double optimumThrottleLevel)
Gets acceleration upper bound.
Definition train.cpp:411
double getAverageTendersTankStatus()
Gets average tenders tank status.
Definition train.cpp:151
double currentResistanceForces
The current resistance forces on the train in Newton.
Definition train.h:120
double adjustAcceleration(double speed, double previousSpeed, double deltaT)
Adjust acceleration.
Definition train.cpp:560
void updateLocNotch()
Updates the location notch.
Definition train.cpp:371
double getAverageLocomotiveTankStatus()
Gets average locomotives tank status.
Definition train.cpp:143
double virtualTravelledDistance
Travelled distance of the train measured from the front tip of the train (virtual and does not affect...
Definition train.h:104
double totalERegenerated
Energy regenerated of the train till time t.
Definition train.h:134
Map< std::shared_ptr< TrainComponent >, double > getTrainCentroids()
This function returns the centroids of all vehicles in the train.
Definition train.cpp:222
double getNextTimeStepSpeed(double gap, double minGap, double speed, double freeFlowSpeed, double aMax, double T_s, double deltaT)
Gets the next time step speed.
Definition train.cpp:430
double getMaxDelayTimeStat(Vector< double > listOfLinksFreeFlowSpeeds, double timeStep)
Gets maximum delay time stat.
Definition train.cpp:709
Vector< std::shared_ptr< Car > > getActiveTanksOfType(TrainTypes::CarType cartype)
Gets active tanks of type.
Definition train.cpp:359
const double g
(Immutable) gravitational acceleration
Definition train.h:74
double currentAcceleration
The current acceleration of the train (at time t)
Definition train.h:112
std::shared_ptr< NetLink > currentFirstLink
Holds the first link the train is on.
Definition train.h:155
double delayTimeStat
The time the train is delayed at time step t, relative to min free flow speed of all spanned links.
Definition train.h:136
double cumDelayTimeStat
Cumulative total time delayed untill time step t, relative to min free flow speed of all spanned link...
Definition train.h:138
double currentTractiveForce
The current tractive forces the train is using in Newton.
Definition train.h:118
double getMinFollowingTrainGap()
Gets minimum following train gap.
Definition train.cpp:107
pair< Vector< double >, double > getTractivePower(double speed, double acceleration, double resistanceForces)
Gets tractive power.
Definition train.cpp:846
void setTrainWeight()
Sets train weight.
Definition train.cpp:326
friend ostream & operator<<(ostream &ostr, Train &train)
Stream insertion operator.
double speedUpDown(double previousSpeed, double acceleration, double deltaT, double freeFlowSpeed)
Gets the speed of the train based on the acceleration.
Definition train.cpp:555
double getAverageTendersStatus()
Gets average tenders status.
Vector< double > currentUsedTractivePowerList
The current used tractive power list.
Definition train.h:195
void setTrainsCurrentLinks(Vector< std::shared_ptr< NetLink > > newLinks)
set the current links the train is spanning
Definition train.cpp:905
double d_des
The desired decceleration value.
Definition train.h:76
double operatorReactionTime
the perception reaction time of the train operator.
Definition train.h:78
static constexpr double speedOfSound
(Immutable) the speed of sound in m / s, this is an approximation of the brackes back propagation
Definition train.h:72
bool rechargeCarsBatteries(double timeStep, double EC_kwh, std::shared_ptr< Locomotive > &loco)
recharge all train cars batteries.
Definition train.cpp:1008
double averageAcceleration
The average journey acceleration of the train from t = 0 to t.
Definition train.h:116
double getTotalEnergyConsumption(double &timeStep, Vector< double > &usedTractivePower)
Gets total energy consumption.
Definition train.cpp:882
bool isOn
True if the train has energy, false if dead.
Definition train.h:230
double previousSpeed
The previous speed of the train (at time t-1)
Definition train.h:108
void updateGradesCurvatures(Vector< double > &LocsCurvature, Vector< double > &LocsGrade, Vector< double > &CarsCurvature, Vector< double > &CarsGrade)
Updates the grades curvatures.
double travelledDistance
Travelled distance of the train measured from the front tip of the train.
Definition train.h:99
int id
The name of the train.
Definition train.h:211
double getEnergyConsumption(double timeStep)
Gets energy consumption.
double getSafeGap(double initialGap, double speed, double freeFlowSpeed, double T_s, bool estimate)
Gets safe gap.
Definition train.cpp:419
Vector< std::shared_ptr< Locomotive > > locomotives
Holds all locomotives in the train.
Definition train.h:171
int getActiveLocomotivesNumber()
Gets active locomotives number.
Definition train.cpp:94
int nlocs
Number of locomotives in the train.
Definition train.h:209
double trainTotalPathLength
The total length of the path the train is suppost to be taking.
Definition train.h:97
tuple< double, double, double > AStarOptimization(double prevSpeed, double currentSpeed, double currentAcceleration, double prevThrottle, Vector< double > vector_grade, Vector< double > vector_curvature, double freeSpeed_ms, double timeStep, Vector< double > u_leader, Vector< double > gapToNextCriticalPoint)
This function adopts the A Star optimization to get the optimum throttle level.
Definition train.cpp:763
Vector< int > trainPath
The predefined path of the train by the simulator node id.
Definition train.h:174
double previousAcceleration
The previous acceleration of the train (at time t-1)
Definition train.h:114
Vector< std::shared_ptr< Locomotive > > ActiveLocos
Maps the train active locomotives types.
Definition train.h:193
int getRechargableLocsNumber()
Gets rechargable locs number.
Definition train.cpp:753
double getTotalTractiveForce(double speed, double acceleration, bool optimize, double optimumThrottleLevel)
Gets total tractive force.
Definition train.cpp:399
double getBatteryEnergyConsumed()
Gets the battery energy consumed in kWh.
Definition train.cpp:111
double coefficientOfFriction
Coefficient of fricition between the trains' wheels and the track.
Definition train.h:87
double cumUsedTractivePower
The cummulative used tractive power (work) that the locomotives provide in kw.
Definition train.h:124
pair< double, double > currentCoordinates
Holds the current coordinates of the tip of the train.
Definition train.h:151
bool outOfEnergy
True if the train ran out of energy.
Definition train.h:236
double calculateAverage(double previousAverage, double currentTimeStepData, double timeStep)
Finds the average of the given arguments.
Definition train.cpp:704
int LastTrainPointpreviousNodeID
The previous node ID the last point of the train just passed.
Definition train.h:215
void rearrangeTrain()
Rearrange train.
Definition train.cpp:270
double pickOptimalThrottleLevelAStar(Vector< double > throttleLevels, int lookAheadCounterToUpdate)
Picks the optimal throttle level considering the A-Star optimization.
Definition train.cpp:837
double getStepAcceleration(double timeStep, double freeFlowSpeed, Vector< double > &gapToNextCriticalPoint, Vector< bool > &gapToNextCriticalPointType, Vector< double > &leaderSpeed)
getStepDynamics
Definition train.cpp:573
Map< std::shared_ptr< TrainComponent >, double > WeightCentroids
Holds the centroid location mapped by the car/loco and relative to the tip of the train.
Definition train.h:157
double getTimeToCollision(double gap, double minGap, double speed, double leaderSpeed)
Gets time to collision.
Definition train.cpp:441
int getRechargableCarsNumber()
Gets rechargable cars number.
Definition train.cpp:743
double waitedTimeAtNode
holds the waited time at any depot
Definition train.h:148
void reducePower(double &reductionFactor)
reducePower
Definition train.cpp:893
double currentSpeed
The current speed of the train (at time t)
Definition train.h:106
Map< TrainTypes::CarType, int > carTypeCount()
car type count
Definition train.cpp:257
Map< TrainTypes::CarType, Vector< std::shared_ptr< Car > > > ActiveCarsTypes
Maps the train active cars types.
Definition train.h:163
int NoPowerCountStep
Counts the number of steps the train could not move forward because of the lack of power source.
Definition train.h:220
double totalMass
The total weight of the train in kg.
Definition train.h:82
bool optimize
True if the train should optimize its energy consumption.
Definition train.h:240
void resetTrainLookAhead()
reset train look ahead parameters
Definition train.cpp:1149
double T_s
Time to fully activate the brakes, considering the network signal speed equals speed of sound.
Definition train.h:91
bool canProvideEnergy(double &EC, double &timeStep)
check if the train can provide the required energy to move forward
Definition train.cpp:1131
bool stopTrainIfNoEnergy
Change this to true if you want the train to stop if it runs out of energy.
Definition train.h:228
double smoothAccelerate(double acceleration, double previousAccelerationValue, double alpha=0.2)
Smooth the acceleration.
Definition train.cpp:551
Vector< std::shared_ptr< NetLink > > currentLinks
The spanned links the train is on.
Definition train.h:178
double totalEmptyMass
The total empty weight of the train.
Definition train.h:84
A vector.
Definition vector.h:24
Definition energyconsumption.cpp:6
_PowerType
Values that represent power types.
Definition traintypes.h:168
_CarType
Values that represent car types.
Definition traintypes.h:23