faif
Space.hpp
1 #ifndef FAIF_SEARCH_SPACE_HPP
2 #define FAIF_SEARCH_SPACE_HPP
3 
4 //
5 //file with the Space concept
6 //
7 
8 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
9 //msvc10.0 warnings for concepts
10 #pragma warning(disable:4510)
11 #pragma warning(disable:4610)
12 #endif
13 
14 
15 #include <iterator>
16 #include <algorithm>
17 #include <vector>
18 #include <boost/bind.hpp>
19 #include <boost/concept_check.hpp>
20 
21 namespace faif {
22  namespace search {
23 
24  /** \brief the typedef-s for space, where the fitness is defined as double */
25  template<typename Ind> struct Space {
26  typedef Ind Individual;
27  typedef double Fitness;
28  };
29 
30  /** \brief the concept for space with fitness
31  */
32  template<typename Space>
33  struct SpaceConcept {
34  typedef typename Space::Individual Individual;
35  typedef typename Space::Fitness Fitness;
36 
37  BOOST_CONCEPT_USAGE(SpaceConcept)
38  {
39  //the method to generate the fitness is required
40  Space::fitness(ind);
41  }
42  Individual ind;
43  };
44 
45  /** \brief Stop condition, finish the algorithm after STEPS_NUM iterations */
46  template< unsigned STEPS_NUM > struct StopAfterNSteps {
47  StopAfterNSteps() : steps_(0) { }
48  template<typename Population> void update(const Population& ) { ++steps_; }
49  bool isFinished() const { return steps_ >= STEPS_NUM; }
50  private:
51  unsigned int steps_;
52  };
53 
54 
55  } //namespace search
56 } //namespace faif
57 
58 
59 #endif
Definition: Chain.h:17
the typedef-s for space, where the fitness is defined as double
Definition: Space.hpp:25
Stop condition, finish the algorithm after STEPS_NUM iterations.
Definition: Space.hpp:46
the concept for space with fitness
Definition: Space.hpp:33