Results¶
One objective¶
Result
pydantic-model
¶
Bases: BaseModel
Outcome of an optimization run. Save it with save() and read it back with load().
Two results are equal when they found the same things; their run records are not compared, since a repeated run differs in its timing.
Config:
frozen:True
Fields:
-
best_fitness(float) -
best_params(dict[str, Any]) -
generations(list[GenerationStats]) -
evaluations(int) -
failures(int) -
reached_threshold(bool) -
stopped(bool) -
run(RunInfo | None)
rebuild_optimizer
¶
rebuild_optimizer(optimizer_class: type[Optimizer] | None = None, *, functions: dict[str, Callable[..., float]] | None = None) -> Optimizer
A new optimizer set up exactly as this result's was, to repeat or extend the run.
Running it gives the same result, given the same objective and, for CMA-ES and Bayesian optimization, the same number of workers (run.workers). An optimizer that isn't one of hone's own is rebuilt by passing its class.
A constraint made with Constraint.function isn't saved with a result: after loading one, pass each such constraint's function by name, as functions={"stress": stress}.
GenerationStats
pydantic-model
¶
Bases: BaseModel
Summary of one generation's fitness, over its successful evaluations.
The fitness fields are None when every evaluation in the generation failed.
Config:
frozen:True
Fields:
-
generation(int) -
evaluations(int) -
failures(int) -
best_fitness(float | None) -
best_params(dict[str, Any] | None) -
worst_fitness(float | None) -
mean(float | None) -
median(float | None) -
std(float | None)
Progress
pydantic-model
¶
Bases: BaseModel
What optimize() passes its callback after each generation.
Config:
frozen:True
Fields:
-
generation(GenerationStats) -
evaluations(int) -
best_fitness(float | None) -
best_params(dict[str, Any] | None) -
elapsed(float)
RunInfo
pydantic-model
¶
Bases: BaseModel
How a result was produced: enough to repeat the run, and to tell runs apart later.
Config:
frozen:True
Fields:
-
optimizer(str) -
config(dict[str, Any]) -
search_space(SearchSpace) -
initial_points(list[dict[str, Any]]) -
objective(str | None) -
workers(int | None) -
timeout(float | None) -
hone_version(str) -
python_version(str) -
numpy_version(str) -
started_at(datetime | None) -
elapsed(float | None)
print_progress
¶
print_progress(progress: Any) -> None
A ready-made optimize() callback: print one line per generation.
For several objectives, the line gives the size of the front and its hypervolume.
Several objectives¶
ParetoResult
pydantic-model
¶
Bases: BaseModel
Outcome of a multi-objective run: the front of everything evaluated. Save it with save() and read it back with load().
Two results are equal when they found the same things; their run records are not compared.
Config:
frozen:True
Fields:
-
front(Front) -
generations(list[ParetoGenerationStats]) -
evaluations(int) -
failures(int) -
stopped(bool) -
run(RunInfo | None)
rebuild_optimizer
¶
rebuild_optimizer(optimizer_class: type[MultiObjectiveOptimizer] | None = None, *, functions: dict[str, Callable[..., float]] | None = None) -> MultiObjectiveOptimizer
A new optimizer set up exactly as this result's was, to repeat or extend the run.
As with Result.rebuild_optimizer: pass the class of an optimizer that isn't one of hone's own, and the functions of any function constraints, by name.
Front
pydantic-model
¶
Bases: BaseModel
The best trade-offs found: no point on the front is beaten on every objective by any point evaluated.
Points are in order of the first objective, best first. Choose among them with best(), for the best value of one objective within limits on the others, or closest(), for the most balanced point.
Config:
frozen:True
Fields:
-
objectives(dict[str, Direction]) -
points(list[ParetoPoint])
ideal
property
¶
ideal: dict[str, float]
The best value of each objective on the front, each from its own point.
best
¶
best(objective: str, where: dict[str, float] | None = None) -> ParetoPoint
The point with the best value of objective, among those within the limits in where.
A limit is a bound on another objective in its own direction: at most the limit for an objective to minimize, at least it for one to maximize. front.best("accuracy", where={"cost": 20}) is the most accurate point costing at most 20.
closest
¶
closest(weights: dict[str, float] | None = None) -> ParetoPoint
The point closest to the ideal by augmented Chebyshev distance, on the front's own scale.
Each objective is scaled so 0 is its best value on the front and 1 its worst, then a point's distance is its largest weighted scaled gap from the ideal, plus a twentieth of their sum to break ties. Unlike a weighted sum, this can pick any point on the front, including those in a dent of it. Weights default to 1 each; give an objective more weight to count its gap for more.
hypervolume
¶
hypervolume(reference: dict[str, float]) -> float
The size of the region of objective space the front dominates, up to the reference point.
The reference gives a value of each objective worse than any point that should count. A better front always has a larger hypervolume.
ParetoPoint
pydantic-model
¶
Bases: BaseModel
A point on the front: its parameters and the value of each objective there.
Config:
frozen:True
Fields:
-
params(dict[str, Any]) -
values(dict[str, float]) -
evaluations(int) -
standard_error(dict[str, float] | None)
ParetoGenerationStats
pydantic-model
¶
Bases: BaseModel
Summary of one generation of a multi-objective run.
Config:
frozen:True
Fields:
-
generation(int) -
evaluations(int) -
failures(int) -
front_size(int) -
hypervolume(float | None)
ParetoProgress
pydantic-model
¶
Bases: BaseModel
What a multi-objective optimizer's optimize() passes its callback after each generation.
Config:
frozen:True
Fields:
-
generation(ParetoGenerationStats) -
evaluations(int) -
front(Front) -
elapsed(float)