Pareto utils¶
Pareto utilities.
- class morl_baselines.common.pareto.ParetoArchive(convex_hull: bool = False)¶
Pareto archive.
Initializes the Pareto archive.
- add(candidate, evaluation: ndarray)¶
Adds the candidate to the memory and removes Pareto inefficient points.
- Parameters:
candidate – The candidate to add.
evaluation – The evaluation of the candidate.
- morl_baselines.common.pareto.filter_convex_dominated(candidates: ndarray | List) ndarray ¶
A fast version to prune a set of points to its convex hull. This leverages the QuickHull algorithm.
This algorithm first computes the convex hull of the set of points and then prunes the Pareto dominated points.
- Parameters:
candidates (ndarray) – A numpy array of vectors.
- Returns:
ndarray – A convex coverage set.
- morl_baselines.common.pareto.filter_pareto_dominated(candidates: ndarray | List, remove_duplicates: bool = True) ndarray ¶
A batched and fast version of the Pareto coverage set algorithm.
- Parameters:
candidates (ndarray) – A numpy array of vectors.
remove_duplicates (bool, optional) – Whether to remove duplicate vectors. Defaults to True.
- Returns:
ndarray – A Pareto coverage set.
- morl_baselines.common.pareto.get_non_dominated(candidates: set) set ¶
This function returns the non-dominated subset of elements.
Source: https://stackoverflow.com/questions/32791911/fast-calculation-of-pareto-front-in-python The code provided in all the stackoverflow answers is wrong. Important changes have been made in this function.
- Parameters:
candidates – The input set of candidate vectors.
- Returns:
The non-dominated subset of this input set.
- morl_baselines.common.pareto.get_non_dominated_inds(solutions: ndarray) ndarray ¶
Returns a boolean array indicating which points are non-dominated.
- morl_baselines.common.pareto.get_non_pareto_dominated_inds(candidates: ndarray | List, remove_duplicates: bool = True) ndarray ¶
A batched and fast version of the Pareto coverage set algorithm.
- Parameters:
candidates (ndarray) – A numpy array of vectors.
remove_duplicates (bool, optional) – Whether to remove duplicate vectors. Defaults to True.
- Returns:
ndarray – The indices of the elements that should be kept to form the Pareto front or coverage set.