Skip to content

Commit

Permalink
Speed up pareto_rank computation.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 619488258
  • Loading branch information
vizier-team authored and copybara-github committed Mar 27, 2024
1 parent 15c07ad commit b0cb94c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions vizier/_src/algorithms/evolution/nsga2.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ def _pareto_rank(ys: np.ndarray) -> np.ndarray:
"""
if ys.shape[0] == 0:
return np.zeros([0])
n = ys.shape[0]
dominated = np.asarray(
[
[np.all(ys[i] <= ys[j]) & np.any(ys[j] > ys[i]) for i in range(n)]
for j in range(n)
]
)
return np.sum(dominated, axis=0)
dominated = [np.all(ys <= r, axis=-1) & np.any(r > ys, axis=-1) for r in ys]
return np.sum(np.stack(dominated), axis=0)


def _crowding_distance(ys: np.ndarray) -> np.ndarray:
Expand Down

0 comments on commit b0cb94c

Please sign in to comment.