From 92792a4c370281718a2183ed26286e4a8002cc4a Mon Sep 17 00:00:00 2001 From: "mhsatman@gmail.com" Date: Fri, 9 Aug 2024 21:25:09 +0300 Subject: [PATCH] update code comments --- src/individual.py | 5 ++++- src/optimizer.py | 20 ++++++++++---------- src/population.py | 6 +++++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/individual.py b/src/individual.py index 3dfaa27..5700e53 100644 --- a/src/individual.py +++ b/src/individual.py @@ -5,8 +5,11 @@ from problems.abstract_problem import AbstractProblem - class GeneType(Enum): + """ + GeneType is an enumeration class that represents the type of genome representation for an individual in an evolutionary algorithm. + The three types of genome representation are BINARY, PERMUTATION, and REAL. + """ BINARY = 1 PERMUTATION = 2 REAL = 3 diff --git a/src/optimizer.py b/src/optimizer.py index c0f21d9..9d3222d 100644 --- a/src/optimizer.py +++ b/src/optimizer.py @@ -88,11 +88,11 @@ def cga( Size of the tournament for selection. problem : AbstractProblem The problem instance used for fitness evaluation. - selection : Callable + selection : SelectionOperator Function or class used for selecting parents. - recombination : Callable + recombination : RecombinationOperator Function or class used for recombination (crossover). - mutation : Callable + mutation : MutationOperator Function or class used for mutation. mins : list[float] List of minimum values for each gene in the chromosome (for real value optimization). @@ -228,11 +228,11 @@ def sync_cga( Probability of mutation in offspring. problem : Callable[[List[float]], float] Function to evaluate the fitness of a solution. Takes a list of floats and returns a float. - selection : Callable + selection : SelectionOperator Function or class used for selecting parents. - recombination : Callable + recombination : RecombinationOperator Function or class used for recombination (crossover). - mutation : Callable + mutation : MutationOperator Function or class used for mutation. mins : List[float] List of minimum values for each gene in the chromosome (for real value optimization). @@ -373,11 +373,11 @@ def alpha_cga( Tournament size for selection. problem : AbstractProblem The problem instance used to evaluate fitness. - selection : Callable + selection : SelectionOperator Function used for selection in the evolutionary algorithm. - recombination : Callable + recombination : RecombinationOperator Function used for recombination (crossover) in the evolutionary algorithm. - mutation : Callable + mutation : MutationOperator Function used for mutation in the evolutionary algorithm. mins : List[float] List of minimum values for each gene in the chromosome (for real value optimization). @@ -527,7 +527,7 @@ def ccga( Type of genome representation (GeneType.BINARY, Genetype.PERMUTATION, GeneType.REAL). problem : AbstractProblem The problem instance used to evaluate fitness. - selection : Callable + selection : SelectionOperator Function used for selection in the evolutionary algorithm. mins : List[float] List of minimum values for each gene in the chromosome (for real value optimization). diff --git a/src/population.py b/src/population.py index 12a99de..2b1c11d 100644 --- a/src/population.py +++ b/src/population.py @@ -7,8 +7,12 @@ from enum import Enum -# "cga", "sync_cga", "alpha_cga", "ccga", "mcccga" class OptimizationMethod(Enum): + """ + OptimizationMethod is an enumeration class that represents the optimization methods used in an evolutionary algorithm. + The five optimization methods are CGA, SYNCGA, ALPHA_CGA, CCGA, and MCCCGA. + "cga", "sync_cga", "alpha_cga", "ccga", "mcccga" + """ CGA = 1 SYNCGA = 2 ALPHA_CGA = 3