25 #ifndef PAGMO_ALGORITHM_SGA_GRAY_H
26 #define PAGMO_ALGORITHM_SGA_GRAY_H
28 #include "../config.h"
29 #include "../problem/base.h"
30 #include "../serialization.h"
33 namespace pagmo {
namespace algorithm {
56 enum type {BEST20 = 0,ROULETTE = 1};
67 enum type {SINGLE_POINT = 0};
69 sga_gray(
int gen = 1,
const double &cr = .95,
const double &m = .02,
int elitism = 1,
70 mutation::type mut = mutation::UNIFORM,
71 selection::type sel = selection::ROULETTE,
72 crossover::type cro = crossover::SINGLE_POINT);
75 std::string get_name()
const;
77 std::string human_readable_extra()
const;
79 friend class boost::serialization::access;
80 template <
class Archive>
81 void serialize(Archive &ar,
const unsigned int)
83 ar & boost::serialization::base_object<base>(*this);
84 ar &
const_cast<int &
>(m_gen);
85 ar &
const_cast<double &
>(m_cr);
86 ar &
const_cast<double &
>(m_m);
87 ar &
const_cast<int &
>(m_elitism);
88 ar &
const_cast<mutation::type &
>(m_mut);
89 ar &
const_cast<selection::type &
>(m_sel);
90 ar &
const_cast<crossover::type &
>(m_cro);
91 ar & m_max_encoding_integer;
104 const mutation::type m_mut;
106 const selection::type m_sel;
108 const crossover::type m_cro;
112 std::vector<int> selection(
const std::vector<fitness_vector> &,
const problem::base &)
const;
113 void crossover(std::vector< std::vector<int> > &pop_x)
const;
114 void mutate(std::vector< std::vector<int> > &pop_x)
const;
118 std::vector<int> double_to_binary(
const double &number,
const double &lb,
const double &ub)
const;
119 double binary_to_double(
const std::vector<int> &binary,
const double &lb,
const double &ub)
const;
120 std::vector<int> gray_to_binary(
const std::vector<int> &gray)
const;
121 std::vector<int> binary_to_gray(
const std::vector<int> &binary)
const;
128 int m_max_encoding_integer;
136 #endif // PAGMO_ALGORITHM_SGA_GRAY_H
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base algorithm.
std::vector< double > decision_vector
Decision vector type.
type
Mutation type, uniform.
type
Selection type, best 20% or roulette.
The Simple Genetic Algorithm with gray encoding (sga_gray)
type
Crossover type, single point.