Skip to content

Commit 7caec55

Browse files
authored
Update README.md
1 parent 5197baa commit 7caec55

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed

README.md

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,14 @@
11
# GeneticAlgorithmPython
22

3-
This project implements the genetic algorithm (GA) in Python mainly using NumPy.
3+
This project implements the genetic algorithm based on NumPy. Out of this project, a library named **PyGAD** (Decimal Genetic Algorithm) is available at [PyPI](https://pypi.org/project/pygad) at this link: https://pypi.org/project/pygad
44

5-
The project has 2 main files which are:
5+
The project has a single module named `pygad.py` which contains a class named `GA`. Simply, to run the genetic algorithm all you need to do is to create an instance of this class and pass the appropriate parameters to its constructor. This class has all the required parameters and methods for implementing the genetic algorithm.
66

7-
1. `ga.py`: Holds all necessary methods for implementing the genetic algorithm inside a class named `GA`.
7+
The documentation starts by discussing the available parameters in addition to the steps of using the library/project.
88

9-
2. `example.py`: Just gives an example of how to use the project by calling the methods in the `ga.py` file.
9+
## Supported Parameters
1010

11-
To test the project, you can simply run the `example.py` file.
12-
13-
```
14-
python example.py
15-
```
16-
17-
## How to Use the Project?
18-
19-
To use the project, here is the summary of the minimum required steps:
20-
21-
1. Prepare the required parameters.
22-
2. Import the `ga.py` module.
23-
3. Create an instance of the `GA` class.
24-
4. Run the genetic algorithm.
25-
5. Plotting Results.
26-
6. Saving & Loading the Results.
27-
28-
Let's discuss how to do each of these steps.
29-
30-
### The Supported Parameters
31-
32-
The project has many parameters to allow customizing the genetic algorithm for your purpose. Before running the GA, the parameters must be prepared. The list of all supported parameters is as follows:
11+
The single module available in the `PyGAD` library is named `pygad.py` and contains a class named `GA`. For creating an instance of this class, there are a number of parameters that allows the user to customize the genetic algorithm. Before running the GA, the parameters must be prepared. The list of all supported parameters is as follows:
3312

3413
- `num_generations` : Number of generations.
3514
- `sol_per_pop` : Number of solutions (i.e. chromosomes) within the population.
@@ -46,13 +25,30 @@ The project has many parameters to allow customizing the genetic algorithm for y
4625
- `random_mutation_min_val=-1.0` : For `random` mutation, the `random_mutation_min_val` parameter specifies the start value of the range from which a random value is selected to be added to the gene. It defaults to `-1`.
4726
- `random_mutation_max_val=1.0` : For `random` mutation, the `random_mutation_max_val` parameter specifies the end value of the range from which a random value is selected to be added to the gene. It defaults to `+1`.
4827

49-
The user doesn't have to specify all of such parameters while creating an instance of the GA class. A very important parameter you must care about is `fitness_func`.
28+
The user doesn't have to specify all of such parameters while creating an instance of the GA class. A very important parameter you must care about is `fitness_func` which defines the fitness function.
29+
30+
Next, the steps of using the PyGAD library are discussed.
31+
32+
## How to Use the PyGAD?
33+
34+
To use PyGAD, here is a summary of the required steps:
35+
36+
1. Preparing the `fitness_func` parameter.
37+
2. Preparing other parameters.
38+
3. Example of preparing the parameters.
39+
4. Import the `pygad.py` module.
40+
5. Create an instance of the `GA` class.
41+
6. Run the genetic algorithm.
42+
7. Plotting Results.
43+
8. Saving & Loading the Results.
44+
45+
Let's discuss how to do each of these steps.
5046

5147
### Preparing the `fitness_func` Parameter
5248

5349
Even there are a number of steps in the genetic algorithm pipeline that can work the same regardless of the problem being solved, one critical step is the calculation of the fitness value. There is no unique way of calculating the fitness value and it changes from one problem to another.
5450

55-
On **`15 April 2020`**, a new argument named `fitness_func` is added that allows the user to specify a custom function to be used as a fitness function. This function must be a **maximization function** so that a solution with a high fitness value returned is selected compared to a solution with a low value. Doing that allows the user to freely use the project to solve any problem by passing the appropriate fitness function.
51+
On **`15 April 2020`**, a new argument named `fitness_func` is added that allows the user to specify a custom function to be used as a fitness function. This function must be a **maximization function** so that a solution with a high fitness value returned is selected compared to a solution with a low value. Doing that allows the user to freely use the library to solve any problem by passing the appropriate fitness function.
5652

5753
Let's discuss an example:
5854

@@ -73,9 +69,9 @@ def fitness_func(solution):
7369
return fitness
7470
```
7571

76-
By creating this function, you are ready to use the project.
72+
By creating this function, you are ready to use the library.
7773

78-
### Parameters Example
74+
### Example of Preparing the Parameters
7975

8076
Here is an example for preparing the parameters:
8177

@@ -97,14 +93,14 @@ keep_parents = 1
9793
num_genes = len(function_inputs)
9894
```
9995

100-
After the parameters are prepared, we can import the `ga` module and build an instance of the GA class.
96+
After the parameters are prepared, we can import the `pygad` module and build an instance of the GA class.
10197

102-
### Import the `ga.py` Module
98+
### Import the `pygad.py` Module
10399

104-
The next step is to import the `ga` module as follows:
100+
The next step is to import the `pygad` module as follows:
105101

106102
```python
107-
import ga
103+
import pygad
108104
```
109105

110106
This module has a class named `GA` which holds the implementation of all methods for running the genetic algorithm.
@@ -178,7 +174,7 @@ print(loaded_ga_instance.best_solution())
178174

179175
## Crossover, Mutation, and Parent Selection
180176

181-
The project supports different types for selecting the parents and applying the crossover & mutation operators.
177+
The library supports different types for selecting the parents and applying the crossover & mutation operators. More features will be added in the future. To ask for a feature, please open an issue in the [GitHub project](https://github.com/ahmedfgad/GeneticAlgorithmPython) of the library: https://github.com/ahmedfgad/GeneticAlgorithmPython
182178

183179
The supported crossover operations at this time are:
184180

@@ -202,7 +198,7 @@ The supported parent selection techniques at this time are:
202198
- Random
203199
- Tournament
204200

205-
More types will be added in the future. You can also ask for supporting more types by opening an issue in the project.
201+
More types will be added in the future. You can also ask for supporting more types by opening an issue in the [GitHub project](https://github.com/ahmedfgad/GeneticAlgorithmPython) associated with the library: https://github.com/ahmedfgad/GeneticAlgorithmPython
206202

207203
## For More Information
208204

@@ -224,7 +220,7 @@ You can also check my book cited as [**Ahmed Fawzy Gad 'Practical Computer Visio
224220

225221
**Important Note**
226222

227-
It is important to note that this project does not implement everything in GA and there are a wide number of variations to be applied. For example, this project just uses decimal representation for the chromosome and the binary representations might be preferred for other problems.
223+
It is important to note that this library does not implement everything in GA and there are a wide number of variations to be applied. For example, this project just uses decimal representation for the chromosome and the binary representations might be preferred for other problems.
228224

229225
## Get in Touch
230226

0 commit comments

Comments
 (0)