PaGMO  1.1.5
algorithm/base.h
1 /*****************************************************************************
2  * Copyright (C) 2004-2015 The PaGMO development team, *
3  * Advanced Concepts Team (ACT), European Space Agency (ESA) *
4  * *
5  * https://github.com/esa/pagmo *
6  * *
7  * act@esa.int *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the *
21  * Free Software Foundation, Inc., *
22  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23  *****************************************************************************/
24 
25 #ifndef PAGMO_ALGORITHM_BASE_H
26 #define PAGMO_ALGORITHM_BASE_H
27 
28 #include <iostream>
29 #include <string>
30 #include <typeinfo>
31 #include <boost/shared_ptr.hpp>
32 
33 #include "../config.h"
34 #include "../population.h"
35 #include "../rng.h"
36 #include "../serialization.h"
37 
38 namespace pagmo
39 {
41 
44 namespace algorithm {
45 
47 class base;
48 
50 typedef boost::shared_ptr<base> base_ptr;
51 
53 
81 class __PAGMO_VISIBLE base
82 {
83  public:
84  base();
86 
91  virtual void evolve(population &p) const = 0;
93 
102  virtual base_ptr clone() const = 0;
103  virtual ~base();
104  std::string human_readable() const;
105  virtual std::string get_name() const;
106  virtual std::string human_readable_extra() const;
108  void set_screen_output(const bool p);
109  bool get_screen_output() const;
110 
112  void reset_rngs(const unsigned int) const;
113 
114  protected:
121  private:
122  friend class boost::serialization::access;
123  template <class Archive>
124  void serialize(Archive &ar, const unsigned int)
125  {
126  ar & m_drng;
127  ar & m_urng;
128  ar & m_screen_output;
129  }
130  protected:
132  mutable unsigned int m_fevals;
133 };
134 
135 std::ostream __PAGMO_VISIBLE_FUNC &operator<<(std::ostream &, const base &);
136 
137 }
138 }
139 
140 BOOST_SERIALIZATION_ASSUME_ABSTRACT(pagmo::algorithm::base)
141 
142 #endif
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base algorithm.
Root PaGMO namespace.
This rng returns an unsigned integer in the [0,2**32-1] range.
Definition: rng.h:47
Base algorithm class.
Population class.
Definition: population.h:70
bool m_screen_output
Indicates to the derived class whether to print stuff on screen.
unsigned int m_fevals
A counter for the number of function evaluations.
rng_uint32 m_urng
Random number generator for unsigned integer values.
std::ostream & operator<<(std::ostream &s, const base &alg)
Overload stream operator for algorithm::base.
rng_double m_drng
Random number generator for double-precision floating point values.
This rng returns a double in the [0,1[ range.
Definition: rng.h:89