src.baseline.bbo.cmaes¶
Module Contents¶
Classes¶
Introduction¶A novel evolutionary optimization strategy based on the derandomized evolution strategy with covariance matrix adaptation. This is accomplished by efficientlyincorporating the available information from a large population, thus significantly re-ducing the number of generations needed to adapt the covariance matrix. |
API¶
- class src.baseline.bbo.cmaes.CMAES(config)[source]¶
Bases:
src.environment.optimizer.basic_optimizer.Basic_OptimizerIntroduction¶
A novel evolutionary optimization strategy based on the derandomized evolution strategy with covariance matrix adaptation. This is accomplished by efficientlyincorporating the available information from a large population, thus significantly re-ducing the number of generations needed to adapt the covariance matrix.
Original paper¶
“Reducing the time complexity of the derandomized evolution strategy with covariance matrix adaptation (CMA-ES).” Evolutionary Computation 11.1 (2003): 1-18.
Initialization
Introduction¶
Initializes the CMA-ES optimizer with the provided configuration settings.
Args:¶
config (object): config object from src/config.py.
The Attributes needed for the CMAES are the following:
log_interval (int): Interval at which logs are recorded.Default is config.maxFEs/config.n_logpoint.
n_logpoint (int): Number of log points to record.Default is 50.
full_meta_data (bool): Flag indicating whether to use full meta data.Default is False.
__FEs (int): Counter for the number of function evaluations.Default is 0.
__config (object): Stores the config object from src/config.py.
NP(int): Set the population size in config to 50.
Attributes:¶
__config (object): Configuration object containing algorithm parameters.
- __str__()[source]¶
Returns a string representation of the CMAES class.
Returns:¶
str: The string “CMAES”.
- run_episode(problem)[source]¶
Introduction¶
Executes a single optimization episode using the CMA-ES (Covariance Matrix Adaptation Evolution Strategy) algorithm on a given problem instance. Tracks the optimization process, logs costs at specified intervals, and optionally collects meta-data about the search trajectory. Use the cma package to implement the CMA-ES algorithm.
Args:¶
problem (object): An optimization problem instance that must provide the following attributes and methods:
dim(int): Dimensionality of the problem.lb(np.ndarray): Lower bounds for the variables.ub(np.ndarray): Upper bounds for the variables.eval(x)(callable): Function to evaluate the objective at pointx.optimum(float or None): Known optimum value of the problem (if available).
Returns:¶
dict: A dictionary containing:
'cost'(list of float): The best cost found at each logging interval.'fes'(int): The total number of function evaluations performed.'metadata'(dict, optional): Ifself.full_meta_datais True, includes:'X'(list of np.ndarray): The population positions at each iteration (in original problem scale).'Cost'(list of np.ndarray): The corresponding costs for each population.