diff --git a/cmake/FindROBINHOOD.cmake b/cmake/FindROBINHOOD.cmake index 9f4be0d7..8f4622a8 100644 --- a/cmake/FindROBINHOOD.cmake +++ b/cmake/FindROBINHOOD.cmake @@ -1,7 +1,7 @@ find_path( ROBINHOOD_INCLUDE_DIRS - NAMES robin_hood/robin_hood.h - HINTS /usr/include /usr/local/include/ ${ROBINHOOD_DIR} $ENV{ROBINHOOD_HOME} + NAMES robin_hood.h + HINTS /usr/include /usr/include/robin_hood/ /usr/local/include/ /usr/local/include/robin_hood/ ${ROBINHOOD_DIR} $ENV{ROBINHOOD_HOME} ) include(FindPackageHandleStandardArgs) diff --git a/examples/knapsack-problem/main.cpp b/examples/knapsack-problem/main.cpp index 79a9f90b..8e8f562a 100644 --- a/examples/knapsack-problem/main.cpp +++ b/examples/knapsack-problem/main.cpp @@ -42,7 +42,8 @@ int main(int t_argc, const char** t_argv) { BranchAndBound() .with_node_optimizer(HiGHS::ContinuousRelaxation()) .with_branching_rule( - Diver>() + MostInfeasible() + //Diver>() ) .with_node_selection_rule(BestBound()) .with_log_level(Info, Blue) diff --git a/lib/include/idol/containers/Map.h b/lib/include/idol/containers/Map.h index 4f9ab6bf..2d156f24 100644 --- a/lib/include/idol/containers/Map.h +++ b/lib/include/idol/containers/Map.h @@ -7,13 +7,24 @@ #include + +#ifdef IDOL_USE_ROBINHOOD +#include +#endif + // Implements hash for pairs (non-symmetric by default (std::hash>) and symmetric impls) // See https://youngforest.github.io/2020/05/27/best-implement-to-use-pair-as-key-to-std-unordered-map-in-C/ namespace idol::impl { +#ifdef IDOL_USE_ROBINHOOD + template using hash = robin_hood::hash; +#else + template using hash = std::hash; +#endif + template inline void hash_combine(std::size_t &seed, const T &val) { - seed ^= std::hash()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + seed ^= hash()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } // auxiliary generic functions to create a hash value using a seed @@ -38,8 +49,8 @@ namespace idol::impl { template std::size_t operator()(const std::pair &t_pair) const { return std::less()(t_pair.first, t_pair.second) ? - std::hash>()(t_pair) - : std::hash>()(std::make_pair(t_pair.second, t_pair.first)); + hash>()(t_pair) + : hash>()(std::make_pair(t_pair.second, t_pair.first)); } }; @@ -63,8 +74,6 @@ struct std::hash> { #ifdef IDOL_USE_ROBINHOOD -#include - namespace idol { template< @@ -73,7 +82,7 @@ namespace idol { class Hash = robin_hood::hash, class KeyEqual = std::equal_to > - using Map = robin_hood::unordered_map; + using Map = robin_hood::unordered_flat_map; }