All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
facility_location_add.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 //=======================================================================
15 #ifndef PAAL_FACILITY_LOCATION_ADD_HPP
16 #define PAAL_FACILITY_LOCATION_ADD_HPP
17 
21 
22 #include <boost/iterator/iterator_adaptor.hpp>
23 
24 #include <vector>
25 #include <numeric>
26 #include <cstdlib>
27 #include <cassert>
28 
29 namespace paal {
30 namespace local_search {
31 
43  template <typename Solution, typename UnchosenElement>
44  bool operator()(Solution &s, UnchosenElement &e) // SolutionElement
45  {
46  s.add_facility(e);
47  return true;
48  }
49 };
50 
55 
63  template <typename Solution>
64  auto operator()(const Solution &sol)->decltype(sol.getUnchosenCopy()) {
65  // the move of UNCHOSEN could be added to the solution
66  return sol.getUnchosenCopy();
67  }
68 };
69 
83  template <typename Solution, typename UnchosenElement>
84  auto operator()(Solution &s, UnchosenElement e) const {
85  auto ret = s.add_facility_tentative(e);
86  auto back = s.remove_facility_tentative(e);
87  assert(ret == -back);
88  return -ret;
89  }
90 };
91 
92 } // local_search
93 } // paal
94 
95 #endif // PAAL_FACILITY_LOCATION_ADD_HPP
gain functor for add moves in facility location problem
bool operator()(Solution &s, UnchosenElement &e)
operator ()
auto operator()(Solution &s, UnchosenElement e) const
operator()
gain functor for add moves in facility location problem
commit functor for add moves in facility location problem
auto operator()(const Solution &sol) -> decltype(sol.getUnchosenCopy())
operator()
bool local_search(Solution &solution, SearchStrategy searchStrategy, ContinueOnSuccess succ, ContinueOnFail fail, components...comps)
detail