hone-python 0.11.0__tar.gz → 0.12.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {hone_python-0.11.0 → hone_python-0.12.0}/PKG-INFO +69 -2
  2. {hone_python-0.11.0 → hone_python-0.12.0}/README.md +68 -1
  3. {hone_python-0.11.0 → hone_python-0.12.0}/hone/__init__.py +23 -4
  4. {hone_python-0.11.0 → hone_python-0.12.0}/hone/benchmarks/__init__.py +1 -0
  5. {hone_python-0.11.0 → hone_python-0.12.0}/hone/benchmarks/__main__.py +27 -0
  6. hone_python-0.12.0/hone/benchmarks/multi.py +447 -0
  7. {hone_python-0.11.0 → hone_python-0.12.0}/hone/config/__init__.py +1 -0
  8. hone_python-0.12.0/hone/config/multi_objective_config.py +86 -0
  9. {hone_python-0.11.0 → hone_python-0.12.0}/hone/objective_function/objective_function.py +10 -0
  10. hone_python-0.12.0/hone/optimizers/__init__.py +8 -0
  11. {hone_python-0.11.0 → hone_python-0.12.0}/hone/optimizers/_gp.py +5 -0
  12. hone_python-0.12.0/hone/optimizers/base.py +247 -0
  13. {hone_python-0.11.0 → hone_python-0.12.0}/hone/optimizers/bayesian.py +59 -46
  14. {hone_python-0.11.0 → hone_python-0.12.0}/hone/optimizers/choice.py +34 -1
  15. hone_python-0.11.0/hone/optimizers/base.py → hone_python-0.12.0/hone/optimizers/core.py +108 -195
  16. {hone_python-0.11.0 → hone_python-0.12.0}/hone/optimizers/genetic/__init__.py +1 -0
  17. hone_python-0.11.0/hone/optimizers/genetic/optimizer.py → hone_python-0.12.0/hone/optimizers/genetic/breeding.py +37 -91
  18. hone_python-0.12.0/hone/optimizers/genetic/nsga2.py +115 -0
  19. hone_python-0.12.0/hone/optimizers/genetic/optimizer.py +106 -0
  20. hone_python-0.12.0/hone/optimizers/multi.py +230 -0
  21. hone_python-0.12.0/hone/optimizers/multi_bayesian.py +153 -0
  22. hone_python-0.12.0/hone/pareto.py +265 -0
  23. {hone_python-0.11.0 → hone_python-0.12.0}/hone/result.py +12 -5
  24. {hone_python-0.11.0 → hone_python-0.12.0}/pyproject.toml +1 -1
  25. hone_python-0.11.0/hone/optimizers/__init__.py +0 -6
  26. {hone_python-0.11.0 → hone_python-0.12.0}/LICENSE +0 -0
  27. {hone_python-0.11.0 → hone_python-0.12.0}/hone/benchmarks/conditional.py +0 -0
  28. {hone_python-0.11.0 → hone_python-0.12.0}/hone/benchmarks/constrained.py +0 -0
  29. {hone_python-0.11.0 → hone_python-0.12.0}/hone/benchmarks/ml.py +0 -0
  30. {hone_python-0.11.0 → hone_python-0.12.0}/hone/benchmarks/problems.py +0 -0
  31. {hone_python-0.11.0 → hone_python-0.12.0}/hone/benchmarks/runner.py +0 -0
  32. {hone_python-0.11.0 → hone_python-0.12.0}/hone/config/bayesian_config.py +0 -0
  33. {hone_python-0.11.0 → hone_python-0.12.0}/hone/config/cmaes_config.py +0 -0
  34. {hone_python-0.11.0 → hone_python-0.12.0}/hone/config/genetic_optimizer_config.py +0 -0
  35. {hone_python-0.11.0 → hone_python-0.12.0}/hone/config/optimizer_config.py +0 -0
  36. {hone_python-0.11.0 → hone_python-0.12.0}/hone/objective_function/__init__.py +0 -0
  37. {hone_python-0.11.0 → hone_python-0.12.0}/hone/optimizers/_pool.py +0 -0
  38. {hone_python-0.11.0 → hone_python-0.12.0}/hone/optimizers/cmaes.py +0 -0
  39. {hone_python-0.11.0 → hone_python-0.12.0}/hone/optimizers/genetic/selection.py +0 -0
  40. {hone_python-0.11.0 → hone_python-0.12.0}/hone/optimizers/genetic/variation.py +0 -0
  41. {hone_python-0.11.0 → hone_python-0.12.0}/hone/optimizers/random_search.py +0 -0
  42. {hone_python-0.11.0 → hone_python-0.12.0}/hone/parameters/__init__.py +0 -0
  43. {hone_python-0.11.0 → hone_python-0.12.0}/hone/parameters/conditions.py +0 -0
  44. {hone_python-0.11.0 → hone_python-0.12.0}/hone/parameters/constraints.py +0 -0
  45. {hone_python-0.11.0 → hone_python-0.12.0}/hone/parameters/parameters.py +0 -0
  46. {hone_python-0.11.0 → hone_python-0.12.0}/hone/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hone-python
