8000 Update example.py · rashed-03/GeneticAlgorithmPython@749d75b · GitHub
[go: up one dir, main page]

Skip to content

Commit 749d75b

Browse files
authored
Update example.py
1 parent 73bb3f1 commit 749d75b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

example.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ga
1+
import pygad
22
import numpy
33

44
num_generations = 50 # Number of generations.
@@ -37,7 +37,7 @@ def fitness_func(solution):
3737
return fitness
3838

3939
# Creating an instance of the GA class inside the ga module. Some parameters are initialized within the constructor.
40-
ga_instance = ga.GA(num_generations=num_generations,
40+
ga_instance = pygad.GA(num_generations=num_generations,
4141
sol_per_pop=sol_per_pop,
4242
num_parents_mating=num_parents_mating,
4343
num_genes=num_genes,
@@ -66,6 +66,7 @@ def fitness_func(solution):
6666
ga_instance.save(filename=filename)
6767

6868
# Loading the saved GA instance.
69-
loaded_ga_instance = ga.load(filename=filename)
69+
loaded_ga_instance = pygad.load(filename=filename)
70+
print("The saved instance of the genetic algorithm is loaded successfully.")
7071
loaded_ga_instance.plot_result()
7172
print(loaded_ga_instance.best_solution())

0 commit comments

Comments
 (0)
0