Network system figure automatization layout overcomes method and the system thereof of intersection
Technical field
The present invention relates to intelligent drawing field, particularly relate to a kind of network system figure automatization layout and overcome method and the system thereof of intersection.
Background technology
Along with deepening continuously of country's intelligent grid construction, in the construction of electrical network, operation, maintenance, need substantial amounts of drawing to support, owing to electric network data amount is big, electrical wiring is complicated, and dynamically change is frequently, if manual drawing, workload is big, and is increasingly difficult in adapt to the needs of modernization electrical network production and construction and development, and automatic mapping function seems important all the more.
Intelligent drawing requires with computer intellectual technology, Man Graphics experience is merged one, how to set up computer discernible numeric layout model according to subjective empirical criteria, for realizing key one ring of Intelligent drawing.Draw the in the world placement model in field (GraphDrawing) can be roughly divided into several types: placement model of trunk branch, orthogonal packing model, tree topology model, power guiding placement model etc..In several class models, orthogonal packing model and tree topology model have graph structure requirement, it is adaptable to specific scene.Though power leads, placement model has stronger motility, but its diversity tendency tilts cabling, has any problem when forming the orthogonal graph of horizontal vertical alignment.
In the Intelligent drawing of electrical network, domestic expert and scholar assess layout effect from the wiring aspect such as total length and crossing number, the method forming multiple-objection optimization.In multiple-objection optimization, the problem being frequently run onto is that searchable layout quantity is too big, it is necessary to adopt the algorithm optimized could find gratifying layout within the of short duration time.Additionally, the multiple outlets containing bus bar elements are usually present intersection, it is necessary to correct.
In the patent publication that publication number is 104361184A, it is proposed that a kind of electric power network automatic placement and routing system and method, including controlling module, data resolution module, layout modules, interconnection module;Described data resolution module, layout modules, interconnection module are connected with described control module respectively;Described data resolution module for reading, resolve the information of electric station and/or transformer station from data base;Described layout modules sets node according to electric station and/or substation information, and is laid out according to established rule according to node location;Described interconnection module is for connecting up according to electric station and/or substation information and layout scenarios.But what the program mainly solved is the problem of difficult interface between electrical network, it is impossible to the geographical position solving node can cause that the follow-up wiring of drawing exists the situation of the intersection being difficult to avoid that.
Summary of the invention
The technical problem to be solved is: provides a kind of network system figure automatization layout to overcome method and the system thereof of intersection, optimizes the layout of network system figure, reduce crossing number, improves layout effect.
In order to solve above-mentioned technical problem, the technical solution used in the present invention is: the method that a kind of network system figure automatization layout overcomes intersection, including
Arrangement space is carried out gridding division;
Obtain gridding divide after arrangement space in each element the first coordinate (x, y);
According to described first coordinate, (x y), calculates the manhatton distance L between each element described;
Obtain each outlet crossing number C1 containing bus bar elements respectively;
Obtain the line intersection sum S2 between each element described;
According to described manhatton distance L, outlet crossing number C1, line intersection sum S2 and first default weights omega the 1, second weights omega the 2, the 3rd weights omega 3, constitution optimization modelWherein m is the number containing bus bar elements;
According to described Optimized model, it is laid out the element in network system figure adjusting.
The invention still further relates to a kind of network system figure automatization layout and overcome the system of intersection, including
Divide module, for arrangement space is carried out gridding division;
First acquisition module, for obtain gridding divide after arrangement space in each element the first coordinate (x, y);
First computing module, for according to described first coordinate, (x y), calculates the manhatton distance L between each element described;
Second acquisition module, for obtaining each outlet crossing number C1 containing bus bar elements respectively;
3rd acquisition module, for obtaining the line intersection sum S2 between each element described;
Constructing module, for according to described manhatton distance L, outlet crossing number C1, line intersection sum S2 and first default weights omega the 1, second weights omega the 2, the 3rd weights omega 3, constitution optimization modelWherein m is the number containing bus bar elements;
Optimize module, for according to described Optimized model, being laid out the element in network system figure adjusting.
The beneficial effects of the present invention is: the total line length considering between element, line between the outlet crossing number containing bus bar elements and each element intersect sum, constitution optimization model, by reducing the value of Optimized model as far as possible, automatically desirable layout is searched out, human resources can be greatly saved, improve work efficiency, and crossing number can be reduced, improve the one-tenth figure aesthetic property of network system figure, improve layout effect;Meanwhile, the space layout utilization rate of Optimized model is high, and can need to arrange the weight of parameters, highly versatile according to user, increases the motility of Optimized model application.
Accompanying drawing explanation
Fig. 1 is the flow chart that a kind of network system figure automatization of present invention layout overcomes the method for intersection;
Fig. 2 is the method flow diagram of the embodiment of the present invention one;
Fig. 3 is the Optimized model layout effect schematic diagram of the embodiment of the present invention one;
Fig. 4 is orthogonal packing model layout effect schematic diagram;
Fig. 5 is tree topology model layout effect schematic diagram;
Fig. 6 is power guiding placement model layout effect schematic diagram;
Fig. 7 is the method flow diagram of the embodiment of the present invention two;
Fig. 8 be the embodiment of the present invention two containing bus bar elements schematic diagram;
Fig. 9 is the polar coordinate schematic diagram of the embodiment of the present invention two;
Figure 10 is the intersection schematic diagram of two set of pieces of the embodiment of the present invention three;
Figure 11 is the method flow diagram of the embodiment of the present invention three;
Figure 12 is the judgement schematic diagram that in the embodiment of the present invention three, two set of pieces lines intersect;
Figure 13 is the structural representation that a kind of network system figure automatization of present invention layout overcomes the system of intersection;
Figure 14 is the system structure schematic diagram of the embodiment of the present invention four.
Label declaration:
1, module is divided;2, the first acquisition module;3, the first computing module;4, the second acquisition module;5, the 3rd acquisition module;6, constructing module;7, module is optimized;
401, unit is set up;402, the first computing unit;403, first obtains unit;404, second obtains unit;
501, the first acquiring unit;502, the 3rd obtains unit;503, the second computing unit;504, the first judging unit;505, the 3rd computing unit;506, the second judging unit;507, the first identifying unit;508, the second identifying unit;509, the 3rd judging unit;510, the 3rd identifying unit;511, the 4th identifying unit;512, the 4th computing unit.
Detailed description of the invention
By describing the technology contents of the present invention in detail, being realized purpose and effect, below in conjunction with embodiment and coordinate accompanying drawing to be explained in detail.
The design of most critical of the present invention is in that: based on multiobject Optimized model, by searching for optimal value, the layout of network system figure is optimized.
Refer to Fig. 1, the method that a kind of network system figure automatization layout overcomes intersection, including
Arrangement space is carried out gridding division;
Obtain gridding divide after arrangement space in each element the first coordinate (x, y);
According to described first coordinate, (x y), calculates the manhatton distance L between each element described;
Obtain each outlet crossing number C1 containing bus bar elements respectively;
Obtain the line intersection sum S2 between each element described;
According to described manhatton distance L, outlet crossing number C1, line intersection sum S2 and first default weights omega the 1, second weights omega the 2, the 3rd weights omega 3, constitution optimization modelWherein m is the number containing bus bar elements;
According to described Optimized model, it is laid out the element in network system figure adjusting.
From the above it can be seen that the beneficial effects of the present invention is: by reducing the value of Optimized model as far as possible, shorten line length, reduce the crossing number in network system figure, search out desirable layout, the one-tenth figure aesthetic property of network system figure can be improved, improve layout effect.
Further, described " according to described first coordinate (x y), calculates the manhatton distance L between each element described " particularly as follows: according to formulaCalculate the manhatton distance L between each element described, wherein δ (i, j) for delta function, when having line between element i and element j, δ (i, j)=1, otherwise δ (i, j)=0.
Seen from the above description, adopt manhatton distance as weighing the model of wire length between grid nodes, meet network system figure and chart the smooth vertical and horizontal feature of cabling, and manhatton distance model has effectiveness and practicality.
Further, described " obtaining each outlet crossing number C1 containing bus bar elements respectively " particularly as follows:
With described containing bus bar elements i for initial point, be 0 direction vertically upward, be positive direction counterclockwise, set up polar coordinate system;
According to formulaCalculate and have the kth element of direct Topology connection angle in polar coordinate system, wherein (x with described containing bus bar elements ii,yi) and (xi,k,yi,k) for described the first coordinate containing bus bar elements i Yu described kth element;
Relatively with the angle of described each element having direct Topology connection containing bus bar elements i, obtain permutation number;
According to described permutation number, obtain the described outlet crossing number C1 containing bus bar elements.
Seen from the above description, by setting up polar coordinate system, calculate and compare and the angle of each element having direct Topology connection containing bus bar elements, obtaining permutation number, it is possible to the crossing number existed after releasing the wiring pressing shortest path.
Further, described " obtain the line between each element described intersect sum S2 " particularly as follows:
Obtaining two set of pieces, one of which is have the first element P1 and the second element P2 of line relation, and another group is have the third element Q1 and fourth element Q2 of line relation;
According to described first element P1, the second element P2, third element Q1 and fourth element Q2 the first coordinate, obtain primary vector Q1P2, secondary vector Q1P1, the 3rd vector P1Q1, the 4th vector P1Q2, the 5th vector Q2P1, the 6th vector Q2P2, the 7th vector P2Q2, the 8th vector P2Q1;
Calculate first multiplication cross result ε the 1, second multiplication cross result ε 2 according to formula ε 1=Q1P2 × Q1P1, ε 2=P1Q1 × P1Q2, ε 3=Q2P1 × Q2P2, ε 4=P2Q2 × P2Q1, third fork takes advantage of result ε 3 and the 4th multiplication cross result ε 4;
Judge that described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork take advantage of whether result ε 3 and the 4th multiplication cross result ε 4 is 0;
If described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork take advantage of result ε 3 and the 4th multiplication cross result ε 4 to be 0, then calculate first dot product result κ the 1, second dot product result κ 2 according to formula κ 1=Q1P2 Q1P1, κ 2=P1Q1 P1Q2, κ 3=Q2P1 Q2P2, κ 4=P2Q2 P2Q1, thirdly take advantage of result κ 3 and the 4th dot product result κ 4;
If described first dot product result κ the 1, second dot product result κ 2, thirdly taking advantage of result κ 3 and the 4th dot product result κ 4 to be all higher than 0, then judge that described two set of pieces are non-intersect, and make the line crossing number C2=0 of described two set of pieces;
If described first dot product result κ the 1, second dot product result κ 2, thirdly taking advantage of result κ 3 and the 4th dot product result κ 4 not to be all higher than 0, then judge that described two set of pieces intersect, and make the line crossing number C2=1 of described two set of pieces;
If described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork take advantage of result ε 3 and the 4th multiplication cross result ε 4 to be all higher than being equal to 0 or being respectively less than equal to 0, then judge that described two set of pieces intersect, and make the line crossing number C2=1 of described two set of pieces;
If described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork take advantage of result ε 3 and the 4th multiplication cross result ε 4 inequality be more than or equal to 0 or inequality is less than or equal to 0, then judge that described two set of pieces are non-intersect, and make the line crossing number C2=0 of described two set of pieces;
According to formulaCalculating line intersection sum S2, wherein t is that any two groups of following the example of in quantity and described two set of pieces of element having annexation are absent from common element.
Seen from the above description, judge whether two set of pieces have intersection by the multiplication cross result of vector and dot product result, simply efficiently.
Refer to Figure 13, the present invention also proposes a kind of network system figure automatization layout and overcomes the system of intersection, including:
Divide module, for arrangement space is carried out gridding division;
First acquisition module, for obtain gridding divide after arrangement space in each element the first coordinate (x, y);
First computing module, for according to described first coordinate, (x y), calculates the manhatton distance L between each element described;
Second acquisition module, for obtaining each outlet crossing number C1 containing bus bar elements respectively;
3rd acquisition module, for obtaining the line intersection sum S2 between each element described;
Constructing module, for according to described manhatton distance L, outlet crossing number C1, line intersection sum S2 and first default weights omega the 1, second weights omega the 2, the 3rd weights omega 3, constitution optimization modelWherein m is the number containing bus bar elements;
Optimize module, for according to described Optimized model, being laid out the element in network system figure adjusting.
Further, described first computing module is specifically for according to formulaCalculate the manhatton distance L between each element described, wherein δ (i, j) for delta function, when having line between element i and element j, δ (i, j)=1, otherwise δ (i, j)=0.
Further, described second acquisition module includes
Set up unit, for described containing bus bar elements i for initial point, be 0 direction vertically upward, be positive direction counterclockwise, set up polar coordinate system;
First computing unit, for according to formulaCalculate and have the kth element of direct Topology connection angle in polar coordinate system, wherein (x with described containing bus bar elements ii,yi) and (xi,k,yi,k) for described the first coordinate containing bus bar elements i Yu described kth element;
First obtains unit, for comparing and the angle of described each element having direct Topology connection containing bus bar elements i, obtains permutation number;
Second obtains unit, for according to described permutation number, obtaining the described outlet crossing number C1 containing bus bar elements.
Further, described 3rd acquisition module includes
First acquiring unit, is used for obtaining two set of pieces, and one of which is have the first element P1 and the second element P2 of line relation, and another group is have the third element Q1 and fourth element Q2 of line relation;
3rd obtains unit, for according to described first element P1, the second element P2, third element Q1 and fourth element Q2 the first coordinate, obtain primary vector Q1P2, secondary vector Q1P1, the 3rd vector P1Q1, the 4th vector P1Q2, the 5th vector Q2P1, the 6th vector Q2P2, the 7th vector P2Q2, the 8th vector P2Q1;
Second computing unit, for calculating first multiplication cross result ε the 1, second multiplication cross result ε 2 according to formula ε 1=Q1P2 × Q1P1, ε 2=P1Q1 × P1Q2, ε 3=Q2P1 × Q2P2, ε 4=P2Q2 × P2Q1, third fork takes advantage of result ε 3 and the 4th multiplication cross result ε 4;
First judging unit, is used for judging that described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork take advantage of whether result ε 3 and the 4th multiplication cross result ε 4 is 0;
3rd computing unit, if taking advantage of result ε 3 and the 4th multiplication cross result ε 4 to be 0 for described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork, then calculate first dot product result κ the 1, second dot product result κ 2 according to formula κ 1=Q1P2 Q1P1, κ 2=P1Q1 P1Q2, κ 3=Q2P1 Q2P2, κ 4=P2Q2 P2Q1, thirdly take advantage of result κ 3 and the 4th dot product result κ 4;
First identifying unit, if for described first dot product result κ the 1, second dot product result κ 2, thirdly taking advantage of result κ 3 and the 4th dot product result κ 4 to be all higher than 0, then judges that described two set of pieces are non-intersect, and makes the line crossing number C2=0 of described two set of pieces;
Second identifying unit, if for described first dot product result κ the 1, second dot product result κ 2, thirdly taking advantage of result κ 3 and the 4th dot product result κ 4 not to be all higher than 0, then judges that described two set of pieces intersect, and makes the line crossing number C2=1 of described two set of pieces;
3rd identifying unit, if taking advantage of result ε 3 and the 4th multiplication cross result ε 4 to be all higher than being equal to 0 or being respectively less than equal to 0 for described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork, then judge that described two set of pieces intersect, and make the line crossing number C2=1 of described two set of pieces;
4th identifying unit, if for described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork takes advantage of result ε 3 and the 4th multiplication cross result ε 4 inequality be more than or equal to 0 or inequality is less than or equal to 0, then judge that described two set of pieces are non-intersect, and make the line crossing number C2=0 of described two set of pieces;
4th computing unit, for according to formulaCalculating line intersection sum S2, wherein t is that any two groups of following the example of in quantity and described two set of pieces of element having annexation are absent from common element.
Embodiment one
Refer to Fig. 2, embodiments of the invention one are: the method that a kind of network system figure automatization layout overcomes intersection, comprise the steps:
S1: arrangement space is carried out gridding division;
Sparse grid will limit layout effect, affect model flexibility, grid is overstocked, can increase computational expense, also layout cosmetic requirements is produced impact, balanced consideration systematic function and model flexibility, the division of cell size Yu arrangement space is provided as follows: use the cell of formed objects to divide layout areas, each element only accounts for a line, not allowing inter-bank to put, element can take up the multiple cells in a line, at most has an element in each cell.Element is placed in cell central authorities, reserves cabling space in element surrounding;That is, it is assumed that arrangement space is rectangular area, according to certain horizontal spacing WunitWith longitudinal pitch HunitSet up grid, Wunit=min (wi)+WspaceI=1 ... n, Hunit=max (hi)+HspaceI=1 ... n, wherein WunitWith HunitFor cell width, wiAnd hiFor the width of i-th element, n is the quantity of element, WspaceAnd HspaceFor the width at the reserved cable tray of element surrounding.
S2: obtain gridding divide after arrangement space in each element the first coordinate (x, y);
Alternatively, for convenience of computer disposal, the upper left corner of arrangement space being set to initial point, level is to the right x-axis positive direction, is y-axis positive direction vertically downward.
S3: judge whether have line between each element, namely judges whether have line between any two element i and j in arrangement space, if so, then performs step S4, if it is not, then perform step S5.
S4: make delta function δ (i, j)=1.
S5: make delta function δ (i, j)=0.
S6: according to the first coordinate of each element and formulaCalculate the manhatton distance L between each element, wherein (xi,yi) for first coordinate of element i, (xj,yj) for first coordinate of element j, n is the quantity of element in arrangement space.
S7: obtain in network system figure containing bus bar elements.
S8: obtain each outlet crossing number C1 containing bus bar elements respectively;Under normal circumstances, bus outlet joint is thrown into element lower end, and according to serial number from left to right, the element of its connection easily improper causes outlet to intersect because putting, the outlet crossing number i.e. crossing number of outlet containing bus bar elements.
S9: obtain the line intersection sum S2 between each element described;Can first take 4 elements that two lines connect, judging whether two lines connecting these 4 elements have intersection, if there being intersection, making its line crossing number is 1, otherwise is then 0, obtain the line crossing number of all described two lines, carry out summation and be line intersection sum.
S10: according to described manhatton distance L, outlet crossing number C1, line intersection sum S2 and first default weights omega the 1, second weights omega the 2, the 3rd weights omega 3, constitution optimization modelWherein m is the number containing bus bar elements.
First weights omega the 1, second weights omega the 2, the 3rd weights omega 3 can directly set manually, namely directly one group of weight is provided by system diagram associated user, it has reacted everyone for line length and two kinds of detest degree intersected, degree is more high, the weight provided is more big, by many people are provided the average of weight, it may be determined that the average preference of system diagram associated user;Can also be set by statistical computation, sequence distributed model in Corpus--based Method, system diagram according to existing manual layout, calculate the value of line length and two kinds of crossing numbers respectively, obtain the sequence distribution of three values, so that it is determined that the proportionate relationship between three values, then it is multiplied by normalisation coefft and can draw weight;Qualitative modeling can also be passed through, the value of three obtained to the value of manually set three weights and statistical computation weights is averaged respectively, as the value of final three weights.
S11: according to described Optimized model, is laid out the element in network system figure adjusting;The value of Optimized model is more little, and layout effect is more good, in seeking the process of optimal solution of described Optimized model, adopt exchange component position, and element being put into the mode of blank position, the direction towards the value F reducing Optimized model is carried out search and is attempted, and finally searches desirable layout.Preferably, in optimization process, the layout of all generations is got rid of and is repeated, as long as the value of Optimized model corresponding to the layout generated is better than the layout of current accessed, then suspends and generates other layouts, and the more optimal layout of priority access, to improve search efficiency.
Line alignment in network system figure is generally determined by shortest path first, and common shortest path first has depth-first search, BFS, A*Algorithm and Djisktra algorithm.It is alternatively possible to use the Djisktra algorithm on Weight grid to complete the calculating of interelement line in network system figure.
For verifying the layout effect of described Optimized model, choose common three kind placement model to compare, including tree topology model, orthogonal packing model, power guiding placement model, use 100 parts of simulating grid topological datas as example, compare into that figure is attractive in appearance and readability by being directly rendered into figure result, carry out the comparison model interest rate situation to space by being calculated as grid number shared by figure with length-width ratio.
Fig. 3 is Optimized model layout effect schematic diagram, and Fig. 4 is orthogonal packing model layout effect schematic diagram, and Fig. 5 is tree topology model layout effect schematic diagram, and Fig. 6 is power guiding placement model layout effect schematic diagram;Table 1 comprises the space availability ratio of above-mentioned four kinds of models, and table 2 comprises the above-mentioned four kinds of models control ability to arrangement space length-width ratio Yu specific area.
|
Layout is taken up space |
Space availability ratio |
Optimized model |
121 units |
24.8% |
Orthogonal packing |
567 units |
5.3% |
Tree topology |
234 units |
12.8% |
Power guiding layout |
391 units |
7.7% |
Table 1
|
Can control area |
Length-width ratio 7 can be controlled--> |
Model for Multi-Objective Optimization |
Yes |
Yes |
Orthogonal packing |
No |
No |
Tree topology |
No |
No |
Power guiding layout |
Yes |
Yes |
Table 2
Comparison diagram 3-6 and table 1-2, result shows, described Optimized model has significant advantage in control arrangement space length-width ratio and optimization arrangement space utilization rate, has all reached achiasmate effect with the model compared reducing on crossing elimination.
Embodiment two
Refer to Fig. 7, the present embodiment is on embodiment one basis, and a kind of specific implementation of step S8 therein comprises the steps:
S801: with containing bus bar elements i for initial point, be 0 direction vertically upward, be positive direction counterclockwise, set up polar coordinate system, angular unit is set as radian, if element i-node degree is dj。
S802: calculating each has the element of direct Topology connection angle in polar coordinate system with described containing bus bar elements;According to formulaCalculate and have the kth element of direct Topology connection angle in polar coordinate system, wherein (x with described containing bus bar elements ii,yi) and (xi,k,yi,k) for described the first coordinate containing bus bar elements i Yu described kth element, k=1 ... dj。
S803: compare and the angle of described each element having direct Topology connection containing bus bar elements i, obtain permutation number;Permutation number is defined as: if 1,2,3 ... a fully intermeshing p of this n number of n1,p2,p3…pnIn, there is pi>pj, < during j, just claim this is a backward to i, arranges p1,p2,p3…pnThe sum of middle backward is called the permutation number of this arrangement.
S804: according to described permutation number, obtains the described outlet crossing number C1 containing bus bar elements;Namely outlet crossing number C1 is equal to permutation number.
Such as, as shown in Figure 8, a kind of element A, B, C, D having direct Topology connection containing bus bar elements with it puts schematic diagram, when calculating angle, for avoiding the multiple element angle of horizontal line to overlap, it is impossible to differentiate and whether intersect, such as element C and element D, initial point slightly can be offset to outlet direction, as shown in Figure 9;Alternatively, offset distance is 0.1 cell or 0.01 cell;A, B, C, D element angle respectively 116 °, 68 °, 279 °, 272 ° containing bus bar elements relatively is calculated according to the formula in step S802, what obtain is ordered as 116 ° < 68 ° < 279 ° < 272 °, the backward wherein existed has: 116 ° < 68 ° and 279 ° < 272 °, namely permutation number is 2, there are 2 intersections after releasing the wiring pressing shortest path, be namely somebody's turn to do the outlet crossing number C1=2 containing bus bar elements.
Because the positive direction that reverse direction is described polar coordinate system, it is thus preferred to ground, it is possible to the angle directly obtaining four elements is ordered as B < A < D < C, contrast sequence A < B < C < D, there are two backwards, namely permutation number is 2, can be readily available the outlet crossing number C1=2 being namely somebody's turn to do containing bus bar elements.
Embodiment three
The present embodiment is on embodiment one basis, and a kind of specific implementation of step S9 therein, in practical layout, there is multiple both threads and be connected to the intersection that four elements occur, such as the decussation on the left of Figure 10, the corner in the middle part of Figure 10 intersects, and on the right side of more random situation such as Figure 10.Although element relative position exists various situation, in layout, the detection of this kind of intersection finds, is all used uniformly across two line segments intersection judgements and processes.
Usual two line segment intersections, the tetragon interior angle that surrounds is all little is equal to 180 °;Two line segments are non-intersect, there is interior angle more than 180 °.Comparatively laborious owing to calculating interior angle size, therefore judge with four vectorial multiplication cross result ε 1, ε 2, ε 3 and ε 4, also have more than 0 less than 0 once discovery is wherein existing, correspond to tetragon and there is the interior angle situation more than 180 ° with less than 180 ° simultaneously, it is possible to quickly return the two disjoint results of line segment.Special circumstances, four vectorial multiplication cross results are congruent to 0, correspond to two line segments on the same line, need to calculate four vector dot result κ 1, κ 2, κ 3 and κ 4, if complete in 0, non-intersect, otherwise two line segment intersection.
Refer to Figure 11, in the present embodiment, step S9 specifically may include steps of:
S901: obtain two set of pieces, one of which is have the first element P1 and the second element P2 of line relation, and another group is have the third element Q1 and fourth element Q2 of line relation.
S902: according to described first element P1, the second element P2, third element Q1 and fourth element Q2 the first coordinate, obtain primary vector Q1P2, secondary vector Q1P1, the 3rd vector P1Q1, the 4th vector P1Q2, the 5th vector Q2P1, the 6th vector Q2P2, the 7th vector P2Q2, the 8th vector P2Q1.
S903: calculate first multiplication cross result ε the 1, second multiplication cross result ε 2 according to formula ε 1=Q1P2 × Q1P1, ε 2=P1Q1 × P1Q2, ε 3=Q2P1 × Q2P2, ε 4=P2Q2 × P2Q1, third fork takes advantage of result ε 3 and the 4th multiplication cross result ε 4.
S904: judge that described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork take advantage of whether result ε 3 and the 4th multiplication cross result ε 4 is 0, if so, then performs step S905, if it is not, then perform step S909.
S905: calculate first dot product result κ the 1, second dot product result κ 2 according to formula κ 1=Q1P2 Q1P1, κ 2=P1Q1 P1Q2, κ 3=Q2P1 Q2P2, κ 4=P2Q2 P2Q1, thirdly take advantage of result κ 3 and the 4th dot product result κ 4.
S906: judge described first dot product result κ the 1, second dot product result κ 2, thirdly take advantage of whether result κ 3 and the 4th dot product result κ 4 is all higher than 0, if so, then performs step S907, if it is not, then perform step S908.
S907: judge that described two set of pieces are non-intersect, namely without intersecting, and makes the line crossing number C2=0 of described two set of pieces.
S908: judge that described two set of pieces intersect, namely have intersection, and make the line crossing number C2=1 of described two set of pieces.
S909: judge that described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork take advantage of whether result ε 3 and the 4th multiplication cross result ε 4 is all higher than being equal to 0 or being respectively less than equal to 0, if so, then perform S910, if it is not, then perform step S911.
S910: judge that described two set of pieces intersect, and make the line crossing number C2=1 of described two set of pieces.
S911: judge that described two set of pieces are non-intersect, and make the line crossing number C2=0 of described two set of pieces.
S912: obtain the line crossing number C2 of all any two set of pieces in arrangement space, according to formulaCalculate line intersection sum S2, wherein t is that any two groups of following the example of in quantity and described two set of pieces of element having annexation are absent from common element, namely arbitrarily take out in all lines two lines and meet that these two lines are not connected to mutual component follow the example of quantity.
Such as, multiplication cross result respectively ε 1 that in Figure 12, two set of pieces shown in (a) are calculated > 0, ε 2 > 0, ε 3 > 0, ε 4 > 0, four multiplication cross results are all higher than 0, therefore, it is determined that it intersects, C2=1;Multiplication cross result respectively ε 1 < 0 that in Figure 12, two set of pieces shown in (b) are calculated, ε 2 < 0, ε 3 < 0, ε 4 < 0, four multiplication cross results are respectively less than 0, therefore, it is determined that it intersects, C2=1;Multiplication cross result respectively ε 1<0, the ε 2>0 that in Figure 12, two set of pieces shown in (b) are calculated, because there is the situation more than 0 with less than 0 simultaneously, third fork can be calculated and take advantage of result ε 3 and the 4th multiplication cross result ε 4, directly judge that described two set of pieces are non-intersect, C2=0;Multiplication cross result respectively ε 1=0 that in Figure 12, two set of pieces shown in (e) are calculated, ε 2 > 0, ε 3 > 0, ε 4 > 0, four multiplication cross results are all higher than being equal to 0, therefore, it is determined that it intersects, C2=1;For (e) in Figure 12 and (f), its four calculated multiplication cross results are 0, therefore its four dot product results are calculated, for two set of pieces shown in (e), its calculated dot product result respectively κ 1 > 0, κ 2 > 0, κ 3 > 0, κ 4 > 0, four dot product results are all higher than 0, therefore, it is determined that described two set of pieces are non-intersect, and C2=0;For two set of pieces shown in (f), its calculated dot product result respectively κ 1>0, κ 2<0, κ 3<0, κ 4>0, four dot product results are not all higher than 0, therefore, it is determined that described two set of pieces intersect, C2=1.
Embodiment four
Refer to Figure 14, the present embodiment is the system that a kind of network system figure automatization layout on the basis of embodiment one, embodiment two and embodiment three overcomes intersection, including
Divide module 1, for arrangement space is carried out gridding division;
First acquisition module 2, for obtain gridding divide after arrangement space in each element the first coordinate (x, y);
First computing module 3, for according to described first coordinate, (x y), calculates the manhatton distance L between each element described;Specifically for according to formulaCalculate the manhatton distance L between each element described, wherein δ (i, j) for delta function, when having line between element i and element j, δ (i, j)=1, otherwise δ (i, j)=0;
Second acquisition module 4, for obtaining each outlet crossing number C1 containing bus bar elements respectively;
3rd acquisition module 5, for obtaining the line intersection sum S2 between each element described;
Constructing module 6, for according to described manhatton distance L, outlet crossing number C1, line intersection sum S2 and first default weights omega the 1, second weights omega the 2, the 3rd weights omega 3, constitution optimization modelWherein m is the number containing bus bar elements;
Optimize module 7, for according to described Optimized model, being laid out the element in network system figure adjusting.
Described second acquisition module 4 includes
Set up unit 401, for described containing bus bar elements i for initial point, be 0 direction vertically upward, be positive direction counterclockwise, set up polar coordinate system;
First computing unit 402, for according to formulaCalculate and have the kth element of direct Topology connection angle in polar coordinate system, wherein (x with described containing bus bar elements ii,yi) and (xi,k,yi,k) for described the first coordinate containing bus bar elements i Yu described kth element;
First obtains unit 403, for comparing and the angle of described each element having direct Topology connection containing bus bar elements i, obtains permutation number;
Second obtains unit 404, for according to described permutation number, obtaining the described outlet crossing number C1 containing bus bar elements.
Described 3rd acquisition module 5 includes
First acquiring unit 501, is used for obtaining two set of pieces, and one of which is have the first element P1 and the second element P2 of line relation, and another group is have the third element Q1 and fourth element Q2 of line relation;
3rd obtains unit 502, for according to described first element P1, the second element P2, third element Q1 and fourth element Q2 the first coordinate, obtain primary vector Q1P2, secondary vector Q1P1, the 3rd vector P1Q1, the 4th vector P1Q2, the 5th vector Q2P1, the 6th vector Q2P2, the 7th vector P2Q2, the 8th vector P2Q1;
Second computing unit 503, for calculating first multiplication cross result ε the 1, second multiplication cross result ε 2 according to formula ε 1=Q1P2 × Q1P1, ε 2=P1Q1 × P1Q2, ε 3=Q2P1 × Q2P2, ε 4=P2Q2 × P2Q1, third fork takes advantage of result ε 3 and the 4th multiplication cross result ε 4;
First judging unit 504, is used for judging that described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork take advantage of whether result ε 3 and the 4th multiplication cross result ε 4 is 0;
3rd computing unit 505, if taking advantage of result ε 3 and the 4th multiplication cross result ε 4 to be 0 for described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork, then calculate first dot product result κ the 1, second dot product result κ 2 according to formula κ 1=Q1P2 Q1P1, κ 2=P1Q1 P1Q2, κ 3=Q2P1 Q2P2, κ 4=P2Q2 P2Q1, thirdly take advantage of result κ 3 and the 4th dot product result κ 4;
Second judging unit 506, is used for judging described first dot product result κ the 1, second dot product result κ 2, thirdly taking advantage of whether result κ 3 and the 4th dot product result κ 4 is all higher than 0;
First identifying unit 507, if for described first dot product result κ the 1, second dot product result κ 2, thirdly taking advantage of result κ 3 and the 4th dot product result κ 4 to be all higher than 0, then judges that described two set of pieces are non-intersect, and makes the line crossing number C2=0 of described two set of pieces;
Second identifying unit 508, if for described first dot product result κ the 1, second dot product result κ 2, thirdly taking advantage of result κ 3 and the 4th dot product result κ 4 not to be all higher than 0, then judges that described two set of pieces intersect, and makes the line crossing number C2=1 of described two set of pieces;
3rd judging unit 509, is used for judging that described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork take advantage of whether result ε 3 and the 4th multiplication cross result ε 4 is all higher than 0 or is respectively less than 0;
3rd identifying unit 510, if taking advantage of result ε 3 and the 4th multiplication cross result ε 4 to be all higher than being equal to 0 or being respectively less than equal to 0 for described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork, then judge that described two set of pieces intersect, and make the line crossing number C2=1 of described two set of pieces;
4th identifying unit 511, if for described first multiplication cross result ε the 1, second multiplication cross result ε 2, third fork takes advantage of result ε 3 and the 4th multiplication cross result ε 4 inequality be more than or equal to 0 or inequality is less than or equal to 0, then judge that described two set of pieces are non-intersect, and make the line crossing number C2=0 of described two set of pieces;
4th computing unit 512, for according to formulaCalculating line intersection sum S2, wherein t is that any two groups of following the example of in quantity and described two set of pieces of element having annexation are absent from common element.
In sum, a kind of network system figure automatization provided by the invention layout overcomes method and the system thereof of intersection, adopt manhatton distance as weighing the model of wire length between grid nodes, meet network system figure to chart the smooth vertical and horizontal feature of cabling, and manhatton distance model has effectiveness and practicality;By setting up polar coordinate system, calculate and compare and the angle of each element having direct Topology connection containing bus bar elements, obtaining permutation number, the crossing number existed after releasing the wiring pressing shortest path;Judge whether two set of pieces have intersection by the multiplication cross result of vector and dot product result, simply efficiently;Consider the line between the total line length between element, outlet crossing number and each element containing bus bar elements and intersect sum, constitution optimization model, by reducing the value of Optimized model as far as possible, automatically desirable layout is searched out, human resources can be greatly saved, raising work efficiency, and the one-tenth figure aesthetic property of network system figure can be improved, improve layout effect;Meanwhile, the space layout utilization rate of Optimized model is high, and can need to arrange the weight of parameters, highly versatile according to user, increases the motility of Optimized model application.
The foregoing is only embodiments of the invention; not thereby the scope of the claims of the present invention is limited; every equivalents utilizing description of the present invention and accompanying drawing content to make, or directly or indirectly it is used in relevant technical field, all in like manner include in the scope of patent protection of the present invention.