.. _program_listing_file_include_cvrp_tabu_search.hpp: Program Listing for File tabu_search.hpp ======================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/cvrp/tabu_search.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef TS_HPP #define TS_HPP #include #include #include #include "cvrp/utils.hpp" struct PairHash { template size_t operator()(const std::pair& p) const { auto hash1 = std::hash{}(p.first); auto hash2 = std::hash{}(p.second); return hash1 ^ hash2; } }; class TabuSearchSolution : public Solution { public: TabuSearchSolution(const std::vector& nodes, const std::vector& vehicles, const std::vector>& distanceMatrix, const int n_tabu = 50, const int max_it = 500); explicit TabuSearchSolution(const Problem& p, const int n_tabu = 50, const int max_it = 500); explicit TabuSearchSolution(const Solution& s, const int n_tabu = 50, const int max_it = 500); void Solve() override; private: int n_tabu_; const int max_it_; double best_cost_ = std::numeric_limits::max(); double new_cost_ = std::numeric_limits::max(); // invert order of v1, v2 and cur, rep+1 std::unordered_set, PairHash> tabu_list_set_; std::queue> tabu_list_queue_; inline bool IsTabu(const std::pair& p) const; inline bool Aspiration(double cost_increase, double cost_reduction) const; }; #endif // TS_HPP