Decision-making method for single warehouse facility site selection (center of gravity method, C language code)

Source: Internet
Author: User

The following is a assignment assigned by the warehouse teacher in the sophomore year. It is about the location selection of a single warehouse. We need to write code in C and compile a program!

This is just a job !!!

Single warehouse facility site selection decision-making method

 

 

The single-facility site selection model has different names, such as the precise center of gravity method, grid method, and center of gravity method. Because the site selection factors only include the transportation rate and the transportation volume of goods at the point, this method is relatively simple.

 

We aim to minimize the cost of warehouse points to reach each target point:

 

That is:

 

Min Tc = Σ viridi I traverse all destinations ............... (0)

 

Among them: TC-total transportation costs;

 

Vi -- I point transportation volume;

 

Ri-the transportation rate to point I;

 

Di-distance from the location of the to-be-determined warehouse to the I point.

 

 

Set the coordinates of the to-be-determined warehouse in the coordinate plane to (x0, y0)

 

Σ Virixi/di X0 =... (1) Σ Viri/di Σ Viriyi/di Y0 =... (2) Σ Viri/di

 

Where di can coordinate formula di = sqr (X0-Xi) 2 + (Y0-Yi) 2 )... (3)

 

The process of solving this method:

 

1. Determine the coordinates of each destination point, and determine the transportation volume of each point and the direct distance freight;

 

2. Use the center of gravity formula to estimate the initial site selection point without considering the distance factor:

 

 

Σ Virixi X0 =... (4) Σ Viri Σ Viriyi Y0... (5) Σ Vir I

 

 

3. Calculate di using the formula (3) (x0, y0) obtained in step 2;

 

4. Replace di with the formula (1) and (2) to obtain the corrected (x0, y0) coordinates;

 

5. Re-calculate di Based on the corrected (x0, y0) coordinates;

 

6. Repeat steps 4 and 5 until the coordinates (x0, y0) do not change or change within the error range in the continuous iteration process;

 

7. Finally, if necessary, calculate the total cost of the optimal site selection using the formula (0.

 

# Include <stdio. h>
# Include <math. h>
Struct xuanzhi
{
Double X, Y, V, R;

} Xz Z [5] = {2000, 0.050, 3000}, {0.050, 2500, 0.075}, {1000, 0.075 }, {8, 1500, 0.075 }};

Main ()
{
Struct xuanzhi;
Int I;
Double D [5];
Double X0 = 0.0, Y0 = 0.0, min = 0.0, Tc = 0.0, t = 0.0, M = 0.0, W = 0.0, X1 = 0.0, Y1 = 0.0, m1 = 0.0, M2 = 0.0, W2 = 0.0, T1 = 0.0, M3 = 0.0, W3 = 0.0;

For (I = 0; I <5; I ++)
{
M + = xz [I]. V * xz [I]. R * xz [I]. X;
W + = xz [I]. V * xz [I]. R;
M1 + = xz [I]. V * xz [I]. R * xz [I]. Y;
}
X0 = m/W;
Y0 = m1/W;
For (I = 0; I <5; I ++)
{
D [I] = SQRT (xz [I]. x-x0) * (xz [I]. x-x0) + (xz [I]. y-y0) * (xz [I]. y-y0 ));
M3 + = xz [I]. V * xz [I]. R * xz [I]. X/d [I];
T1 + = xz [I]. V * xz [I]. R * xz [I]. Y/d [I];
W3 + = xz [I]. V * xz [I]. R/D [I];
}
X1 = m3/W3;
Y1 = t1/W3;
Do
{
X0 = x1;
Y0 = Y1;
For (I = 0; I <5; I ++)
{
D [I] = SQRT (xz [I]. x-x0) * (xz [I]. x-x0) + (xz [I]. y-y0) * (xz [I]. y-y0 ));
M2 + = xz [I]. V * xz [I]. R * xz [I]. X/d [I];
T + = xz [I]. V * xz [I]. R * xz [I]. Y/d [I];
W2 + = xz [I]. V * xz [I]. R/D [I];
}

X1 = m2/W2;
Y1 = T/W2;
M2 = 0.0;
T = 0.0;
W2 = 0.0;
} While (FABS (x0-x1)-0.00000001> 0 & FABS (y0-y1)-0.00000001> 0 );
Printf ("X0 = % 12lf, Y0 = % 12lf/N", x0, y0 );
For (I = 0; I <5; I ++)
{
D [I] = SQRT (xz [I]. x-x0) * (xz [I]. x-x0) + (xz [I]. y-y0) * (xz [I]. y-y0 ));
Min = xz [I]. V * xz [I]. R * d [I];
TC + = min;
}
Printf ("Min Tc = % 12lf/N", Tc );
Getch ();
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.