10template<ProgramType T>
14 this->survival = surv;
17template<ProgramType T>
30 else if (
ind1.fitness.crowding_dist >
ind2.fitness.crowding_dist)
32 else if (
ind2.fitness.crowding_dist >
ind1.fitness.crowding_dist)
38template<ProgramType T>
51 for (
size_t i = 0;
i<
front.size();
i++)
53 crowding_distance(pop,
front,
i);
59 size_t winner = tournament(pop,
68template<ProgramType T>
94 crowding_distance(pop,
front,
i);
96 for (
int j = 0;
j <
Fi.size(); ++
j)
103 crowding_distance(pop,
front,
i);
115template<ProgramType T>
122 vector<vector<int>>
front;
129 std::vector<unsigned int>
dom;
138 int compare =
p->fitness.dominates(
q.fitness);
148 p->fitness.dominated.clear();
149 p->fitness.dominated =
dom;
151 if (
p->fitness.dcounter == 0) {
153 p->fitness.set_rank(1);
165 std::sort(
front.at(0).begin(),
front.at(0).end());
168 while (
front.at(
fi-1).size() > 0) {
171 for (
int i = 0;
i <
fronti.size(); ++
i) {
176 for (
int j = 0;
j <
p.fitness.dominated.size() ; ++
j) {
182 q->fitness.dcounter -= 1;
184 if (
q->fitness.dcounter == 0) {
187 q->fitness.set_rank(
fi+1);
188 Q.push_back(
p.fitness.dominated.at(
j));
200template<ProgramType T>
212 const int fsize = F.size();
223 for (
int m = 0; m <
limit; ++m) {
230 pop.
individuals.at(F.at(0))->fitness.crowding_dist = std::numeric_limits<float>::max();
232 pop.
individuals.at(F.at(
fsize-1))->fitness.crowding_dist = std::numeric_limits<float>::max();
236 if (pop.
individuals.at(F.at(
i))->fitness.crowding_dist != std::numeric_limits<float>::max())
240 (pop.
individuals.at(F.at(
i+1))->fitness.get_wvalues().at(m) - pop.
individuals.at(F.at(
i-1))->fitness.get_wvalues().at(m))
void bind_engine(py::module &m, string name)
vector< size_t > get_island_indexes(int island)
vector< std::shared_ptr< Individual< T > > > individuals
void crowding_distance(Population< T > &, vector< vector< int > > &, int)
size_t tournament(Population< T > &pop, size_t i, size_t j) const
vector< size_t > survive(Population< T > &pop, int island, const Parameters &p)
survival according to the survival scheme of NSGA-II
vector< vector< int > > fast_nds(Population< T > &, vector< size_t > &)
vector< size_t > select(Population< T > &pop, int island, const Parameters &p)
selection according to the survival scheme of NSGA-II
Iter select_randomly(Iter start, Iter end)
< nsga2 selection operator for getting the front
sort based on objective m
sort based on rank, breaking ties with crowding distance