estim8.optimizers#

This submodule implements the optimization of an objective function using various optimization algorithms.

class estim8.optimizers.Optimization(objective: Objective | Callable, method: str | List[str], bounds: dict, optimizer_kwargs: dict = {}, use_parallel=True, task_id: str = 'estimate')#

Bases: object

Class that manages the optimization of an objective function.

Methods

get_optimization_method(method)

Get the optimization method.

optimize()

Optimize the objective function.

optimize_pygmo_archi(objective, bounds, ...)

Optimize the objective function using a pygmo archipelago.

optimize_pygmo_archipelago_continued(_, ...)

Continue optimizing the objective function using a pygmo archipelago object.

prepare_optimizer_kwargs(method, ...)

Prepare the optimizer keyword arguments.

static get_optimization_method(method: str | List[str]) Callable#

Get the optimization method.

Parameters:
methodstr | List[str]

The optimization method(s).

Returns:
callable

The optimization function.

Raises:
KeyError

If the method is not supported.

NotImplementedError

If the method is not implemented.

optimization_funcs = {'bh': <function basinhopping>, 'de': <function differential_evolution>, 'dual_annealing': <function dual_annealing>, 'gp': <function gp_minimize>, 'local': <function minimize>, 'shgo': <function shgo>}#
optimize()#

Optimize the objective function.

Returns:
tuple

The optimization result and additional information.

static optimize_pygmo_archi(objective: ~typing.Callable, bounds: dict, algos: ~typing.List[str], algos_kwargs: ~typing.List[dict], n_processes: int = 2, pop_size=50, topology=<pygmo.core.unconnected object>, max_iter: int = 10, report: int = 0, init_pool: bool = True) Tuple[dict, PygmoEstimationInfo]#

Optimize the objective function using a pygmo archipelago.

Parameters:
objectivecallable

The objective function to be optimized.

boundsdict

The bounds for the parameters.

algosList[str]

The optimization algorithms to be used.

algos_kwargsList[dict]

The keyword arguments for the optimization algorithms.

n_processesint, optional

The number of processes to use, by default joblib.cpu_count().

pop_sizeint, optional

The population size, by default 50.

topologypygmo.topology, optional

The topology of the archipelago, by default pygmo.unconnected().

max_iterint, optional

The number of evolutions, by default 10.

report: int, optional

The report level during optimization, by default 0. A report level of 1 yields data on the archipelago’s island champions over evolutions. With a report level of 2 the islands current states are printed in the Log.

Returns:
Tuple[dict, generalized_islands.PygmoEstimationInfo]

The optimization result and additional information.

static optimize_pygmo_archipelago_continued(_, estimation_info: PygmoEstimationInfo, max_iter: int = 10) Tuple[dict, PygmoEstimationInfo]#

Continue optimizing the objective function using a pygmo archipelago object.

Parameters:
estimation_infogeneralized_islands.PygmoEstimationInfo

The estimation information and the archipelago itself before evolution(s).

max_iterint, optional

The number of evolutions, by default 10.

Returns:
Tuple[dict, generalized_islands.PygmoEstimationInfo]

The optimization result and additional information.

prepare_optimizer_kwargs(method, optimizer_kwargs)#

Prepare the optimizer keyword arguments.

Parameters:
methodstr | List[str]

The optimization method(s).

optimizer_kwargsdict

The optimizer keyword arguments.

Returns:
dict

The prepared optimizer keyword arguments.

Raises:
ValueError

If the list of algorithms doesn’t match the list of algorithm kwargs.

pygmo_algos = {'bee_colony', 'cmaes', 'compass_search', 'de', 'de1220', 'gaco', 'gwo', 'ihs', 'mbh', 'nsga2', 'pso', 'scipy_optimize', 'sea', 'sga', 'simulated_annealing', 'xnes'}#