All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
local_search_concepts.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_LOCAL_SEARCH_CONCEPTS_HPP
17 #define PAAL_LOCAL_SEARCH_CONCEPTS_HPP
18 
21 
22 #include <boost/concept_check.hpp>
23 
24 #include <type_traits>
25 
26 namespace paal {
27 namespace local_search {
28 namespace concepts {
29 
30 template <typename Functor, typename Solution, typename SearchComponents>
31 struct concepts_base {
32  Functor functor;
33  Solution s;
34  typedef typename move_type<SearchComponents, Solution>::value_type Move;
35  Move u;
36 };
37 
38 template <typename X, typename Solution, typename SearchComponents>
39 struct get_moves : concepts_base<X, Solution, SearchComponents> {
40  BOOST_CONCEPT_USAGE(get_moves) {
41  auto i = this->functor(this->s);
42  auto b = std::begin(i);
43  auto e = std::end(i);
44  for (auto x = b; x != e; ++x) {
46  boost::ignore_unused_variable_warning(uu);
47  }
48  }
49 };
50 
51 template <typename X, typename Solution, typename SearchComponents>
52 struct gain : concepts_base<X, Solution, SearchComponents> {
53  BOOST_CONCEPT_USAGE(gain) {
54  boost::ignore_unused_variable_warning(this->functor(this->s, this->u) > this->functor(this->s, this->u));
55  }
56 };
57 
58 template <typename X, typename Solution, typename SearchComponents>
59 struct commit : concepts_base<X, Solution, SearchComponents> {
60  BOOST_CONCEPT_USAGE(commit) {
61  bool b = this->functor(this->s, this->u);
62  boost::ignore_unused_variable_warning(b);
63  }
64 };
65 
66 template <typename X, typename Solution> class search_components {
68  typedef typename Traits::GetMovesT NG;
69  typedef typename Traits::GainT IC;
70  typedef typename Traits::CommitT SU;
71 
72  public:
73  BOOST_CONCEPT_ASSERT((get_moves<NG, Solution, X>));
74  BOOST_CONCEPT_ASSERT((gain<IC, Solution, X>));
75  BOOST_CONCEPT_ASSERT((commit<SU, Solution, X>));
76 };
77 
78 } // concepts
79 } // local_search
80 } // paal
81 
82 #endif // PAAL_LOCAL_SEARCH_CONCEPTS_HPP
Traits class for search_components.
bool local_search(Solution &solution, SearchStrategy searchStrategy, ContinueOnSuccess succ, ContinueOnFail fail, components...comps)
detail