3
- Version: 0.11.0
3
+ Version: 0.12.0
4
4
  Summary: A python-based optimization engine/library.
5
5
  License-Expression: BSD-3-Clause
6
6
  License-File: LICENSE
@@ -338,6 +338,45 @@ Other settings, such as `seed`, `maximize`, `noise` or `threshold`, are passed o
338
338
 
339
339
  All four take the same arguments and support `optimize()`, `ask()` and `tell()`. A new optimizer subclasses `Optimizer` and implements `_next_population`, which returns each generation's individuals; the base class handles handing out candidates, recording results and failures, tracking the best result, stopping and the `Result`.
340
340
 
341
+ ### Several objectives
342
+
343
+ When a design is judged on more than one thing, such as accuracy and cost, or mass and stiffness, a weighted sum forces you to price one against the other before seeing what the trade-off looks like, and some trade-offs no weighting can reach. Name each objective and its direction instead, and have the objective function return a dict of them. The run returns the **front**: every design found for which no other is at least as good on every objective and better on one. You choose from it afterwards.
344
+
345
+ ```python
346
+ from hone import NSGA2, NSGA2Config
347
+
348
+ config = NSGA2Config(objectives={"accuracy": "maximize", "cost": "minimize"}, max_evaluations=2000, seed=0)
349
+
350
+ def train(**params):
351
+ ...
352
+ return {"accuracy": accuracy, "cost": cost}
353
+
354
+ result = NSGA2(search_space, config).optimize(train)
355
+ choice = result.front.best("accuracy", where={"cost": 20}) # the most accurate design costing at most 20
356
+ print(choice.params, choice.values)
357
+ ```
358
+
359
+ `optimize()` returns a `ParetoResult`, whose `front` holds `ParetoPoint`s, each with its `params` and `values`. To choose from it:
360
+
361
+ | Method | Returns |
362
+ | --- | --- |
363
+ | `front.best(objective, where={...})` | The best point on one objective, with the others at most (or, for those maximized, at least) the limits given |
364
+ | `front.closest(weights)` | The point nearest the ideal, by augmented Chebyshev distance on objectives scaled from the front's best value of each to its worst. Unlike a weighted sum it can pick any point, including one in a dent in the front. Weights default to equal |
365
+ | `front.ideal`, `front.nadir` | The best and the worst value of each objective on the front |
366
+ | `front.hypervolume(reference)` | The region the front dominates, up to a reference point: one number that grows as the front gets closer and wider |
367
+
368
+ | Optimizer | Config | Approach |
369
+ | --- | --- | --- |
370
+ | `MultiObjectiveBayesian` | `MultiObjectiveBayesianConfig` | Each candidate draws random weights for the objectives and goes where a Gaussian process expects the most improvement in their weighted combination. The first choice for 200 evaluations or fewer. `method="parego"`, the default, models the combination; `method="models"` models each objective, which did better on three objectives at 20 evaluations per dimension and costs a few times more computation per candidate. Supports range and choice parameters |
371
+ | `NSGA2` | `NSGA2Config` | A genetic algorithm that ranks the population by fronts and spreads it along them. The choice for larger budgets; breeds as the genetic optimizer does, so it handles every kind of parameter |
372
+ | `MultiObjectiveRandomSearch` | `MultiObjectiveConfig` | Evaluates random points; useful as a baseline |
373
+
374
+ `choose_pareto_optimizer(search_space, objectives, max_evaluations)` picks `MultiObjectiveBayesian` up to 200 evaluations, unless a choice parameter has `choose_n`, and `NSGA2` otherwise, as the benchmark suggests; other settings are passed on to the chosen optimizer's config. On it, Bayesian optimization's median front beats NSGA2's on 12 of the 13 problem and budget pairs both run on and don't tie.
375
+
376
+ Everything else works as with one objective: constraints, conditions, workers and time limits, failed evaluations, checkpoints, `ask()` and `tell(trial, {...})`, starting points, `save()`, `load()` and `rebuild_optimizer()`. With `noise=True`, each point on the front is an average, with its number of evaluations and the `standard_error` of each objective. `print_progress` prints the size of the front and its hypervolume. A dict with missing or extra keys, or a value that isn't a number, raises `TypeError`; `maximize`, `threshold` and `final_evaluations` don't apply.
377
+
378
+ [examples/cantilever_beam.py](examples/cantilever_beam.py) designs a beam in steel, aluminium or carbon fibre that is light, cheap and stiff, three objectives, under a stress limit that depends on the material, and chooses the stiffest design under a mass and a cost limit. Tuning for more than three objectives is out of scope for now: with many objectives nearly every design is on the front, and the search loses its pull.
379
+
341
380
  ### Benchmarks
