How erickfmm/anmetal works
Project Type and Purpose
• This is a Python library (“anmetal”) for numeric optimization and metaheuristics.
• It offers iterative methods (one-solution optimizers) and a suite of population-based metaheuristic algorithms, plus a collection of benchmark problems (NP-hard tasks, nonlinear functions) and utility functions (binarization, repair strategies).
High-Level Architecture
a. Interfaces Layer
• IMetaheuristic
• ISolution
• IProblem
b. Core Modules
• iterative_methods (one-solution methods: Euler, Newton)
• population (subpackages for ABC, ACO, PSO, GA, etc.)
c. Problems Layer
• nonlinear_functions (1-D, 2-D, N-D)
• nphard_real (partition, subset)
• nphard_categorical (knapsack, sudoku)
d. Utils Layer
• binarization_float, binarization_strategy
• points_utils
e. Consumer/Test Layer
• test and tests folders, which import the above modules to validate and demonstrate usage.
Component Identification and Relationships
• The population submodules implement IMetaheuristic and produce ISolution instances.
• Each algorithm class in population/… calls into problem objects (IProblem), passing objective_function, repair_function, preprocess_function.
• Problems modules implement IProblem; they expose methods and properties (min_x, max_x, ndim, objective_function, repair_function).
• iterative_methods is independent but sits alongside population (both use ISolution or raw numeric data).
• utils modules are dependencies of both population and problems for operations like binarization and point conversions.
• population → Interfaces (implements IMetaheuristic, ISolution)
• problems → Interfaces (implements IProblem)
• population → problems (calls objective_function)
• population & problems → utils (use binarization, point utilities)
• tests → all modules (import and validate)
Architectural Patterns and Principles
• Inversion of Control via interfaces (IMetaheuristic, IProblem) to allow plugging in any algorithm/problem.
• Separation of concerns: algorithms, problem definitions, utilities.
• Extensibility points: adding a new metaheuristic under population or a new problem under problems.