From ba55f176c85d3e394cec6d351fe9025323ac5aaf Mon Sep 17 00:00:00 2001 From: Piotr Wawrzyniak Date: Sat, 10 Dec 2022 22:32:26 +0100 Subject: [PATCH 1/6] Force not allow_duplicate_genes to work --- pygad.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygad.py b/pygad.py index 4b1e2916..4ad23417 100644 --- a/pygad.py +++ b/pygad.py @@ -1695,7 +1695,7 @@ def single_point_crossover(self, parents, offspring_size): # The new offspring has its second half of its genes from the second parent. offspring[k, crossover_point:] = parents[parent2_idx, crossover_point:] - if (self.mutation_type is None) and (self.allow_duplicate_genes == False): + if self.allow_duplicate_genes == False: if self.gene_space is None: offspring[k], _, _ = self.solve_duplicate_genes_randomly(solution=offspring[k], min_val=self.random_mutation_min_val, @@ -1761,7 +1761,7 @@ def two_points_crossover(self, parents, offspring_size): # The genes between the 2 points are copied from the second parent. offspring[k, crossover_point1:crossover_point2] = parents[parent2_idx, crossover_point1:crossover_point2] - if (self.mutation_type is None) and (self.allow_duplicate_genes == False): + if self.allow_duplicate_genes == False: if self.gene_space is None: offspring[k], _, _ = self.solve_duplicate_genes_randomly(solution=offspring[k], min_val=self.random_mutation_min_val, @@ -1821,7 +1821,7 @@ def uniform_crossover(self, parents, offspring_size): # The gene will be copied from the second parent if the current gene index is 1. offspring[k, gene_idx] = parents[parent2_idx, gene_idx] - if (self.mutation_type is None) and (self.allow_duplicate_genes == False): + if self.allow_duplicate_genes == False: if self.gene_space is None: offspring[k], _, _ = self.solve_duplicate_genes_randomly(solution=offspring[k], min_val=self.random_mutation_min_val, @@ -1877,7 +1877,7 @@ def scattered_crossover(self, parents, offspring_size): gene_sources = numpy.random.randint(0, 2, size=self.num_genes) offspring[k, :] = numpy.where(gene_sources == 0, parents[parent1_idx, :], parents[parent2_idx, :]) - if (self.mutation_type is None) and (self.allow_duplicate_genes == False): + if self.allow_duplicate_genes == False: if self.gene_space is None: offspring[k], _, _ = self.solve_duplicate_genes_randomly(solution=offspring[k], min_val=self.random_mutation_min_val, From a12b7aad64059611853f111005bb772033d9db45 Mon Sep 17 00:00:00 2001 From: "Wawrzyniak (EXT)" Date: Wed, 14 Dec 2022 13:32:51 +0100 Subject: [PATCH 2/6] Enable option plot show --- pygad.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygad.py b/pygad.py index 4ad23417..bc7280b0 100644 --- a/pygad.py +++ b/pygad.py @@ -3361,7 +3361,8 @@ def plot_fitness(self, font_size=14, plot_type="plot", color="#3870FF", - save_dir=None): + save_dir=None, + show=True): """ Creates, shows, and returns a figure that summarizes how the fitness value evolved by generation. Can only be called after completing at least 1 generation. If no generation is completed, an exception is raised. @@ -3399,7 +3400,8 @@ def plot_fitness(self, if not save_dir is None: matplotlib.pyplot.savefig(fname=save_dir, bbox_inches='tight') - matplotlib.pyplot.show() + if show: + matplotlib.pyplot.show() return fig From e98e742ba1ff1861b13821aed9d84aed1408ae8b Mon Sep 17 00:00:00 2001 From: "Wawrzyniak (EXT)" Date: Wed, 14 Dec 2022 20:59:31 +0100 Subject: [PATCH 3/6] Add comment --- pygad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygad.py b/pygad.py index bc7280b0..071658a2 100644 --- a/pygad.py +++ b/pygad.py @@ -3376,7 +3376,7 @@ def plot_fitness(self, plot_type: Type of the plot which can be either "plot" (default), "scatter", or "bar". color: Color of the plot which defaults to "#3870FF". save_dir: Directory to save the figure. - + show: For True show the plot Returns the figure. """ From 3a77e4caa835e8573b31abb8268517729e0960df Mon Sep 17 00:00:00 2001 From: Piotr Wawrzyniak Date: Sat, 11 Mar 2023 23:33:52 +0100 Subject: [PATCH 4/6] Add new package definition --- pyproject.toml | 3 +++ setup.cfg | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 pyproject.toml create mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..8fd8d67e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..bd4eb6ec --- /dev/null +++ b/setup.cfg @@ -0,0 +1,7 @@ +[metadata] +name = pygad +version = 2.18.1-a +description= PyGAD: A Python 3 Library for Building the Genetic Algorithm and Training Machine Learning Algoithms (Keras & PyTorch). + +[options] +packages = ["pygad"] \ No newline at end of file From 41956ae7c8b8c2660f4976e9908286d73d692844 Mon Sep 17 00:00:00 2001 From: Piotr Wawrzyniak Date: Sat, 11 Mar 2023 23:40:08 +0100 Subject: [PATCH 5/6] Apply auto find --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index bd4eb6ec..cf275c12 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,4 +4,4 @@ version = 2.18.1-a description= PyGAD: A Python 3 Library for Building the Genetic Algorithm and Training Machine Learning Algoithms (Keras & PyTorch). [options] -packages = ["pygad"] \ No newline at end of file +packages = find: \ No newline at end of file From e60e1610eaba110b589f3fd0a9d82044e4b3f2d9 Mon Sep 17 00:00:00 2001 From: Piotr Wawrzyniak Date: Sun, 12 Mar 2023 13:17:29 +0100 Subject: [PATCH 6/6] Remove new package setup --- pyproject.toml | 3 --- setup.cfg | 7 ------- 2 files changed, 10 deletions(-) delete mode 100644 pyproject.toml delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 8fd8d67e..00000000 --- a/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[build-system] -requires = ["setuptools", "setuptools-scm"] -build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index cf275c12..00000000 --- a/setup.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[metadata] -name = pygad -version = 2.18.1-a -description= PyGAD: A Python 3 Library for Building the Genetic Algorithm and Training Machine Learning Algoithms (Keras & PyTorch). - -[options] -packages = find: \ No newline at end of file