342
381
 
343
382
  `hone.benchmarks` runs optimizers on test problems with known optima and reports how close each one gets:
@@ -346,6 +385,7 @@ All four take the same arguments and support `optimize()`, `ask()` and `tell()`.
346
385
  python -m hone.benchmarks # full suite: 36 problems, 10 seeds each, five budgets
347
386
  python -m hone.benchmarks --quick # 6 problems, 5 seeds, three budgets; takes seconds
348
387
  python -m hone.benchmarks --budgets 10 20 # only the budgets you name, in evaluations per dimension
388
+ python -m hone.benchmarks --multi # several objectives: 7 problems, scored by hypervolume gap
349
389
  ```
350
390
 
351
391
  The suite has five standard continuous functions (sphere, ellipsoid, Rosenbrock, Rastrigin and Ackley) in 2, 5 and 10 dimensions, rotated versions of four of them in which the variables interact, and integer, mixed and categorical problems: 36 in all. Each function is shifted so its optimum is away from the centre of the search space. Every optimizer gets exactly the same number of evaluations. Each problem runs at five budgets, 10, 20, 50, 100 and 1,000 evaluations per dimension, because the best optimizer for a slow simulation that allows a few dozen runs is often not the best one for a cheap function evaluated thousands of times. Latest results are in [benchmarks/results.md](benchmarks/results.md).
@@ -394,11 +434,38 @@ Requires Python 3.12 or later and [Poetry](https://python-poetry.org/) 2.
394
434
  | --- | --- |
395
435
  | `make test` | Install the dependencies and run the tests with coverage |
396
436
  | `make lint` | Run ruff, then mypy to check types |
397
- | `make docker-test` | Build the Docker image and run the tests inside it |
437
+ | `make docker-test` | Build the Docker image and run the tests inside it (see [Running in Docker](#running-in-docker)) |
398
438
  | `make benchmark` | Run the full benchmark suite and update `benchmarks/results.md` |
399
439
  | `make benchmark-noisy` | Run the noisy problems and update `benchmarks/noisy-results.md` |
400
440
  | `make benchmark-ml` | Run the machine learning tuning problems and update `benchmarks/ml-results.md` |
401
441
  | `make benchmark-constrained` | Run the constrained problems and update `benchmarks/constrained-results.md` |
442
+ | `make benchmark-conditional` | Run the conditional problems and update `benchmarks/conditional-results.md` |
443
+ | `make benchmark-multi` | Run the multi-objective problems and update `benchmarks/multi-results.md` |
444
+
445
+ ### Running in Docker
446
+
447
+ With [Docker](https://docs.docker.com/get-docker/) installed you can run hone without Python or Poetry on your machine. The image holds hone with its development dependencies, the tests, the examples and the saved benchmark summaries, on Python 3.14.
448
+
449
+ ```sh
450
+ make docker-build # build the image, tagged hone
451
+ make docker-test # run the tests in it
452
+ make docker-shell # a shell in it, with hone installed
453
+ docker run --rm hone python examples/pressure_vessel.py
454
+ ```
455
+
456
+ To run a script of your own, mount its folder and run it from there:
457
+
458
+ ```sh
459
+ docker run --rm -v "$PWD:/work" -w /work hone python my_search.py
460
+ ```
461
+
462
+ To run a benchmark and keep its results, mount the `benchmarks` folder so the files it writes land in your copy:
463
+
464
+ ```sh
465
+ docker run --rm -v "$PWD/benchmarks:/src/benchmarks" hone python -m hone.benchmarks --quick --markdown benchmarks/quick-results.md
466
+ ```
467
+
468
+ Rebuild the image after changing hone's code; changing only the code reuses the cached dependency layer, so it takes seconds.
402
469
 
403
470
  To release, raise `version` in `pyproject.toml` and add a section for it to `CHANGELOG.md`. Once the change is on `main` and its checks pass, CI tags the version, publishes a GitHub release with that section as its notes and the built package attached, and uploads the same package to PyPI as `hone-python`.
404
471
 
@@ -317,6 +317,45 @@ Other settings, such as `seed`, `maximize`, `noise` or `threshold`, are passed o
317
317
 
318
318
  All four take the same arguments and support `optimize()`, `ask()` and `tell()`. A new optimizer subclasses `Optimizer` and implements `_next_population`, which returns each generation's individuals; the base class handles handing out candidates, recording results and failures, tracking the best result, stopping and the `Result`.
319
319
 
320
+ ### Several objectives
321
+
322
+ When a design is judged on more than one thing, such as accuracy and cost, or mass and stiffness, a weighted sum forces you to price one against the other before seeing what the trade-off looks like, and some trade-offs no weighting can reach. Name each objective and its direction instead, and have the objective function return a dict of them. The run returns the **front**: every design found for which no other is at least as good on every objective and better on one. You choose from it afterwards.
323
+
324
+ ```python
325
+ from hone import NSGA2, NSGA2Config
326
+
327
+ config = NSGA2Config(objectives={"accuracy": "maximize", "cost": "minimize"}, max_evaluations=2000, seed=0)
328
+
329
+ def train(**params):
330
+ ...
331
+ return {"accuracy": accuracy, "cost": cost}
332
+
333
+ result = NSGA2(search_space, config).optimize(train)
334
+ choice = result.front.best("accuracy", where={"cost": 20}) # the most accurate design costing at most 20
335
+ print(choice.params, choice.values)
336
+ ```
337
+
338
+ `optimize()` returns a `ParetoResult`, whose `front` holds `ParetoPoint`s, each with its `params` and `values`. To choose from it:
339
+
340
+ | Method | Returns |
341
+ | --- | --- |
342
+ | `front.best(objective, where={...})` | The best point on one objective, with the others at most (or, for those maximized, at least) the limits given |
343
+ | `front.closest(weights)` | The point nearest the ideal, by augmented Chebyshev distance on objectives scaled from the front's best value of each to its worst. Unlike a weighted sum it can pick any point, including one in a dent in the front. Weights default to equal |
344
+ | `front.ideal`, `front.nadir` | The best and the worst value of each objective on the front |
345
+ | `front.hypervolume(reference)` | The region the front dominates, up to a reference point: one number that grows as the front gets closer and wider |
346
+
347
+ | Optimizer | Config | Approach |
348
+ | --- | --- | --- |
349
+ | `MultiObjectiveBayesian` | `MultiObjectiveBayesianConfig` | Each candidate draws random weights for the objectives and goes where a Gaussian process expects the most improvement in their weighted combination. The first choice for 200 evaluations or fewer. `method="parego"`, the default, models the combination; `method="models"` models each objective, which did better on three objectives at 20 evaluations per dimension and costs a few times more computation per candidate. Supports range and choice parameters |
350
+ | `NSGA2` | `NSGA2Config` | A genetic algorithm that ranks the population by fronts and spreads it along them. The choice for larger budgets; breeds as the genetic optimizer does, so it handles every kind of parameter |
351
+ | `MultiObjectiveRandomSearch` | `MultiObjectiveConfig` | Evaluates random points; useful as a baseline |
352
+
353
+ `choose_pareto_optimizer(search_space, objectives, max_evaluations)` picks `MultiObjectiveBayesian` up to 200 evaluations, unless a choice parameter has `choose_n`, and `NSGA2` otherwise, as the benchmark suggests; other settings are passed on to the chosen optimizer's config. On it, Bayesian optimization's median front beats NSGA2's on 12 of the 13 problem and budget pairs both run on and don't tie.
354
+
355
+ Everything else works as with one objective: constraints, conditions, workers and time limits, failed evaluations, checkpoints, `ask()` and `tell(trial, {...})`, starting points, `save()`, `load()` and `rebuild_optimizer()`. With `noise=True`, each point on the front is an average, with its number of evaluations and the `standard_error` of each objective. `print_progress` prints the size of the front and its hypervolume. A dict with missing or extra keys, or a value that isn't a number, raises `TypeError`; `maximize`, `threshold` and `final_evaluations` don't apply.
356
+
357
+ [examples/cantilever_beam.py](examples/cantilever_beam.py) designs a beam in steel, aluminium or carbon fibre that is light, cheap and stiff, three objectives, under a stress limit that depends on the material, and chooses the stiffest design under a mass and a cost limit. Tuning for more than three objectives is out of scope for now: with many objectives nearly every design is on the front, and the search loses its pull.
358
+
320
359
  ### Benchmarks
321
360
 
322
361
  `hone.benchmarks` runs optimizers on test problems with known optima and reports how close each one gets:
@@ -325,6 +364,7 @@ All four take the same arguments and support `optimize()`, `ask()` and `tell()`.
325
364
  python -m hone.benchmarks # full suite: 36 problems, 10 seeds each, five budgets
326
365
  python -m hone.benchmarks --quick # 6 problems, 5 seeds, three budgets; takes seconds
327
366
  python -m hone.benchmarks --budgets 10 20 # only the budgets you name, in evaluations per dimension
367
+ python -m hone.benchmarks --multi # several objectives: 7 problems, scored by hypervolume gap
328
368
  ```
