Disclosure of Invention
The invention aims to solve the defects in the prior art, and provides a two-degree-of-freedom space-based multi-element map annotation optimization DDEGA-NM algorithm and a system, which are used for improving the quality of an initial population by adding a local optimal arrangement and combination mode and controlling the range of random generation of the initial population, changing the proportion of individuals of a new population generated by a differential algorithm and a genetic algorithm, and adding a part of individuals generated by high-quality candidate positions randomly.
In order to achieve the above purpose, the present invention provides the following technical solutions:
A multi-element map annotation optimization DDEGA-NM algorithm based on two-degree-of-freedom space comprises the following steps:
s1, inputting experimental vector Map data Map0, wherein the Map comprises different layers of points, lines and planes, and each layer is provided with a plurality of elements;
S2, outputting a result of Outcome lists, wherein the result comprises a annotation candidate position Name, type, X and Y data information which are selected by each element, and Outcome = [ Name, type, X and Y ];
S3, defining a one-dimensional list Labels _1 and a two-dimensional list Labels _2, wherein Labels_1 and Labels _2 are used for representing all candidate position sets of all elements;
S4, determining the number of candidate positions and minimum and maximum buffer distance values of the marks from the elements based on a vector Map0, and generating candidate positions for the point, line and surface elements respectively to obtain a candidate position set;
s5, randomly generating an initial population by using an optimization DDEGA algorithm;
S6, acquiring each candidate position Name, type, X and Y-coordinate information one by adopting a circulation function, and scoring each candidate position by adopting a annotation gland, annotation ambiguity and annotation priority factors;
s7, generating each element, sequencing the elements according to the theoretical limit value of the candidate position from small to large, wherein the lower the grading value is, the higher the priority of the corresponding candidate position is;
S8, combining the candidate position theory limit values as an individual X (1) of the initial population, and ensuring that DDEGA-NM algorithm can keep the individual with the lowest score in each loop iteration;
s9, four scoring factors including annotation conflict, annotation gland, annotation ambiguity and annotation priority are adopted to evaluate the populations X (1) -X (100), and the minimum scoring value combination is directly added into the next generation population so as to ensure that the current optimal annotation candidate position combination is not lost;
s10, sorting the scoring values of the generated initial population X (1) -X (100), taking the individuals with the scores of the first 50% to participate in generating a next generation population, generating 30% and 60% of new individuals through a genetic algorithm and a differential evolution algorithm respectively, randomly selecting candidate position serial numbers [1- |N ] of each element to combine and generate 10% of individuals, and adding the individuals into the next generation new population to form new population individuals X (1) -X (100);
s11, judging whether the new populations X (1) -X (100) meet the iteration termination condition or not, wherein the method specifically comprises the following steps:
if the iteration condition is not met, the step S9 is entered, and the next loop iteration is started;
if the iteration termination condition is met, outputting X (n) with the smallest scoring value in the new populations X (1) -X (100);
S12, decoding the X (n) to obtain the determined candidate position coordinate information of each element, and storing Outcome, outcome = [ Name, type, X, Y ];
And S13, outputting a note configuration result Outcome after finishing.
Preferably, in step S3, the one-dimensional list Labels _1 and the two-dimensional list Labels _2 each include five fields, which are Name of the element, type of the element, X coordinate and Y coordinate of the candidate location center point of the annotation, and theoretical limit score F, label= [ Name, type, X, Y, F ].
Preferably, the determining the number of candidate positions and the maximum buffer distance value of the mark from the element in step S4 specifically includes:
setting different buffer distance parameters;
and (3) finding a point with the first derivative of 0 by adopting a curve fitting mode, wherein the point is a stable point of the curve, and further determining a proper maximum buffer distance value.
Preferably, the optimization DDEGA algorithm described in step S5 randomly generates the initial population:
1) Firstly, scoring the candidate positions generated by the candidate positions according to annotation gland, annotation ambiguity and annotation priority;
2) Then, the candidate positions of each element are ranked in order from small to large according to the scoring value;
3) Finally, generating the quality of the initial population based on the newly ordered candidate position optimization DDEGA.
Preferably, step S6 further includes:
The scoring value is expressed by F, the label= [ Name, type, X, Y, F ] data obtained each time are stored in a two-dimensional list Labels _1, and Labels _1 represents all candidate position information of all elements;
Namely:
Labels_1=[Label1-1,Label1-2,Label1-3,……,Label1-N*M,Label2-1,Label2-2,
Label2-3,……,Label2-N*M,……,LabelS-1,LabelS-2,LabelS-3,……,LabelS-N*M];
Label S-N*M represents the N.times.M candidate position coordinates and theoretical limit value scoring information set of the S-th element.
Preferably, the ordered result is denoted Labels _2:
Labels_2=[Label1-[1],Label1-[2],Label1-[3],……,Label1-[N*M],Label2-[1],
Label2-[2],Label2-[3],……,Label2-[N*M],……,LabelS-[1],LabelS-[2],LabelS-[3],……,LabelS-[N*M]];
Wherein Label S-[N*M] represents the candidate set of positional information for theoretical limit value Fth row N.times.M in the S-th element.
Preferably, the first candidate position Label S-[1] of each element in Labels _2 is called the theoretical optimal candidate position of the element, and the set (Label 1-[1],Label2-[1],Label3-[1],……,LabelS-[1]) is called the candidate position theoretical limit value combination V, and contains the optimal candidate position of each element under the condition of no annotation conflict, and the selection should be considered first in the annotation configuration process.
Preferably, in step S9, for the other 99 population individuals, the candidate positions are no longer randomly generated from the element numbers [1] - [ n×m ], but after the candidate position score value of Labels _2 is ordered, the candidate position selection interval is manually controlled, and the candidate position selection interval is randomly selected only in the candidate position numbers [1] - [ |n×m/3| ] (|n×m/3|represents the maximum integer not greater than n×m/3) of each element (Label 1-labelS), so as to optimize the 99 population individuals.
A two-degree-of-freedom space-based multi-element map annotation optimization DDEGA-NM system, comprising:
a central processing unit, a memory;
The memory is a short-term memory or a persistent memory;
The central processor is configured to communicate with the memory, execute instruction operations in the memory on the two-degree-of-freedom space-based multi-element map annotation optimization DDEGA-NM system to perform a two-degree-of-freedom space-based multi-element map annotation optimization DDEGA-NM algorithm;
Further comprises:
a computer-readable storage medium comprising instructions that when executed on a computer cause the computer to perform a two-degree-of-freedom space-based multi-element map annotation optimization DDEGA-NM algorithm.
The invention has the technical effects and advantages that:
1. Optimizing an initial population, and improving the quality of the initial population by adding a local optimal arrangement and combination mode and controlling the random generation range of the initial population;
2. Optimizing the genetic process, changing the differential algorithm and the proportion of individuals in the new population generated by the genetic algorithm, and adding a part of individuals randomly generated by high-quality candidate positions;
3. By optimizing DDEGA algorithm with better effect in element map annotation configuration, the initial population quality and genetic iteration process are controlled, so that the time for searching high-quality annotation candidate position combination mode can be reduced, the efficiency of automatic annotation configuration can be improved, and annotation gland and annotation ambiguity can be reduced to a certain extent.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, based on the embodiments of the invention, which are apparent to those of ordinary skill in the art without inventive faculty, are intended to be within the scope of the invention.
Thus, the following detailed description of the embodiments of the invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, based on the embodiments of the invention, which are apparent to those of ordinary skill in the art without inventive faculty, are intended to be within the scope of the invention.
The invention provides a multi-element map annotation optimization DDEGA-NM algorithm based on a two-degree-of-freedom space, which comprises input description, output description and annotation configuration processes. The detailed process of the technical scheme is described as follows:
(1) The input instruction input is experimental vector Map data Map0 of the patent of the invention, the Map comprises different layers of points, lines and planes, and each layer is provided with a plurality of elements;
(2) The output description is based on the technical method of the invention, realizes annotation configuration for each element of the map, and the output result is Outcome list, which contains the annotation candidate position Name, type, X and Y data information of each element selected, outcome = [ Name, type, X, Y ], as shown in the following table:
Table 1 outputs candidate location coordinate information Outcome
| Field name |
Meaning of field |
Field type |
Field description |
| Name |
Element name |
TEXT |
The name information of the element(s), |
| Type |
Element type |
TEXT |
Is divided into point, polyline, polygon types |
| X |
Abscissa of the circle |
DECIMAL |
Determined candidate location center point abscissa information |
| Y |
Ordinate of the ordinate |
DECIMAL |
Determined candidate location center point ordinate information |
As shown in fig. 1, (3) a token configuration process;
(3-1) definition of parameters;
(3-1-1) defining a one-dimensional list Label. Label is used for representing the coordinate information of each candidate position of the element, and comprises five fields, namely Name of the element, type of the element, X coordinate and Y coordinate of a center point of a marked candidate position, theoretical limit value score F, label= [ Name, type, X, Y, F ];
(3-1-2) defining two-dimensional lists Labels _1 and Labels _2, each representing the entire candidate location set for all elements;
(3-2) generating candidate positions, namely determining the number (N.times.M) of candidate positions and minimum and maximum buffer distance values (b min and b max) of the marks from elements based on a vector Map0, wherein the specific method is as follows:
Setting different buffer distance parameters, setting the minimum buffer distance of the notes to 1/n of a text height, setting the maximum buffer distance to 2/n, 3/n, 4/n, and 4/n of a text height, and storing all lists List1 into List2 by (for iin range) circulation function, namely, calculating the corresponding note score theoretical limit value F of different minimum and maximum buffer distances (b min and b max) by List1, wherein b min=D/8,bmax = 2*D/n, 3*D/n, 4*D/n, and n is equal to n, and the minimum and maximum buffer distances are represented by List1, and List1 is represented by List min,bmax and F List2=[[D/n,2*D/n,F1],[D/n,3*D/n,F2],[D/n,4*D/n,F3],……,[D/n,n*D/n,Fn-1]];
Determining a proper maximum buffer distance value, along with the increase of the maximum buffer distance, meaning that the selectable space range of the candidate position of the annotation is increased, the annotation with less collision of the gland is likely to occur, the corresponding theoretical limit value is gradually reduced, and when the maximum buffer distance is continuously increased, the theoretical limit value gradually shows a decreasing trend, so that a curve equation can be obtained by adopting a fitting curve mode, and then a point with a first derivative of 0 is found, wherein the point is a stable point of the curve, and the specific process is as follows:
Filling b max from 2*D/n to n D/n values into an array Ld, wherein ld= [2*D/n,3*D/n,4*D/n, ], and n is D/n, and the next step is to obtain abscissa data of a fitting curve;
Filling theoretical limit values F corresponding to different buffer distances in a List2 into an array Fd, wherein Fd= [ F 1,F2,F3,……,Fn-1 ] is used as ordinate data of a fitting curve in the next step;
Taking data in the array Ld as an abscissa and data in the array Fd as an ordinate, performing curve cubic polynomial function fitting, and solving an expression P1 of a cubic polynomial curve fitting equation, wherein P1=Ax 3+Bx2 +Cx+D;
deriving the cubic polynomial P1 to obtain a first-order derivative function p2=3ax 2 +2bx+c, and obtaining a solution x1 which is a positive number by setting the first-order derivative function to 0; if there are two positive solutions x1 and x2 (x 1< x 2), taking the smaller value of x1 as the solution, x representing the plateau under the curve;
Calculating the smallest absolute value of the difference between n and x1 in the array ld= [2*D/n,3*D/n, 4*D/n.. The number n is the appropriate maximum buffer distance b max;
Then generating N.times.M candidate positions for the point, line and surface elements respectively to obtain a candidate position set Result [ ], which is specifically as follows:
Determining a reference position according to the position of a target element on the map, wherein the target element is an element needing to be added with a mark;
determining a candidate region according to the reference position and the buffer distance, wherein the buffer distance is a preset value, and the candidate region is a partial region on the map;
Dividing the candidate region;
Determining a plurality of candidate positions according to the division result of the candidate areas;
determining one candidate position in the plurality of candidate positions as a target position;
the annotation corresponding to the target element is arranged at the target location.
(3-3) Optimizing DDEGA the mode of randomly generating the initial population by the algorithm, namely firstly scoring the generated candidate positions in (3-2) by marking gland, marking ambiguity and marking priority, then sequencing the candidate positions of each element in the order from the scoring value to the big value again, and finally optimizing DDEGA based on the candidate positions after the new sequencing to generate the quality of the initial population;
(3-3-1) using a (for iin range) circulation function, obtaining each candidate position Name, type, X and Y-coordinate information in the list Result [ ] one by one with Label, grading each candidate position by using a annotation gland, annotation ambiguity and annotation priority factor, wherein the grading value is represented by F, the label= [ Name, type, X, Y, F ] data obtained each time are stored in a two-dimensional list Labels _1, and Labels _1 represents all candidate position information of all elements;
Namely:
Labels_1=[Label1-1,Label1-2,Label1-3,……,Label1-N*M,Label2-1,Label2-2,
Label2-3,……,Label2-N*M,……,LabelS-1,LabelS-2,LabelS-3,……,LabelS-N*M];
Wherein Label S-N*M represents the N.times.M candidate position coordinates and theoretical limit value scoring information set of the S-th element, enter (3-3-2)
(3-3-2) Ranking each element of Labels _1 generated in (3-3-1) in order of decreasing score value according to theoretical limit value F of candidate position, the lower the score value, the higher the priority of the corresponding candidate position. The ordered result is denoted Labels _2:
Labels_2=[Label1-[1],Label1-[2],Label1-[3],……,Label1-[N*M],Label2-[1],
Label2-[2],Label2-[3],……,Label2-[N*M],……,LabelS-[1],LabelS-[2],LabelS-[3],……,LabelS-[N*M]];
Wherein Label S-[N*M] represents a set of candidate position information for theoretical limit value F row N.times.M in the S-th element, the first candidate position Label S-[1] of each element in Labels _2 is called theoretical optimal candidate position of the element, the set formed (Label 1-[1],Label2-[1],Label3-[1],……,LabelS-[1]) is called candidate position theoretical limit value combination V, and the optimal candidate position of each element under no annotation conflict is included, and the selection should be considered firstly in the annotation configuration process;
(3-3-3) taking the combination V of the theoretical limit values of candidate positions as an individual X (1) of the initial population, ensuring that DDEGA-NM algorithm can keep the individual with the lowest score in each cycle iteration, for the other 99 population individuals, randomly generating candidate positions from element numbers [1] - [ N ] M, artificially controlling candidate position selection intervals only in candidate position numbers [1] - [ |N ] M/3| ] ] (|N is the largest integer not more than N|M/3) of each element (Label 1-labelS) after being sequenced by Labels _2 candidate position scoring values, optimizing 99 population individuals to obtain initial population individuals X (2) -X (100), and forming initial populations Y1:X (1) -X (100);
(3-4) evaluating the population X (1) -X (100) by adopting four scoring factors of annotation conflict, annotation gland, annotation ambiguity and annotation priority, directly adding the minimum scoring value combination into the next generation population to ensure that the current optimal annotation candidate position combination is not lost, and entering (3-5);
(3-5) optimizing a genetic loop iteration process, namely sorting the scoring values of the initial populations X (1) -X (100) generated in the step (3-4), taking the individuals with the scores of the first 50% to participate in generating a next generation population, respectively generating 30% and 60% of new individuals through a Genetic Algorithm (GA) and a differential evolution algorithm (DDE), randomly selecting candidate position serial numbers [1- |N|M/3| ] of each element (Label 1-labelS) to combine and generate 10% of individuals, adding the 10% of individuals into the next generation new population to form new population individuals X (1) -X (100), and entering (3-6);
(3-6) judging whether the new populations X (1) -X (100) meet the iteration termination condition, if not, entering (3-4) to start the next loop iteration, and if so, outputting X (n) with the minimum scoring value in the new populations X (1) -X (100) to enter (3-7);
(3-7) decoding X (n) to obtain the determined candidate position coordinate information of each element (Label 1-labelS), storing Outcome, outcome = [ Name, type, X, Y ];
and (3-8) ending, and outputting a note configuration result Outcome.
According to the method, the quality of the initial population and the genetic iteration process are controlled by optimizing the DDEGA algorithm with a good effect in the element map annotation configuration, so that the time for searching a high-quality annotation candidate position combination mode can be reduced, the efficiency of automatic annotation configuration is improved, and annotation pressing and annotation ambiguity can be reduced to a certain extent.
Comparative example 1
As shown in fig. 2, the DDEGA algorithm steps are as follows:
(1) The initial population is generated by setting 8 candidate positions for each element, and then randomly selecting one candidate position around each element for combination to obtain a position set X (1), namely a group of solutions of the initial population, which are also called a group of chromosomes. In this way again, a set of Y (Y is set to 100 in the algorithm) positions X (1) -X (100), the initial population Y1, is obtained in total;
(2) Evaluating candidate positions by using four factors of annotation conflict, annotation gland, annotation ambiguity and annotation priority, so as to calculate fitness scores of all chromosomes, and then directly adding the chromosomes with the lowest scores into the next generation population;
(3) Sorting the scoring values of the initial population generated in the step (2), taking the individuals with the scores of the first 50 percent to participate in the next generation reproduction, and jointly generating a new population by a Genetic Algorithm (GA) and a differential evolution algorithm (DDE), wherein 70 percent of chromosomes are generated by the differential evolution algorithm, and 30 percent of chromosomes are generated by the genetic crossover mutation algorithm;
(4) And (3) performing loop iteration, namely outputting the optimal chromosome combination and decoding if the maximum iteration value set by iteration is reached, and entering the step (2) if the maximum iteration value is not reached, and continuing the loop iteration.
The DDEGA algorithm has a good effect on the multi-element map annotation configuration, but also has the problems of long running time and low convergence speed.
Compared with DDEGA algorithm, the method improves the quality of the initial population by adding a local optimal arrangement and combination mode and controlling the random generation range of the initial population;
secondly, changing the proportion of individuals in the new population generated by a difference algorithm and a genetic algorithm, and adding a part of individuals randomly generated by high-quality candidate positions;
Finally, by optimizing DDEGA algorithm with better effect in element map annotation configuration, the initial population quality and the genetic iteration process are controlled, so that the time for searching high-quality annotation candidate position combination mode can be reduced, the efficiency of automatic annotation configuration can be improved, and annotation pressing cover and annotation ambiguity can be reduced to a certain extent.
It should be noted that the foregoing description is only a preferred embodiment of the present invention, and although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood that modifications, equivalents, improvements and modifications to the technical solution described in the foregoing embodiments may occur to those skilled in the art, and all modifications, equivalents, and improvements are intended to be included within the spirit and principle of the present invention.