Skip to content

Commit

Permalink
fix some linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sengels-tum committed Feb 21, 2025
1 parent 1c99d8d commit 5473e1f
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 23 deletions.
1 change: 1 addition & 0 deletions include/CustomExceptions.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <cstddef>
#include <exception>
#include <string>
#include <utility>
Expand Down
27 changes: 22 additions & 5 deletions include/Definitions.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#pragma once
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <limits>
#include <stdexcept>
#include <string>
#include <system_error>
#include <utility>
#include <vector>

namespace cda_rail {
Expand All @@ -17,24 +22,36 @@ constexpr double ABS_PWL_ERROR = 10;
constexpr double LINE_SPEED_ACCURACY = 0.1;
constexpr double LINE_SPEED_TIME_ACCURACY = 0.1;

enum class VertexType { NoBorder = 0, VSS = 1, TTD = 2, NoBorderVSS = 3 };
enum class SolutionStatus {
enum class VertexType : std::uint8_t {
NoBorder = 0,
VSS = 1,
TTD = 2,
NoBorderVSS = 3
};
enum class SolutionStatus : std::uint8_t {
Optimal = 0,
Feasible = 1,
Infeasible = 2,
Timeout = 3,
Unknown = 4
};
enum class ExportOption {
enum class ExportOption : std::uint8_t {
NoExport = 0,
ExportSolution = 1,
ExportSolutionWithInstance = 2,
ExportLP = 3,
ExportSolutionAndLP = 4,
ExportSolutionWithInstanceAndLP = 5
};
enum class OptimalityStrategy { Optimal = 0, TradeOff = 1, Feasible = 2 };
enum class VelocityRefinementStrategy { None = 0, MinOneStep = 1 };
enum class OptimalityStrategy : std::uint8_t {
Optimal = 0,
TradeOff = 1,
Feasible = 2
};
enum class VelocityRefinementStrategy : std::uint8_t {
None = 0,
MinOneStep = 1
};

// Helper functions

Expand Down
3 changes: 2 additions & 1 deletion include/EOMHelper.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstdint>
#include <utility>

// EOM = Equations of Motion
Expand Down Expand Up @@ -74,7 +75,7 @@ double max_time_profile_from_rear_to_ma_point(double v_1, double v_2,
double v_m, double a, double d,
double s, double obd);

enum class MATimingStrategy { ExtremeProfiles = 0 };
enum class MATimingStrategy : std::uint8_t { ExtremeProfiles = 0 };

double min_time_from_rear_to_ma_point(
double v_1, double v_2, double v_min, double v_max, double a, double d,
Expand Down
1 change: 0 additions & 1 deletion include/MultiArray.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once
#include <cstddef>
#include <memory>
#include <sstream>
#include <stdexcept>
#include <vector>
Expand Down
19 changes: 10 additions & 9 deletions include/VSSModel.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#pragma once

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <limits>
#include <stdexcept>
#include <utility>
#include <vector>

namespace cda_rail::vss {
using SeparationFunction = std::function<double(size_t, size_t)>;

enum class ModelType {
enum class ModelType : std::uint8_t {
Discrete = 0,
Continuous = 1,
Inferred = 2,
Expand All @@ -20,9 +23,7 @@ enum class ModelType {
namespace functions {
[[nodiscard]] static double uniform(size_t i, size_t n) {
double ret_val = (static_cast<double>(i) + 1) / static_cast<double>(n);
if (ret_val > 1) {
ret_val = 1;
}
ret_val = std::min<double>(ret_val, 1);
return ret_val;
}

Expand All @@ -34,7 +35,7 @@ namespace functions {
const auto n_points = static_cast<double>(n) - 1;
const auto k = n_points - static_cast<double>(i);
constexpr double pi = 3.14159265358979323846;
return 0.5 + 0.5 * std::cos((2 * k - 1) * pi / (2 * n_points));
return 0.5 + (0.5 * std::cos((2 * k - 1) * pi / (2 * n_points)));
}

[[nodiscard]] static size_t max_n_blocks(const SeparationFunction& sep_func,
Expand All @@ -57,15 +58,15 @@ namespace functions {
}
}

return static_cast<size_t>(std::floor(1 / min_frac + eps));
return static_cast<size_t>(std::floor((1 / min_frac) + eps));
}
} // namespace functions

class Model {
private:
ModelType model_type = ModelType::Continuous;
bool only_stop_at_vss = false;
std::vector<SeparationFunction> separation_functions = {};
ModelType model_type = ModelType::Continuous;
bool only_stop_at_vss = false;
std::vector<SeparationFunction> separation_functions;

public:
// Constructors
Expand Down
8 changes: 5 additions & 3 deletions include/solver/GeneralSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#include "probleminstances/GeneralProblemInstance.hpp"

#include <chrono>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <plog/Appenders/ColorConsoleAppender.h>
#include <plog/Formatters/TxtFormatter.h>
#include <plog/Initializers/ConsoleInitializer.h>
#include <plog/Log.h>
#include <plog/Init.h>
#include <plog/Severity.h>
#include <string>
#include <type_traits>

namespace cda_rail::solver {
Expand Down
5 changes: 4 additions & 1 deletion include/solver/mip-based/GenPOMovingBlockMIPSolver.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#pragma once

#include "Definitions.hpp"
#include "datastructure/GeneralTimetable.hpp"
#include "datastructure/RailwayNetwork.hpp"
#include "datastructure/Train.hpp"
#include "gurobi_c++.h"
#include "probleminstances/GeneralPerformanceOptimizationInstance.hpp"
#include "solver/GeneralSolver.hpp"
#include "solver/mip-based/GeneralMIPSolver.hpp"

// NOLINTNEXTLINE(misc-include-cleaner)
#include "gtest/gtest_prod.h"
#include <cstddef>
#include <cstdint>
Expand Down
6 changes: 5 additions & 1 deletion include/solver/mip-based/GeneralMIPSolver.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#pragma once

#include "Definitions.hpp"
#include "MultiArray.hpp"
#include "gurobi_c++.h"
#include "gurobi_c.h"
#include "probleminstances/GeneralProblemInstance.hpp"
#include "solver/GeneralSolver.hpp"

#include <cstddef>
#include <filesystem>
#include <optional>
#include <plog/Log.h>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>

namespace cda_rail::solver::mip_based {

Expand Down
6 changes: 5 additions & 1 deletion include/solver/mip-based/VSSGenTimetableSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
#include "gurobi_c++.h"
#include "probleminstances/GeneralPerformanceOptimizationInstance.hpp"
#include "probleminstances/VSSGenerationTimetable.hpp"
#include "solver/GeneralSolver.hpp"
#include "unordered_map"

#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <optional>
#include <string>
#include <utility>
#include <vector>

namespace cda_rail::solver::mip_based {

enum class UpdateStrategy { Fixed = 0, Relative = 1 };
enum class UpdateStrategy : std::uint8_t { Fixed = 0, Relative = 1 };

struct SolverStrategy {
bool iterative_approach = false;
Expand Down Expand Up @@ -46,6 +49,7 @@ struct ModelDetailMBInformation {
};

struct ModelSettings {
// NOLINTNEXTLINE(readability-redundant-member-init)
vss::Model model_type = vss::Model();
bool use_pwl = false;
bool use_schedule_cuts = true;
Expand Down
1 change: 0 additions & 1 deletion src/solver/mip-based/VSSGenTimetableSolver_fixedRoutes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <cmath>
#include <cstddef>
#include <math.h>
#include <string>

// NOLINTBEGIN(performance-inefficient-string-concatenation,bugprone-unchecked-optional-access)
Expand Down

0 comments on commit 5473e1f

Please sign in to comment.