Nsga2 mainly improves the NSGA algorithm. NSGA was proposed in a paper titled multiobjective Function Optimization Using nondominated sorting genetic algorithms published by N. Srinivas and K. Deb in 1995. This algorithm has a good effect in quickly finding the front of the company and maintaining the diversity of populations. However, the following problems have also occurred in applications over the years:
1. The time for non-dominated sorting is very complex, which is O (Mn3 ). M indicates the number of target functions, and N indicates the population size.
2. Elite policies are not supported. The elite strategy has a good performance in maintaining good individuals and accelerating convergence to the forefront of the company.
3. You must specify the sharing parameter. This parameter will have a great impact on the diversity of the population.
The nsga2 algorithm will be improved in the following aspects:
1. Fast non-dominated sorting
When NSGA performs non-dominated sorting, each individual in the population with n needs to compare M objective functions with the N-1 individual in the population. The complexity is O (Mn ), therefore, the complexity of the N individual populations is O (Mn), that is, the time complexity of each of the population members is O (Mn ). In the worst case, each package level contains only one entity, so the time complexity required for N grading will be increased to O (Mn3 ). In view of this, a fast non-dominated sorting method is proposed in this paper. The time complexity of this method is O (Mn ).
The algorithm needs to save two quantities:
(1). Control the number of NP. This is the number of individual p that can be dominated in the feasible solution space.
(2). sp. This is a set of all the individuals controlled by individual P in the feasible solution space.
The pseudocode of the Sorting Algorithm is as follows:
Def fast_nondominated_sort (P ):
F = []
For P in P:
SP = []
NP = 0
For Q in P:
If P> q: # If P controls Q, add Q to the SP list.
Sp. append (q)
Else if P <q: # If P is dominated by Q, add np to 1
NP + = 1
If NP = 0:
P_rank = 1 # If the NP of the individual is 0, the individual is the first level of
F1.append (P)
F. append (F1)
I = 0
While f [I]:
Q = []
For P in F [I]:
For Q in SP: # Sort all the individuals in the SP set
NQ-= 1
If NQ = 0: # if the number of inactive individuals is 0, the inactive individuals
Q_rank = I + 2 # this individual has a maximum of 1 (+ 1) of the current maximum. At this time, the initial I value is 0, so we need to add 2
Q. append (q)
F. append (q)
I + = 1
In the above pseudo code, the first part of the loop is a dual loop, and the time complexity is O (n2). In the second part of the loop, we can assume that there are X levels in total, and each level of the most (N-N/x) each individual, each individual's dominant set also has a maximum of (N-N/x) each individual. It can be concluded that the number of cycles is x * (N-N/x) * (N-N/X) = (x-1) 2/x2) n2m, that is, the time complexity is O (Mn ).
2. Retention of individual diversity in a population
In the original NSGA algorithm, the sharing function method is used to maintain species diversity. This method contains a sharing parameter, which is the expected sharing range in the problem to be solved. In this range, two individuals share the fitness of each other. However, this method has two difficulties:
(1). the shared function method depends heavily on the selected shared parameter value to maintain the diversity of performance.
(2) Each individual in the population must be compared with other individuals. Therefore, the global complexity of this method is O (n2 ).
In nsga2, the exclusion algorithm and elite policy are used to replace the sharing function algorithm. To implement these two methods, we need to first define two operations: Density Estimation and exclusion operators.
(1). Density Estimation
To calculate the crowded distance, sort all the individuals in the population in ascending order based on each target function. The congestion distance between the first and last individual is infinite, the congestion distance of the I-th individual is set to the sum of all target function values of the I + 1 and I-th individual. The specific method is as follows:
Def crowding_distance_assignment (I)
Nlen = Len (I) # Number of individuals in I
For I in I:
I. Distance = 0 # initialize the congestion distance of all individuals
For objfun in M: # m is the list of all target functions.
I = sort (I, objfun) # sort by objective function objfun in ascending order
I [0] = I [Len [I]-1] = ∞ # Set the distance between the first and last bodies to infinity.
For I in xrange (1, Len (I)-2 ):
I [I]. distance = I [I]. distance + (objfun (I [I + 1])-objfun (I [I-1])/(max (objfun ()-min (objfun ()))
In pseudo-code, objfun (I) is used to obtain the target function value for the individual I. Max (objfun () is the maximum value of the objective function objfun (), and min (objfun () is the minimum value of the objective function objfun. Its complexity is O (mnlogn ).
3. Subject Loop
(1). The population P0 starts from random initialization. In addition, P0 is sorted in non-dominant order to initialize the rank value of each individual.
(2). T = 0
(3) using the binary championship method to select an individual from PT and perform crossover and mutation operations to generate a new generation of Population QT.
(4). the combined population RT = PT uqt is generated by merging Pt and qt.
(5). Non-dominated sorting of RT, and selecting n individuals through exclusion and elite retention policies to form a new generation of Pt + 1 Population.
(6) Jump to step 3, and cycle until the end conditions are met.
The specific steps in step 5 are as follows:
The pseudocode is as follows:
While condition:
RT = Pt + QT
F = fast_nondominate_sort (RT)
Pt + 1 = []
I = 0
While Len (Pt + 1) + Len (F [I]) <n:
Crowding_distance_assignment (F [I])
Pt + 1 + = f [I]
I + = 1
Pt + 1 + = f [I] [0: N-len (Pt + 1)]
Qt + 1 = make_new_generation (Pt + 1)
T = t + 1
The overall complexity of the nsag2 algorithm is analyzed as follows:
(1). Non-dominated sorting. The worst complexity is O (M (2n) 2 ).
(2) assign a value to the congestion Distance Estimation. The worst complexity is O (M (2n) log (2n )).
(3). Sort crowded operations with the worst complexity of O (2 nlog (2n )).
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/lf8289/archive/2008/04/14/2291466.aspx