Shuffles the values and sorts them afterwards. This can be used to break the tie when the highest utility score is not unique. The shuffle randomizes order, which is preserved by the mergesort algorithm. Args: values: Contains the values to be selected from. n_insta
(values: np.ndarray, n_instances: int = 1)
| 35 | |
| 36 | |
| 37 | def shuffled_argmin(values: np.ndarray, n_instances: int = 1) -> np.ndarray: |
| 38 | """ |
| 39 | Shuffles the values and sorts them afterwards. This can be used to break |
| 40 | the tie when the highest utility score is not unique. The shuffle randomizes |
| 41 | order, which is preserved by the mergesort algorithm. |
| 42 | |
| 43 | Args: |
| 44 | values: Contains the values to be selected from. |
| 45 | n_instances: Specifies how many indices and values to return. |
| 46 | Returns: |
| 47 | The indices and values of the n_instances smallest values. |
| 48 | """ |
| 49 | |
| 50 | indexes, index_values = shuffled_argmax(-values, n_instances) |
| 51 | |
| 52 | return indexes, -index_values |
| 53 | |
| 54 | |
| 55 | def multi_argmax(values: np.ndarray, n_instances: int = 1) -> np.ndarray: |
no test coverage detected
searching dependent graphs…