Runtime based metric.
It tries to maximise the gap between the running time of the target solver
and the other solvers in the portfolio. Use this metric with exact solvers
which provide the same objective values for an instance. The goal is that
the instances generated would take less time to solve by the target solver.
| Parameters: |
-
runtimes
(ndarray[float])
–
Running times of each solver over every instances.
It is expected that the first value is the score of the target.
-
aggregate_fn
(Callable, default:
max
)
–
Function to aggregate the result of multiple repetitions.
by default, it uses np.max.
|
Returns:
np.ndarray: Performance biases for every instance. Instance.p attribute.
Source code in digneapy/core/_scores.py
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 | def maximise_runtime_gap(
runtimes: np.ndarray, aggregate_fn: Callable = np.max
) -> np.ndarray:
"""Runtime based metric.
It tries to maximise the gap between the running time of the target solver
and the other solvers in the portfolio. Use this metric with exact solvers
which provide the same objective values for an instance. The goal is that
the instances generated would take less time to solve by the target solver.
Args:
runtimes (np.ndarray[float]): Running times of each solver over every instances.
It is expected that the first value is the score of the target.
aggregate_fn (Callable): Function to aggregate the result of multiple repetitions.
by default, it uses np.max.
Returns:
np.ndarray: Performance biases for every instance. Instance.p attribute.
"""
if runtimes.ndim < 2 or runtimes.ndim > 3:
raise ValueError(
"Expected a 2d or 3d numpy array (i, solver, repetitions)"
"Where `i` is the number of instances, `solver` the number of solvers in the portfolio, "
"and repetitions is the number of repetitions performed by the solver on each instance."
f" Instead, scores have shape: {runtimes.shape}"
)
if runtimes.ndim == 2:
return np.min(runtimes[:, 1:], axis=1) - runtimes[:, 0]
else:
aggregated = aggregate_fn(runtimes, axis=-1)
return np.min(aggregated[:, 1:], axis=-1) - aggregated[:, 0]
|