Runner¶
Execute simulations across experimental grids.
trade_study.run_grid(world, scorer, grid, observables, *, annotations=None, n_jobs=1, callback=None)
¶
Run all configurations in a grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
world
|
Simulator
|
Simulator that generates (truth, observations). |
required |
scorer
|
Scorer
|
Scorer that evaluates observables. |
required |
grid
|
list[dict[str, Any]]
|
List of config dicts to evaluate. |
required |
observables
|
list[Observable]
|
Observable definitions (for column ordering). |
required |
annotations
|
list[Annotation] | None
|
Optional external annotations (costs, etc.). |
None
|
n_jobs
|
int
|
Number of parallel workers (-1 for all CPUs). |
1
|
callback
|
ProgressCallback | None
|
Optional progress callback invoked after each trial
with |
None
|
Returns:
| Type | Description |
|---|---|
ResultsTable
|
ResultsTable with scored results. |
Source code in src/trade_study/runner.py
trade_study.run_adaptive(world, scorer, factors, observables, *, n_trials=100, seed=42)
¶
Run adaptive multi-objective optimization via optuna.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
world
|
Simulator
|
Simulator. |
required |
scorer
|
Scorer
|
Scorer for observables. |
required |
factors
|
list[Factor]
|
Factor definitions (from design module). |
required |
observables
|
list[Observable]
|
Observable definitions. |
required |
n_trials
|
int
|
Number of optuna trials. |
100
|
seed
|
int
|
Random seed. |
42
|
Returns:
| Type | Description |
|---|---|
ResultsTable
|
ResultsTable with scored results. |
Source code in src/trade_study/runner.py
trade_study.run_successive_halving(trials, sim, *, rungs, eta=3.0, metric, mode='min')
¶
Successive-halving multi-fidelity early-stopping (#104).
Evaluates every trial at the lowest rung, keeps the top 1/eta by
metric (according to mode), promotes survivors to the next
budget, and repeats until the highest rung. Every (trial, rung)
evaluation is recorded as one row in the returned :class:ResultsTable,
with rung index and budget stored in per-row metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trials
|
list[dict[str, Any]]
|
Candidate configurations to evaluate. |
required |
sim
|
PartialEvaluator
|
A :class: |
required |
rungs
|
list[float]
|
Strictly ascending list of budgets (e.g. epochs, iterations). Length determines the number of halving rounds. |
required |
eta
|
float
|
Reduction factor between rungs (>1). Each rung keeps
|
3.0
|
metric
|
str
|
Observable name used to rank trials at each rung. |
required |
mode
|
str
|
|
'min'
|
Returns:
| Type | Description |
|---|---|
ResultsTable
|
class: |
ResultsTable
|
Per-row metadata contains |
ResultsTable
|
|
ResultsTable
|
|
ResultsTable
|
|
ResultsTable
|
validator when arguments are invalid. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
Source code in src/trade_study/runner.py
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 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
trade_study.run_hyperband(trial_factory, sim, *, max_budget, eta=3.0, metric, mode='min')
¶
Hyperband: multi-bracket successive-halving (#104).
Wraps :func:run_successive_halving with the bracket schedule from
Li et al. (2017). Each bracket trades off the number of initial
trials against the minimum budget per trial; together they hedge
against picking either ratio wrong.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trial_factory
|
Callable[[int, int], list[dict[str, Any]]]
|
Callable |
required |
sim
|
PartialEvaluator
|
A :class: |
required |
max_budget
|
float
|
Maximum resource |
required |
eta
|
float
|
Reduction factor (>1). Defaults to 3. |
3.0
|
metric
|
str
|
Observable used for ranking within each bracket. |
required |
mode
|
str
|
|
'min'
|
Returns:
| Name | Type | Description |
|---|---|---|
Concatenated |
ResultsTable
|
class: |
ResultsTable
|
additional |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/trade_study/runner.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |