-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastDominatedSort.py
More file actions
26 lines (20 loc) · 936 Bytes
/
Copy pathFastDominatedSort.py
File metadata and controls
26 lines (20 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from Fruit_NSGAII.chromosome import Chromosome
def fast_non_dominate_sorting(chromosome_list):
# calculate niche count ( non-dominate count )
for x in chromosome_list:
x.niche_score = sum([1 if y.fitness_cost > x.fitness_cost and y.fitness_piece > x.fitness_piece else 0 for y in chromosome_list])
# sorted list by niche count (DESC)
Chromosome.status = 'niche-sort'
chromosome_list = sorted(chromosome_list)
# assign pareto rank regraded Front pareto ranking.
for x in chromosome_list:
if x.niche_score == 0:
x.pareto_rank = 1
else:
for y in chromosome_list:
if y.fitness_cost > x.fitness_cost and y.fitness_piece > x.fitness_piece:
x.pareto_rank = y.pareto_rank + 1
# sorted list by pareto rank (ASC)
Chromosome.status = 'pareto-sort'
chromosome_list = sorted(chromosome_list)
return chromosome_list