File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -79,20 +79,20 @@ def crowding_distance(front):
79
79
obj_sorted = sorted (obj , key = lambda x : x [1 ])
80
80
81
81
# Get the minimum and maximum values for the current objective.
82
- obj_min_val = obj_sorted [ 0 ][ 1 ]
83
- obj_max_val = obj_sorted [ - 1 ][ 1 ]
82
+ obj_min_val = min ( population [:, obj_idx ])
83
+ obj_max_val = max ( population [:, obj_idx ])
84
84
denominator = obj_max_val - obj_min_val
85
85
# To avoid division by zero, set the denominator to a tiny value.
86
86
if denominator == 0 :
87
87
denominator = 0.0000001
88
-
88
+
89
89
# Set the crowding distance to the first and last solutions (after being sorted) to infinity.
90
- inf_val = 999999999
90
+ inf_val = float ( 'inf' )
91
91
# crowding_distance[0] = inf_val
92
92
obj_sorted [0 ][2 ] = inf_val
93
93
# crowding_distance[-1] = inf_val
94
94
obj_sorted [- 1 ][2 ] = inf_val
95
-
95
+
96
96
# If there are only 2 solutions in the current front, then do not proceed.
97
97
# The crowding distance for such 2 solutions is infinity.
98
98
if len (obj_sorted ) <= 2 :
You can’t perform that action at this time.
0 commit comments