114 void evaluate(Individual& ind);
123 const Individual& tournamentSelect();
138 bool isBetterFitness(
Real a,
Real b)
const;
147 std::vector<Individual> m_population;
151 bool m_initialized =
false;
154 size_t m_generation = 0;
Genetic Algorithm optimizer.
void setMode(OptimizationMode mode) override
Set optimization mode (minimize or maximize).
void setBounds(const Coordinates &lower, const Coordinates &upper) override
Set lower/upper bounds of the search hyper-rectangle.
Solution optimize() override
Run GA for max_generations.
Solution getBestSolution() const override
Get the best solution found so far.
void setCallback(StepCallback cb) override
Register a callback invoked after each generation.
void setObjectiveFunction(ObjectiveFunction func) override
Set the objective function to optimize.
void step() override
Perform one generation: selection, crossover, mutation, evaluation, and serial update of the global b...
const std::vector< Individual > & getPopulation() const
Access the current population.
Abstract base class for all optimization algorithms.
std::function< void(const Solution ¤t_best, size_t iteration)> StepCallback
Callback invoked after each step/generation.
OptimizationMode
Optimization goal.
std::function< Real(const Coordinates &)> ObjectiveFunction
Objective function signature.
std::vector< Real > Coordinates
A point in the N-dimensional search space.
double Real
Scalar precision used across optimizers.
Abstract optimizer interface for PSO, GA, and future algorithms.
Configuration parameters for GA.
size_t elitism_count
Number of top individuals copied unchanged to next generation.
size_t tournament_k
Tournament size for selection (k >= 2).
Real mutation_rate
Per-gene mutation probability.
size_t population_size
Size of the population.
Real crossover_rate
Probability of performing crossover in reproduction.
Real mutation_sigma
Mutation magnitude (scaled by coordinate span).
size_t max_generations
Number of generations to evolve.
A single population member.
Coordinates genome
Encoded parameters (genome).
Real fitness
Fitness value for this genome.
Represents a candidate solution in the search space.