How hugodovs/gl2o works
1. What this repository is
- GL2O is a Python library for “learning to optimize”: it runs optimization algorithms, trains meta-optimizers over those runs, and then evaluates and visualizes the results.
- The codebase is organized around an experiment pipeline rather than a single application.
2. Top-level orchestration
- The main control flow lives under mlo/application/.
- These modules split the experiment lifecycle into distinct phases: building an experiment, preprocessing for meta-optimization, preprocessing for optimization, and postprocessing/analysis.
- main.py is the likely entry point that wires a chosen YAML config into this pipeline.
3. Configuration-driven experiments
- cfg/exp1/ contains the concrete experiment definitions.
- The train, pre_opt, and post_opt folders indicate a staged workflow: train/meta-learn first, then run optimization, then generate outputs such as plots.
- This configuration layer is the main boundary between experiment setup and algorithm code.
4. Experiment assembly and shared state
- mlo/application/builder.py and mlo/application/experiment.py appear to assemble the components for a run and hold the experiment-level coordination logic.
- mlo/components/infoset.py likely acts as a shared data container for metrics, observations, or run-state passed between stages.
5. Task model and benchmark domain
- Optimization problems are represented in mlo/components/tasks/.
- task.py defines the task abstraction, while bbob.py ties the project to the BBOB benchmark family.
- mlo/components/task_distributions/ adds a layer for sampling or managing collections of tasks, so experiments can train/evaluate over distributions rather than a single objective.
6. Optimization algorithms
- mlo/components/optimizers/ contains the concrete optimizers being compared or learned over.
- The set includes CMA-ES variants, DE, PSO, random search, one-plus-one, and specialized methods like LIOH and SHIWA.
- optimizer.py is the common interface boundary that the rest of the system uses, which lets the application treat all optimizers uniformly.
7. Meta-optimization layer
- mlo/components/metaoptimizers/ contains the learning-to-optimize machinery.
- The deepga_table/ subtree is the main meta-optimizer implementation, organized into population members, selection, mutation, slicing, and core algorithm logic.
- mpi_extensions.py suggests distributed or parallel execution support for scaling meta-optimization runs.
8. Factory-based dependency creation
- mlo/factories/ is the indirection layer that maps config names to concrete tasks, optimizers, meta-optimizers, and visualizers.
- This keeps the application layer from importing algorithm classes directly and makes the system extensible via configuration.
9. Postprocessing and visualization
- mlo/components/visualizers/ contains the output-generation layer.
- ecdf.py and heatmap.py indicate the main analysis products: benchmark-performance curves and performance landscapes.
- postprocessing_optimization.py likely turns raw experiment outputs into these visual artifacts.
10. Utility and experiment support
- mlo/utils/generator.py provides helper generation logic, likely for tasks, samples, or parameter sets.
- logexample.py and plot_metaloss.py are standalone analysis/demo scripts rather than core runtime components.
- The data/ directory is just a workspace placeholder, implying the repo expects experiment artifacts or datasets to be generated locally.
11. Architecture in one sentence
- The system flows from YAML experiment definitions into factory-built tasks and optimizers, runs them through a staged application pipeline, optionally meta-trains an optimizer with distributed support, and finally emits benchmark visualizations and summaries.
Main entry points: builder.py Builder · experiment.py Experiment · optimizer.py Optimizer · preprocessing_optimization.py Opt prep
Components 25
Config
YAML experiment definitions for staged runs
Application
Experiment lifecycle orchestration
- Builder · Assembles an experiment from config and factories
mlo/application/builder.py - Experiment · Coordinates the staged experiment lifecycle
mlo/application/experiment.py - Meta prep · Preprocessing for meta-optimization
mlo/application/preprocessing_metaoptimization.py - Opt prep · Preprocessing for optimization runs
mlo/application/preprocessing_optimization.py - Postprocess · Aggregates results and prepares analysis outputs
mlo/application/postprocessing_optimization.py
Components
Core optimization, meta-optimization, tasks, and output modules
- Info set · Shared run metrics and observations passed between stages
mlo/components/infoset.py - Task · Abstract optimization problem interface
mlo/components/tasks/task.py - BBOB task · Concrete benchmark task family
mlo/components/tasks/bbob.py - Task dist · Samples or manages collections of tasks
mlo/components/task_distributions/task_distribution.py - Optimizer · Common optimizer interface used by the application
mlo/components/optimizers/optimizer.py - CMA-ES · Evolution strategy baseline and variants
mlo/components/optimizers/cmaes.py - DE · Differential evolution baseline
mlo/components/optimizers/de.py - PSO · Particle swarm optimizer
mlo/components/optimizers/pso.py - DeepGA · Main learning-to-optimize algorithm
mlo/components/metaoptimizers/deepga_table/deepga.py - GA ops · Population member, selection, mutation, and slicing logic
mlo/components/metaoptimizers/deepga_table/member.py - Visualizer · Common visualization interface
mlo/components/visualizers/visualizer.py - ECDF · Performance curve output
mlo/components/visualizers/ecdf.py - Heatmap · Performance landscape output
mlo/components/visualizers/heatmap.py
Factories
Config-to-implementation binding layer
- Opt factory · Resolves optimizer names from config
mlo/factories/optimizer.py - Meta factory · Resolves meta-optimizer implementations
mlo/factories/meta_optimizer.py - Viz factory · Resolves visualization backends
mlo/factories/visualizer.py
Other components
- Main · CLI entry that loads a config and starts the pipeline
main.py
Connections 26
- Main → Train cfg: loads · Entry point selects a staged experiment config
- Main → Builder: starts · Bootstraps the experiment assembly
- Builder → Experiment: creates · Builds the run coordinator
- Builder → Opt factory: binds · Maps optimizer names to concrete classes
- Builder → Meta factory: binds · Maps meta-optimizer names to concrete classes
- Builder → Viz factory: binds · Maps analysis names to visualizers
- Experiment → Meta prep: phase · Runs meta-optimization preprocessing
- Experiment → Opt prep: phase · Runs optimization preprocessing
- Experiment → Postprocess: phase · Runs postprocessing and analysis
- Meta prep → Info set: writes · Stores shared state for later stages
- Opt prep → Task dist: uses · Prepares task sampling for optimization
- Opt prep → Optimizer: runs · Executes optimizers through the common API
- Task dist → Task: provides · Supplies tasks to training or evaluation
- Task → BBOB task: implements · BBOB benchmark specialization
- Optimizer → CMA-ES: concrete · One of the main optimizer implementations
- Optimizer → DE: concrete · One of the main optimizer implementations
- Optimizer → PSO: concrete · One of the main optimizer implementations
- Meta factory → DeepGA: creates · Instantiates the learning-to-optimize algorithm
- DeepGA → GA ops: uses · Population dynamics and genetic operators
- Postprocess → Visualizer: uses · Formats outputs via the visualizer API
- Visualizer → ECDF: concrete · Benchmark curve visualization
- Visualizer → Heatmap: concrete · Benchmark surface visualization
- Train cfg → Builder: configures · Training config drives assembly choices
- Opt cfgs → Opt prep: configures · Optimization config selects runtime parameters
- Post cfgs → Postprocess: configures · Postprocessing config selects analysis outputs
- Info set → DeepGA: feeds · Shared state can inform meta-optimization