329
369
 
330
370
  The suite has five standard continuous functions (sphere, ellipsoid, Rosenbrock, Rastrigin and Ackley) in 2, 5 and 10 dimensions, rotated versions of four of them in which the variables interact, and integer, mixed and categorical problems: 36 in all. Each function is shifted so its optimum is away from the centre of the search space. Every optimizer gets exactly the same number of evaluations. Each problem runs at five budgets, 10, 20, 50, 100 and 1,000 evaluations per dimension, because the best optimizer for a slow simulation that allows a few dozen runs is often not the best one for a cheap function evaluated thousands of times. Latest results are in [benchmarks/results.md](benchmarks/results.md).
@@ -373,11 +413,38 @@ Requires Python 3.12 or later and [Poetry](https://python-poetry.org/) 2.
373
413
  | --- | --- |
374
414
  | `make test` | Install the dependencies and run the tests with coverage |
375
415
  | `make lint` | Run ruff, then mypy to check types |
376
- | `make docker-test` | Build the Docker image and run the tests inside it |
416
+ | `make docker-test` | Build the Docker image and run the tests inside it (see [Running in Docker](#running-in-docker)) |
377
417
  | `make benchmark` | Run the full benchmark suite and update `benchmarks/results.md` |
378
418
  | `make benchmark-noisy` | Run the noisy problems and update `benchmarks/noisy-results.md` |
379
419
  | `make benchmark-ml` | Run the machine learning tuning problems and update `benchmarks/ml-results.md` |
380
420
  | `make benchmark-constrained` | Run the constrained problems and update `benchmarks/constrained-results.md` |
421
+ | `make benchmark-conditional` | Run the conditional problems and update `benchmarks/conditional-results.md` |
422
+ | `make benchmark-multi` | Run the multi-objective problems and update `benchmarks/multi-results.md` |
423
+
424
+ ### Running in Docker
425
+
426
+ With [Docker](https://docs.docker.com/get-docker/) installed you can run hone without Python or Poetry on your machine. The image holds hone with its development dependencies, the tests, the examples and the saved benchmark summaries, on Python 3.14.
427
+
428
+ ```sh
429
+ make docker-build # build the image, tagged hone
430
+ make docker-test # run the tests in it
431
+ make docker-shell # a shell in it, with hone installed
432
+ docker run --rm hone python examples/pressure_vessel.py
433
+ ```
434
+
435
+ To run a script of your own, mount its folder and run it from there:
436
+
437
+ ```sh
438
+ docker run --rm -v "$PWD:/work" -w /work hone python my_search.py
439
+ ```
440
+
441
+ To run a benchmark and keep its results, mount the `benchmarks` folder so the files it writes land in your copy:
442
+
443
+ ```sh
444
+ docker run --rm -v "$PWD/benchmarks:/src/benchmarks" hone python -m hone.benchmarks --quick --markdown benchmarks/quick-results.md
445
+ ```
446
+
447
+ Rebuild the image after changing hone's code; changing only the code reuses the cached dependency layer, so it takes seconds.
381
448
 
382
449
  To release, raise `version` in `pyproject.toml` and add a section for it to `CHANGELOG.md`. Once the change is on `main` and its checks pass, CI tags the version, publishes a GitHub release with that section as its notes and the built package attached, and uploads the same package to PyPI as `hone-python`.
383
450
 
@@ -1,34 +1,55 @@
1
- from hone.config import BayesianConfig, CMAESConfig, GeneticOptimizerConfig, OptimizerConfig, SelectionMethod
1
+ from hone.config import BayesianConfig, CMAESConfig, GeneticOptimizerConfig, MultiObjectiveBayesianConfig, MultiObjectiveConfig, NSGA2Config, OptimizerConfig, SelectionMethod
2
2
  from hone.optimizers import (
3
3
  CMAES,
4
4
  BayesianOptimizer,
5
5
  EvaluationFailed,
6
6
  GeneticOptimizer,
7
+ MultiObjectiveBayesian,
8
+ MultiObjectiveOptimizer,
9
+ MultiObjectiveRandomSearch,
10
+ NSGA2,
7
11
  Optimizer,
8
12
  RandomSearch,
9
13
  Trial,
10
14
  UnsupportedSearchSpace,
11
15
  choose_optimizer,
16
+ choose_pareto_optimizer,
12
17
  )
13
18
  from hone.parameters import ChoiceParameter, Condition, Constraint, FixedParameter, InfeasibleSearchSpace, RangeParameter, SearchSpace
19
+ from hone.pareto import Front, ParetoGenerationStats, ParetoPoint, ParetoProgress, ParetoResult
14
20
  from hone.result import GenerationStats, Progress, Result, RunInfo, print_progress
15
21
 
16
22
  __all__ = [
17
23
  "BayesianConfig",
18
24
  "BayesianOptimizer",
25
+ "ChoiceParameter",
26
+ "choose_optimizer",
27
+ "choose_pareto_optimizer",
19
28
  "CMAES",
20
29
  "CMAESConfig",
21
- "ChoiceParameter",
22
30
  "Condition",
23
31
  "Constraint",
24
32
  "EvaluationFailed",
25
33
  "FixedParameter",
34
+ "Front",
26
35
  "GenerationStats",
27
36
  "GeneticOptimizer",
28
37
  "GeneticOptimizerConfig",
29
38
  "InfeasibleSearchSpace",
39
+ "MultiObjectiveBayesian",
40
+ "MultiObjectiveBayesianConfig",
41
+ "MultiObjectiveConfig",
42
+ "MultiObjectiveOptimizer",
43
+ "MultiObjectiveRandomSearch",
44
+ "NSGA2",
45
+ "NSGA2Config",
30
46
  "Optimizer",
31
47
  "OptimizerConfig",
48
+ "ParetoGenerationStats",
49
+ "ParetoPoint",
50
+ "ParetoProgress",
51
+ "ParetoResult",
52
+ "print_progress",
32
53
  "Progress",
33
54
  "RandomSearch",
34
55
  "RangeParameter",
@@ -38,6 +59,4 @@ __all__ = [
38
59
  "SelectionMethod",
39
60
  "Trial",
40
61
  "UnsupportedSearchSpace",
41
- "choose_optimizer",
42
- "print_progress",
43
62
  ]
@@ -2,6 +2,7 @@
2
2
  from .conditional import conditional_problems
3
3
  from .constrained import constrained_problems
4
4
  from .ml import ml_problems
5
+ from .multi import MultiProblem, multi_problems, run_multi_benchmark, summarize_multi
5
6
  from .problems import Problem, noisy_problems, quick_problems, standard_problems
6
7
  from .runner import (
7
8
  BUDGETS,
@@ -7,6 +7,7 @@ from importlib.metadata import version
7
7
 
8
8
  from . import ml
9
9
  from .conditional import conditional_problems
10
+ from .multi import multi_markdown, multi_problems, run_multi_benchmark, summarize_multi
10
11
  from .constrained import constrained_problems
11
12
  from .problems import noisy_problems, quick_problems, standard_problems
12
13
  from .runner import BUDGETS, load_summaries, regressions, run_benchmark, save_summaries, summarize, to_markdown
@@ -29,6 +30,9 @@ def main(argv: list[str] | None = None) -> int:
29
30
  suite.add_argument("--ml", action="store_true", help="run the machine learning tuning problems instead (needs scikit-learn)")
30
31
  suite.add_argument("--noisy", action="store_true", help="run the problems with noise added to every evaluation instead")
31
32
  suite.add_argument("--constrained", action="store_true", help="run the problems with constraints instead")
33
+ suite.add_argument(
34
+ "--multi", action="store_true", help="run the problems with several objectives instead, scored by hypervolume"
35
+ )
32
36
  suite.add_argument(
33
37
  "--conditional", action="store_true", help="run the problems with conditional parameters, and their flat versions, instead"
34
38
  )
@@ -48,6 +52,8 @@ def main(argv: list[str] | None = None) -> int:
48
52
  parser.add_argument("--baseline", help="compare against summaries saved with --save; exit 1 on a regression")
49
53
  args = parser.parse_args(argv)
50
54
 
55
+ if args.multi:
56
+ return _multi(args)
51
57
  default_budgets: Sequence[int]
52
58
  if args.quick:
53
59
  problems, default_budgets = quick_problems(), QUICK_BUDGETS
@@ -90,5 +96,26 @@ def main(argv: list[str] | None = None) -> int:
90
96
  return 0
91
97
 
92
98
 
99
+ def _multi(args: argparse.Namespace) -> int:
100
+ """The multi-objective suite: its own runs, scored by hypervolume gap."""
101
+ problems = multi_problems()
102
+ seeds = args.seeds or 10
103
+ budgets = sorted(set(args.budgets or BUDGETS))
104
+ start = time.perf_counter()
105
+ summaries = summarize_multi(run_multi_benchmark(problems, seeds=range(seeds), budgets_per_dimension=budgets, jobs=args.jobs))
106
+ elapsed = time.perf_counter() - start
107
+ table = multi_markdown(summaries)
108
+ print(table)
109
+ setup = f"{len(problems)} problems, {seeds} seeds, budgets of {_join(budgets)} evaluations per dimension"
110
+ print(f"{setup}, in {elapsed:.0f}s")
111
+ if args.markdown:
112
+ with open(args.markdown, "w") as f:
113
+ f.write(f"# Multi-objective benchmark results\n\nGenerated by `python -m hone.benchmarks --multi` with hone {version('hone-python')}: {setup}.\n\n{table}")
114
+ if args.save:
115
+ with open(args.save, "w") as f:
116
+ f.write("[\n" + ",\n".join(s.model_dump_json() for s in summaries) + "\n]\n")
117
+ return 0
118
+
119
+
93
120
  if __name__ == "__main__":
94
121
  sys.exit(main())