Support of multi-objective optimization using Non-Dominated Sorting Genetic Algorithm II (NSGA-II) using the NSGA2 class in the pygad.utils.nsga2 module. Just return a list, tuple, or numpy.ndarray from the fitness function and the library will consider the problem as multi-objective optimization. All the objectives are expected to be maximization. Check [this section](https://pygad.readthedocs.io/en/latest/pygad_more.html#multi-objective-optimization) for an example.
The parent selection methods and adaptive mutation are edited to support multi-objective optimization.
Two new NSGA-II parent selection methods are supported in the pygad.utils.parent_selection module: 1) Tournament selection for NSGA-II 2) NSGA-II selection.
The plot_fitness() method in the pygad.plot module has a new optional parameter named label to accept the label of the plots. This is only used for multi-objective problems. Otherwise, it is ignored. It defaults to None and accepts a list, tuple, or numpy.ndarray. The labels are used in a legend inside the plot.
The default color in the methods of the pygad.plot module is changed to the greenish #64f20c color.
A new instance attribute named pareto_fronts added to the pygad.GA instances that holds the pareto fronts when solving a multi-objective problem.
The gene_type accepts a list, tuple, or numpy.ndarray for integer data types given that the precision is set to None (e.g. gene_type=[float, [int, None]]).
In the cal_pop_fitness() method, the fitness value is re-used if save_best_solutions=True and the solution is found in the best_solutions attribute. These parameters also can help re-using the fitness of a solution instead of calling the fitness function: keep_elitism, keep_parents, and save_solutions.
The value 99999999999 is replaced by float('inf') in the 2 methods wheel_cumulative_probs() and stochastic_universal_selection() inside the pygad.utils.parent_selection.ParentSelection class.
The plot_result() method in the pygad.visualize.plot.Plot class is removed. Instead, please use the plot_fitness() if you did not upgrade yet.
pygad.utils.nsga2
is created that has theNSGA2
class that includes the functionalities of NSGA-II. The class has these methods: 1)get_non_dominated_set()
2)non_dominated_sorting()
3)crowding_distance()
4)sort_solutions_nsga2()
. Check [this section](https://pygad.readthedocs.io/en/latest/pygad_more.html#multi-objective-optimization) for an example.NSGA2
class in thepygad.utils.nsga2
module. Just return alist
,tuple
, ornumpy.ndarray
from the fitness function and the library will consider the problem as multi-objective optimization. All the objectives are expected to be maximization. Check [this section](https://pygad.readthedocs.io/en/latest/pygad_more.html#multi-objective-optimization) for an example.pygad.utils.parent_selection
module: 1) Tournament selection for NSGA-II 2) NSGA-II selection.plot_fitness()
method in thepygad.plot
module has a new optional parameter namedlabel
to accept the label of the plots. This is only used for multi-objective problems. Otherwise, it is ignored. It defaults toNone
and accepts alist
,tuple
, ornumpy.ndarray
. The labels are used in a legend inside the plot.pygad.plot
module is changed to the greenish#64f20c
color.pareto_fronts
added to thepygad.GA
instances that holds the pareto fronts when solving a multi-objective problem.gene_type
accepts alist
,tuple
, ornumpy.ndarray
for integer data types given that the precision is set toNone
(e.g.gene_type=[float, [int, None]]
).cal_pop_fitness()
method, the fitness value is re-used ifsave_best_solutions=True
and the solution is found in thebest_solutions
attribute. These parameters also can help re-using the fitness of a solution instead of calling the fitness function:keep_elitism
,keep_parents
, andsave_solutions
.99999999999
is replaced byfloat('inf')
in the 2 methodswheel_cumulative_probs()
andstochastic_universal_selection()
inside thepygad.utils.parent_selection.ParentSelection
class.plot_result()
method in thepygad.visualize.plot.Plot
class is removed. Instead, please use theplot_fitness()
if you did not upgrade yet.