MTCT
Design Automation and Optimization for ETCS Railway Networks
Loading...
Searching...
No Matches
Timetable.hpp
Go to the documentation of this file.
1#ifndef CDA_RAIL_DATASTRUCTURE_TIMETABLE_HPP
2#define CDA_RAIL_DATASTRUCTURE_TIMETABLE_HPP
3
5#include "Definitions.hpp"
9#include "nlohmann/json_fwd.hpp"
10
11#include <algorithm>
12#include <cstddef>
13#include <filesystem>
14#include <memory>
15#include <optional>
16#include <string>
17#include <utility>
18#include <vector>
19
20namespace cda_rail {
21
33 friend class Timetable;
34
35private:
36 // member variables have no default -> user-defined constructors
37 double m_service_time; // earliest start of service
38 double m_service_duration; // minimal service duration
39 std::shared_ptr<Station> m_station; // pointer to a station
40
47 static void check_ptr_validity(std::shared_ptr<Station const> const& ptr) {
48 if (!ptr) {
50 "Station pointer cannot be null");
51 }
52 }
53
54public:
55 /*
56 * CONSTRUCTOR
57 */
58
59 // user-defined constructor
72 ScheduledStop(double const serviceTime, double const serviceDuration,
73 std::shared_ptr<Station> station)
74 : m_service_time(serviceTime), m_service_duration(serviceDuration),
75 m_station(std::move(station)) {
76 cda_rail::exceptions::throw_if_negative(m_service_time, "Service time");
78 "Service duration");
79 check_ptr_validity(m_station);
80 }
81
82 // Rule of 0 (default constructor overwriting does not affect copy/move
83 // constructors and destructor)
84
85 /*
86 * GETTER
87 */
93 [[nodiscard]] double get_service_time() const { return m_service_time; }
94
100 [[nodiscard]] double get_earliest_departure() const {
101 return m_service_time + m_service_duration;
102 }
103
109 [[nodiscard]] double get_service_duration() const {
110 return m_service_duration;
111 }
112
118 [[nodiscard]] Station const& get_station() const { return *m_station; }
119
120 /*
121 * SETTER
122 */
131 void set_service_time(double new_service_time) {
132 cda_rail::exceptions::throw_if_negative(new_service_time, "Service time");
133 m_service_time = new_service_time;
134 }
135
143 void set_service_duration(double new_service_duration) {
144 cda_rail::exceptions::throw_if_negative(new_service_duration,
145 "Service duration");
146 m_service_duration = new_service_duration;
147 }
148
157 void set_station(std::shared_ptr<Station> new_station) {
158 check_ptr_validity(new_station);
159 m_station = std::move(new_station);
160 }
161};
162
175class Schedule {
176private:
177 double m_entry_time{}; // (earliest) entry time: >= 0
178 double m_exit_time{}; // (desired) exit time: >= entry_time
179
180 double m_initial_velocity{}; // initial velocity: >= 0
181 double m_exit_velocity{}; // (desired) exit velocity: >= 0
182
183 size_t m_entry_vertex{}; // id of entry vertex
184 size_t m_exit_vertex{}; // id of exit vertex
185
186 std::vector<ScheduledStop> m_stops{}; // list of stops, may be empty
187
198 static void check_stops_validity(std::vector<ScheduledStop> const& stops);
199
207 static std::pair<bool, std::optional<cda_rail::exceptions::CustomException>>
208 check_stops_validity_helper(std::vector<ScheduledStop> const& stops);
209
217 Schedule() = default;
218 friend class Timetable;
219
220public:
221 // user-defined-constructor
240 Schedule(double entry_time, double initial_velocity, size_t entry_vertex,
241 double exit_time, double exit_velocity, size_t exit_vertex,
242 std::vector<ScheduledStop> stops = {});
243
244 // Rule of 0: defaults suffice
245
246 /*
247 * GETTER
248 */
249
255 [[nodiscard]] double get_entry_time() const { return m_entry_time; }
256
262 [[nodiscard]] double get_exit_time() const { return m_exit_time; }
263
269 [[nodiscard]] double get_initial_velocity() const {
270 return m_initial_velocity;
271 }
272
278 [[nodiscard]] double get_exit_velocity() const { return m_exit_velocity; }
279
285 [[nodiscard]] size_t get_entry_vertex() const { return m_entry_vertex; }
286
292 [[nodiscard]] size_t get_exit_vertex() const { return m_exit_vertex; }
293
300 [[nodiscard]] std::vector<ScheduledStop> const& get_stops() const {
301 return m_stops;
302 }
303
312 [[nodiscard]] size_t get_station_index(std::string const& station_name) const;
313
314 /*
315 * SETTER
316 */
317
325 void set_entry_time(double const newEntryTime) {
326 cda_rail::exceptions::throw_if_negative(newEntryTime, "Entry time");
327 m_entry_time = newEntryTime;
328 }
329
338 void set_exit_time(double const newExitTime) {
339 cda_rail::exceptions::throw_if_less_than(newExitTime, m_entry_time,
340 "Exit time");
341 m_exit_time = newExitTime;
342 }
343
351 void set_initial_velocity(double const newInitialVelocity) {
353 "Initial velocity");
354 m_initial_velocity = newInitialVelocity;
355 }
356
364 void set_exit_velocity(double const newExitVelocity) {
365 cda_rail::exceptions::throw_if_negative(newExitVelocity, "Exit velocity");
366 m_exit_velocity = newExitVelocity;
367 }
368
374 void set_entry_vertex(size_t const newEntryVertex) {
375 m_entry_vertex = newEntryVertex;
376 }
377
386 void set_entry_vertex(size_t const newEntryVertex, Network const& network) {
387 if (!network.has_vertex(newEntryVertex)) {
388 throw exceptions::VertexNotExistentException(newEntryVertex);
389 }
390 set_entry_vertex(newEntryVertex);
391 }
392
398 void set_exit_vertex(size_t const newExitVertex) {
399 m_exit_vertex = newExitVertex;
400 }
401
410 void set_exit_vertex(size_t const newExitVertex, Network const& network) {
411 if (!network.has_vertex(newExitVertex)) {
412 throw exceptions::VertexNotExistentException(newExitVertex);
413 }
414 set_exit_vertex(newExitVertex);
415 }
416
424 void set_stops(std::vector<ScheduledStop> new_stops) {
425 check_stops_validity(new_stops);
426 m_stops = std::move(new_stops);
427 }
428
441 void insert_stop(ScheduledStop new_stop);
442
452 void remove_stop(std::string const& station_name,
453 bool throw_exception_if_not_existent = true);
454
461
463 std::ranges::stable_sort(m_stops, {}, &ScheduledStop::get_service_time);
464 }
465};
466
476private:
477 StationList m_station_list{};
478 TrainList m_train_list{};
479 std::vector<Schedule> m_schedules{};
480
490
491 void set_train_list(const TrainList& tl) {
492 this->m_train_list = tl;
493 this->m_schedules = std::vector<Schedule>(
494 tl.size(), Schedule()); // this requires friendship
495 }
496
503 void parse_schedule_data(const nlohmann::json& schedule_data, size_t i);
504
512 void add_json_data(nlohmann::json& j, size_t i, const Network& network) const;
513
517 void sort_stops_by_service_time() {
518 for (auto& schedule : m_schedules) {
519 schedule.sort_stops_by_service_time();
520 }
521 }
522
523 [[nodiscard]] std::pair<bool,
524 std::optional<cda_rail::exceptions::CustomException>>
525 check_consistency_helper() const;
526
527public:
531 Timetable() = default;
540 Timetable(StationList station_list, TrainList train_list,
541 const std::vector<Schedule>& schedules);
548 Timetable(const std::filesystem::path& p, const Network& network);
554 Timetable(const std::string& path, const Network& network)
555 : Timetable(std::filesystem::path(path), network) {};
556
562 Timetable(char const* const path, Network const& network)
563 : Timetable(std::filesystem::path(path), network) {};
564
565 // Custom copy constructor and assignment operator for deep copying
566 // When copying, we need to ensure that ScheduledStop objects point to
567 // the stations in the copied StationList, not the original ones
576 Timetable(const Timetable& other)
577 : m_station_list(other.m_station_list), m_train_list(other.m_train_list),
578 m_schedules(other.m_schedules) {
579 // After copying, update all ScheduledStop objects to point to the new
580 // stations The StationList copy creates new Station objects, so we need to
581 // update the shared_ptr in ScheduledStop to point to these new objects
582 for (auto& schedule : m_schedules) {
583 for (auto& stop : schedule.m_stops) {
584 // Find the corresponding station in the new station list
585 auto const& station_name = stop.m_station->name;
586 if (m_station_list.has_station(station_name)) {
587 stop.m_station = m_station_list.get_station_ptr(station_name);
588 }
589 }
590 }
591 }
592
600 if (this != &other) {
601 m_station_list = other.m_station_list;
602 m_train_list = other.m_train_list;
603 m_schedules = other.m_schedules;
604
605 // Update all ScheduledStop objects to point to the new stations
606 for (auto& schedule : m_schedules) {
607 for (auto& stop : schedule.m_stops) {
608 auto const& station_name = stop.m_station->name;
609 if (m_station_list.has_station(station_name)) {
610 stop.m_station = m_station_list.get_station_ptr(station_name);
611 }
612 }
613 }
614 }
615 return *this;
616 }
617
618 // Default move constructor and assignment operator
620 Timetable(Timetable&&) noexcept = default;
622 Timetable& operator=(Timetable&&) noexcept = default;
623
628 [[nodiscard]] constexpr auto begin() const { return m_schedules.cbegin(); };
633 [[nodiscard]] constexpr auto end() const { return m_schedules.cend(); };
635 [[nodiscard]] constexpr auto cbegin() const { return m_schedules.cbegin(); };
641 [[nodiscard]] constexpr auto cend() const { return m_schedules.cend(); };
647 [[nodiscard]] constexpr auto crbegin() const {
648 return m_schedules.crbegin();
649 };
650
651 [[nodiscard]] constexpr auto crend() const { return m_schedules.crend(); };
652
653 // Export / Import
660 void export_timetable(const std::filesystem::path& p,
661 const Network& network) const;
668 void export_timetable(const std::string& path, const Network& network) const {
669 export_timetable(std::filesystem::path(path), network);
670 };
671
674 void export_timetable(char const* const path, Network const& network) const {
675 export_timetable(std::filesystem::path(path), network);
676 };
677
685 [[nodiscard]] static Timetable import_timetable(const std::string& path,
686 const Network& network) {
687 return {path, network};
688 };
689
696 [[nodiscard]] static Timetable
697 import_timetable(const std::filesystem::path& p, const Network& network) {
698 return {p, network};
699 };
700
707 [[nodiscard]] static Timetable import_timetable(char const* const path,
708 const Network& network) {
709 return {path, network};
710 };
711
717
718 [[nodiscard]] StationList const& get_station_list() const {
719 return m_station_list;
720 };
721
726 [[nodiscard]] TrainList const& get_train_list() const {
727 return m_train_list;
728 };
729
737 [[nodiscard]] Schedule const& get_schedule(size_t const trainIndex) const {
738 if (!m_train_list.has_train(trainIndex)) {
740 }
741 return m_schedules.at(trainIndex);
742 };
743
750 [[nodiscard]] Schedule const&
751 get_schedule(std::string const& train_name) const {
752 return get_schedule(m_train_list.get_train_index(train_name));
753 };
754
760 [[nodiscard]] double latest_exit_time() const;
761
766 [[nodiscard]] Train& editable_train(size_t const index) {
767 return m_train_list.editable_train(index);
768 };
769
775 [[nodiscard]] Train& editable_train(std::string const& name) {
776 return m_train_list.editable_train(name);
777 };
778
786 [[nodiscard]] Schedule& editable_schedule(size_t const trainIndex) {
787 if (!m_train_list.has_train(trainIndex)) {
789 }
790 return m_schedules.at(trainIndex);
791 };
792
799 [[nodiscard]] Schedule& editable_schedule(std::string const& train_name) {
800 return editable_schedule(m_train_list.get_train_index(train_name));
801 };
802
814 [[nodiscard]] std::vector<
815 std::pair<size_t, std::vector<cda_rail::index_vector>>>
816 get_stop_tracks(size_t const tr, std::string const& station_name,
817 Network const& network,
818 cda_rail::index_set const& edges_to_consider) const {
819 return m_station_list.get_stop_tracks(
820 station_name, m_train_list.get_train(tr).get_length(), network,
821 edges_to_consider);
822 };
823
829
830 void add_empty_station(const std::string& station_name) {
831 m_station_list.add_empty_station(station_name);
832 };
833
842 void insert_stop(size_t train_index, std::string const& station_name,
843 double service_time, double service_duration);
855 void insert_stop(std::string const& train_name,
856 std::string const& station_name, double const serviceTime,
857 double const serviceDuration) {
858 insert_stop(m_train_list.get_train_index(train_name), station_name,
859 serviceTime, serviceDuration);
860 }
861
870 void remove_stop(size_t train_index, std::string const& station_name,
871 bool throw_exception_if_not_existent = true);
884 void remove_stop(std::string const& train_name,
885 std::string const& station_name,
886 bool throw_exception_if_not_existent = true) {
887 remove_stop(m_train_list.get_train_index(train_name), station_name,
888 throw_exception_if_not_existent);
889 }
890
898 void add_track_to_station(std::string const& station_name,
899 Network::EdgeInput const& new_edge,
900 Network const& network) {
901 m_station_list.add_track_to_station(station_name, new_edge, network);
902 };
903
904private:
925 [[nodiscard]] size_t add_train_private_helper(
926 std::string const& train_name, double length, double max_speed,
927 double acceleration, double deceleration, bool tim, double entry_time,
928 double initial_velocity, size_t entry_vertex, double exit_time,
929 double exit_velocity, size_t exit_vertex);
930
931public:
949 [[nodiscard]] size_t add_train(std::string const& train_name, double length,
950 double max_speed, double acceleration,
951 double deceleration, bool tim,
952 double entry_time, double initial_velocity,
953 Network::VertexInput const& entry_vertex,
954 double exit_time, double exit_velocity,
955 Network::VertexInput const& exit_vertex,
956 Network const& network) {
957 return add_train_private_helper(
958 train_name, length, max_speed, acceleration, deceleration, tim,
959 entry_time, initial_velocity, entry_vertex.resolve(&network), exit_time,
960 exit_velocity, exit_vertex.resolve(&network));
961 };
962
979 [[nodiscard]] size_t
980 add_train(std::string const& train_name, double length, double max_speed,
981 double acceleration, double deceleration, double entry_time,
982 double initial_velocity, Network::VertexInput const& entry_vertex,
983 double exit_time, double exit_velocity,
984 Network::VertexInput const& exit_vertex, Network const& network) {
985 return add_train(train_name, length, max_speed, acceleration, deceleration,
986 true, entry_time, initial_velocity, entry_vertex,
987 exit_time, exit_velocity, exit_vertex, network);
988 };
989
990 // No stop removal for now
991
992 // Further helpers
993
1007 [[nodiscard]] bool check_consistency(Network const& network) const;
1008
1016 std::vector<std::pair<size_t, cda_rail::index_set>> const& new_edges) {
1017 m_station_list.update_after_discretization(new_edges);
1018 }
1019
1026 std::vector<std::pair<size_t, cda_rail::index_vector>> const& new_edges) {
1027 m_station_list.update_after_discretization(new_edges);
1028 }
1029
1038 [[nodiscard]] std::pair<size_t, size_t>
1039 time_index_interval(size_t train_index, double dt,
1040 bool tn_inclusive = true) const;
1052 [[nodiscard]] std::pair<size_t, size_t>
1053 time_index_interval(std::string const& train_name, double const dt,
1054 bool const tnInclusive = true) const {
1055 return time_index_interval(m_train_list.get_train_index(train_name), dt,
1056 tnInclusive);
1057 };
1058};
1059} // namespace cda_rail
1060
1061#endif // CDA_RAIL_DATASTRUCTURE_TIMETABLE_HPP
Directed multigraph representing a railway network.
Definition RailwayNetwork.hpp:163
bool has_vertex(size_t index) const
Checks whether a numeric vertex index is valid.
Definition RailwayNetwork.hpp:417
Specific schedule object with fixed entry/exit constraints.
Definition Timetable.hpp:175
void insert_stop(ScheduledStop new_stop)
Inserts one stop while preserving stop-list invariants.
Definition Timetable.cpp:86
void remove_stop(std::string const &station_name, bool throw_exception_if_not_existent=true)
Removes a stop by station name.
Definition Timetable.cpp:103
double get_exit_velocity() const
Obtains the exit velocity.
Definition Timetable.hpp:278
double get_entry_time() const
Provides the entry time.
Definition Timetable.hpp:255
double get_exit_time() const
Gets the scheduled exit time.
Definition Timetable.hpp:262
void set_stops(std::vector< ScheduledStop > new_stops)
Replaces the stop list for this schedule.
Definition Timetable.hpp:424
void set_exit_time(double const newExitTime)
Sets the exit time.
Definition Timetable.hpp:338
void set_initial_velocity(double const newInitialVelocity)
Updates the initial velocity.
Definition Timetable.hpp:351
size_t get_exit_vertex() const
Gets the exit vertex of the schedule.
Definition Timetable.hpp:292
void set_entry_vertex(size_t const newEntryVertex)
Sets the entry vertex.
Definition Timetable.hpp:374
std::vector< ScheduledStop > const & get_stops() const
Retrieves the scheduled stops for this train.
Definition Timetable.hpp:300
friend class Timetable
Definition Timetable.hpp:218
void set_exit_vertex(size_t const newExitVertex)
Sets the exit vertex id.
Definition Timetable.hpp:398
void set_exit_vertex(size_t const newExitVertex, Network const &network)
Sets the exit vertex id after validating it against a network.
Definition Timetable.hpp:410
size_t get_station_index(std::string const &station_name) const
Returns the index of a scheduled stop by station name.
Definition Timetable.cpp:43
void set_entry_vertex(size_t const newEntryVertex, Network const &network)
Sets the entry vertex id after validating it against a network.
Definition Timetable.hpp:386
size_t get_entry_vertex() const
Determines the network vertex where the train enters.
Definition Timetable.hpp:285
void set_exit_velocity(double const newExitVelocity)
Sets the exit velocity.
Definition Timetable.hpp:364
double get_initial_velocity() const
Obtains the initial velocity.
Definition Timetable.hpp:269
void set_entry_time(double const newEntryTime)
Sets the entry time.
Definition Timetable.hpp:325
void sort_stops_by_service_time()
Sorts the scheduled stops by service time.
Definition Timetable.hpp:462
Scheduling information for a stop within a timetable.
Definition Timetable.hpp:32
void set_service_time(double new_service_time)
Sets the earliest service start time.
Definition Timetable.hpp:131
ScheduledStop(double const serviceTime, double const serviceDuration, std::shared_ptr< Station > station)
Constructs a scheduled stop for a concrete station.
Definition Timetable.hpp:72
Station const & get_station() const
Accesses the station associated with this stop.
Definition Timetable.hpp:118
double get_earliest_departure() const
Computes the earliest departure time from this stop.
Definition Timetable.hpp:100
double get_service_duration() const
Accesses the minimum service duration.
Definition Timetable.hpp:109
double get_service_time() const
Retrieves the earliest service start time.
Definition Timetable.hpp:93
friend class Timetable
Definition Timetable.hpp:33
void set_service_duration(double new_service_duration)
Sets the minimum service duration.
Definition Timetable.hpp:143
void set_station(std::shared_ptr< Station > new_station)
Sets the station for this scheduled stop.
Definition Timetable.hpp:157
Container and persistence API for named stations.
Definition Station.hpp:81
The trains of an instance together with what they are to do.
Definition Timetable.hpp:475
void update_after_discretization(std::vector< std::pair< size_t, cda_rail::index_set > > const &new_edges)
Updates the timetable after network discretization.
Definition Timetable.hpp:1015
bool check_consistency(Network const &network) const
Checks whether timetable data is consistent with the network.
Definition Timetable.cpp:379
void insert_stop(std::string const &train_name, std::string const &station_name, double const serviceTime, double const serviceDuration)
Inserts a scheduled stop for a train identified by name.
Definition Timetable.hpp:855
Timetable(const Timetable &other)
Copy constructor that performs a deep copy.
Definition Timetable.hpp:576
Schedule const & get_schedule(size_t const trainIndex) const
Retrieves the schedule for a given train.
Definition Timetable.hpp:737
void export_timetable(char const *const path, Network const &network) const
Exports the timetable to a file.
Definition Timetable.hpp:674
constexpr auto crbegin() const
Const reverse iterator to the last schedule.
Definition Timetable.hpp:647
void export_timetable(const std::filesystem::path &p, const Network &network) const
Exports the timetable to the given filesystem path.
Definition Timetable.cpp:213
constexpr auto crend() const
Read-only reverse iterator before the first schedule.
Definition Timetable.hpp:651
constexpr auto cend() const
Returns a const iterator to one past the last schedule.
Definition Timetable.hpp:641
TrainList const & get_train_list() const
Provides access to the train list.
Definition Timetable.hpp:726
double latest_exit_time() const
Returns the latest scheduled exit time across all trains.
Definition Timetable.cpp:239
size_t add_train(std::string const &train_name, double length, double max_speed, double acceleration, double deceleration, bool tim, double entry_time, double initial_velocity, Network::VertexInput const &entry_vertex, double exit_time, double exit_velocity, Network::VertexInput const &exit_vertex, Network const &network)
Adds a train to the timetable with specified entry/exit constraints.
Definition Timetable.hpp:949
void update_after_discretization(std::vector< std::pair< size_t, cda_rail::index_vector > > const &new_edges)
Updates the timetable after discretization.
Definition Timetable.hpp:1025
constexpr auto end() const
Provides the end iterator for iterating over schedules.
Definition Timetable.hpp:633
Timetable(Timetable &&) noexcept=default
Move constructor.
Timetable(const std::string &path, const Network &network)
Constructs a timetable from a file path specified as a string.
Definition Timetable.hpp:554
void export_timetable(const std::string &path, const Network &network) const
Writes the timetable to a file.
Definition Timetable.hpp:668
Timetable(char const *const path, Network const &network)
Constructs a timetable from a C-string path.
Definition Timetable.hpp:562
void remove_stop(std::string const &train_name, std::string const &station_name, bool throw_exception_if_not_existent=true)
Removes a stop from a train's schedule by station name.
Definition Timetable.hpp:884
Schedule & editable_schedule(size_t const trainIndex)
Provides mutable access to the schedule of a train.
Definition Timetable.hpp:786
size_t add_train(std::string const &train_name, double length, double max_speed, double acceleration, double deceleration, double entry_time, double initial_velocity, Network::VertexInput const &entry_vertex, double exit_time, double exit_velocity, Network::VertexInput const &exit_vertex, Network const &network)
Adds a new train to the timetable.
Definition Timetable.hpp:980
std::vector< std::pair< size_t, std::vector< cda_rail::index_vector > > > get_stop_tracks(size_t const tr, std::string const &station_name, Network const &network, cda_rail::index_set const &edges_to_consider) const
Retrieves available track segments for a train at a station.
Definition Timetable.hpp:816
StationList const & get_station_list() const
Provides access to the station list.
Definition Timetable.hpp:718
void remove_stop(size_t train_index, std::string const &station_name, bool throw_exception_if_not_existent=true)
Removes a stop from a train's schedule by train index.
Definition Timetable.cpp:319
static Timetable import_timetable(const std::filesystem::path &p, const Network &network)
Imports a timetable from a file.
Definition Timetable.hpp:697
constexpr auto cbegin() const
Read-only iterator to the first schedule (explicit const).
Definition Timetable.hpp:635
static Timetable import_timetable(char const *const path, const Network &network)
Loads a timetable from a file.
Definition Timetable.hpp:707
Schedule const & get_schedule(std::string const &train_name) const
Retrieves the schedule for a train by name.
Definition Timetable.hpp:751
std::pair< size_t, size_t > time_index_interval(size_t train_index, double dt, bool tn_inclusive=true) const
Returns the discrete time-index interval relevant for one train.
Definition Timetable.cpp:248
Train & editable_train(size_t const index)
Provides mutable access to a train by index.
Definition Timetable.hpp:766
std::pair< size_t, size_t > time_index_interval(std::string const &train_name, double const dt, bool const tnInclusive=true) const
Computes the time index interval for a train, identified by name.
Definition Timetable.hpp:1053
Timetable & operator=(const Timetable &other)
Copy assignment operator that performs a deep copy.
Definition Timetable.hpp:599
Timetable()=default
Creates an empty timetable.
Train & editable_train(std::string const &name)
Obtains a mutable reference to a train by name.
Definition Timetable.hpp:775
void add_empty_station(const std::string &station_name)
Adds a new station to the timetable with no scheduled stops.
Definition Timetable.hpp:830
void insert_stop(size_t train_index, std::string const &station_name, double service_time, double service_duration)
Inserts a scheduled stop for a train identified by index.
Definition Timetable.cpp:303
Schedule & editable_schedule(std::string const &train_name)
Provides mutable access to the schedule of a train by name.
Definition Timetable.hpp:799
void add_track_to_station(std::string const &station_name, Network::EdgeInput const &new_edge, Network const &network)
Adds a new track to the specified station.
Definition Timetable.hpp:898
static Timetable import_timetable(const std::string &path, const Network &network)
Imports a timetable from a file.
Definition Timetable.hpp:685
constexpr auto begin() const
Provides a read-only iterator to the first schedule.
Definition Timetable.hpp:628
Container for trains with name-based indexing.
Definition Train.hpp:200
size_t size() const
Retrieves the number of trains in the list.
Definition Train.hpp:283
Properties and characteristics of a train.
Definition Train.hpp:26
Thrown when input values do not satisfy expected constraints.
Definition CustomExceptions.hpp:97
Thrown when a referenced train does not exist.
Definition CustomExceptions.hpp:207
Thrown when a referenced vertex does not exist.
Definition CustomExceptions.hpp:133
void throw_if_less_than(double const value, double const threshold, std::string_view const name)
Throws if a value is less than a threshold.
Definition CustomExceptions.hpp:323
void throw_if_negative(double const value, std::string_view const name)
Validates that a value is non-negative.
Definition CustomExceptions.hpp:349
Definition CustomExceptions.hpp:15
std::unordered_set< size_t > index_set
Definition Definitions.hpp:22
Unified edge descriptor accepted by all public API functions.
Definition RailwayNetwork.hpp:207
Unified vertex descriptor accepted by all public API functions.
Definition RailwayNetwork.hpp:172
Represents a station as a named set of network tracks (edge indices).
Definition Station.hpp:24