Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
stop_criteriaparameter for multi-objective problems. Enhancing stop_criteria for Multi-Objective Optimization #314stop_criteriaissue in the release version #323stop_criteriaparameter is passed as an iterable (e.g. list) for multi-objective problems (e.g.['reach_50_60', 'reach_20, 40']). Enhancing stop_criteria for Multi-Objective Optimization #314get_matplotlib()function from theplot_genes()method inside thepygad.visualize.plot.Plotclass to import the matplotlib library. plot_genes() missing matplt() #315select_unique_value()inside thepygad/helper/unique.pyscript to select a unique gene from an array of values.get_random_mutation_range()inside thepygad/utils/mutation.pyscript that returns the random mutation range (min and max) for a single gene by its index.change_random_mutation_value_dtypeinside thepygad/utils/mutation.pyscript that changes the data type of the value used to apply random mutation.round_random_mutation_value()inside thepygad/utils/mutation.pyscript that rounds the value used to apply random mutation.pygad/helper/misc.pyscript with a class calledHelperthat has the following helper methods:change_population_dtype_and_round(): For each gene in the population, round the gene value and change the data type.change_gene_dtype_and_round(): Round the change the data type of a single gene.mutation_change_gene_dtype_and_round(): Decides whether mutation is done by replacement or not. Then it rounds and change the data type of the new gene value.validate_gene_constraint_callable_output(): Validates the output of the user-defined callable/function that checks whether the gene constraint defined in thegene_constraintparameter is satisfied or not.get_gene_dtype(): Returns the gene data type from thegene_typeinstance attribute.get_random_mutation_range(): Returns the random mutation range using therandom_mutation_min_valandrandom_mutation_min_valinstance attributes.get_initial_population_range(): Returns the initial population values range using theinit_range_lowandinit_range_highinstance attributes.generate_gene_value_from_space(): Generates/selects a value for a gene using thegene_spaceinstance attribute.generate_gene_value_randomly(): Generates a random value for the gene. Only used ifgene_spaceisNone.generate_gene_value(): Generates a value for the gene. It checks whethergene_spaceisNoneand calls eithergenerate_gene_value_randomly()orgenerate_gene_value_from_space().filter_gene_values_by_constraint(): Receives a list of values for a gene. Then it filters such values using the gene constraint.get_valid_gene_constraint_values(): Selects one valid gene value that satisfy the gene constraint. It simply callsgenerate_gene_value()to generate some gene values then it filters such values usingfilter_gene_values_by_constraint().mutation_process_random_value()inside thepygad/utils/mutation.pyscript that generates constrained random values for mutation. It calls eithergenerate_gene_value()orget_valid_gene_constraint_values()based on whether thegene_constraintparameter is used or not.gene_constraintis added. It accepts a list of callables (i.e. functions) acting as constraints for the gene values. Before selecting a value for a gene, the callable is called to ensure the candidate value is valid. Check the [Gene Constraint](https://pygad.readthedocs.io/en/latest/pygad_more.html#gene-constraint) section for more information. Add inequality constraint of two different genes #119sample_sizeis added. To select a gene value that respects a constraint, this variable defines the size of the sample from which a value is selected randomly. Useful if eitherallow_duplicate_genesorgene_constraintis used. An instance attribute of the same name is created in the instances of thepygad.GAclass. Check the [sample_size Parameter](https://pygad.readthedocs.io/en/latest/pygad_more.html#sample-size-parameter) section for more information.sample_sizeparameter instead ofnum_trialsin the methodssolve_duplicate_genes_randomly()andunique_float_gene_from_range()inside thepygad/helper/unique.pyscript. It is the maximum number of values to generate as the search space when looking for a unique float value out of a range.allow_duplicate_genes=False. Previously, gene values were checked for duplicates before rounding, which could allow near-duplicates like 7.61 and 7.62 to pass. After rounding (e.g., both becoming 7.6), this resulted in unintended duplicates. The fix ensures gene values are now rounded before duplicate checks, preventing such cases.sort_solutions_nsga2()method in thepygad/utils/nsga2.pyscript to accept an optional parameter calledfind_best_solutionwhen calling this method just to find the best solution.get_non_dominated_set()method inside thepygad/utils/nsga2.pyscript. It was swapping the non-dominated and dominated sets. In other words, it used the non-dominated set as if it is the dominated set and vice versa. All the calls to this method were edited accordingly. Incorrect Pareto Front Assignment #320.best_solution()method when retrieving the best solution for multi-objective problems. fix: best_solution for multi-objective optimization #330 #331