15 #ifndef PAAL_N_QUEENS_COMPONENTS_HPP
16 #define PAAL_N_QUEENS_COMPONENTS_HPP
20 #include <boost/iterator/function_input_iterator.hpp>
21 #include <boost/range/adaptor/transformed.hpp>
36 Move(
int from,
int to) : m_from(from), m_to(to) {}
76 template <
typename Solution>
93 result_type operator()(std::tuple<int, int> t)
const {
94 return Move(std::get<0>(t), std::get<1>(t));
109 template <
typename Solution>
struct types_eval {
110 using SolutionIter = decltype(std::declval<Solution>().begin());
113 using IterPair = std::pair<Subset, Subset>;
114 using Range = boost::iterator_range<Subset>;
126 template <
typename Solution>
128 const Solution &solution)
const->typename types_eval<Solution>::Range {
129 return data_structures::make_subsets_iterator_range<2>(
130 solution.begin(), solution.end(),
make_move{});
147 template <
typename Solution>
150 int y1 = solution.get_y(x1);
152 int y2 = solution.get_y(x2);
154 return -solution.get_num_attacing(x1, y2) -
155 solution.get_num_attacing(x2, y1) +
156 solution.get_num_attacing(x1, y1) - 2 +
157 solution.get_num_attacing(x2, y2) - 2 -
158 2 * (std::abs(x1 - x2) == std::abs(y1 - y2));
164 #endif // PAAL_N_QUEENS_COMPONENTS_HPP
Move(int from, int to)
constructor
Move operator()(int from, int to) const
operator()
auto operator()(const Solution &solution) const -> typename types_eval< Solution >::Range
operator() returns all the elements
int get_to() const
getter for m_to
Iterator to all k-subsets of given collection.
int get_from() const
getter for m_from
int operator()(const Solution &solution, Move move) const
computes difference in cost
bool local_search(Solution &solution, SearchStrategy searchStrategy, ContinueOnSuccess succ, ContinueOnFail fail, components...comps)
detail
bool operator()(Solution &sol, Move move) const
Operator swaps elements of the solution range.