Summary of the invention
The present invention proposes a kind of based on the preferential channel cubic metre of earth and stone moving method of minimum distance, and the present invention can support extensive channel segmentation cubic metre of earth and stone balance allotment.
The present invention adopts following technical scheme:
A kind of based on the preferential channel cubic metre of earth and stone moving method of minimum distance, it is characterized in that: channel is divided into equidistant m section, wherein the value of m is the positive integer greater than 0, the value maximum of m can arrive 10000, obtain the 1st section, the 2nd section, the 3rd section, the m section, the segmentation number of maximum cut-fill transition distance is k, wherein the value of k is the positive integer greater than 0, the value maximum of k can arrive 100, obtain the surplus of each segmentation interior cubic metre of earth and stone amount of excavation or amount of fill, at first between all adjacent segmentations, carry out the balance allotment of cubic meter amount of excavation and amount of fill, then between the adjacent segmentation of all times, carry out a cubic meter balance allotment, and the like, carry out a cubic meter balance allotment between all segmentations in maximum allotment segmentation distance range, if in maximum allotment segmentation distance range, still have the segmentation cubic metre of earth and stone not have balance, then directly spoir or borrow earth, concrete steps are as follows:
The 1st step: parameter is set
The cubic metre of earth and stone surplus of each segmentation in m the segmentation is set to T[1 respectively], T[2], T[m], the residue earthwork is that cubic metre of earth and stone residue is arranged in this segmentation of positive numerical representation, need this cubic metre of earth and stone is moved to other segmentation or directly cheats spoir to spoir, the residue earthwork is that the segmentation of negative represents to lack in this segmentation the cubic metre of earth and stone, need be from other segmentation or ditch borrow earth, two-dimensional array a[m+1 is set] [m+1], be used to write down the earthwork of allocating between the segmentation, the initial value that array a is set is 0, if carrying out the number-of-fragments of cut-fill transition is i, the allotment step-length is j, it is 1 that first number-of-fragments i that begins to allocate is set, the step-length j that begins to allocate is 1, enters for the 2nd step, and described step-length is the difference of carrying out between cubic meter number-of-fragments of two segmentations of balance allotment;
The 2nd step: calculating need be carried out cubic meter numbering of two segmentations of balance allotment
Carry out cubic meter two number-of-fragments of balance allotment and be respectively i and i+j, entered into for the 3rd step;
Whether the 3rd step: judging needs to carry out a cubic meter balance allotment between two segmentations
If the cubic metre of earth and stone surplus T[i of i section] and the cubic metre of earth and stone surplus T[i+j of i+j section] multiplied result is more than or equal to 0 between the two, then do not need to carry out a cubic meter balance allotment between two segmentations, the cubic metre of earth and stone surplus T[i of i section] and the cubic metre of earth and stone surplus T[i+j of i+j section] value do not do any variation, enters into for the 5th step; Otherwise entered for the 4th step;
The 4th step: carry out a cubic meter balance allotment between two segmentations
If the cubic metre of earth and stone surplus T[i of i section] absolute value more than or equal to the cubic metre of earth and stone surplus T[i+j of i+j section] absolute value, the cubic metre of earth and stone surplus T[i of i section then is set] equal the cubic metre of earth and stone surplus T[i of i section] add the cubic metre of earth and stone surplus T[i+j of i+j section], a[i is set] [i+j] equal the cubic metre of earth and stone surplus T[i+j of i+j section], a[i+j is set] [i] equal the cubic metre of earth and stone surplus T[i+j of i+j section] negative, the cubic metre of earth and stone surplus T[i+j of i+j section is set] equal 0; If the cubic metre of earth and stone surplus T[i of i section] absolute value is less than the cubic metre of earth and stone surplus T[i+j of i+j section] absolute value, the cubic metre of earth and stone surplus T[i+j of i+j section then is set] equal the cubic metre of earth and stone surplus T[i+j of i+j section] add the cubic metre of earth and stone surplus T[i of i section], the two-dimensional array a[i+j of allotment earthwork is set between i+j section and the i section] [i] equal the cubic metre of earth and stone surplus T[i of i section], the two-dimensional array a[i of allotment earthwork between record i section and the i+j section is set] [i+j] equal the cubic metre of earth and stone surplus T[i of i section] negative, the cubic metre of earth and stone surplus T[i of i section is set] equal 0; Entered for the 5th step;
The 5th step: new number-of-fragments i is set
If current number-of-fragments i+j less than m, then is provided with i and equals i+1, entered into for the 2nd step; If current number-of-fragments i+j equals m, then entered for the 6th step;
The 6th step: new allotment step-length j is set
If current allotment step-length j then is provided with j and equals j+1 less than k, i is set equals 1, got back to for the 2nd step; If current allotment step-length j equals k, entered for the 7th step;
The 7th step: cut-fill transition finishes
The channel cut-fill transition finishes, and with each fragmentation value output of the residue cubic metre of earth and stone non-0, will write down result's output of the two-dimensional array a of allotment earthwork between the segmentation, and computing finishes.
Compared with prior art, the present invention has following advantage and beneficial effect:
1, this method only need be carried out the bidimensional cycle calculations and can be realized cubic metre of earth and stone balance allotment between the channel segmentation, avoid classic method to exist and carry out the efficiency that the cubic metre of earth and stone is optimized the allotment existence, thereby this method can be supported extensive channel segmentation cubic metre of earth and stone balance allotment;
2, because this method is simple and computing velocity is fast, thereby can carry out polytype channel route selection at short notice, reduce the computation burden of route selection, and then produce the more variant projects of location of selecting;
3, this method can also be applied to optimal design such as Water Resources Allocation, output pipe network laying, highway cut-fill transition, freight transportation allotment.
Embodiment
Based on the preferential channel cubic metre of earth and stone moving method of minimum distance, it is characterized in that: channel is divided into equidistant m section, wherein the value of m is the positive integer greater than 0, the value maximum of m can arrive 10000, obtain the 1st section, the 2nd section, the 3rd section, the m section, the segmentation number of maximum cut-fill transition distance is k, wherein the value of k is the positive integer greater than 0, the value maximum of k can arrive 100, obtain the surplus of each segmentation interior cubic metre of earth and stone amount of excavation or amount of fill, at first between all adjacent segmentations, carry out the balance allotment of cubic meter amount of excavation and amount of fill, then between the adjacent segmentation of all times, carry out a cubic meter balance allotment, and the like, carry out a cubic meter balance allotment between all segmentations in maximum allotment segmentation distance range, if in maximum allotment segmentation distance range, still have the segmentation cubic metre of earth and stone not have balance, then directly spoir or borrow earth, concrete steps are as follows:
The 1st step: parameter is set
The cubic metre of earth and stone surplus of each segmentation in m the segmentation is set to T[1 respectively], T[2], T[m], the residue earthwork is that cubic metre of earth and stone residue is arranged in this segmentation of positive numerical representation, need this cubic metre of earth and stone is moved to other segmentation or directly cheats spoir to spoir, the residue earthwork is that the segmentation of negative represents to lack in this segmentation the cubic metre of earth and stone, need be from other segmentation or ditch borrow earth, two-dimensional array a[m+1 is set] [m+1], be used to write down the earthwork of allocating between the segmentation, the initial value that array a is set is 0, if carrying out the number-of-fragments of cut-fill transition is i, the allotment step-length is j, it is 1 that first number-of-fragments i that begins to allocate is set, the step-length j that begins to allocate is 1, enters for the 2nd step, and described step-length is the difference of carrying out between cubic meter number-of-fragments of two segmentations of balance allotment;
The 2nd step: calculating need be carried out cubic meter numbering of two segmentations of balance allotment
Carry out cubic meter two number-of-fragments of balance allotment and be respectively i and i+j, entered into for the 3rd step;
Whether the 3rd step: judging needs to carry out a cubic meter balance allotment between two segmentations
If the cubic metre of earth and stone surplus T[i of i section] and the cubic metre of earth and stone surplus T[i+j of i+j section] multiplied result is more than or equal to 0 between the two, then do not need to carry out a cubic meter balance allotment between two segmentations, the cubic metre of earth and stone surplus T[i of i section] and the cubic metre of earth and stone surplus T[i+j of i+j section] value do not do any variation, enters into for the 5th step; Otherwise entered for the 4th step;
The 4th step: carry out a cubic meter balance allotment between two segmentations
If the cubic metre of earth and stone surplus T[i of i section] absolute value more than or equal to the cubic metre of earth and stone surplus T[i+j of i+j section] absolute value, the cubic metre of earth and stone surplus T[i of i section then is set] equal the cubic metre of earth and stone surplus T[i of i section] add the cubic metre of earth and stone surplus T[i+j of i+j section], a[i is set] [i+j] equal the cubic metre of earth and stone surplus T[i+j of i+j section], a[i+j is set] [i] equal the cubic metre of earth and stone surplus T[i+j of i+j section] negative, the cubic metre of earth and stone surplus T[i+j of i+j section is set] equal 0; If the cubic metre of earth and stone surplus T[i of i section] absolute value is less than the cubic metre of earth and stone surplus T[i+j of i+j section] absolute value, the cubic metre of earth and stone surplus T[i+j of i+j section then is set] equal the cubic metre of earth and stone surplus T[i+j of i+j section] add the cubic metre of earth and stone surplus T[i of i section], the two-dimensional array a[i+j of allotment earthwork is set between i+j section and the i section] [i] equal the cubic metre of earth and stone surplus T[i of i section], the two-dimensional array a[i of allotment earthwork between record i section and the i+j section is set] [i+j] equal the cubic metre of earth and stone surplus T[i of i section] negative, the cubic metre of earth and stone surplus T[i of i section is set] equal 0; Entered for the 5th step;
The 5th step: new number-of-fragments i is set
If current number-of-fragments i+j less than m, then is provided with i and equals i+1, entered into for the 2nd step; If current number-of-fragments i+j equals m, then entered for the 6th step;
The 6th step: new allotment step-length j is set
If current allotment step-length j then is provided with j and equals j+1 less than k, i is set equals 1, got back to for the 2nd step; If current allotment step-length j equals k, entered for the 7th step;
The 7th step: cut-fill transition finishes
The channel cut-fill transition finishes, and with each fragmentation value output of the residue cubic metre of earth and stone non-0, will write down result's output of the two-dimensional array a of allotment earthwork between the segmentation, and computing finishes.
Fig. 1, Fig. 2 are based on the preferential channel optimization method for designing of minimum distance and represent the synoptic diagram, process flow diagram and the false code that relate in the embodiment, and the section length that maximum adjustable is joined among Fig. 1 is 3,
The concrete technical step that the invention process is given an example is as follows:
(1) the 1st step: parameter is set
It is 5 that the equidistant segments of channel is set, the segmentation number that maximum allotment distance is set is 2, the cubic metre of earth and stone surplus that each segmentation in 5 segmentations is set is respectively T[1]=2, T[2]=-3, T[3]=-2, T[4]=3, T[5]=1, the residue earthwork is that cubic metre of earth and stone residue is arranged in this segmentation of positive numerical representation, need this cubic metre of earth and stone is moved to other segmentation or directly cheats spoir to spoir, the residue earthwork is that the segmentation of negative represents to lack in this segmentation the cubic metre of earth and stone, need be from other segmentation or ditch borrow earth, two-dimensional array a[6 is set] earthwork allocated between the segmentation of [6] record, the initial value that array a is set is 0, it is 1 that first number-of-fragments i that begins to allocate is set, the step-length j that begins to allocate is 1, described step-length is the difference of carrying out between cubic meter number-of-fragments of two segmentations of balance allotment, if current two number-of-fragments of allocating are 1 and 2, then step-length is 1, if current two number-of-fragments of allocating are 2 and 4, then step-length is numbered 2, enters for (2) the 2nd steps;
(2) the 2nd steps: two number-of-fragments that calculating need be allocated
If carrying out the number-of-fragments of cut-fill transition is 1, the allotment step-length is 1, and two number-of-fragments then allocating are respectively 1 and 2, enters into for (3) the 3rd steps;
Whether (3) the 3rd steps: judging needs to carry out a cubic meter balance allotment between two segmentations
T[1] * T[2]=2* (3)=-6 is less than 0, then needs to carry out a cubic meter balance allotment between two segmentations, enters for (4) the 4th steps;
(4) the 4th steps: carry out a cubic meter balance allotment between two segmentations
T[1] absolute value be 2, T[2] absolute value is 3, T[2] absolute value is greater than T[1] absolute value, T[2 is set]=T[2]+T[1]=-3+2=-1, a[2 is set] [1] equal 2, and a[1 is set] [2] equal-2, T[1]=0, entered for (5) the 5th steps;
(5) the 5th steps: new number-of-fragments i is set
Current number-of-fragments i+j=1+1 then is provided with i=i+1=2 less than m=5, gets back to for (6) the 2nd steps;
(6) the 2nd steps: two number-of-fragments that calculating need be allocated
If carrying out the number-of-fragments of cut-fill transition is 2, the allotment step-length is 1, and two number-of-fragments then allocating are respectively 2 and 3, enters into for (7) the 3rd steps;
Whether (7) the 3rd steps: judging needs to carry out a cubic meter balance allotment between two segmentations
T[2] * T[3]=(1) * (2)=2 is greater than 0, then do not need to carry out a cubic meter balance allotment between two segmentations, enters for (8) the 5th steps;
(8) the 5th steps: new number-of-fragments i is set
Current number-of-fragments i+j=2+1 then is provided with i=2+1=3 less than m=5, gets back to for (9) the 2nd steps;
(9) the 2nd steps: two number-of-fragments that calculating need be allocated
The number-of-fragments that carries out cut-fill transition is 3, and the allotment step-length is 1, and two number-of-fragments then allocating are respectively 3 and 4, enters into for (10) the 3rd steps;
Whether (10) the 3rd steps: judging needs to carry out a cubic meter balance allotment between two segmentations
T[3] * T[4]=(2) * 3=-6 is less than 0, then needs to carry out a cubic meter balance allotment between two segmentations, enters for (11) the 4th steps;
(11) the 4th steps: carry out a cubic meter balance allotment between two segmentations
T[3] absolute value be 2, T[4] absolute value is 3, T[4] absolute value is greater than T[3] absolute value, T[4 is set]=T[4]+T[3]=3+ (2)=1, a[4 is set] [3] equal-2, and a[3 is set] [4] equal 2, T[3]=0, entered for (12) the 5th steps;
(12) the 5th steps: new number-of-fragments i is set
Current number-of-fragments i+j=3+1=4 then is provided with i=i+1=4 less than m=5, gets back to for (13) the 2nd steps;
(13) the 2nd steps: two number-of-fragments that calculating need be allocated
The number-of-fragments that carries out cut-fill transition is 4, and the allotment step-length is 1, and two number-of-fragments then allocating are respectively 4 and 5, enters into for (14) the 3rd steps;
Whether (14) the 3rd steps: judging needs to carry out a cubic meter balance allotment between two segmentations
T[4] * T[5]=1*1=1 is greater than 0, then do not need to carry out a cubic meter balance allotment between two segmentations, enters for (15) the 5th steps;
(15) the 5th steps: new number-of-fragments i is set
Current number-of-fragments i+j=4+1=5 equals m=5, enters for (16) the 6th steps;
(16) the 6th steps: new allotment step-length j is set
Current allotment step-length 1 then is provided with j and equals j+1=2 less than k=2, i is set equals 1, gets back to for (17) the 2nd steps;
(17) the 2nd steps: two number-of-fragments that calculating need be allocated
The number-of-fragments that carries out cut-fill transition is i=1, and the allotment step-length is j=2, and two number-of-fragments then allocating are respectively 1 and 3, enters into for (18) the 3rd steps;
Whether (18) the 3rd steps: judging needs to carry out a cubic meter balance allotment between two segmentations
T[1]=0, T[3]=0, multiplied result equals 0 between the two, does not then need to carry out a cubic meter balance allotment between two segmentations, enters into for (19) the 5th steps;
(19) the 5th steps: new number-of-fragments i is set
Current number-of-fragments 1+2 then is provided with i and equals 1+1=2 less than m=5, gets back to for (20) the 2nd steps;
(20) the 2nd steps: two number-of-fragments that calculating need be allocated
The number-of-fragments that carries out cut-fill transition is 2, and the allotment step-length is 2, and two number-of-fragments then allocating are respectively 2 and 4, enters into for (21) the 3rd steps;
Whether (21) the 3rd steps: judging needs to carry out a cubic meter balance allotment between two segmentations
T[2]=-1 and T[4]=1, multiplied result is less than 0 between the two, then needs to carry out a cubic meter balance allotment between two segmentations, enters for (22) the 4th steps;
(22) the 4th steps: carry out a cubic meter balance allotment between two segmentations
T[2] absolute value equal T[4] absolute value, T[2 then is set] equal T[2] add T[4]=0, a[2 is set] [4] equal T[4]=1, a[4 is set] [2] equal-T[4]=-1, T[4 is set] equal 0, entered for (23) the 5th steps;
(23) the 5th steps: new number-of-fragments i is set
Current number-of-fragments 2+2 then is provided with i and equals i+1=3 less than m=5, gets back to for (24) the 2nd steps;
(24) calculate two number-of-fragments that to allocate
The number-of-fragments that carries out cut-fill transition is 3, and the allotment step-length is 2, and two number-of-fragments then allocating are respectively 3 and 5, enters into for (25) the 3rd steps;
Whether (25) the 3rd steps: judging needs to carry out a cubic meter balance allotment between two segmentations
T[3]=0, T[5]=1, multiplied result equals 0 between the two, does not then need to carry out a cubic meter balance allotment between two segmentations, T[3] and T[5] value do not do any variation, enter into (26) the 5th and go on foot;
(26) the 5th steps: new number-of-fragments i is set
Current number-of-fragments 3+2 equals m=5, then enters for (27) the 6th steps;
(27) the 6th steps: new allotment step-length j is set
Current allotment step-length j equals k=2, enters for (28) the 7th steps;
(28) the 7th steps: cut-fill transition finishes
The channel cut-fill transition finishes, and with each fragmentation value output of the residue cubic metre of earth and stone non-0, with result's output of two-dimensional array a, computing finishes.
Then the result of this example output is
Segmentation 5 residue earthworks are 1, and all the other segmentations have all realized a cubic meter equalization of embankments and cuttings.
Following table is each segmentation cut-fill transition result
The allotment implication of table as a result is as follows:
(1) segmentation 1 is given segmentation 2 with the cut-fill transition of 2 units;
(2) segmentation 2 from segmentation 1 obtain 2 units the cubic metre of earth and stone, from segmentation 4, obtain 1 unit the cubic metre of earth and stone;
(3) segmentation 3 obtains the cubic metre of earth and stone of 2 units from segmentation 4;
(4) segmentation 4 is given segmentation 2 with the cut-fill transition of 1 unit, gives segmentation 3 with the cut-fill transition of 2 units;
(5) segmentation 5 does not have to allocate with the cubic metre of earth and stone of other segmentation.
Be false code below based on the preferential channel cubic metre of earth and stone method for designing of minimum distance
1 m,k,T(1),...,T(m);
2 a(i,j)=0,i,j =1,2,...,m+1
3 i=1,j =1;
4 if(T(i)*T(i+j)<0)
5 {
6 if(abs(T(i))>=abs(T(i+j)))
7 {
8 T(i)=T(i)+T(i+j);
9 a(i,i+j)=T(i+j);
10 a(i+j,i)=-T(i+j);
11 T(i+j)=0;
12 }
13 if(abs(T(i))<abs(T(i+j)))
14 {
15 T(i+j)=T(i+j)+T(i);
16 a(i+j,i)=T(i);
17 a(i,i+j)=-T(i);
18 T(i)=0;
19 }
20?}
21?If(i+j <m)
22?{ i=i+1;
23 goto 4;
24?}
25?If(?j<k)
26?{ j=j+1;
i=1;
27 goto 4;
28?}
29?for(i=1;j <m+1;i++)
30?if(T(i)!=0)
31 printf,i,T(i);
32?for(i=1;i <m+1;i++)
33?for(j=1;j <m+1;j++)
34 Print,i,j,T(i)。