diff --git a/setcoveringsolver/setcovering/algorithm.hpp b/setcoveringsolver/setcovering/algorithm.hpp index add32cc..ea2f172 100644 --- a/setcoveringsolver/setcovering/algorithm.hpp +++ b/setcoveringsolver/setcovering/algorithm.hpp @@ -2,6 +2,11 @@ #include "setcoveringsolver/setcovering/reduction.hpp" +#include "optimizationtools/utils/output.hpp" +#include "optimizationtools/utils/utils.hpp" + +#include + namespace setcoveringsolver { namespace setcovering diff --git a/setcoveringsolver/setcovering/algorithm_formatter.cpp b/setcoveringsolver/setcovering/algorithm_formatter.cpp index 6658b5d..0a6131c 100644 --- a/setcoveringsolver/setcovering/algorithm_formatter.cpp +++ b/setcoveringsolver/setcovering/algorithm_formatter.cpp @@ -88,17 +88,17 @@ void AlgorithmFormatter::print( } void AlgorithmFormatter::update_solution( - const Solution& solution_new, + const Solution& solution, const std::string& s) { if (optimizationtools::is_solution_strictly_better( objective_direction(), output_.solution.feasible(), output_.solution.objective_value(), - solution_new.feasible(), - solution_new.objective_value())) { + solution.feasible(), + solution.objective_value())) { output_.time = parameters_.timer.elapsed_time(); - output_.solution = solution_new; + output_.solution = solution; print(s); output_.json["IntermediaryOutputs"].push_back(output_.to_json()); parameters_.new_solution_callback(output_, s); @@ -106,15 +106,15 @@ void AlgorithmFormatter::update_solution( } void AlgorithmFormatter::update_bound( - Cost bound_new, + Cost bound, const std::string& s) { if (optimizationtools::is_bound_strictly_better( objective_direction(), output_.bound, - bound_new)) { + bound)) { output_.time = parameters_.timer.elapsed_time(); - output_.bound = bound_new; + output_.bound = bound; print(s); output_.json["IntermediaryOutputs"].push_back(output_.to_json()); parameters_.new_solution_callback(output_, s); diff --git a/setcoveringsolver/setcovering/algorithm_formatter.hpp b/setcoveringsolver/setcovering/algorithm_formatter.hpp index 2c0672f..bbcfa0d 100644 --- a/setcoveringsolver/setcovering/algorithm_formatter.hpp +++ b/setcoveringsolver/setcovering/algorithm_formatter.hpp @@ -36,12 +36,12 @@ class AlgorithmFormatter /** Update the solution. */ void update_solution( - const Solution& solution_new, + const Solution& solution, const std::string& s); /** Update the bound. */ void update_bound( - Cost bound_new, + Cost bound, const std::string& s); /** Method to call at the end of the algorithm. */ diff --git a/setcoveringsolver/setcovering/algorithms/large_neighborhood_search.cpp b/setcoveringsolver/setcovering/algorithms/large_neighborhood_search.cpp index 5135425..f216f3e 100644 --- a/setcoveringsolver/setcovering/algorithms/large_neighborhood_search.cpp +++ b/setcoveringsolver/setcovering/algorithms/large_neighborhood_search.cpp @@ -6,8 +6,6 @@ #include "optimizationtools/containers/indexed_set.hpp" #include "optimizationtools/containers/indexed_binary_heap.hpp" -#include - using namespace setcoveringsolver::setcovering; struct LargeNeighborhoodSearchSet diff --git a/setcoveringsolver/setcovering/algorithms/local_search_row_weighting.cpp b/setcoveringsolver/setcovering/algorithms/local_search_row_weighting.cpp index 78a035f..8ecdd3b 100644 --- a/setcoveringsolver/setcovering/algorithms/local_search_row_weighting.cpp +++ b/setcoveringsolver/setcovering/algorithms/local_search_row_weighting.cpp @@ -4,11 +4,6 @@ #include "setcoveringsolver/setcovering/algorithms/greedy.hpp" #include "optimizationtools/containers/indexed_set.hpp" -#include "optimizationtools/containers/indexed_binary_heap.hpp" -#include "optimizationtools/utils/utils.hpp" - -#include -#include using namespace setcoveringsolver::setcovering; diff --git a/setcoveringsolver/setcovering/instance.cpp b/setcoveringsolver/setcovering/instance.cpp index dc64ffb..8dbb067 100644 --- a/setcoveringsolver/setcovering/instance.cpp +++ b/setcoveringsolver/setcovering/instance.cpp @@ -1,12 +1,8 @@ #include "setcoveringsolver/setcovering/instance.hpp" -#include "setcoveringsolver/setcovering/instance_builder.hpp" #include "optimizationtools/containers/indexed_set.hpp" -#include "optimizationtools/containers/indexed_map.hpp" -#include -#include -#include +#include #include #include diff --git a/setcoveringsolver/setcovering/instance.hpp b/setcoveringsolver/setcovering/instance.hpp index 7fa2536..85761d9 100644 --- a/setcoveringsolver/setcovering/instance.hpp +++ b/setcoveringsolver/setcovering/instance.hpp @@ -1,6 +1,9 @@ #pragma once -#include "optimizationtools/utils/output.hpp" +#include +#include +#include +#include namespace setcoveringsolver { diff --git a/setcoveringsolver/setcovering/instance_builder.cpp b/setcoveringsolver/setcovering/instance_builder.cpp index 275dd51..c1c2d62 100644 --- a/setcoveringsolver/setcovering/instance_builder.cpp +++ b/setcoveringsolver/setcovering/instance_builder.cpp @@ -1,5 +1,7 @@ #include "setcoveringsolver/setcovering/instance_builder.hpp" +#include + using namespace setcoveringsolver::setcovering; void InstanceBuilder::add_sets(SetId number_of_sets) diff --git a/setcoveringsolver/setcovering/solution.cpp b/setcoveringsolver/setcovering/solution.cpp index 5ff211e..d4150ec 100644 --- a/setcoveringsolver/setcovering/solution.cpp +++ b/setcoveringsolver/setcovering/solution.cpp @@ -1,5 +1,10 @@ #include "setcoveringsolver/setcovering/solution.hpp" +#include "optimizationtools/utils/utils.hpp" + +#include +#include + using namespace setcoveringsolver::setcovering; Solution::Solution(const Instance& instance): @@ -33,7 +38,8 @@ Solution::Solution( } } -void Solution::write(std::string certificate_path) const +void Solution::write( + const std::string& certificate_path) const { if (certificate_path.empty()) return; diff --git a/setcoveringsolver/setcovering/solution.hpp b/setcoveringsolver/setcovering/solution.hpp index 47df841..d5685ec 100644 --- a/setcoveringsolver/setcovering/solution.hpp +++ b/setcoveringsolver/setcovering/solution.hpp @@ -4,9 +4,8 @@ #include "optimizationtools/containers/indexed_set.hpp" #include "optimizationtools/containers/indexed_map.hpp" -#include "optimizationtools/utils/utils.hpp" -#include +#include "nlohmann//json.hpp" namespace setcoveringsolver { @@ -91,7 +90,7 @@ class Solution */ /** Write the solution to a file. */ - void write(std::string certificate_path) const; + void write(const std::string& certificate_path) const; /** Export solution characteristics to a JSON structure. */ nlohmann::json to_json() const;