25 #ifndef PAGMO_ALGORITHM_NSPSO_H
26 #define PAGMO_ALGORITHM_NSPSO_H
28 #include "../config.h"
29 #include "../serialization.h"
32 namespace pagmo {
namespace algorithm {
60 nspso(
int gen=100,
double minW = 0.4,
double maxW = 1.0,
double C1 = 2.0,
double C2 = 2.0,
61 double CHI = 1.0,
double v_coeff = 0.5,
int leader_selection_range = 10, diversity_mechanism_type = CROWDING_DISTANCE);
65 std::string get_name()
const;
68 std::string human_readable_extra()
const;
71 struct one_dim_fit_comp {
72 one_dim_fit_comp(
const std::vector<fitness_vector> &fit, fitness_vector::size_type dim):m_fit(fit),m_dim(dim){};
75 return m_fit[idx1][m_dim] < m_fit[idx2][m_dim];
77 const std::vector<fitness_vector>& m_fit;
78 fitness_vector::size_type m_dim;
81 struct crowding_pareto_comp{
82 crowding_pareto_comp(
const std::vector<population::size_type> &pareto_rank,
const std::vector<double> &crowding_d):m_pareto_rank(pareto_rank),m_crowding_d(crowding_d){};
85 if (m_pareto_rank[idx1] == m_pareto_rank[idx2]) {
86 return (m_crowding_d[idx1] > m_crowding_d[idx2]);
89 return (m_pareto_rank[idx1] < m_pareto_rank[idx2]);
92 const std::vector<population::size_type> &m_pareto_rank;
93 const std::vector<double> &m_crowding_d;
96 struct nspso_individual {
107 double minfit(
unsigned int,
unsigned int,
const std::vector<fitness_vector> &)
const;
108 void compute_maxmin(std::vector<double> &,
const std::vector<fitness_vector> &)
const;
109 void compute_niche_count(std::vector<int> &,
const std::vector<std::vector<double> > &,
double)
const;
110 double euclidian_distance(
const std::vector<double> &,
const std::vector<double> &)
const;
111 std::vector<std::vector<population::size_type> > compute_domination_list(
const pagmo::problem::base &,
112 const std::vector<fitness_vector> &,
113 const std::vector<constraint_vector> &)
const;
114 std::vector<population::size_type> compute_domination_count(
const std::vector<std::vector<population::size_type> > &)
const;
115 std::vector<population::size_type> compute_pareto_rank(
const std::vector<std::vector<population::size_type> > &)
const;
116 std::vector<std::vector<population::size_type> > compute_pareto_fronts(
const std::vector<population::size_type> &)
const;
117 std::vector<std::vector<population::size_type> > compute_pareto_fronts(
const pagmo::problem::base &,
118 const std::vector<fitness_vector> &,
119 const std::vector<constraint_vector> &)
const;
120 std::vector<double> compute_crowding_d(
const std::vector<fitness_vector> &,
const std::vector<std::vector<population::size_type> > &)
const;
121 fitness_vector compute_ideal(
const std::vector<fitness_vector> &,
const std::vector<population::size_type> &)
const;
122 fitness_vector compute_nadir(
const std::vector<fitness_vector> &,
const std::vector<population::size_type> &)
const;
124 friend class boost::serialization::access;
125 template <
class Archive>
126 void serialize(Archive &ar,
const unsigned int)
128 ar & boost::serialization::base_object<base>(*this);
129 ar &
const_cast<int &
>(m_gen);
130 ar &
const_cast<double &
>(m_minW);
131 ar &
const_cast<double &
>(m_maxW);
132 ar &
const_cast<double &
>(m_C1);
133 ar &
const_cast<double &
>(m_C2);
134 ar &
const_cast<double &
>(m_CHI);
135 ar &
const_cast<double &
>(m_v_coeff);
136 ar &
const_cast<int &
>(m_leader_selection_range);
137 ar &
const_cast<diversity_mechanism_type &
>(m_diversity_mechanism);
147 const double m_v_coeff;
148 const int m_leader_selection_range;
149 const diversity_mechanism_type m_diversity_mechanism;
157 #endif // PAGMO_ALGORITHM_NSPSO_H
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base algorithm.
std::vector< double > decision_vector
Decision vector type.
std::vector< double > fitness_vector
Fitness vector type.
diversity_mechanism_type
Mechanism used to asses diversity.
std::vector< double > constraint_vector
Constraint vector type.
container_type::size_type size_type
Population size type.
Non-dominated Sorting Particle Swarm Optimizer (NSPSO)