Skip to content

hone

hone is a Python optimization engine. It finds the parameters that minimize or maximize a function you give it, and is built for functions that are slow, noisy or constrained: simulations, physical tests and model training.

Install

pip install hone-python

It needs Python 3.12 or later. The package is named hone-python because hone is taken on PyPI; in code it is still import hone.

Quickstart

from hone import GeneticOptimizer, GeneticOptimizerConfig, RangeParameter


def objective_function(x, y):
    return x**2 + y**2


# Each parameter of the objective function is declared with the values it may take.
x = RangeParameter("x", -5, 5)
y = RangeParameter("y", -5, 5)

optimizer = GeneticOptimizer(search_space=[x, y], config=GeneticOptimizerConfig(threshold=0.01, seed=0))
result = optimizer.optimize(objective_function)
print(result.best_fitness, result.best_params)

The optimizer minimizes by default; set maximize=True in the config to maximize instead.

Where next

  • Running an optimization: parallel and remote evaluations, progress, checkpoints, failures and noise.
  • Search spaces: parameters, constraints, conditional parameters and starting points.
  • Choosing an optimizer: which optimizer suits which problem, and how to configure it.
  • Examples: complete scripts for engineering design and model tuning.
  • API reference: every class and function, generated from the code.