optilab.optimizers package
Submodules
optilab.optimizers.cma_es module
CMA-ES optimizer: Covariance Matrix Adaptation Evolution Strategy.
- class CmaEs(population_size: int, sigma0: float)[source]
Bases:
OptimizerCMA-ES optimizer: Covariance Matrix Adaptation Evolution Strategy.
- __init__(population_size: int, sigma0: float)[source]
Class constructor.
- Parameters:
population_size – Size of the population.
sigma0 – Starting value of the sigma,
- static _stop_internal(es: CMAEvolutionStrategy) bool[source]
Check an instance of CMA-ES optimizer for internal stop criteria.
- Parameters:
es – An instance of CMA-ES optimizer.
- Returns:
- If true, the internal stop criteria of CMA-ES have been reached and optimization
should be ended.
- static _spawn_cmaes(bounds: Bounds, dim: int, population_size: int, sigma0: float) CMAEvolutionStrategy[source]
Create a new instance of cma optimizer.
- Parameters:
bounds – The bounds of the search area.
dim – The dimensionality of the search area.
- Returns:
A new cma optimizer instance.
- _stop(es: CMAEvolutionStrategy, log: PointList, population_size: int, call_budget: int, target: float, tolerance: float) bool[source]
Decide if the optimization should be stopped.
- Parameters:
es – CMA-ES instance.
log – Results log.
population_size – The size of the population in one generation.
call_budget – Maximum number of optimized function calls.
target – Global minimum value of the optimized function.
tolerance – Tolerated error value of the optimization.
- Returns:
True if the optimization should be stopped.
- optimize(function: ObjectiveFunction, bounds: Bounds, call_budget: int, tolerance: float, target: float = 0.0) PointList[source]
Run a single optimization of provided objective function.
- Parameters:
function – Objective function to optimize.
bounds – Search space of the function.
call_budget – Max number of calls to the objective function.
tolerance – Tolerance of y value to count a solution as acceptable.
target – Objective function value target, default 0.
- Returns:
Results log from the optimization.
optilab.optimizers.ipop_cma_es module
IPOP-CMA-ES optimizer: CMA-ES with increasing population restarts.
- class IpopCmaEs(population_size: int)[source]
Bases:
CmaEsIPOP-CMA-ES optimizer: CMA-ES with increasing population restarts.
- optimize(function: ObjectiveFunction, bounds: Bounds, call_budget: int, tolerance: float, target: float = 0.0) PointList[source]
Run a single optimization of provided objective function.
- Parameters:
function – Objective function to optimize.
bounds – Search space of the function.
call_budget – Max number of calls to the objective function.
tolerance – Tolerance of y value to count a solution as acceptable.
target – Objective function value target, default 0.
- Returns:
Results log from the optimization.
optilab.optimizers.knn_cma_es module
KNN-CMA-ES optimizer. CMA-ES is enhanced with a KNN metamodel similar to the one from LMM-CMA-ES.
- class KnnCmaEs(population_size: int, sigma0: float, num_neighbors: int, buffer_size: int)[source]
Bases:
CmaEsKNN-CMA-ES optimizer. CMA-ES is enhanced with a KNN metamodel similar to the one from LMM-CMA-ES.
- __init__(population_size: int, sigma0: float, num_neighbors: int, buffer_size: int)[source]
Class constructor.
- Parameters:
population_size – Size of the population.
sigma0 – Starting value of the sigma,
num_neighbors – Number of neighbors used by KNN metamodel.
buffer_size – Number of last evaluated points provided to KNN metamodel.
- optimize(function: ObjectiveFunction, bounds: Bounds, call_budget: int, tolerance: float, target: float = 0.0) PointList[source]
Run a single optimization of provided objective function.
- Parameters:
function – Objective function to optimize.
bounds – Search space of the function.
call_budget – Max number of calls to the objective function.
tolerance – Tolerance of y value to count a solution as acceptable.
target – Objective function value target, default 0.
- Returns:
Results log from the optimization.
optilab.optimizers.knn_ipop_cma_es module
KNN-IPOP-CMA-ES optimizer. IPOP-CMA-ES is enhanced with a KNN metamodel similar to the one from LMM-CMA-ES.
- class KnnIpopCmaEs(population_size: int, num_neighbors: int, buffer_size: int)[source]
Bases:
CmaEsKNN-IPOP-CMA-ES optimizer: CMA-ES with increasing population restarts and with KNN metamodel similar to LMM-CMA-ES.
- __init__(population_size: int, num_neighbors: int, buffer_size: int)[source]
Class constructor.
- Parameters:
population_size – Starting size of the population.
num_neighbors – Number of neighbors used by KNN metamodel.
buffer_size – Number of last evaluated points provided to KNN metamodel.
- optimize(function: ObjectiveFunction, bounds: Bounds, call_budget: int, tolerance: float, target: float = 0.0) PointList[source]
Run a single optimization of provided objective function.
- Parameters:
function – Objective function to optimize.
bounds – Search space of the function.
call_budget – Max number of calls to the objective function.
tolerance – Tolerance of y value to count a solution as acceptable.
target – Objective function value target, default 0.
- Returns:
Results log from the optimization.
optilab.optimizers.lmm_cma_es module
LMM-CMA-ES optimizer: CMA-ES with local polynomial regression metamodel.
- class LmmCmaEs(population_size: int, sigma0: float, polynomial_dim: int)[source]
Bases:
CmaEsLMM-CMA-ES optimizer: CMA-ES with local polynomial regression metamodel.
- __init__(population_size: int, sigma0: float, polynomial_dim: int)[source]
Class constructor.
- Parameters:
population_size – Size of the population.
sigma0 – Starting value of the sigma,
polynomial_dim – Dimension of the polynomial regression.
- optimize(function: ObjectiveFunction, bounds: Bounds, call_budget: int, tolerance: float, target: float = 0.0) PointList[source]
Run a single optimization of provided objective function.
- Parameters:
function – Objective function to optimize.
bounds – Search space of the function.
call_budget – Max number of calls to the objective function.
tolerance – Tolerance of y value to count a solution as acceptable.
target – Objective function value target, default 0.
- Returns:
Results log from the optimization.
optilab.optimizers.lmm_ipop_cma_es module
LMM-IPOP-CMA-ES optimizer: IPOP-CMA-ES with local polynomial regression metamodel. It’s a fusion of IPOP-CMA-ES and LMM-CMA-ES.
- class LmmIpopCmaEs(population_size: int, polynomial_dim: int)[source]
Bases:
CmaEsLMM-IPOP-CMA-ES optimizer: IPOP-CMA-ES with local polynomial regression metamodel. It’s a fusion of IPOP-CMA-ES and LMM-CMA-ES.
- __init__(population_size: int, polynomial_dim: int)[source]
Class constructor.
- Parameters:
population_size – Size of the population.
polynomial_dim – Dimension of the polynomial regression.
- optimize(function: ObjectiveFunction, bounds: Bounds, call_budget: int, tolerance: float, target: float = 0.0) PointList[source]
Run a single optimization of provided objective function.
- Parameters:
function – Objective function to optimize.
bounds – Search space of the function.
call_budget – Max number of calls to the objective function.
tolerance – Tolerance of y value to count a solution as acceptable.
target – Objective function value target, default 0.
- Returns:
Results log from the optimization.
optilab.optimizers.optimizer module
Base class for optimizers.
- class Optimizer(name: str, population_size: int, hyperparameters: Dict[str, Any])[source]
Bases:
objectBase class for optimizers.
- __init__(name: str, population_size: int, hyperparameters: Dict[str, Any]) None[source]
Class constructor.
- Parameters:
name – Name of this optimizer.
population_size – Size of the population.
hyperparameters – Dictionary with the hyperparameters of the optimizer.
- static _stop_budget(log: PointList, population_size: int, call_budget: int) bool[source]
Check if the call budget will allow for another algorithm generation.
- Parameters:
log – Log with all points evaluated so far.
population_size – Number of points in a single generation.
call_budget – Number of allowed point evaluations.
- Returns:
- If true, the call budget has been expended and another generation
cannot be evaluated.
- static _stop_target_found(log: PointList, target: float, tolerance: float) bool[source]
Check if the optimal function value has been found.
- Parameters:
log – Log with all points evaluated so far.
target – Global optimum value of the optimized function.
tolerance – Allowed error value from global optimum value.
- Returns:
If true, the global optimum has been found.
- _stop_external(log: PointList, population_size: int, call_budget: int, target: float, tolerance: float) bool[source]
Check if the external stop criteria has been met, i.e. if the budget has been expended or the the global optimum has been found.
- Parameters:
log – Log with all points evaluated so far.
population_size – Number of points in a single generation.
call_budget – Number of allowed point evaluations.
target – Global optimum value of the optimized function.
tolerance – Allowed error value from global optimum value.
- Returns:
- If true, the external stop criteria has been met and the optimization
should be stopped.
- optimize(function: ObjectiveFunction, bounds: Bounds, call_budget: int, tolerance: float, target: float = 0.0) PointList[source]
Run a single optimization of provided objective function.
- Parameters:
function – Objective function to optimize.
bounds – Search space of the function.
call_budget – Max number of calls to the objective function.
tolerance – Tolerance of y value to count a solution as acceptable.
target – Objective function value target, default 0.
- Returns:
Results log from the optimization.
- run_optimization(num_runs: int, function: ObjectiveFunction, bounds: Bounds, call_budget: int, tolerance: float, target: float = 0.0, *, num_processes: int = 1) OptimizationRun[source]
Optimize a provided objective function.
- Parameters:
num_runs – Number of optimization runs to perform.
function – Objective function to optimize.
bounds – Search space of the function.
call_budget – Max number of calls to the objective function.
tolerance – Tolerance of y value to count a solution as acceptable.
target – Objective function value target, default 0.
num_processes (int) – Number of concurrent processes to use to speed up the optimization. By default only one is used.
- Returns:
Metadata of optimization run.
optilab.optimizers.top_half_knn_ipop_cma_es module
Top-half KNN-IPOP-CMA-ES optimizer.
IPOP-CMA-ES enhanced with a KNN-based top-half metamodel: each generation, the surrogate estimates all candidates and only the best half is evaluated with the real objective function.
- class TopHalfKnnIpopCmaEs(population_size: int, num_neighbors: int, buffer_size: int)[source]
Bases:
CmaEsTop-half KNN-IPOP-CMA-ES optimizer.
Uses the
TopHalfMetamodelwith a KNN surrogate: every generation the surrogate pre-screens all lambda candidates and only the best mu = lambda / 2 are evaluated with the real objective. Penalised values for the remaining candidates guarantee that CMA-ES updates its state exclusively from real evaluations.- __init__(population_size: int, num_neighbors: int, buffer_size: int)[source]
Class constructor.
- Parameters:
population_size – Starting size of the population.
num_neighbors – Number of neighbours used by the KNN surrogate.
buffer_size – Number of last evaluated points provided to the KNN surrogate for training.
- optimize(function: ObjectiveFunction, bounds: Bounds, call_budget: int, tolerance: float, target: float = 0.0) PointList[source]
Run a single optimisation of the provided objective function.
- Parameters:
function – Objective function to optimise.
bounds – Search space of the function.
call_budget – Max number of calls to the objective function.
tolerance – Tolerance of y value to accept a solution.
target – Objective function value target, default 0.
- Returns:
Results log from the optimisation.
Module contents
Submodule containing optimizers.