src.baseline.metabbo.lga

Module Contents

Classes

LGA

Introduction

Learned Genetic Algorithm parametrizes selection and mutation rate adaptation as cross- and self-attention modules and use MetaBBO to evolve their parameters on a set of diverse optimization tasks.

API

class src.baseline.metabbo.lga.LGA(config)[source]

Bases: src.rl.basic_agent.Basic_Agent

Introduction

Learned Genetic Algorithm parametrizes selection and mutation rate adaptation as cross- and self-attention modules and use MetaBBO to evolve their parameters on a set of diverse optimization tasks.

Original paper

Discovering attention-based genetic algorithms via meta-black-box optimization.” Proceedings of the Genetic and Evolutionary Computation Conference. (2023).

Official Implementation

LGA

Args:

  • config (object): Configuration object containing agent and training parameters, such as device, save directories, and training intervals.

Attributes:

  • M (int): Population size for the optimizer.

  • T (int): Number of steps to skip in each action.

  • J (int): Number of evaluations per candidate.

  • optimizer (CMA): CMA-ES optimizer instance.

  • x_population (np.ndarray): Current population of candidate solutions.

  • meta_performances (List[List[float]]): Performance history for each candidate.

  • best_x (np.ndarray): Best candidate solution found so far.

  • costs (Any): Placeholder for cost tracking.

  • best_lga (int): Index of the best candidate in the population.

  • gbest (float): Best fitness score achieved.

  • learning_step (int): Number of learning steps completed.

  • cur_checkpoint (int): Current checkpoint index for saving.

  • task_step (int): Number of tasks (episodes) completed.

Methods:

  • str(): Returns the string identifier for the agent.

  • get_step(): Returns the current learning step.

  • optimizer_step(): Samples a new population from the optimizer.

  • train_episode(…): Runs a training episode, evaluates the population, and updates the optimizer.

  • rollout_episode(…): Evaluates the best candidate in a single environment.

  • update(): Updates the optimizer with new fitness scores and refreshes the population.

  • log_to_tb_train(…): Logs training metrics and extra information to TensorBoard.

Returns:

Methods return various outputs, such as training progress, evaluation results, and logging status. See individual method docstrings for details.

Raises:

  • Any exceptions raised by underlying environment, optimizer, or file I/O operations may propagate.

Notes:

  • This class assumes the existence of supporting classes and functions such as Basic_Agent, CMA, ParallelEnv, save_class, and appropriate environment interfaces.

  • The agent is designed for meta-optimization tasks and may require adaptation for specific problem domains.

Initialization

Initialize the basic_agent with config.

__str__()[source]
get_step()[source]
optimizer_step()[source]
train_episode(envs, seeds: Optional[Union[int, List[int], numpy.ndarray]], para_mode: Literal[dummy, subproc, ray, ray - subproc] = 'dummy', compute_resource={}, tb_logger=None, required_info={})[source]
rollout_episode(env, seed=None, required_info={})[source]
update()[source]
log_to_tb_train(tb_logger, mini_step, gbest, extra_info={})[source]