Optimizer¶
This module provides the core functionality for optimizing functions using evolutionary algorithms.
- class pyevopt.optimizer.Optimizer(algorithm: Algorithm)¶
The core class for optimizing functions using evolutionary algorithms.
This class provides the functionality to run an optimization process, which can be used to find the optimal solution of an objective function.
Attributes¶
- algorithm: Algorithm
Evolutionary algorithm used to optimize.
- run(objective, dimension, domain, sampler: Sampler, stop_criteria: EarlyStopCriteria, pop_size: int = 60)¶
Runs the optimization process using the evolutionary algorithm.
This method initializes the population, evaluates the fitness of each solution, and iteratively updates the population until one of the termination conditions is met.
Parameters¶
- objectivecallable
The objective function to optimize.
- dimensionint
The number of features in the optimization problem.
- domaintuple
A tuple specifying the lower and upper bounds for each feature (e.g., (-1, 1) for all features).
- samplerSampler
A sampler used to initialize and update the population.
- stop_criterialist of TerminationCondition
Termination condition that must be met for the optimization process to stop.
- pop_sizeint
The initial size of the population.
Returns¶
- dict:
P: np.ndarray - Last population generated by the optimizer
F: np.ndarray - Fitness values obtained for ach individual of the last population generated by the optimizer.
best: int - Index of the best solution found by the optimizer.