All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
2_local_search.hpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2013 Piotr Wygocki
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
16 #ifndef PAAL_2_LOCAL_SEARCH_HPP
17 #define PAAL_2_LOCAL_SEARCH_HPP
18 
25 
26 namespace paal {
27 namespace local_search {
28 
51 template <typename... Args>
52 using TwoLocalcomponents = data_structures::components<
53  Gain, data_structures::NameWithDefault<GetMoves, two_local_searchget_moves>,
54  data_structures::NameWithDefault<Commit, two_local_search_commit>>::type<
55  Args...>;
56 
68 template <typename Gain, typename GetMoves = two_local_searchget_moves>
69 auto make_two_local_search_components(Gain ch, GetMoves gm = GetMoves{}) {
70  return TwoLocalcomponents<Gain, GetMoves>(std::move(ch), std::move(gm));
71 }
72 
79 template <typename Metric>
80 auto get_default_two_local_components(const Metric &m) {
82 }
83 
101 template <typename SearchStrategy, typename ContinueOnSuccess,
102  typename ContinueOnFail, typename Cycle, typename... components>
103 bool two_local_search(Cycle &cycle, SearchStrategy searchStrategy,
104  ContinueOnSuccess on_success, ContinueOnFail on_fail,
105  components... comps) {
107  CSFLCh cycleSFLCh(cycle);
109  cycleAdapted(cycleSFLCh);
110  return local_search(cycleAdapted, std::move(searchStrategy),
111  std::move(on_success), std::move(on_fail),
112  std::move(comps)...);
113 }
114 
125 template <typename Cycle, typename... components>
126 bool tsp_first_improving(Cycle &cycle, components... comps) {
129  std::move(comps)...);
130 }
131 
132 } // local_search
133 } // paal
134 
135 #endif // PAAL_2_LOCAL_SEARCH_HPP
functor return false
Definition: functors.hpp:222
bool two_local_search(Cycle &cycle, SearchStrategy searchStrategy, ContinueOnSuccess on_success, ContinueOnFail on_fail, components...comps)
local search for two - opt in tsp adapts tsp to local_search_multi_solution
adapts cycle to have begin and end pointing to edge collection
data_structures::components< GetMoves, Gain, Commit > components
Definition for the components class for local search usually this class is not directly used...
data_structures::components< Gain, data_structures::NameWithDefault< GetMoves, two_local_searchget_moves >, data_structures::NameWithDefault< Commit, two_local_search_commit >>::type< Args...> TwoLocalcomponents
represents step of 2 local search in multi solution where Solution is Cycle, SolutionElement is pair ...
auto get_default_two_local_components(const Metric &m)
get default two local search components
bool local_search(Solution &solution, SearchStrategy searchStrategy, ContinueOnSuccess succ, ContinueOnFail fail, components...comps)
detail
adopts any cycle to start (vbegin) i place of the last change(flip)
This strategy uses find_positive_predicate as stop condition.
auto make_two_local_search_components(Gain ch, GetMoves gm=GetMoves{})
make template function for TwoLocalcomponents, just to avoid providing type names in template...
functor return true
Definition: functors.hpp:227
bool tsp_first_improving(Cycle &cycle, components...comps)
simple version of two_local_search