Skip to content

Commit

Permalink
Modified use of crowding distance calculation to work with new implem…
Browse files Browse the repository at this point in the history
…entation
  • Loading branch information
danyoungday committed May 20, 2024
1 parent 71035ab commit a6ae838
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions use_cases/eluc/prescriptors/nsga2/torch_prescriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ def _select_parents(self, candidates: list[Candidate], n_parents: int) -> list[C
for front in fronts:
# Compute crowding distance here even though it's technically not necessary now
# so that later we can sort by distance
crowding_distance = nsga2_utils.calculate_crowding_distance(front)
for candidate, distance in zip(front, crowding_distance):
candidate.distance = distance
nsga2_utils.calculate_crowding_distance(front)
if len(parents) + len(front) > n_parents: # If adding this front exceeds num_parents
front = sorted(front, key=lambda candidate: candidate.distance, reverse=True)
parents += front[:n_parents - len(parents)]
Expand Down

0 comments on commit a6ae838

Please sign in to comment.