Prepare PyGAD 3.7.0 release#358
Merged
Merged
Conversation
Add GA.push_to_vilvik() convenience wrapper for the Vilvik SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
These are the changes yet applied to be released in PyGAD 3.7.0. The changes are not published yet in the PyPI package.
num_generationsparameter.num_generationsparameter must be assigned a positive integer. Previously, any number (positive/negative, int/float) was accepted.activation.pyis added into thepygad.helpermodule to include the activation function used by thecnnandnnmodules.pygad.parent_selection.ParentSelectionclass, thestochastic_universal_selection()method now calls thewheel_cumulative_probs()method instead of repeating the code of calculating the probabilities used for parent selection.wheel_cumulative_probs()method in thepygad.parent_selection.ParentSelectionclass is refactored to reduce its computational time.numpy.where()to decide which the source parent of each gene within theuniform_crossover()method in theutils/crossover.pyscript. The same was already applied to thescattered_crossover()method.nncnngacnnkerasgatorchgavisualize/plot.pyscript where thelabelsparameter ofboxplot()has been renamedtick_labelsin Matplotlib.best_solutions_fitnesslist (instance attribute topygad.GA) has the fitness of the last generation duplicated when an early stop happens inside theon_generation()callback. This made its size incompatible with thebest_solutionslist.NSGA3class lives in the newpygad/utils/nsga3.pyscript and is mixed into thepygad.GAclass the same wayNSGA2is.nsga3_selection()for plain NSGA-III selection, and 2)tournament_selection_nsga3()for the tournament variant. Use them by settingparent_selection_typeto'nsga3'or'tournament_nsga3'.nsga3_num_divisionsis added to thepygad.GAconstructor. It is required whenparent_selection_typeis'nsga3'or'tournament_nsga3'and sets the number of divisions per objective axis used to build the structured reference points (thepparameter from Deb & Jain 2014). The total number of reference points isC(M + p - 1, p)whereMis the number of objectives.sol_per_popis smaller than the number of NSGA-III reference points, PyGAD raises a warning and grows the population to match before the generational loop starts.crossover_type='sbx'. The shape of the spread is controlled by the newsbx_crossover_etaparameter (default 30).mutation_type='polynomial'. The size of the change is controlled by the newpolynomial_mutation_etaparameter (default 20).time_<seconds>stops the run when the time insiderun()is at least the given number of seconds;evaluations_<N>stops the run when the number of fitness function calls reaches the given count. New instance attributenum_fitness_evaluationscounts the calls.pygad.utils.quality_indicatorswith four functions to measure the quality of a Pareto front:hypervolume,inverted_generational_distance,generational_distance, andspacing.pygad.benchmarkswith built-in benchmark problems.pygad.benchmarks.classichas Sphere, Rastrigin, Rosenbrock, Griewank, Schwefel, Ackley, and Himmelblau.pygad.benchmarks.zdthas the ZDT family (ZDT1, ZDT2, ZDT3, ZDT4, ZDT6).pygad.benchmarks.dtlzhas DTLZ1, DTLZ2, DTLZ3, and DTLZ4.pygad.benchmarks.knapsackhas the 0/1 Knapsack problem. Each class is callable with the PyGAD fitness signature and returns negated values (for the minimization-style problems) so PyGAD can maximize toward the original minimum.pygad.benchmarks.tspwith aTSPclass for the Travelling Salesman Problem. The class accepts either 2Dcoordinatesor a precomputeddistance_matrix, exposesgene_space,gene_type, andallow_duplicate_genesfor the permutation encoding, and returns the negative tour length as the fitness./examples:examples/benchmarks/has one runnable example per benchmark (classic, ZDT, DTLZ, knapsack, and TSP), andexamples/quality_indicators/has one runnable example per quality indicator (hypervolume, IGD, GD, and spacing).plot_pareto_front_curve()now also supports 3 objectives (3D scatter). M >= 4 still raises and points to the new high-dimensional plots.pygad.GA. The first three work on the final population (no extra flag needed):plot_pareto_front_pcp()(parallel coordinates, any M >= 2),plot_pareto_front_scatter_matrix()(M-by-M pairwise scatter, best for M >= 4), andplot_pareto_front_heatmap()(solutions-by-objectives heatmap). The other four requiresave_solutions=True:plot_fitness_band()(per-generation min / mean / max with a shaded band),plot_non_dominated_hypervolume()(hypervolume of the non-dominated set per generation),plot_population_diversity()(mean pairwise distance per generation), andplot_pareto_front_evolution()(non-dominated set overlaid every k generations).NSGA3.nsga3_normalize_fitness(). The safeguard for near-zero denominators used to collapse to0for tiny negative values (the realistic case under PyGAD-max), which silently produced wrong normalized values. The safeguard now keeps the negative sign.pygad/utils/nsga.pyhosts theNSGAmixin withnon_dominated_sorting()andget_non_dominated_set(), which are shared between NSGA-II and NSGA-III.nsga2.pynow only carries NSGA-II specific code (crowding_distance,sort_solutions_nsga2).nsga3.pynow only carries the NSGA-III algorithm primitives. Thensga3_selection()andtournament_selection_nsga3()methods have moved topygad/utils/parent_selection.pynext to their NSGA-II counterparts. The engine-time helpers_bootstrap_nsga3_reference_points(),_nsga3_grow_population(),_nsga3_generate_extra_random_solutions(), and_nsga3_generate_single_random_gene()now live inpygad/utils/engine.py.nsga3_so the algorithm-specific surface is easy to spot. Algorithm primitives becomensga3_generate_reference_points,nsga3_compute_ideal_point,nsga3_find_extreme_points,nsga3_compute_intercepts,nsga3_normalize_fitness,nsga3_associate_to_reference_points, andnsga3_niching_select. Module-level helpers gain the same prefix (_nsga3_pick_target_reference_point,_nsga3_pick_candidate_at_reference,_nsga3_enumerate_compositions,_nsga3_validate_multi_objective_fitness,_nsga3_accumulate_fronts). The constants are renamedNSGA3_ASF_EPSILONandNSGA3_INTERCEPT_NEAR_ZERO. Names that already had NSGA-II parallels (tournament_selection_nsga3,pareto_fronts,non_dominated_sorting) keep their original spelling.normalize,maximize,behavior,color,optimization, ...) so the library stays consistent.fl_indicestocritical_front_indices,fl_assoctocritical_front_associations,fl_disttocritical_front_distances,st_indicestoselection_pool_indices,st_fitnesstoselection_pool_fitness,accepted_assoctoaccepted_associations,Ktonum_to_select(innsga3_niching_select).init_range_low/init_range_high,gene_space,gene_type(single dtype or nested per-gene[type, precision]),gene_constraint, andallow_duplicate_genes=False. Previously, only the gene-space / init-range sampling step was applied; gene constraints and duplicate resolution were skipped, which could leave the grown rows in an invalid state.Reportmixin inpygad/utils/report.pyaddsga_instance.generate_report(filename, ...)to build a PDF report of the run. The report bundles a configuration table, a run-summary table, the best solution, and every applicable plot (auto-selected based on the run's properties: SOO vs MOO, number of objectives,save_solutions,save_best_solutions). The report usesreportlabandmatplotlib, both available through the new optional dependency extrapip install pygad[report].examples/example_generate_report.pyshows how to build a PDF report after running a multi-objective GA.pygad.md,releases.md,visualize.md, andutils.mddocumentation pages were updated to reflect the new module layout, the renamed methods, the newgenerate_report()entry point, and the new NSGA-III instance attributes (nsga3_num_divisions,nsga3_reference_points). The "Other Instance Attributes & Methods" section inpygad.mdis now grouped by area (Lifecycle, Population, Fitness, Parent Selection, NSGA-II, NSGA-III, Crossover, Mutation, Elitism, Gene Constraints, Saving) so each method or attribute appears under its topic.solutionhas.