Skip to content

Commit

Permalink
Add draft log_targets
Browse files Browse the repository at this point in the history
  • Loading branch information
olafmersmann committed Jan 29, 2025
1 parent 236c552 commit 8ddcb4b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/cocoviz/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,28 @@
from .result import ProblemDescription, ResultSet


def log_targets(results: ResultSet, indicator: ind.Indicator | str, number_of_targets: int = 101):
indicator = ind.resolve(indicator)

targets = {}
for desc, problem_results in results.by_problem():
indicator_values = pl.concat([r._data for r in problem_results])[indicator.name]
low = indicator_values.min()
high = indicator_values.max()
delta = high - low

mul = np.logspace(-16, 0, number_of_targets)
if low == high:
targets[desc] = np.linspace(low, high, 1)
elif indicator.larger_is_better:
targets[desc] = low + delta * mul
else:
targets[desc] = np.flip(low + delta * mul)
return targets


def linear_targets(
results: ResultSet, indicator: ind.Indicator, number_of_targets: int = 101
results: ResultSet, indicator: ind.Indicator | str, number_of_targets: int = 101
) -> dict[ProblemDescription, ArrayLike]:
indicator = ind.resolve(indicator)

Expand Down

0 comments on commit 8ddcb4b

Please sign in to comment.