Skip to content

Moving Block Routing using Simulation#109

Draft
sengels-tum wants to merge 20 commits intomainfrom
moving-block-simulation
Draft

Moving Block Routing using Simulation#109
sengels-tum wants to merge 20 commits intomainfrom
moving-block-simulation

Conversation

@sengels-tum
Copy link
Copy Markdown
Collaborator

This PR adds simulation methods and optimizers in the context of moving block routing

ottoblep and others added 2 commits May 7, 2025 17:20
* Add nix devshell

* Add tools for pre-commit hooks and linting

* Add example test for new simulation category

* Add tool for graph visualization

* Add empty class `SimulationInstance`

* Add members and test for `SimulationInstance`

* Determine simulation parameters

* Add struct `RoutingSolutionTrain`

* Switch integer type

* Add general classes for routing

* Add random solution generation

* Move consistency check and restrict access qualifiers

* Update dev packages

* Add dev scripts

* Add class `RoutingSolution`

* Add class `EdgeTrajectory`

* Add struct `SpeedTargets`

* Add search through speed targets

* Add edge trajectory simulation

* Simplify edge simulation and add part of edge transition

* Switch datatypes and structures

* Switch to ninja build tool

* Fix random solution generation

* Add edge transition logic

* Add `TrainTrajectory`

* Formalize edge transition outcomes

* Fix includes and tests

* Add check for planned stop

* Generate amount of timestep from schedule

* Generate initial train state from schedule

* Check overspeed outcome

* Add part of trajectory construction

* Keep reference to instance in trajectory objects

* Add `limit_speed_after`

* Use const iterator

* Remove undefined constructor

* Add test for `limit_speed_after`

* Add braking logic helper functions

* Save information about edge transitions

* Fix range of `switch_directions`

* Index timesteps from 0

* Add `distance_to_last_transition` and `is_feasible_braking_point`

* Fix orientation format

* Fix test

* Convert member functions to const

* Add helpers to SpeedTargets

* Clarify trajectory object naming

* Sort member functions

* Consider carried over targets when limiting speeds

* Rename internal function

* Add const to `RoutingSolver` members

* Add braking function

* Fix const member initialization

* Enable holding both until a fixed time and a minimum time

* Add edge speed limiting logic

* Clarify timestep indexing

* Begin trajectory construction logic

* Add `find_next_reversal`

* Finish trajectory construction logic

* Add test for trajectory construction

* Refactor random solution generation

* Use calculated amount of switch vars in test

* Fix edge simulation exiting immediately

* Fix timestep range check

* Track visited stops

* Rework edge transition logic

We need compatability for passing multiple edges in one timestep

* Narrow scope

* Fix acceleration sign

* Make sub trajectory selection more robust

* Make checks for timestep range train specific

* Fix range error while pruning trajectories

* Include hold in returned braking period

* Clarify error message

* Improve struct member names

* Determine last timestep during construction

* Fix transition timestep increment

* Recalculate entire trajectory when adjusting first target

* Rename variable to avoid confusion with member

* Terminate construction after simulation time ends

* Establish invariant for `EdgeEntry`

* Fix control flow for revisited planned stop

* Fix accidental iterator decrement

* Update tools

* Fix incorrect use of map erase

* Resolve name collision

* Fix missing member initialization

* Skip target restoration at end of simulation

* Split functions for searching trajectories

* When not reversing out of dead end wait until end of time

* Change type

* Replace `ulong` with `u_int64_t`

* Edge index has type `size_t`

* Remove redundant range checks

* Test more solutions with random target amount

* Prevent integer underflow

* Remove redundant calculation

* Disable optimizations in debug mode

This should be covered by default behavior but isn't.

* Fix braking distance calculation

* Fix negative braking time

* Remove remaining distance calculation

* Fix incorrect `std::signbit` usage

* Disallow default constructors

* Allow const members

* Add include guards

* Add solution and trajectory sets

* Explain map keys in solution and trajectory sets

* Add test for trajectory set

* Pass solution set by reference

* Test size of solution and trajectory sets

* Add trajectory set export to csv

* Add trajectory plotting

* Change test network

* Add speed limit checks

* Add indication for inactive trains

* Add todo

* Make a copy of traversal instead of referencing

Last element of edge_trajs can change at any time.

* Add todo

* Introduce namespace `cda_rail::sim`

* Add random search

* Add train distance

* Fix random solution test

* Add collision objective

* Simplify and document distance penalties

* Fix missing iteration

* Test random search

* Add test for train distance

* Fix distance calculation

* Simplify random search abort criterium

* Reduce testing time

* Move test of trajectory export

* Check for sufficient time resolution

* Choose more appropriate exception types

* Fix missing train in plot

* Add critical TODOs

* Disable unused and cpp warnings

fortify warning cannot be turned off otherwise even with explicit `D_FORTIFY_SOURCE=0`

* Add vertex shortest paths

* Add undirected vertex shortest paths

* Fix train distance calculation with using vertex shortest paths

* Add helpers for testing train distance exactly

* Fix entry position

* Fix fall-through in switch statement

* Add detailed test for train distance

* Refactor collision detection

* Add destination objective

* Enable early train exit according to schedule

* Add stop objective

* Add TODO

* Add plot for speed curves

* Make amount of speed targets into a decision variable

* Add random search

* Add missing function

* Make trajectories copyable using reference wrapper

* Add `contains` helper to trajectory set

* Fix uninitialized variable

* Fix penalty for trains without stops

* Fix premature abort of greedy search

* Plot all tests

* Add todo

* Shuffle train placement order

* Add `SolverResult` class

* Add destination penalty for single trains

* Add stop penalty for single trains

* Pass reference

* Inline stop handling

* Simplify train iteration

* Reduce duplicate calculations with solver result object

* Add todo

* Remove unused arguments

* Add greedy search

* Test incremental solution building

* Add TODO

* Switch to normal second-order euler

* Record score history

* Add unidirectional network template

* Add score history csv export

* Add `ScoreHistoryCollection`

* Add app for collecting simulator statistics

* Move dev scripts into subdirectory

* Solve resource conflict in parallel search

* Limit thread count

* Improve thread task assignment

* Use explicit time types

* Expand search abort criteria

* Add network conversion script

* Fix initial edge selection for tests

* Add second executable for simulator

* Add converted overtake network

* Remove unused import

* Add local search

* Add search method comparison executable

* Remove outdated documentation

* Add grasp search

* Update dev scripts for launching apps

* Introduce local search parameter testing

* Improve parameter search and export

* Measure on same network

* Shorten grasp name

* Update best local search parameters

* Convert Stammstrecke16Trains to unidirectional

* Add openGA submodule

* Add random solution overload for GA supplied random generator

* Remove outdated documentation

* Add GA mutate

* Add rest of GA helpers

* Bind member function objects

* Test genetic algorithm

* Convert results of genetic search

* Add GA to method comparison

* Pass parameters to GA

* Avoid copy when binding reference

* Add GA parameter search

* Fix GA testing parameters

* Add mutation rate to GA param testing

* Add GA population parameter testing

* Add GA elite to parameter testing

* Add GA with local improvment

* Improve GA testing parameters

* Improve search parameter passing

* Automate measure for multiple networks

* Formalize local search params

* Prepare conversion to vss solution format

* Finish solution conversion

* Add TODO

* Adjust optimal genetic params

* Add simultaneous measurement

* Save individual scores in history

* Fix double division

* Further automate testing

* Add bidirectional networks for exporting simulator solutions

* Indicate error attempting to export a train skipping tracks

* Create example network without skipping for testing ExportVSS

* Remove TODO

* Normalize and test summing of objective scores

* Automate parameter search measurements

* Reenable optimization

* Update parameters and fix export

* Record sample number in of score collection

* Adjust comparison parameters

* Update launcher scripts

* Fix seed for multiple calls a second

* Update optimum parameters

* Update parameters

* Add multithreading test

* Add requirements.txt

* Remove openGA submodule

* Add openGA as file

We need to define `mtx_rand` a static.
Instead of applying a patch we include the modified source directly.

* Remove development artifacts

* Revert compile flag changes

// NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast,cppcoreguidelines-pro-bounds-array-to-pointer-decay,bugprone-exception-escape)

int main(int argc, char** argv) {

Check warning

Code scanning / CodeQL

Poorly documented large function Warning

Poorly documented function: fewer than 2% comments for a function of 208 lines.

Copilot Autofix

AI 12 months ago

To address the issue, we will add comments to document the purpose and functionality of the main function and its key sections. This will include:

  1. A high-level comment at the start of the main function explaining its overall purpose.
  2. Inline comments for each major block of code to describe what it does.
  3. Comments for any non-obvious operations or parameters to clarify their intent.

These changes will improve the readability and maintainability of the function without altering its functionality.


Suggested changeset 1
apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp b/apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp
--- a/apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp
+++ b/apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp
@@ -15,4 +15,8 @@
 int main(int argc, char** argv) {
-  auto args = gsl::span<char*>(argv, argc);
+  // Main function for running genetic parameter testing on a timetable simulation.
+  // This function imports the network and timetable, sets up simulation parameters,
+  // and performs multithreaded genetic algorithm optimization with varying crossover fractions.
 
+  // Parse command-line arguments for model and output paths.
+  auto args = gsl::span<char*>(argv, argc);
   const std::string model_path  = args[1];
@@ -22,2 +26,3 @@
 
+  // Import the network and timetable data.
   cda_rail::Network network =
@@ -27,4 +32,6 @@
 
+  // Initialize the simulation instance with the imported data.
   cda_rail::sim::SimulationInstance instance{network, timetable, false};
 
+  // Determine the number of available hardware threads for multithreading.
   size_t processor_count = std::thread::hardware_concurrency();
@@ -33,2 +40,3 @@
 
+  // Set up default genetic algorithm parameters.
   cda_rail::sim::GeneticParams ga_params{
@@ -44,2 +52,3 @@
   {
+    // Test different crossover fractions for the genetic algorithm.
     std::vector<double> xover_fractions = {0.01, 0.025, 0.1, 0.5, 0.7, 0.99};
@@ -47,2 +56,3 @@
     for (double xover_fraction : xover_fractions) {
+      // Initialize a collection to store score histories and a mutex for thread safety.
       cda_rail::sim::ScoreHistoryCollection score_coll;
@@ -50,4 +60,6 @@
 
+      // Update the crossover fraction in the genetic algorithm parameters.
       ga_params.xover_frac = xover_fraction;
 
+      // Launch worker threads to perform genetic algorithm optimization.
       std::vector<std::thread> workers;
@@ -57,2 +69,3 @@
 
+          // Perform multiple runs of the genetic algorithm and collect results.
           for (size_t sample_runs = 0; sample_runs < 3; sample_runs++) {
@@ -68,2 +81,3 @@
 
+      // Wait for all worker threads to finish.
       while (workers.size() > 0) {
@@ -73,2 +87,3 @@
 
+      // Save the score history to a CSV file for the current crossover fraction.
       auto save_path =
EOF
@@ -15,4 +15,8 @@
int main(int argc, char** argv) {
auto args = gsl::span<char*>(argv, argc);
// Main function for running genetic parameter testing on a timetable simulation.
// This function imports the network and timetable, sets up simulation parameters,
// and performs multithreaded genetic algorithm optimization with varying crossover fractions.

// Parse command-line arguments for model and output paths.
auto args = gsl::span<char*>(argv, argc);
const std::string model_path = args[1];
@@ -22,2 +26,3 @@

// Import the network and timetable data.
cda_rail::Network network =
@@ -27,4 +32,6 @@

// Initialize the simulation instance with the imported data.
cda_rail::sim::SimulationInstance instance{network, timetable, false};

// Determine the number of available hardware threads for multithreading.
size_t processor_count = std::thread::hardware_concurrency();
@@ -33,2 +40,3 @@

// Set up default genetic algorithm parameters.
cda_rail::sim::GeneticParams ga_params{
@@ -44,2 +52,3 @@
{
// Test different crossover fractions for the genetic algorithm.
std::vector<double> xover_fractions = {0.01, 0.025, 0.1, 0.5, 0.7, 0.99};
@@ -47,2 +56,3 @@
for (double xover_fraction : xover_fractions) {
// Initialize a collection to store score histories and a mutex for thread safety.
cda_rail::sim::ScoreHistoryCollection score_coll;
@@ -50,4 +60,6 @@

// Update the crossover fraction in the genetic algorithm parameters.
ga_params.xover_frac = xover_fraction;

// Launch worker threads to perform genetic algorithm optimization.
std::vector<std::thread> workers;
@@ -57,2 +69,3 @@

// Perform multiple runs of the genetic algorithm and collect results.
for (size_t sample_runs = 0; sample_runs < 3; sample_runs++) {
@@ -68,2 +81,3 @@

// Wait for all worker threads to finish.
while (workers.size() > 0) {
@@ -73,2 +87,3 @@

// Save the score history to a CSV file for the current crossover fraction.
auto save_path =
Copilot is powered by AI and may make mistakes. Always verify output.

// NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast,cppcoreguidelines-pro-bounds-array-to-pointer-decay,bugprone-exception-escape)

int main(int argc, char** argv) {

Check warning

Code scanning / CodeQL

Poorly documented large function Warning

Poorly documented function: fewer than 2% comments for a function of 102 lines.

Copilot Autofix

AI 12 months ago

To fix the issue, we will add comments to document the purpose of the main function and its key components. This includes:

  1. Adding a high-level comment at the start of the function to describe its overall purpose.
  2. Adding inline comments to explain the purpose of key variables, operations, and logic blocks.
  3. Ensuring that the comments are concise but informative, providing enough context for someone unfamiliar with the code to understand its intent.

No changes to the functionality of the code will be made.


Suggested changeset 1
apps/vss_generation_timetable_simulator_search_methods_testing.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/vss_generation_timetable_simulator_search_methods_testing.cpp b/apps/vss_generation_timetable_simulator_search_methods_testing.cpp
--- a/apps/vss_generation_timetable_simulator_search_methods_testing.cpp
+++ b/apps/vss_generation_timetable_simulator_search_methods_testing.cpp
@@ -16,4 +16,10 @@
 int main(int argc, char** argv) {
+  // Entry point of the program. This function sets up the simulation environment,
+  // parses input arguments, initializes parameters, and runs simulations using
+  // different search methods.
+
+  // Parse command-line arguments
   auto args = gsl::span<char*>(argv, argc);
 
+  // Paths for input model and output results
   const std::string model_path  = args[1];
@@ -23,2 +29,3 @@
 
+  // Import the network and timetable data
   cda_rail::Network network =
@@ -28,24 +35,29 @@
 
+  // Create a simulation instance with the imported data
   cda_rail::sim::SimulationInstance instance{network, timetable, false};
 
+  // Determine the number of available processors for multithreading
   size_t processor_count = std::thread::hardware_concurrency();
   if (processor_count == 0)
-    processor_count = 1;
+    processor_count = 1; // Fallback to a single processor if detection fails
 
+  // Genetic algorithm parameters for the simulation
   cda_rail::sim::GeneticParams ga_params{
-      .is_multithread = false,
-      .population     = 1000,
-      .gen_max        = 100,
-      .stall_max      = 10,
-      .n_elite        = 10,
-      .xover_frac     = 0.7,
-      .mut_rate       = 0.1,
+      .is_multithread = false, // Disable multithreading for this example
+      .population     = 1000, // Population size
+      .gen_max        = 100,  // Maximum number of generations
+      .stall_max      = 10,   // Maximum number of generations without improvement
+      .n_elite        = 10,   // Number of elite individuals to retain
+      .xover_frac     = 0.7,  // Crossover fraction
+      .mut_rate       = 0.1,  // Mutation rate
   };
 
+  // Local search parameters for the simulation
   cda_rail::sim::LocalParams loc_params{
-      .start_sampling_range_fraction = 0.4,
-      .abort_sampling_range_fraction = 0.001,
-      .contraction_coeff             = 0.99,
+      .start_sampling_range_fraction = 0.4,   // Initial sampling range
+      .abort_sampling_range_fraction = 0.001, // Termination sampling range
+      .contraction_coeff             = 0.99,  // Contraction coefficient
   };
 
+  // List of search methods to evaluate
   std::vector<std::string> methods = {"random", "random+local", "greedy",
@@ -53,2 +65,3 @@
 
+  // Iterate over each search method and run the simulation
   for (std::string method : methods) {
EOF
@@ -16,4 +16,10 @@
int main(int argc, char** argv) {
// Entry point of the program. This function sets up the simulation environment,
// parses input arguments, initializes parameters, and runs simulations using
// different search methods.

// Parse command-line arguments
auto args = gsl::span<char*>(argv, argc);

// Paths for input model and output results
const std::string model_path = args[1];
@@ -23,2 +29,3 @@

// Import the network and timetable data
cda_rail::Network network =
@@ -28,24 +35,29 @@

// Create a simulation instance with the imported data
cda_rail::sim::SimulationInstance instance{network, timetable, false};

// Determine the number of available processors for multithreading
size_t processor_count = std::thread::hardware_concurrency();
if (processor_count == 0)
processor_count = 1;
processor_count = 1; // Fallback to a single processor if detection fails

// Genetic algorithm parameters for the simulation
cda_rail::sim::GeneticParams ga_params{
.is_multithread = false,
.population = 1000,
.gen_max = 100,
.stall_max = 10,
.n_elite = 10,
.xover_frac = 0.7,
.mut_rate = 0.1,
.is_multithread = false, // Disable multithreading for this example
.population = 1000, // Population size
.gen_max = 100, // Maximum number of generations
.stall_max = 10, // Maximum number of generations without improvement
.n_elite = 10, // Number of elite individuals to retain
.xover_frac = 0.7, // Crossover fraction
.mut_rate = 0.1, // Mutation rate
};

// Local search parameters for the simulation
cda_rail::sim::LocalParams loc_params{
.start_sampling_range_fraction = 0.4,
.abort_sampling_range_fraction = 0.001,
.contraction_coeff = 0.99,
.start_sampling_range_fraction = 0.4, // Initial sampling range
.abort_sampling_range_fraction = 0.001, // Termination sampling range
.contraction_coeff = 0.99, // Contraction coefficient
};

// List of search methods to evaluate
std::vector<std::string> methods = {"random", "random+local", "greedy",
@@ -53,2 +65,3 @@

// Iterate over each search method and run the simulation
for (std::string method : methods) {
Copilot is powered by AI and may make mistakes. Always verify output.
cda_rail::sim::TrainState overshot_state) {
double edge_length = network.get_edge(overshot_state.edge).length;
bool exit_point = (overshot_state.position > 1);
size_t vertex;

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable vertex is not used.

Copilot Autofix

AI 12 months ago

To fix the issue, the unused variable vertex should be removed from the function cda_rail::sim::determine_exit. This involves:

  1. Deleting the declaration of vertex on line 159.
  2. Ensuring that no other parts of the function rely on vertex (which is already the case here).

This change will not affect the functionality of the code, as vertex is not used anywhere in the function.


Suggested changeset 1
src/simulation/EdgeTrajectory.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/simulation/EdgeTrajectory.cpp b/src/simulation/EdgeTrajectory.cpp
--- a/src/simulation/EdgeTrajectory.cpp
+++ b/src/simulation/EdgeTrajectory.cpp
@@ -158,3 +158,3 @@
   bool   exit_point  = (overshot_state.position > 1);
-  size_t vertex;
+
   bool   crossing_orientation;
EOF
@@ -158,3 +158,3 @@
bool exit_point = (overshot_state.position > 1);
size_t vertex;

bool crossing_orientation;
Copilot is powered by AI and may make mistakes. Always verify output.
double edge_length = network.get_edge(overshot_state.edge).length;
bool exit_point = (overshot_state.position > 1);
size_t vertex;
bool crossing_orientation;

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable crossing_orientation is not used.

Copilot Autofix

AI 12 months ago

To fix the issue, the unused variable crossing_orientation should be removed from the function determine_exit. This involves deleting its declaration on line 160. No other changes are necessary, as the variable is not used elsewhere in the function.


Suggested changeset 1
src/simulation/EdgeTrajectory.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/simulation/EdgeTrajectory.cpp b/src/simulation/EdgeTrajectory.cpp
--- a/src/simulation/EdgeTrajectory.cpp
+++ b/src/simulation/EdgeTrajectory.cpp
@@ -159,3 +159,2 @@
   size_t vertex;
-  bool   crossing_orientation;
   double leftover_movement;
EOF
@@ -159,3 +159,2 @@
size_t vertex;
bool crossing_orientation;
double leftover_movement;
Copilot is powered by AI and may make mistakes. Always verify output.
bool exit_point = (overshot_state.position > 1);
size_t vertex;
bool crossing_orientation;
double leftover_movement;

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable leftover_movement is not used.

Copilot Autofix

AI 12 months ago

To fix the issue, the unused variable leftover_movement should be removed from the function cda_rail::sim::determine_exit. This involves deleting its declaration on line 161. No other changes are necessary, as the variable is not referenced elsewhere in the function.


Suggested changeset 1
src/simulation/EdgeTrajectory.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/simulation/EdgeTrajectory.cpp b/src/simulation/EdgeTrajectory.cpp
--- a/src/simulation/EdgeTrajectory.cpp
+++ b/src/simulation/EdgeTrajectory.cpp
@@ -160,3 +160,2 @@
   bool   crossing_orientation;
-  double leftover_movement;
 
EOF
@@ -160,3 +160,2 @@
bool crossing_orientation;
double leftover_movement;

Copilot is powered by AI and may make mistakes. Always verify output.
// This is the definite integral under the braking curve
// As defined in EdgeTrajectory speed changes are done at maximum acceleration
// Zero-crossing and bidirectionality need to be considered
double braking_dist =

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable braking_dist is not used.

Copilot Autofix

AI 12 months ago

To fix the issue, the unused variable braking_dist should be removed from the function is_feasible_braking_point. This involves deleting its declaration and the associated computation on lines 183–187. Since the variable is not used elsewhere in the function, this change will not affect the program's behavior.


Suggested changeset 1
src/simulation/TrainTrajectory.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/simulation/TrainTrajectory.cpp b/src/simulation/TrainTrajectory.cpp
--- a/src/simulation/TrainTrajectory.cpp
+++ b/src/simulation/TrainTrajectory.cpp
@@ -182,7 +182,3 @@
   // Zero-crossing and bidirectionality need to be considered
-  double braking_dist =
-      starting_speed * required_braking_time +
-      (0.5 * std::copysign((required_braking_time - 1) *
-                               (required_braking_time * accel),
-                           speed_diff));
+// Removed unused variable braking_dist and its computation
 
EOF
@@ -182,7 +182,3 @@
// Zero-crossing and bidirectionality need to be considered
double braking_dist =
starting_speed * required_braking_time +
(0.5 * std::copysign((required_braking_time - 1) *
(required_braking_time * accel),
speed_diff));
// Removed unused variable braking_dist and its computation

Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread test/test_simulation.cpp
Train train =
timetable.get_train_list().get_train(random_train_index(rng_engine));

sim::SimulationInstance instance(network, timetable, true);

Check notice

Code scanning / CodeQL

Declaration hides variable Note test

Variable instance hides another variable of the same name (on
line 107
).

Copilot Autofix

AI 12 months ago

To fix the issue, we will rename the inner instance variable declared on line 115 to a more descriptive name, such as local_instance. This will eliminate the shadowing of the outer instance variable declared on line 107. The change will be limited to the EdgeTrajectory test function, and no other functionality will be affected.

Suggested changeset 1
test/test_simulation.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test/test_simulation.cpp b/test/test_simulation.cpp
--- a/test/test_simulation.cpp
+++ b/test/test_simulation.cpp
@@ -114,4 +114,4 @@
 
-    sim::SimulationInstance instance(network, timetable, true);
-    sim::RoutingSolution    solution(instance, train, rng_engine);
+    sim::SimulationInstance local_instance(network, timetable, true);
+    sim::RoutingSolution    solution(local_instance, train, rng_engine);
 
EOF
@@ -114,4 +114,4 @@

sim::SimulationInstance instance(network, timetable, true);
sim::RoutingSolution solution(instance, train, rng_engine);
sim::SimulationInstance local_instance(network, timetable, true);
sim::RoutingSolution solution(local_instance, train, rng_engine);

Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread test/test_simulation.cpp
size_t train_idx = random_train_index(rng_engine);

Train train = timetable.get_train_list().get_train(train_idx);
sim::SimulationInstance instance(network, timetable, true);

Check notice

Code scanning / CodeQL

Declaration hides variable Note test

Variable instance hides another variable of the same name (on
line 150
).

Copilot Autofix

AI 12 months ago

To fix the issue, we should rename the inner instance variable on line 158 to a distinct name that reflects its purpose. This will eliminate the shadowing and make the code more readable. For example, we could rename it to temp_instance or local_instance. This change will ensure that the outer instance variable remains accessible and unambiguous throughout the function.

Suggested changeset 1
test/test_simulation.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test/test_simulation.cpp b/test/test_simulation.cpp
--- a/test/test_simulation.cpp
+++ b/test/test_simulation.cpp
@@ -157,4 +157,4 @@
     Train train = timetable.get_train_list().get_train(train_idx);
-    sim::SimulationInstance instance(network, timetable, true);
-    sim::RoutingSolution    solution(instance, train, rng_engine);
+    sim::SimulationInstance temp_instance(network, timetable, true);
+    sim::RoutingSolution    solution(temp_instance, train, rng_engine);
 
EOF
@@ -157,4 +157,4 @@
Train train = timetable.get_train_list().get_train(train_idx);
sim::SimulationInstance instance(network, timetable, true);
sim::RoutingSolution solution(instance, train, rng_engine);
sim::SimulationInstance temp_instance(network, timetable, true);
sim::RoutingSolution solution(temp_instance, train, rng_engine);

Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread test/test_simulation.cpp
sim::SimulationInstance instance(network, timetable, true);
sim::RoutingSolutionSet solution_set{instance};
sim::TrainTrajectorySet traj{instance, solution_set};
const TrainList& list = instance.timetable.get_train_list();

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable list is not used.

Copilot Autofix

AI 12 months ago

To fix the issue, the unused variable list should be removed from the code. This involves deleting the line where list is declared. No additional changes are required, as the variable is not used elsewhere in the function.


Suggested changeset 1
test/test_simulation.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test/test_simulation.cpp b/test/test_simulation.cpp
--- a/test/test_simulation.cpp
+++ b/test/test_simulation.cpp
@@ -211,3 +211,3 @@
   sim::TrainTrajectorySet traj{instance, solution_set};
-  const TrainList&        list = instance.timetable.get_train_list();
+
 
EOF
@@ -211,3 +211,3 @@
sim::TrainTrajectorySet traj{instance, solution_set};
const TrainList& list = instance.timetable.get_train_list();


Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread test/test_simulation.cpp
for (auto train_idx = train_idxs.begin(); train_idx != train_idxs.end();
train_idx++) {
const auto train = train_list.get_train(*train_idx);
double previous_score = result.get_score_set().get_score();

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable previous_score is not used.

Copilot Autofix

AI 12 months ago

To fix the issue, we will remove the unused variable previous_score from line 275. This will eliminate the unnecessary declaration and improve code readability. No additional changes are required since the variable is not used elsewhere in the code.


Suggested changeset 1
test/test_simulation.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test/test_simulation.cpp b/test/test_simulation.cpp
--- a/test/test_simulation.cpp
+++ b/test/test_simulation.cpp
@@ -274,3 +274,2 @@
       const auto           train          = train_list.get_train(*train_idx);
-      double               previous_score = result.get_score_set().get_score();
       sim::RoutingSolution round_sol{instance, train, rng_engine};
EOF
@@ -274,3 +274,2 @@
const auto train = train_list.get_train(*train_idx);
double previous_score = result.get_score_set().get_score();
sim::RoutingSolution round_sol{instance, train, rng_engine};
Copilot is powered by AI and may make mistakes. Always verify output.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2025

Codecov Report

Attention: Patch coverage is 91.38462% with 112 lines in your changes missing coverage. Please review.

Project coverage is 96.7%. Comparing base (da43380) to head (76f4bd7).

Files with missing lines Patch % Lines
src/simulation/RoutingSolver.cpp 90.7% 26 Missing ⚠️
src/simulation/TrainTrajectorySet.cpp 80.0% 23 Missing ⚠️
src/simulation/TrainTrajectory.cpp 90.5% 20 Missing ⚠️
src/simulation/RoutingSolution.cpp 68.4% 18 Missing ⚠️
src/simulation/EdgeTrajectory.cpp 89.9% 13 Missing ⚠️
src/simulation/SpeedTargets.cpp 92.3% 4 Missing ⚠️
src/simulation/Objectives.cpp 95.7% 3 Missing ⚠️
test/test_simulation.cpp 98.4% 3 Missing ⚠️
src/simulation/RoutingSolutionSet.cpp 98.6% 1 Missing ⚠️
src/simulation/SolverResult.cpp 97.8% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #109     +/-   ##
=======================================
- Coverage   97.3%   96.7%   -0.6%     
=======================================
  Files         44      56     +12     
  Lines      13060   14366   +1306     
  Branches    1559    1745    +186     
=======================================
+ Hits       12708   13902   +1194     
- Misses       352     464    +112     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2025

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v18.1.8) reports: 767 concern(s)
  • apps/vss_generation_timetable_simulator.cpp:4:1: warning: [misc-include-cleaner]

    included header future is not used directly

        4 | #include <future>
          | ^~~~~~~~~~~~~~~~~
        5 | #include <gsl/span>
  • apps/vss_generation_timetable_simulator.cpp:8:1: warning: [misc-include-cleaner]

    included header ConsoleInitializer.h is not used directly

        8 | #include <plog/Initializers/ConsoleInitializer.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        9 | #include <plog/Log.h>
  • apps/vss_generation_timetable_simulator.cpp:11:1: warning: [misc-include-cleaner]

    included header thread is not used directly

       11 | #include <thread>
          | ^~~~~~~~~~~~~~~~~
       12 | 
  • apps/vss_generation_timetable_simulator.cpp:18:13: warning: [misc-include-cleaner]

    no header providing "plog::get" is directly included

        1 |   if (plog::get() == nullptr) {
          |             ^
  • apps/vss_generation_timetable_simulator.cpp:20:11: warning: [misc-include-cleaner]

    no header providing "plog::init" is directly included

        1 |     plog::init(plog::debug, &console_appender);
          |           ^
  • apps/vss_generation_timetable_simulator.cpp:20:22: warning: [misc-include-cleaner]

    no header providing "plog::debug" is directly included

        1 |     plog::init(plog::debug, &console_appender);
          |                      ^
  • apps/vss_generation_timetable_simulator.cpp:23:7: warning: [misc-include-cleaner]

    no header providing "strcmp" is directly included

        3 |   if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 ||
          |       ^
  • apps/vss_generation_timetable_simulator.cpp:23:14: warning: [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    do not use pointer arithmetic

       23 |   if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 ||
          |              ^
  • apps/vss_generation_timetable_simulator.cpp:23:48: warning: [cppcoreguidelines-pro-bounds-pointer-arithmetic]

    do not use pointer arithmetic

       23 |   if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 ||
          |                                                ^
  • apps/vss_generation_timetable_simulator.cpp:27:14: warning: [performance-avoid-endl]

    do not use 'std::endl' with streams; use '\n' instead

       27 |           << std::endl;
          |              ^~~~~~~~~
          |              '\n'
  • apps/vss_generation_timetable_simulator.cpp:27:19: warning: [misc-include-cleaner]

    no header providing "std::endl" is directly included

        6 |           << std::endl;
          |                   ^
  • apps/vss_generation_timetable_simulator.cpp:28:10: warning: [misc-include-cleaner]

    no header providing "std::exit" is directly included

        3 |     std::exit(0);
          |          ^
  • apps/vss_generation_timetable_simulator.cpp:36:3: warning: [misc-const-correctness]

    variable 'network' of type 'cda_rail::Network' can be declared 'const'

       36 |   cda_rail::Network network =
          |   ^
          |                     const 
  • apps/vss_generation_timetable_simulator.cpp:36:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Network" is directly included

        1 |   cda_rail::Network network =
          |             ^
  • apps/vss_generation_timetable_simulator.cpp:38:3: warning: [misc-const-correctness]

    variable 'timetable' of type 'cda_rail::Timetable' can be declared 'const'

       38 |   cda_rail::Timetable timetable =
          |   ^
          |                       const 
  • apps/vss_generation_timetable_simulator.cpp:38:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Timetable" is directly included

        1 |   cda_rail::Timetable timetable =
          |             ^
  • apps/vss_generation_timetable_simulator.cpp:41:3: warning: [misc-const-correctness]

    variable 'instance' of type 'cda_rail::sim::SimulationInstance' can be declared 'const'

       41 |   cda_rail::sim::SimulationInstance instance{network, timetable, false};
          |   ^
          |                                     const 
  • apps/vss_generation_timetable_simulator.cpp:41:18: warning: [misc-include-cleaner]

    no header providing "cda_rail::sim::SimulationInstance" is directly included

        2 |   cda_rail::sim::SimulationInstance instance{network, timetable, false};
          |                  ^
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator.cpp:48:24: warning: statement should be inside braces [google-readability-braces-around-statements,readability-braces-around-statements]
       48 |   if (std::get<0>(res))
          |                        ^
          |                         {
       49 |     std::get<0>(res).value().get_trajectories().export_csv(output_path +
       50 |                                                            "/result.csv");
          |                                                                           
  • apps/vss_generation_timetable_simulator.cpp:49:5: warning: [bugprone-unchecked-optional-access]

    unchecked access to optional value

       49 |     std::get<0>(res).value().get_trajectories().export_csv(output_path +
          |     ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:4:1: warning: [misc-include-cleaner]

    included header future is not used directly

        4 | #include <future>
          | ^~~~~~~~~~~~~~~~~
        5 | #include <gsl/span>
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:6:1: warning: [misc-include-cleaner]

    included header ColorConsoleAppender.h is not used directly

        6 | #include <plog/Appenders/ColorConsoleAppender.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        7 | #include <plog/Formatters/TxtFormatter.h>
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:7:1: warning: [misc-include-cleaner]

    included header TxtFormatter.h is not used directly

        7 | #include <plog/Formatters/TxtFormatter.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        8 | #include <plog/Initializers/ConsoleInitializer.h>
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:8:1: warning: [misc-include-cleaner]

    included header ConsoleInitializer.h is not used directly

        8 | #include <plog/Initializers/ConsoleInitializer.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        9 | #include <plog/Log.h>
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:9:1: warning: [misc-include-cleaner]

    included header Log.h is not used directly

        9 | #include <plog/Log.h>
          | ^~~~~~~~~~~~~~~~~~~~~
       10 | #include <string>
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:21:49: warning: [performance-faster-string-find]

    'find_last_of' called with a string literal consisting of a single character; consider using the more effective overload accepting a character

       21 |       model_path.substr(model_path.find_last_of("/"), model_path.length());
          |                                                 ^~~
          |                                                 '/'
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:23:3: warning: [misc-const-correctness]

    variable 'network' of type 'cda_rail::Network' can be declared 'const'

       23 |   cda_rail::Network network =
          |   ^
          |                     const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:23:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Network" is directly included

        1 |   cda_rail::Network network =
          |             ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:25:3: warning: [misc-const-correctness]

    variable 'timetable' of type 'cda_rail::Timetable' can be declared 'const'

       25 |   cda_rail::Timetable timetable =
          |   ^
          |                       const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:25:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Timetable" is directly included

        1 |   cda_rail::Timetable timetable =
          |             ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:28:18: warning: [misc-include-cleaner]

    no header providing "cda_rail::sim::SimulationInstance" is directly included

        2 |   cda_rail::sim::SimulationInstance instance{network, timetable, false};
          |                  ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:30:3: warning: [misc-include-cleaner]

    no header providing "size_t" is directly included

        3 |   size_t processor_count = std::thread::hardware_concurrency();
          |   ^
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:31:28: warning: statement should be inside braces [google-readability-braces-around-statements,readability-braces-around-statements]
       31 |   if (processor_count == 0)
          |                            ^
          |                             {
       32 |     processor_count = 1;
          |                         
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:45:5: warning: [misc-const-correctness]

    variable 'xover_fractions' of type 'std::vector' can be declared 'const'

       45 |     std::vector<double> xover_fractions = {0.01, 0.025, 0.1, 0.5, 0.7, 0.99};
          |     ^
          |                         const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:45:10: warning: [misc-include-cleaner]

    no header providing "std::vector" is directly included

       12 |     std::vector<double> xover_fractions = {0.01, 0.025, 0.1, 0.5, 0.7, 0.99};
          |          ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:47:10: warning: [misc-const-correctness]

    variable 'xover_fraction' of type 'double' can be declared 'const'

       47 |     for (double xover_fraction : xover_fractions) {
          |          ^
          |                 const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:49:12: warning: [misc-include-cleaner]

    no header providing "std::mutex" is directly included

        6 |       std::mutex                            hist_mutex;
          |            ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:55:17: warning: [modernize-use-emplace]

    use emplace_back instead of push_back

       55 |         workers.push_back(std::thread{[&]() {
          |                 ^~~~~~~~~~~~~~~~~~~~~~
          |                 emplace_back(
       56 |           cda_rail::sim::RoutingSolver solver{instance};
       57 | 
       58 |           for (size_t sample_runs = 0; sample_runs < 3; sample_runs++) {
       59 |             auto res = solver.genetic_search(ga_params);
       60 | 
       61 |             if (std::get<0>(res)) {
       62 |               const std::lock_guard<std::mutex> lock(hist_mutex);
       63 |               score_coll.add(std::get<1>(res));
       64 |             }
       65 |           }
       66 |         }});
          |          ~
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:62:26: warning: [misc-include-cleaner]

    no header providing "std::lock_guard" is directly included

       62 |               const std::lock_guard<std::mutex> lock(hist_mutex);
          |                          ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:69:14: warning: [readability-container-size-empty]

    the 'empty' method should be used to check for emptiness instead of 'size'

       69 |       while (workers.size() > 0) {
          |              ^~~~~~~~~~~~~~~~~~
          |              !workers.empty()
    /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_vector.h:1090:7: note: method 'vector'::empty() defined here
     1090 |       empty() const _GLIBCXX_NOEXCEPT
          |       ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:75:62: warning: [performance-inefficient-string-concatenation]

    string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead

       75 |           output_path + "/results/genetic_params/crossover/" + model_name;
          |                                                              ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:76:17: warning: [misc-include-cleaner]

    no header providing "cda_rail::is_directory_and_create" is directly included

        1 |       cda_rail::is_directory_and_create(save_path);
          |                 ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:84:5: warning: [misc-const-correctness]

    variable 'mut_rates' of type 'std::vector' can be declared 'const'

       84 |     std::vector<double> mut_rates = {0.01, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99};
          |     ^
          |                         const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:86:10: warning: [misc-const-correctness]

    variable 'mut_rate' of type 'double' can be declared 'const'

       86 |     for (double mut_rate : mut_rates) {
          |          ^
          |                 const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:94:17: warning: [modernize-use-emplace]

    use emplace_back instead of push_back

       94 |         workers.push_back(std::thread{[&]() {
          |                 ^~~~~~~~~~~~~~~~~~~~~~
          |                 emplace_back(
       95 |           cda_rail::sim::RoutingSolver solver{instance};
       96 | 
       97 |           for (size_t sample_runs = 0; sample_runs < 3; sample_runs++) {
       98 |             auto res = solver.genetic_search(ga_params);
       99 | 
      100 |             if (std::get<0>(res)) {
      101 |               const std::lock_guard<std::mutex> lock(hist_mutex);
      102 |               score_coll.add(std::get<1>(res));
      103 |             }
      104 |           }
      105 |         }});
          |          ~
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:108:14: warning: [readability-container-size-empty]

    the 'empty' method should be used to check for emptiness instead of 'size'

      108 |       while (workers.size() > 0) {
          |              ^~~~~~~~~~~~~~~~~~
          |              !workers.empty()
    /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_vector.h:1090:7: note: method 'vector'::empty() defined here
     1090 |       empty() const _GLIBCXX_NOEXCEPT
          |       ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:114:61: warning: [performance-inefficient-string-concatenation]

    string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead

      114 |           output_path + "/results/genetic_params/mut_rate/" + model_name;
          |                                                             ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:122:5: warning: [misc-const-correctness]

    variable 'pops' of type 'std::vector<size_t>' (aka 'vector') can be declared 'const'

      122 |     std::vector<size_t> pops = {10, 100, 1000};
          |     ^
          |                         const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:124:10: warning: [misc-const-correctness]

    variable 'pop' of type 'size_t' (aka 'unsigned long') can be declared 'const'

      124 |     for (size_t pop : pops) {
          |          ^
          |                 const 
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:129:30: warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
      129 |       ga_params.n_elite    = (size_t)std::round(0.1 * pop);
          |                              ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:129:30: warning: [google-readability-casting]

    C-style casts are discouraged; use static_cast

      129 |       ga_params.n_elite    = (size_t)std::round(0.1 * pop);
          |                              ^~~~~~~~                     
          |                              static_cast<size_t>(         )
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:129:43: warning: [misc-include-cleaner]

    no header providing "std::round" is directly included

        3 |       ga_params.n_elite    = (size_t)std::round(0.1 * pop);
          |                                           ^
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:129:55: warning: narrowing conversion from 'size_t' (aka 'unsigned long') to 'double' [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
      129 |       ga_params.n_elite    = (size_t)std::round(0.1 * pop);
          |                                                       ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:133:17: warning: [modernize-use-emplace]

    use emplace_back instead of push_back

      133 |         workers.push_back(std::thread{[&]() {
          |                 ^~~~~~~~~~~~~~~~~~~~~~
          |                 emplace_back(
      134 |           cda_rail::sim::RoutingSolver solver{instance};
      135 | 
      136 |           for (size_t sample_runs = 0; sample_runs < 3; sample_runs++) {
      137 |             auto res = solver.genetic_search(ga_params);
      138 | 
      139 |             if (std::get<0>(res)) {
      140 |               const std::lock_guard<std::mutex> lock(hist_mutex);
      141 |               score_coll.add(std::get<1>(res));
      142 |             }
      143 |           }
      144 |         }});
          |          ~
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:147:14: warning: [readability-container-size-empty]

    the 'empty' method should be used to check for emptiness instead of 'size'

      147 |       while (workers.size() > 0) {
          |              ^~~~~~~~~~~~~~~~~~
          |              !workers.empty()
    /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_vector.h:1090:7: note: method 'vector'::empty() defined here
     1090 |       empty() const _GLIBCXX_NOEXCEPT
          |       ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:153:56: warning: [performance-inefficient-string-concatenation]

    string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead

      153 |           output_path + "/results/genetic_params/pop/" + model_name;
          |                                                        ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:161:5: warning: [misc-const-correctness]

    variable 'elites' of type 'std::vector' can be declared 'const'

      161 |     std::vector<double> elites = {0.01, 0.05, 0.1, 0.25, 0.5};
          |     ^
          |                         const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:163:10: warning: [misc-const-correctness]

    variable 'elite' of type 'double' can be declared 'const'

      163 |     for (double elite : elites) {
          |          ^
          |                 const 
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:168:11: warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
      168 |           (size_t)std::round(elite * (double)ga_params.population);
          |           ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:168:11: warning: [google-readability-casting]

    C-style casts are discouraged; use static_cast

      168 |           (size_t)std::round(elite * (double)ga_params.population);
          |           ^~~~~~~~                                                
          |           static_cast<size_t>(                                    )
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:168:38: warning: [google-readability-casting]

    C-style casts are discouraged; use static_cast

      168 |           (size_t)std::round(elite * (double)ga_params.population);
          |                                      ^~~~~~~~                    
          |                                      static_cast<double>(        )
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:172:17: warning: [modernize-use-emplace]

    use emplace_back instead of push_back

      172 |         workers.push_back(std::thread{[&]() {
          |                 ^~~~~~~~~~~~~~~~~~~~~~
          |                 emplace_back(
      173 |           cda_rail::sim::RoutingSolver solver{instance};
      174 | 
      175 |           for (size_t sample_runs = 0; sample_runs < 3; sample_runs++) {
      176 |             auto res = solver.genetic_search(ga_params);
      177 | 
      178 |             if (std::get<0>(res)) {
      179 |               const std::lock_guard<std::mutex> lock(hist_mutex);
      180 |               score_coll.add(std::get<1>(res));
      181 |             }
      182 |           }
      183 |         }});
          |          ~
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:186:14: warning: [readability-container-size-empty]

    the 'empty' method should be used to check for emptiness instead of 'size'

      186 |       while (workers.size() > 0) {
          |              ^~~~~~~~~~~~~~~~~~
          |              !workers.empty()
    /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_vector.h:1090:7: note: method 'vector'::empty() defined here
     1090 |       empty() const _GLIBCXX_NOEXCEPT
          |       ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:192:58: warning: [performance-inefficient-string-concatenation]

    string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead

      192 |           output_path + "/results/genetic_params/elite/" + model_name;
          |                                                          ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:200:5: warning: [misc-const-correctness]

    variable 'multithreads' of type 'std::vector' can be declared 'const'

      200 |     std::vector<bool> multithreads = {false, true};
          |     ^
          |                       const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:200:10: warning: [misc-include-cleaner]

    no header providing "std::vector" is directly included

      200 |     std::vector<bool> multithreads = {false, true};
          |          ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:202:10: warning: [misc-const-correctness]

    variable 'multithread' of type 'bool' can be declared 'const'

      202 |     for (bool multithread : multithreads) {
          |          ^
          |               const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:204:7: warning: [misc-const-correctness]

    variable 'hist_mutex' of type 'std::mutex' can be declared 'const'

      204 |       std::mutex                            hist_mutex;
          |       ^
          |                                             const 
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:216:64: warning: [performance-inefficient-string-concatenation]

    string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead

      216 |           output_path + "/results/genetic_params/multithread/" + model_name;
          |                                                                ^
  • apps/vss_generation_timetable_simulator_genetic_parameter_testing.cpp:219:44: warning: [readability-implicit-bool-conversion]

    implicit conversion 'bool' -> 'int'

      219 |                             std::to_string(multithread) + ".csv");
          |                                            ^          
          |                                            static_cast<int>( )
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:4:1: warning: [misc-include-cleaner]

    included header future is not used directly

        4 | #include <future>
          | ^~~~~~~~~~~~~~~~~
        5 | #include <gsl/span>
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:6:1: warning: [misc-include-cleaner]

    included header ColorConsoleAppender.h is not used directly

        6 | #include <plog/Appenders/ColorConsoleAppender.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        7 | #include <plog/Formatters/TxtFormatter.h>
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:7:1: warning: [misc-include-cleaner]

    included header TxtFormatter.h is not used directly

        7 | #include <plog/Formatters/TxtFormatter.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        8 | #include <plog/Initializers/ConsoleInitializer.h>
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:8:1: warning: [misc-include-cleaner]

    included header ConsoleInitializer.h is not used directly

        8 | #include <plog/Initializers/ConsoleInitializer.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        9 | #include <plog/Log.h>
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:9:1: warning: [misc-include-cleaner]

    included header Log.h is not used directly

        9 | #include <plog/Log.h>
          | ^~~~~~~~~~~~~~~~~~~~~
       10 | #include <string>
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:21:49: warning: [performance-faster-string-find]

    'find_last_of' called with a string literal consisting of a single character; consider using the more effective overload accepting a character

       21 |       model_path.substr(model_path.find_last_of("/"), model_path.length());
          |                                                 ^~~
          |                                                 '/'
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:23:3: warning: [misc-const-correctness]

    variable 'network' of type 'cda_rail::Network' can be declared 'const'

       23 |   cda_rail::Network network =
          |   ^
          |                     const 
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:23:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Network" is directly included

        1 |   cda_rail::Network network =
          |             ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:25:3: warning: [misc-const-correctness]

    variable 'timetable' of type 'cda_rail::Timetable' can be declared 'const'

       25 |   cda_rail::Timetable timetable =
          |   ^
          |                       const 
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:25:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Timetable" is directly included

        1 |   cda_rail::Timetable timetable =
          |             ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:28:18: warning: [misc-include-cleaner]

    no header providing "cda_rail::sim::SimulationInstance" is directly included

        2 |   cda_rail::sim::SimulationInstance instance{network, timetable, false};
          |                  ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:30:3: warning: [misc-include-cleaner]

    no header providing "size_t" is directly included

        3 |   size_t processor_count = std::thread::hardware_concurrency();
          |   ^
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:31:28: warning: statement should be inside braces [google-readability-braces-around-statements,readability-braces-around-statements]
       31 |   if (processor_count == 0)
          |                            ^
          |                             {
       32 |     processor_count = 1;
          |                         
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:34:3: warning: [misc-const-correctness]

    variable 'test_timeouts' of type 'std::vector<size_t>' (aka 'vector') can be declared 'const'

       34 |   std::vector<size_t> test_timeouts = {1, 2, 5, 10, 50, 100, 250};
          |   ^
          |                       const 
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:34:8: warning: [misc-include-cleaner]

    no header providing "std::vector" is directly included

       12 |   std::vector<size_t> test_timeouts = {1, 2, 5, 10, 50, 100, 250};
          |        ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:38:10: warning: [misc-include-cleaner]

    no header providing "std::mutex" is directly included

        6 |     std::mutex                            hist_mutex;
          |          ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:42:15: warning: [modernize-use-emplace]

    use emplace_back instead of push_back

       42 |       workers.push_back(std::thread{[&]() {
          |               ^~~~~~~~~~~~~~~~~~~~~~
          |               emplace_back(
       43 |         cda_rail::sim::RoutingSolver solver{instance};
       44 | 
       45 |         for (size_t sample = 0; sample < std::floor(100 / processor_count);
       46 |              sample++) {
       47 |           auto res =
       48 |               solver.greedy_search(std::chrono::seconds{10}, {},
       49 |                                    {std::chrono::milliseconds{train_to}});
       50 | 
       51 |           if (std::get<0>(res)) {
       52 |             const std::lock_guard<std::mutex> lock(hist_mutex);
       53 |             score_coll.add(std::get<1>(res));
       54 |           }
       55 |         }
       56 |       }});
          |        ~
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:45:33: warning: narrowing conversion from 'size_t' (aka 'unsigned long') to 'typename __gnu_cxx::__enable_if<__is_integer<unsigned long>::__value, double>::__type' (aka 'double') [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
       45 |         for (size_t sample = 0; sample < std::floor(100 / processor_count);
          |                                 ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:45:47: warning: [misc-include-cleaner]

    no header providing "std::floor" is directly included

        3 |         for (size_t sample = 0; sample < std::floor(100 / processor_count);
          |                                               ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:52:24: warning: [misc-include-cleaner]

    no header providing "std::lock_guard" is directly included

       52 |             const std::lock_guard<std::mutex> lock(hist_mutex);
          |                        ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:59:12: warning: [readability-container-size-empty]

    the 'empty' method should be used to check for emptiness instead of 'size'

       59 |     while (workers.size() > 0) {
          |            ^~~~~~~~~~~~~~~~~~
          |            !workers.empty()
    /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_vector.h:1090:7: note: method 'vector'::empty() defined here
     1090 |       empty() const _GLIBCXX_NOEXCEPT
          |       ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:65:60: warning: [performance-inefficient-string-concatenation]

    string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead

       65 |         output_path + "/results/greedy_params/stall_time/" + model_name;
          |                                                            ^
  • apps/vss_generation_timetable_simulator_greedy_parameter_testing.cpp:66:15: warning: [misc-include-cleaner]

    no header providing "cda_rail::is_directory_and_create" is directly included

        1 |     cda_rail::is_directory_and_create(save_path);
          |               ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:4:1: warning: [misc-include-cleaner]

    included header future is not used directly

        4 | #include <future>
          | ^~~~~~~~~~~~~~~~~
        5 | #include <gsl/span>
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:6:1: warning: [misc-include-cleaner]

    included header ColorConsoleAppender.h is not used directly

        6 | #include <plog/Appenders/ColorConsoleAppender.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        7 | #include <plog/Formatters/TxtFormatter.h>
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:7:1: warning: [misc-include-cleaner]

    included header TxtFormatter.h is not used directly

        7 | #include <plog/Formatters/TxtFormatter.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        8 | #include <plog/Initializers/ConsoleInitializer.h>
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:8:1: warning: [misc-include-cleaner]

    included header ConsoleInitializer.h is not used directly

        8 | #include <plog/Initializers/ConsoleInitializer.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        9 | #include <plog/Log.h>
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:9:1: warning: [misc-include-cleaner]

    included header Log.h is not used directly

        9 | #include <plog/Log.h>
          | ^~~~~~~~~~~~~~~~~~~~~
       10 | #include <string>
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:21:49: warning: [performance-faster-string-find]

    'find_last_of' called with a string literal consisting of a single character; consider using the more effective overload accepting a character

       21 |       model_path.substr(model_path.find_last_of("/"), model_path.length());
          |                                                 ^~~
          |                                                 '/'
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:23:3: warning: [misc-const-correctness]

    variable 'network' of type 'cda_rail::Network' can be declared 'const'

       23 |   cda_rail::Network network =
          |   ^
          |                     const 
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:23:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Network" is directly included

        1 |   cda_rail::Network network =
          |             ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:25:3: warning: [misc-const-correctness]

    variable 'timetable' of type 'cda_rail::Timetable' can be declared 'const'

       25 |   cda_rail::Timetable timetable =
          |   ^
          |                       const 
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:25:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Timetable" is directly included

        1 |   cda_rail::Timetable timetable =
          |             ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:28:18: warning: [misc-include-cleaner]

    no header providing "cda_rail::sim::SimulationInstance" is directly included

        2 |   cda_rail::sim::SimulationInstance instance{network, timetable, false};
          |                  ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:30:3: warning: [misc-include-cleaner]

    no header providing "size_t" is directly included

        3 |   size_t processor_count = std::thread::hardware_concurrency();
          |   ^
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:31:28: warning: statement should be inside braces [google-readability-braces-around-statements,readability-braces-around-statements]
       31 |   if (processor_count == 0)
          |                            ^
          |                             {
       32 |     processor_count = 1;
          |                         
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:34:3: warning: [misc-const-correctness]

    variable 'params' of type 'std::vector<std::tuple<double, double, double>>' can be declared 'const'

       34 |   std::vector<std::tuple<double, double, double>> params = {
          |   ^
          |                                                   const 
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:34:8: warning: [misc-include-cleaner]

    no header providing "std::vector" is directly included

       12 |   std::vector<std::tuple<double, double, double>> params = {
          |        ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:34:20: warning: [misc-include-cleaner]

    no header providing "std::tuple" is directly included

       12 |   std::vector<std::tuple<double, double, double>> params = {
          |                    ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:41:10: warning: [misc-include-cleaner]

    no header providing "std::mutex" is directly included

        6 |     std::mutex                            hist_mutex;
          |          ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:45:15: warning: [modernize-use-emplace]

    use emplace_back instead of push_back

       45 |       workers.push_back(std::thread{[&]() {
          |               ^~~~~~~~~~~~~~~~~~~~~~
          |               emplace_back(
       46 |         cda_rail::sim::RoutingSolver solver{instance};
       47 | 
       48 |         for (size_t sample = 0; sample < 20; sample++) {
       49 |           auto res = solver.random_local_search(
       50 |               std::chrono::seconds{8},
       51 |               {std::get<0>(param), std::get<1>(param), std::get<2>(param)});
       52 | 
       53 |           if (std::get<0>(res)) {
       54 |             const std::lock_guard<std::mutex> lock(hist_mutex);
       55 |             score_coll.add(std::get<1>(res));
       56 |           }
       57 |         }
       58 |       }});
          |        ~
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:54:24: warning: [misc-include-cleaner]

    no header providing "std::lock_guard" is directly included

       54 |             const std::lock_guard<std::mutex> lock(hist_mutex);
          |                        ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:61:12: warning: [readability-container-size-empty]

    the 'empty' method should be used to check for emptiness instead of 'size'

       61 |     while (workers.size() > 0) {
          |            ^~~~~~~~~~~~~~~~~~
          |            !workers.empty()
    /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_vector.h:1090:7: note: method 'vector'::empty() defined here
     1090 |       empty() const _GLIBCXX_NOEXCEPT
          |       ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:66:67: warning: [performance-inefficient-string-concatenation]

    string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead

       66 |     auto save_path = output_path + "/results/local_params/multi/" + model_name;
          |                                                                   ^
  • apps/vss_generation_timetable_simulator_local_parameter_testing.cpp:67:15: warning: [misc-include-cleaner]

    no header providing "cda_rail::is_directory_and_create" is directly included

        1 |     cda_rail::is_directory_and_create(save_path);
          |               ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:3:1: warning: [misc-include-cleaner]

    included header algorithm is not used directly

        3 | #include <algorithm>
          | ^~~~~~~~~~~~~~~~~~~~
        4 | #include <filesystem>
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:5:1: warning: [misc-include-cleaner]

    included header future is not used directly

        5 | #include <future>
          | ^~~~~~~~~~~~~~~~~
        6 | #include <gsl/span>
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:7:1: warning: [misc-include-cleaner]

    included header ColorConsoleAppender.h is not used directly

        7 | #include <plog/Appenders/ColorConsoleAppender.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        8 | #include <plog/Formatters/TxtFormatter.h>
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:8:1: warning: [misc-include-cleaner]

    included header TxtFormatter.h is not used directly

        8 | #include <plog/Formatters/TxtFormatter.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        9 | #include <plog/Initializers/ConsoleInitializer.h>
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:9:1: warning: [misc-include-cleaner]

    included header ConsoleInitializer.h is not used directly

        9 | #include <plog/Initializers/ConsoleInitializer.h>
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       10 | #include <plog/Log.h>
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:10:1: warning: [misc-include-cleaner]

    included header Log.h is not used directly

       10 | #include <plog/Log.h>
          | ^~~~~~~~~~~~~~~~~~~~~
       11 | #include <string>
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:22:49: warning: [performance-faster-string-find]

    'find_last_of' called with a string literal consisting of a single character; consider using the more effective overload accepting a character

       22 |       model_path.substr(model_path.find_last_of("/"), model_path.length());
          |                                                 ^~~
          |                                                 '/'
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:24:3: warning: [misc-const-correctness]

    variable 'network' of type 'cda_rail::Network' can be declared 'const'

       24 |   cda_rail::Network network =
          |   ^
          |                     const 
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:24:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Network" is directly included

        1 |   cda_rail::Network network =
          |             ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:26:3: warning: [misc-const-correctness]

    variable 'timetable' of type 'cda_rail::Timetable' can be declared 'const'

       26 |   cda_rail::Timetable timetable =
          |   ^
          |                       const 
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:26:13: warning: [misc-include-cleaner]

    no header providing "cda_rail::Timetable" is directly included

        1 |   cda_rail::Timetable timetable =
          |             ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:29:18: warning: [misc-include-cleaner]

    no header providing "cda_rail::sim::SimulationInstance" is directly included

        2 |   cda_rail::sim::SimulationInstance instance{network, timetable, false};
          |                  ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:31:3: warning: [misc-include-cleaner]

    no header providing "size_t" is directly included

        4 |   size_t processor_count = std::thread::hardware_concurrency();
          |   ^
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_search_methods_testing.cpp:32:28: warning: statement should be inside braces [google-readability-braces-around-statements,readability-braces-around-statements]
       32 |   if (processor_count == 0)
          |                            ^
          |                             {
       33 |     processor_count = 1;
          |                         
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:51:3: warning: [misc-const-correctness]

    variable 'methods' of type 'std::vectorstd::string' (aka 'vector<basic_string>') can be declared 'const'

       51 |   std::vector<std::string> methods = {"random", "random+local", "greedy",
          |   ^
          |                            const 
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:51:8: warning: [misc-include-cleaner]

    no header providing "std::vector" is directly included

       13 |   std::vector<std::string> methods = {"random", "random+local", "greedy",
          |        ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:56:10: warning: [misc-include-cleaner]

    no header providing "std::mutex" is directly included

        7 |     std::mutex                            hist_mutex;
          |          ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:60:15: warning: [modernize-use-emplace]

    use emplace_back instead of push_back

       60 |       workers.push_back(std::thread{[&]() {
          |               ^~~~~~~~~~~~~~~~~~~~~~
          |               emplace_back(
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:63:13: warning: [cppcoreguidelines-init-variables]

    variable 'max_samples' is not initialized

       63 |         int max_samples;
          |             ^          
          |                         = 0
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_search_methods_testing.cpp:65:59: warning: statement should be inside braces [google-readability-braces-around-statements,readability-braces-around-statements]
       65 |             method == "random+local" || method == "grasp")
          |                                                           ^
          |                                                            {
       66 |           max_samples = 10;
       67 |         else
          |         } 
    /home/runner/work/mtct/mtct/apps/vss_generation_timetable_simulator_search_methods_testing.cpp:67:13: warning: statement should be inside braces [google-readability-braces-around-statements,readability-braces-around-statements]
       67 |         else
          |             ^
          |              {
       68 |           max_samples = 3;
          |                           
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:73:16: warning: [misc-include-cleaner]

    no header providing "std::tuple" is directly included

       13 |           std::tuple<std::optional<cda_rail::sim::SolverResult>,
          |                ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:73:27: warning: [misc-include-cleaner]

    no header providing "std::optional" is directly included

        7 |           std::tuple<std::optional<cda_rail::sim::SolverResult>,
          |                           ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:73:51: warning: [misc-include-cleaner]

    no header providing "cda_rail::sim::SolverResult" is directly included

        2 |           std::tuple<std::optional<cda_rail::sim::SolverResult>,
          |                                                   ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:95:24: warning: [misc-include-cleaner]

    no header providing "std::lock_guard" is directly included

       95 |             const std::lock_guard<std::mutex> lock(hist_mutex);
          |                        ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:98:51: warning: [performance-inefficient-string-concatenation]

    string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead

       98 |                 output_path + "/results/methods/" + model_name + "/best_traj_" +
          |                                                   ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:98:80: warning: [performance-inefficient-string-concatenation]

    string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead

       98 |                 output_path + "/results/methods/" + model_name + "/best_traj_" +
          |                                                                                ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:102:16: warning: [misc-include-cleaner]

    no header providing "std::cout" is directly included

        7 |           std::cout << "Sample completed." << std::endl;
          |                ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:102:47: warning: [performance-avoid-endl]

    do not use 'std::endl' with streams; use '\n' instead

      102 |           std::cout << "Sample completed." << std::endl;
          |                                               ^~~~~~~~~
          |                                               '\n'
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:102:52: warning: [misc-include-cleaner]

    no header providing "std::endl" is directly included

        7 |           std::cout << "Sample completed." << std::endl;
          |                                                    ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:107:12: warning: [readability-container-size-empty]

    the 'empty' method should be used to check for emptiness instead of 'size'

      107 |     while (workers.size() > 0) {
          |            ^~~~~~~~~~~~~~~~~~
          |            !workers.empty()
    /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_vector.h:1090:7: note: method 'vector'::empty() defined here
     1090 |       empty() const _GLIBCXX_NOEXCEPT
          |       ^
  • apps/vss_generation_timetable_simulator_search_methods_testing.cpp:112:15: warning: [misc-include-cleaner]

    no header providing "cda_rail::is_directory_and_create" is directly included

        1 |     cda_rail::is_directory_and_create(output_path + "/results/methods/" +
          |               ^
  • include/simulation/RoutingSolutionSet.hpp:6:1: warning: [misc-include-cleaner]

    included header algorithm is not used directly

        6 | #include <algorithm>
          | ^~~~~~~~~~~~~~~~~~~~
        7 | 

Have any feedback or feature suggestions? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants