50 auto front =
fast_nds(pop, island_pool);
51 for (
size_t i = 0; i< front.size(); i++)
56 vector<size_t> selected(0);
57 for (
int i = 0; i < island_pool.size(); ++i)
60 *
r.select_randomly(island_pool.begin(), island_pool.end()),
61 *
r.select_randomly(island_pool.begin(), island_pool.end()));
63 selected.push_back(winner);
75 auto original_size = idx_end - idx_start;
80 auto front =
fast_nds(pop, island_pool);
83 vector<size_t> selected;
89 && ( selected.size() + front.at(i).size() < original_size )
92 std::vector<int>& Fi = front.at(i);
96 for (
int j = 0; j < Fi.size(); ++j)
97 selected.push_back(Fi.at(j));
104 std::sort(front.at(i).begin(),front.at(i).end(),
sort_n(pop));
107 const int extra = original_size - selected.size();
108 for (
int j = 0; j < extra; ++j)
109 selected.push_back(front.at(i).at(j));
122 vector<vector<int>> front;
127 for (
int i = 0; i < island_pool.size(); ++i) {
129 std::vector<unsigned int> dom;
134 for (
int j = 0; j < island_pool.size(); ++j) {
138 int compare = p->fitness.dominates(q.
fitness);
141 dom.push_back(island_pool[j]);
142 }
else if (compare == -1) {
147 p->fitness.dcounter = dcount;
148 p->fitness.dominated.clear();
149 p->fitness.dominated = dom;
151 if (p->fitness.dcounter == 0) {
153 p->fitness.set_rank(1);
155 front.at(0).push_back(island_pool[i]);
165 std::sort(front.at(0).begin(), front.at(0).end());
168 while (front.at(fi-1).size() > 0) {
169 std::vector<int>& fronti = front.at(fi-1);
171 for (
int i = 0; i < fronti.size(); ++i) {
182 q->fitness.dcounter -= 1;
184 if (q->fitness.dcounter == 0) {
187 q->fitness.set_rank(fi+1);
206 std::vector<int> F = front.at(fronti);
212 const int fsize = F.size();
215 for (
int i = 0; i < fsize; ++i)
216 pop.
individuals.at(F.at(i))->fitness.crowding_dist = 0;
220 const int limit = pop.
individuals.at(0)->fitness.get_wvalues().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();
234 for (
int i = 1; i < fsize-1; ++i)
236 if (pop.
individuals.at(F.at(i))->fitness.crowding_dist != std::numeric_limits<float>::max())
239 pop.
individuals.at(F.at(i))->fitness.crowding_dist +=
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))
241 / (pop.
individuals.at(F.at(fsize-1))->fitness.get_wvalues().at(m) - pop.
individuals.at(F.at(0))->fitness.get_wvalues().at(m));