pycellga.example package
Submodules
pycellga.example.example_alpha_cga module
- class pycellga.example.example_alpha_cga.ExampleProblem[source]
Bases:
object
Example problem class to be minimized.
This class implements a simple sum of squares function with a global minimum value of 0, achieved when all elements of the chromosome are equal to 0.
- pycellga.example.example_alpha_cga.run_alpha_cga_example()[source]
Run the Alpha Cellular Genetic Algorithm (alpha_cga) using the optimizer module.
The alpha_cga is configured with a 5x5 grid, 100 generations, and a chromosome size of 10. The problem being solved is an instance of the ExampleProblem class, with real-valued genes, constrained by specified mins and maxs.
- Returns:
A tuple containing the best solution chromosome and its corresponding value.
- Return type:
tuple
pycellga.example.example_ccga module
- class pycellga.example.example_ccga.ExampleProblem[source]
Bases:
object
Example problem class to be minimized.
This class implements a simple binary optimization problem, where the goal is to maximize the number of 1s.
- f(x)[source]
Compute the objective function value.
This method implements a simple sum of binary values.
- Parameters:
x (list or numpy.ndarray) – The input chromosome represented as a list or array of binary values (0s and 1s).
- Returns:
The computed value of the function given the input x.
- Return type:
int
- pycellga.example.example_ccga.run_ccga_example()[source]
Run the Compact Cellular Genetic Algorithm (ccga) using the optimizer module.
The ccga is configured with a 5x5 grid, 100 generations, and a chromosome size of 10. The problem being solved is an instance of the ExampleProblem class, with binary genes, constrained by specified mins and maxs.
- Returns:
A tuple containing the best solution chromosome and its corresponding value.
- Return type:
tuple
pycellga.example.example_cga module
- class pycellga.example.example_cga.ExampleProblem[source]
Bases:
object
Example problem class to be minimized.
This class implements a simple sum of squares function with a global minimum value of 0, achieved when all elements of the chromosome are equal to 0.
- pycellga.example.example_cga.run_cga_example()[source]
Run the Cellular Genetic Algorithm (cga) using the optimizer module.
The cga is configured with a 5x5 grid, 100 generations, and a chromosome size of 5. The problem being solved is an instance of the ExampleProblem class, with real-valued genes, constrained by specified mins and maxs.
- Returns:
A tuple containing the best solution chromosome and its corresponding value.
- Return type:
tuple
pycellga.example.example_mcccga module
- class pycellga.example.example_mcccga.RealProblem[source]
Bases:
object
Example problem class to be minimized.
This class implements a simple sum of squares function with a global minimum value of 0, achieved when all elements of the chromosome are equal to 0.
- pycellga.example.example_mcccga.run_mcccga_example()[source]
Run the Machine-Coded Compact Cellular Genetic Algorithm (mcccga) using the optimizer module.
The mcccga is configured with a 5x5 grid, 100 generations, and a chromosome size of 10. The problem being solved is an instance of the RealProblem class, with real genes, constrained by specified mins and maxs.
- Returns:
A tuple containing the best solution chromosome and its corresponding value.
- Return type:
tuple
pycellga.example.example_sync_cga module
- class pycellga.example.example_sync_cga.ExampleProblem[source]
Bases:
object
Example problem class to be minimized.
This class implements a simple sum of squares function with a global minimum value of 0, achieved when all elements of the chromosome are equal to 0.
- pycellga.example.example_sync_cga.run_sync_cga_example()[source]
Run the Synchronous Cellular Genetic Algorithm (sync_cga) using the optimizer module.
The sync_cga is configured with a 5x5 grid, 100 generations, and a chromosome size of 5. The problem being solved is an instance of the ExampleProblem class, with real-valued genes, constrained by specified mins and maxs.
- Returns:
A tuple containing the best solution chromosome and its corresponding value.
- Return type:
tuple