filter_dominated_within_sets#
- moocore.filter_dominated_within_sets(data, /, *, maximise=False, keep_weakly=False)[source]#
Given a dataset with multiple sets (last column gives the set index), filter dominated points within each set.
Executes the
filter_dominated()
function within each set in a dataset and returns back a dataset. This is roughly equivalent to partitioningdata
according to the last column, filtering dominated solutions within each partition, and joining back the result.- Parameters:
data (
ArrayLike
) – Numpy array of numerical values and set numbers, containing multiple datasets. For example the output of theread_datasets()
function.maximise (
bool
|list
[bool
], default:False
) – Whether the objectives must be maximised instead of minimised. Either a single boolean value that applies to all objectives or a list of booleans, with one value per objective. Also accepts a 1D numpy array with values 0 or 1 for each objectivekeep_weakly (
bool
, default:False
) – IfFalse
, do not delete duplicates of nondominated points.
- Returns:
ndarray
– A numpy array where each set only contains nondominated points with respect to the set (last column is the set index). Points from one set can still dominate points from another set.
Examples
>>> x = moocore.get_dataset("input1.dat") >>> pf_per_set = moocore.filter_dominated_within_sets(x) >>> len(pf_per_set) 42 >>> pf_per_set array([[ 0.20816431, 4.62275469, 1. ], [ 0.22997367, 1.11772205, 1. ], [ 0.58799475, 0.73891181, 1. ], [ 1.5964888 , 5.98825094, 2. ], [ 5.2812367 , 3.47800969, 2. ], [ 2.16315952, 4.7394435 , 2. ], ... [ 0.6510164 , 9.42381213, 9. ], [ 1.30291449, 4.50417698, 9. ], [ 0.62230271, 3.56945324, 10. ], [ 0.86723965, 1.58599089, 10. ], [ 6.43135537, 1.00153569, 10. ]]) >>> pf = moocore.filter_dominated(x[:, :-1]) >>> len(pf) 6 >>> pf array([[0.20816431, 4.62275469], [0.22997367, 1.11772205], [0.58799475, 0.73891181], [1.54506255, 0.38303122], [0.17470556, 8.89066343], [8.57911868, 0.35169752]]) >>> moocore.filter_dominated_within_sets(x[(x[:, 2] >= 3) & (x[:, 2] <= 5), :]) array([[2.60764118, 6.31309852, 3. ], [3.22509709, 6.1522834 , 3. ], [0.37731545, 9.02211752, 3. ], [4.61023932, 2.29231998, 3. ], [0.2901393 , 8.32259412, 4. ], [1.54506255, 0.38303122, 4. ], [4.43498452, 4.13150648, 5. ], [9.78758589, 1.41238277, 5. ], [7.85344142, 3.02219054, 5. ], [0.9017068 , 7.49376946, 5. ], [0.17470556, 8.89066343, 5. ]])
The above returns sets 3,4,5 with dominated points within each set removed.
See also
read_datasets
read datasets from a file.
filter_dominated
to be used with a single dataset.