15 #ifndef PAAL_2_LOCAL_SEARCH_COMPONENTS_HPP
16 #define PAAL_2_LOCAL_SEARCH_COMPONENTS_HPP
28 template <
typename Element>
struct Swap {
35 Swap(Element from, Element to) : m_from(from), m_to(to) {}
49 Element
get_to()
const {
return m_to; }
68 template <
typename Element>
97 template <
typename Solution,
typename SolutionElement>
101 return m_metric(from.first, from.second) +
102 m_metric(to.first, to.second) - m_metric(from.first, to.first) -
103 m_metric(from.second, to.second);
107 const Metric &m_metric;
122 template <
typename SolutionElement,
typename Solution>
139 template <
typename Solution>
struct types_eval {
140 using SolutionIter = decltype(std::declval<Solution>().begin());
143 using Range = boost::iterator_range<Subset>;
153 template <
typename Solution>
155 Solution &solution)
const->typename types_eval<Solution>::Range {
156 return data_structures::make_subsets_iterator_range<2>(
157 solution.begin(), solution.end(),
make_swap{});
164 #endif // PAAL_2_LOCAL_SEARCH_COMPONENTS_HPP
Swap< Element > operator()(Element from, Element to) const
operator()
Commit class for local_search.
Commit class for local_search.
Swap(Element from, Element to)
constructor
Element get_to() const
getter for m_to
Iterator to all k-subsets of given collection.
int operator()(const Solution &, const Swap< SolutionElement > &swap)
returns gain for given adjustment
bool local_search(Solution &solution, SearchStrategy searchStrategy, ContinueOnSuccess succ, ContinueOnFail fail, components...comps)
detail
Element get_from() const
getter for m_from
auto operator()(Solution &solution) const -> typename types_eval< Solution >::Range
return all pairs of elements from solution
gain_two_opt(const Metric &m)
bool operator()(Solution &s, const Swap< SolutionElement > &swap)
flips appropriate segment in the solution