Skip to content

Commit 7be45be

Browse files
committed
Enhance README and renew typing to a modern one
1 parent ee1bfd4 commit 7be45be

File tree

4 files changed

+98
-94
lines changed

4 files changed

+98
-94
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ We use the $k$% attainment surface or empirical attainment function and visualiz
1313

1414
![Demo of the attainment surface](figs/demo.png)
1515

16-
The original paper is available below.
16+
The original paper is available below:
1717

1818
[1] [On the Performance Assessment and Comparison of Stochastic Multi-objective Optimizers](https://eden.dei.uc.pt/~cmfonsec/fonseca-ppsn1996-reprint.pdf)
1919

20+
> [!IMPORTANT]
21+
> When you use this package, please cite the paper:
22+
> [Python Tool for Visualizing Variability of Pareto Fronts over Multiple Runs](https://arxiv.org/abs/2305.08852).
23+
2024
**NOTE**
2125

2226
When we define $N$ as `n_independent_runs`, and $K$ as `the number of unique objective values in the first objective`,
@@ -123,7 +127,7 @@ if __name__ == "__main__":
123127

124128
Please cite the following paper:
125129

126-
```
130+
```bibtex
127131
@article{watanabe2023pareto,
128132
title = {{P}ython Tool for Visualizing Variability of {P}areto Fronts over Multiple Runs},
129133
author = {S. Watanabe},

eaf/eaf.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Optional
1+
from __future__ import annotations
22

33
from eaf.utils import LOGEPS
44

@@ -8,7 +8,7 @@
88
import numpy as np
99

1010

11-
def _get_pf_set_list(costs: np.ndarray) -> List[np.ndarray]:
11+
def _get_pf_set_list(costs: np.ndarray) -> list[np.ndarray]:
1212
"""
1313
Get the list of Pareto front sets.
1414
@@ -19,14 +19,14 @@ def _get_pf_set_list(costs: np.ndarray) -> List[np.ndarray]:
1919
For now, we only support n_obj == 2.
2020
2121
Returns:
22-
pf_set_list (List[np.ndarray]):
22+
pf_set_list (list[np.ndarray]):
2323
The list of the Pareto front sets.
2424
The shape is (trial number, Pareto solution index, objective index).
2525
Note that each pareto front set is sorted based on the ascending order of
2626
the first objective.
2727
"""
2828
_cost_copy = costs.copy()
29-
pf_set_list: List[np.ndarray] = []
29+
pf_set_list: list[np.ndarray] = []
3030
for _costs in _cost_copy:
3131
# Sort by the first objective, then the second objective
3232
order = np.lexsort((-_costs[:, 1], _costs[:, 0]))
@@ -35,7 +35,7 @@ def _get_pf_set_list(costs: np.ndarray) -> List[np.ndarray]:
3535
return pf_set_list
3636

3737

38-
def _compute_emp_att_surf(X: np.ndarray, pf_set_list: List[np.ndarray], levels: np.ndarray) -> np.ndarray:
38+
def _compute_emp_att_surf(X: np.ndarray, pf_set_list: list[np.ndarray], levels: np.ndarray) -> np.ndarray:
3939
"""
4040
Compute the empirical attainment surface of the given Pareto front sets.
4141
@@ -53,7 +53,7 @@ def _compute_emp_att_surf(X: np.ndarray, pf_set_list: List[np.ndarray], levels:
5353
level=1 leads to the best attainment surface,
5454
level=n_independent_runs leads to the worst attainment surface,
5555
level=n_independent_runs//2 leads to the median attainment surface.
56-
pf_set_list (List[np.ndarray]):
56+
pf_set_list (list[np.ndarray]):
5757
The list of the Pareto front sets.
5858
The shape is (trial number, Pareto solution index, objective index).
5959
Note that each pareto front set is sorted based on the ascending order of
@@ -105,9 +105,9 @@ def _compute_emp_att_surf(X: np.ndarray, pf_set_list: List[np.ndarray], levels:
105105

106106
def get_empirical_attainment_surface(
107107
costs: np.ndarray,
108-
levels: List[int],
109-
larger_is_better_objectives: Optional[List[int]] = None,
110-
log_scale: Optional[List[int]] = None,
108+
levels: list[int],
109+
larger_is_better_objectives: list[int] | None = None,
110+
log_scale: list[int] | None = None,
111111
) -> np.ndarray:
112112
"""
113113
Get the empirical attainment surface given the costs observations.
@@ -117,7 +117,7 @@ def get_empirical_attainment_surface(
117117
The costs obtained in the observations.
118118
The shape must be (n_independent_runs, n_samples, n_obj).
119119
For now, we only support n_obj == 2.
120-
levels (List[int]):
120+
levels (list[int]):
121121
A list of `level` described below:
122122
Control the k in the k-% attainment surface.
123123
k = level / n_independent_runs
@@ -126,10 +126,10 @@ def get_empirical_attainment_surface(
126126
level=1 leads to the best attainment surface,
127127
level=n_independent_runs leads to the worst attainment surface,
128128
level=n_independent_runs//2 leads to the median attainment surface.
129-
larger_is_better_objectives (Optional[List[int]]):
129+
larger_is_better_objectives (list[int] | None):
130130
The indices of the objectives that are better when the values are larger.
131131
If None, we consider all objectives are better when they are smaller.
132-
log_scale (Optional[List[int]]):
132+
log_scale (list[int] | None):
133133
The indices of the log scale.
134134
For example, if you would like to plot the first objective in the log scale,
135135
you need to feed log_scale=[0].

0 commit comments

Comments
 (0)