Metrics
apply_par(performance, budget, par_factor=10.0)
Apply PAR-k (Penalized Average Runtime) transformation to performance data.
This function replaces timeout values (values > budget) with budget * par_factor. This is crucial for algorithm selection because raw timeout values (e.g., 1200.999) look almost identical to near-timeout solves (e.g., 1199), but in practice timeouts should be heavily penalized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
performance
|
DataFrame | ndarray
|
Performance data where each value represents the runtime of an algorithm on an instance. Values greater than the budget indicate timeouts. |
required |
budget
|
float
|
The algorithm cutoff time. Values exceeding this are considered timeouts. |
required |
par_factor
|
float
|
The penalization factor. Timeouts will be replaced with budget * par_factor. Defaults to 10.0 (PAR10). |
10.0
|
Returns:
| Type | Description |
|---|---|
DataFrame | ndarray
|
pd.DataFrame | np.ndarray: Performance data with timeouts penalized. Returns the same type as the input. |
Examples:
>>> import pandas as pd
>>> perf = pd.DataFrame({'algo1': [100, 1201, 500], 'algo2': [200, 200, 1201]})
>>> apply_par(perf, budget=1200, par_factor=10)
algo1 algo2
0 100 200
1 12000 200
2 500 12000
Source code in asf/metrics/par10.py
apply_par10(performance, budget)
Apply PAR10 (Penalized Average Runtime with factor 10) transformation.
Convenience function that calls apply_par with par_factor=10.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
performance
|
DataFrame | ndarray
|
Performance data. |
required |
budget
|
float
|
The algorithm cutoff time. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame | ndarray
|
pd.DataFrame | np.ndarray: Performance data with timeouts penalized by 10x. |
See Also
apply_par: The general PAR-k transformation function.
Source code in asf/metrics/par10.py
running_time_closed_gap(schedules, performance, budget, feature_time, par=10.0, feature_groups=None)
Calculates the closed gap metric for a given selector.
Parameters
schedules : dict[str, list[tuple[str, float] | str]] The schedules to evaluate. performance : pd.DataFrame The performance data for the algorithms. budget : float The budget for the scenario. feature_time : pd.DataFrame The feature time data for each instance. par : float, default=10.0 The penalization factor for unsolved instances. feature_groups : dict[str, Any] or None, default=None Feature group definitions including prerequisite information.
Returns
float The closed gap value, representing the improvement over the single best solver.
Source code in asf/metrics/baselines.py
running_time_selector_performance(schedules, performance, budget=5000.0, feature_time=None, par=10.0, return_per_instance=False)
Calculates the total running time for a selector based on the given schedules and performance data.
The schedule can contain both feature groups (strings) and algorithm selections (tuples). Feature groups are evaluated in order, and their computation time is only added if the instance is not yet solved when the feature group appears in the schedule.
Parameters
schedules : dict[str, list[tuple[str, float] | str]] The schedules to evaluate, where each key is an instance and the value is a list of items. Each item can be: - A string: the name of a feature group to compute (uses full actual time) - A tuple (feature_group, budget): a feature group with a time budget - A tuple (algorithm, budget): an algorithm to run with its allocated budget performance : pd.DataFrame The performance data for the algorithms. budget : float, default=5000.0 The budget for the scenario. feature_time : pd.DataFrame or None, default=None The feature time data for each instance. Columns should be feature group names. par : float, default=10.0 The penalization factor for unsolved instances. return_per_instance : bool, default=False If True, return a dict mapping instance to running time. If False, return the sum of all running times.
Returns
dict[str, float] or float If return_per_instance is True, returns a dictionary mapping each instance to its total running time. Otherwise, returns the sum of all running times.
Source code in asf/metrics/baselines.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
single_best_solver(performance, maximize=False, budget=5000.0, par=10.0)
Selects the single best solver across all instances based on the aggregated performance.
Parameters
performance : pd.DataFrame The performance data for the algorithms. maximize : bool, default=False Whether to maximize or minimize the performance. budget : float or None, default=5000.0 The runtime budget. If provided with par, timeouts are penalized. par : float or None, default=10.0 The penalization factor for timeouts.
Returns
float The best aggregated performance value across all instances.
Source code in asf/metrics/baselines.py
virtual_best_solver(performance, maximize=False, budget=5000.0, par=10.0)
Selects the virtual best solver for each instance by choosing the best performance per instance.
Parameters
performance : pd.DataFrame The performance data for the algorithms. maximize : bool, default=False Whether to maximize or minimize the performance. budget : float or None, default=5000.0 The runtime budget. If provided with par, timeouts are penalized. par : float or None, default=10.0 The penalization factor for timeouts.
Returns
float The sum of the best performance values for each instance.