diff --git a/CMakeLists.txt b/CMakeLists.txt index cbebc9e4f..8bf1ff759 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,8 +206,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL Linux) set(THREADS_PREFER_PTHREAD_FLAG ON) endif () find_package(Threads REQUIRED) -find_package(TBB COMPONENTS tbb) # required for ubuntu 22+ - +find_package(TBB COMPONENTS tbb) find_package(ZLIB REQUIRED) #Required for CoinUtils set(GFLAGS_USE_TARGET_NAMESPACE TRUE) diff --git a/src/cpp/benders/benders_by_batch/BendersByBatch.cpp b/src/cpp/benders/benders_by_batch/BendersByBatch.cpp index 574f2cb51..73e096b5a 100644 --- a/src/cpp/benders/benders_by_batch/BendersByBatch.cpp +++ b/src/cpp/benders/benders_by_batch/BendersByBatch.cpp @@ -296,8 +296,9 @@ void BendersByBatch::GetSubproblemCut( worker->get_subgradient( subproblem_data.var_name_and_subgradient); // dual pi_s auto subpb_cost_under_approx = GetAlpha_i()[ProblemToId(name)]; - *batch_subproblems_costs_contribution_in_gap_per_proc += std::max( - subproblem_data.subproblem_cost - subpb_cost_under_approx, 0.0); + // Tbb includes min max define of windows std::numeric_limits::max(); + *batch_subproblems_costs_contribution_in_gap_per_proc += (std::max)( + subproblem_data.subproblem_cost - subpb_cost_under_approx, 0.0); double cut_value_at_x_cut = subproblem_data.subproblem_cost; for (const auto &[candidate_name, x_cut_candidate_value] : _data.x_cut) { auto subgradient_at_name = @@ -325,7 +326,8 @@ double BendersByBatch::Gap() const { if (_data.is_in_initial_relaxation) { return RelaxedGap() * _data.lb; } else { - return std::max(AbsoluteGap(), RelativeGap() * _data.lb); + // Tbb 2020 includes Windows min max defines + return (std::max)(AbsoluteGap(), RelativeGap() * _data.lb); } } /*! diff --git a/src/cpp/benders/benders_core/BendersBase.cpp b/src/cpp/benders/benders_core/BendersBase.cpp index 5df28bfb1..7ce03dec8 100644 --- a/src/cpp/benders/benders_core/BendersBase.cpp +++ b/src/cpp/benders/benders_core/BendersBase.cpp @@ -200,7 +200,7 @@ void BendersBase::UpdateStoppingCriterion() { else if (_data.lb + _options.ABSOLUTE_GAP >= _data.best_ub) _data.stopping_criterion = StoppingCriterion::absolute_gap; else if (((_data.best_ub - _data.lb) / - std::max(std::abs(_data.best_ub), std::abs(_data.lb))) <= + (std::max)(std::abs(_data.best_ub), std::abs(_data.lb))) <= _options.RELATIVE_GAP) _data.stopping_criterion = StoppingCriterion::relative_gap; } @@ -843,7 +843,8 @@ void BendersBase::BoundSimplexIterations(int subproblem_iterations){ void BendersBase::ResetSimplexIterationsBounds() { _data.max_simplexiter = 0; - _data.min_simplexiter = std::numeric_limits::max(); + // Tbb 2020 includes Windows min max defines that's why we don't write std::numeric_limits::max(); + _data.min_simplexiter = (std::numeric_limits::max)(); } bool BendersBase::IsResumeMode() const { return _options.RESUME; } diff --git a/src/cpp/benders/benders_core/CMakeLists.txt b/src/cpp/benders/benders_core/CMakeLists.txt index 966393309..bb5e7744d 100644 --- a/src/cpp/benders/benders_core/CMakeLists.txt +++ b/src/cpp/benders/benders_core/CMakeLists.txt @@ -6,6 +6,8 @@ # Targets # =========================================================================== +find_package(TBB REQUIRED CONFIG) + add_library(benders_core) target_sources(benders_core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/BendersBase.cpp @@ -63,9 +65,7 @@ target_link_libraries(benders_core antaresXpansion::outer_loop_lib ) -if (TBB_FOUND) - target_link_libraries(benders_core PRIVATE tbb) -endif () +target_link_libraries(benders_core PRIVATE TBB::tbb) install(DIRECTORY include/antares-xpansion DESTINATION "include" diff --git a/src/cpp/benders/benders_core/include/antares-xpansion/benders/benders_core/BendersBase.h b/src/cpp/benders/benders_core/include/antares-xpansion/benders/benders_core/BendersBase.h index 3f9be98ae..3a8c90da8 100644 --- a/src/cpp/benders/benders_core/include/antares-xpansion/benders/benders_core/BendersBase.h +++ b/src/cpp/benders/benders_core/include/antares-xpansion/benders/benders_core/BendersBase.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include diff --git a/src/cpp/exe/full_run/CMakeLists.txt b/src/cpp/exe/full_run/CMakeLists.txt index e9280065b..64eb11772 100644 --- a/src/cpp/exe/full_run/CMakeLists.txt +++ b/src/cpp/exe/full_run/CMakeLists.txt @@ -34,8 +34,6 @@ target_link_libraries(full_run antaresXpansion::helpers ) -if (TBB_FOUND) - target_link_libraries(full_run PRIVATE tbb) -endif () +target_link_libraries(full_run PRIVATE TBB::tbb) install(TARGETS full_run DESTINATION bin) \ No newline at end of file diff --git a/src/cpp/lpnamer/main/ProblemGeneration.cpp b/src/cpp/lpnamer/main/ProblemGeneration.cpp index 49bac47ff..b2a480a5a 100644 --- a/src/cpp/lpnamer/main/ProblemGeneration.cpp +++ b/src/cpp/lpnamer/main/ProblemGeneration.cpp @@ -1,9 +1,11 @@ +#include +#include + #include "antares-xpansion/lpnamer/main/ProblemGeneration.h" #include -#include #include #include diff --git a/src/cpp/lpnamer/problem_modifier/CMakeLists.txt b/src/cpp/lpnamer/problem_modifier/CMakeLists.txt index d520f9cc2..758241edc 100644 --- a/src/cpp/lpnamer/problem_modifier/CMakeLists.txt +++ b/src/cpp/lpnamer/problem_modifier/CMakeLists.txt @@ -65,12 +65,10 @@ target_link_libraries(lp_namer_problem_modifier Antares::antares-solver-simulation ) -if (TBB_FOUND) - target_link_libraries(lp_namer_problem_modifier PRIVATE tbb) -endif () +target_link_libraries(lp_namer_problem_modifier PRIVATE TBB::tbb) add_library(${PROJECT_NAME}::lp_namer_problem_modifier ALIAS lp_namer_problem_modifier) install(DIRECTORY include/antares-xpansion DESTINATION "include" -) \ No newline at end of file +) diff --git a/src/cpp/lpnamer/problem_modifier/FileProblemsProviderAdapter.cpp b/src/cpp/lpnamer/problem_modifier/FileProblemsProviderAdapter.cpp index c8c6291c8..beff54953 100644 --- a/src/cpp/lpnamer/problem_modifier/FileProblemsProviderAdapter.cpp +++ b/src/cpp/lpnamer/problem_modifier/FileProblemsProviderAdapter.cpp @@ -2,9 +2,11 @@ // Created by marechaljas on 09/01/24. // +#include +#include + #include "antares-xpansion/lpnamer/problem_modifier/FileProblemsProviderAdapter.h" -#include #include "antares-xpansion/lpnamer/problem_modifier/FileProblemProviderAdapter.h" diff --git a/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp b/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp index d9136aa12..a32e3ca24 100644 --- a/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp +++ b/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp @@ -1,7 +1,9 @@ +#include +#include + #include "antares-xpansion/lpnamer/problem_modifier/LinkProblemsGenerator.h" #include -#include #include #include "antares-xpansion/lpnamer/problem_modifier/IProblemProviderPort.h" diff --git a/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.cpp b/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.cpp index 0ff57078b..85a4c7b19 100644 --- a/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.cpp +++ b/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.cpp @@ -2,9 +2,11 @@ // Created by marechaljas on 25/11/22. // +#include +#include + #include "antares-xpansion/lpnamer/problem_modifier/ZipProblemsProviderAdapter.h" -#include #include #include "antares-xpansion/helpers/ArchiveReader.h" diff --git a/src/cpp/sensitivity/SensitivityStudy.cpp b/src/cpp/sensitivity/SensitivityStudy.cpp index 1dba02a77..439ed0557 100644 --- a/src/cpp/sensitivity/SensitivityStudy.cpp +++ b/src/cpp/sensitivity/SensitivityStudy.cpp @@ -1,6 +1,9 @@ +#include +#include + + #include "antares-xpansion/sensitivity/SensitivityStudy.h" -#include #include #include #include diff --git a/vcpkg.json b/vcpkg.json index c006b78fc..4545167dc 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -33,6 +33,13 @@ "features": [ "zlib" ] + }, + "tbb" + ], + "overrides": [ + { + "name": "tbb", + "version-string": "2020_U3" } ] }