MTCT
Design Automation and Optimization for ETCS Railway Networks
Loading...
Searching...
No Matches
Definitions.hpp
Go to the documentation of this file.
1#ifndef CDA_RAIL_DEFINITIONS_HPP
2#define CDA_RAIL_DEFINITIONS_HPP
3
4#include <cstddef>
5#include <cstdint>
6#include <limits>
7#include <stdexcept>
8#include <string>
9#include <unordered_set>
10#include <vector>
11
12// Infinity is a valid value, e.g., the maximal travel time of a train that may
13// stop. With -ffinite-math-only (also part of -ffast-math), the compiler may
14// drop comparisons with it, which silently yields wrong models.
15#if defined(__FINITE_MATH_ONLY__) && __FINITE_MATH_ONLY__
16#error "cda-rail must not be compiled with -ffinite-math-only or -ffast-math"
17#endif
18
19namespace cda_rail {
20
21using index_vector = std::vector<size_t>;
22using index_set = std::unordered_set<size_t>;
23
24// Constants
25constexpr double INF = std::numeric_limits<double>::max() / 3;
26constexpr double EPS = 1000 * std::numeric_limits<double>::epsilon();
27constexpr double GRB_EPS = 1e-4;
28constexpr double V_MIN = 0.3;
29constexpr double STOP_TOLERANCE = 10;
30constexpr double ABS_PWL_ERROR = 10;
31constexpr double LINE_SPEED_ACCURACY = 0.1;
32constexpr double LINE_SPEED_TIME_ACCURACY = 0.1;
33constexpr double MIN_NON_ZERO = 0.1;
34constexpr double MIN_OCCUPIED_LENGTH = 1;
35
36// TODO: Sensible to move any of these
37
48enum class VertexType : std::uint8_t {
50 VSS = 1,
51 TTD = 2,
53};
54
55enum class SolutionStatus : std::uint8_t {
61};
62
63[[nodiscard]] constexpr std::string
65 switch (status) {
67 return "Optimal";
69 return "Feasible";
71 return "Infeasible";
73 return "Timeout";
75 return "Unknown";
76 default:
77 throw std::invalid_argument("Unknown solution status.");
78 }
79}
80
87enum class OptimalityStrategy : std::uint8_t {
91};
92
99enum class VelocityRefinementStrategy : std::uint8_t {
100 None = 0,
102};
103
104} // namespace cda_rail
105
106#endif // CDA_RAIL_DEFINITIONS_HPP
Definition CustomExceptions.hpp:15
constexpr double INF
Definition Definitions.hpp:25
constexpr double LINE_SPEED_ACCURACY
Definition Definitions.hpp:31
constexpr double EPS
Definition Definitions.hpp:26
VelocityRefinementStrategy
How the discrete velocities of a vertex are chosen.
Definition Definitions.hpp:99
@ MinOneStep
Definition Definitions.hpp:101
@ None
Definition Definitions.hpp:100
std::unordered_set< size_t > index_set
Definition Definitions.hpp:22
constexpr double MIN_OCCUPIED_LENGTH
Definition Definitions.hpp:34
std::vector< size_t > index_vector
Definition Definitions.hpp:21
constexpr double LINE_SPEED_TIME_ACCURACY
Definition Definitions.hpp:32
constexpr std::string solution_status_to_string(SolutionStatus const status)
The name of status, as it is reported, exported and imported.
Definition Definitions.hpp:64
constexpr double GRB_EPS
Definition Definitions.hpp:27
constexpr double V_MIN
Definition Definitions.hpp:28
constexpr double ABS_PWL_ERROR
Definition Definitions.hpp:30
SolutionStatus
What a solver was able to say about the instance it was given.
Definition Definitions.hpp:55
@ Infeasible
Definition Definitions.hpp:58
@ Unknown
Definition Definitions.hpp:60
@ Feasible
Definition Definitions.hpp:57
@ Timeout
Definition Definitions.hpp:59
@ Optimal
Definition Definitions.hpp:56
OptimalityStrategy
How hard a solver tries to prove optimality.
Definition Definitions.hpp:87
@ TradeOff
Definition Definitions.hpp:89
constexpr double MIN_NON_ZERO
Definition Definitions.hpp:33
constexpr double STOP_TOLERANCE
Definition Definitions.hpp:29
VertexType
Which kind of block border a vertex is.
Definition Definitions.hpp:48
@ NoBorder
Definition Definitions.hpp:49
@ TTD
Definition Definitions.hpp:51
@ VSS
Definition Definitions.hpp:50
@ NoBorderVSS
Definition Definitions.hpp:52