Algorithm analysis and verification of assembly line Scheduling Problems

Source: Internet
Author: User

Algorithm analysis and verification of assembly line Scheduling Problems
1 Problem description a car factory has two assembly lines, each of which has n assembly stations. The assembly station j of assembly line I is represented as Si, j, and the Assembly time of the station is ai, j. An automobile chassis enters the factory, and then enters the assembly line I (I is 1 or 2), which takes the time of ei. After passing through the j assembly station of a line, the chassis came to the j + 1 assembly station of any assembly line. If it stays in the same assembly line, there is no moving overhead. However, if it is moved to another line, it takes ti, j. After leaving the nth assembly station in an assembly line, the finished car chassis took time for xi to leave the factory. The problem to be solved is to determine which stations should be selected in assembly line 1 and which stations should be selected in assembly line 2 to minimize the total time for automobile passing through the factory. 2. algorithm parsing the following describes the Scheduling Problem of the assembly line in steps through dynamic planning. 2.1 Step 1: describe the characteristics of the optimal structure observe a through the assembly station S1, j the fastest route, it is found that it must be through the assembly station 1 or 2 (J-1 ). Therefore, through the assembly station S1, j's fastest route can only be one of the following: • through the assembly station S1, j −1's fastest route, then directly through the assembly station S1, j. • Transfer from assembly line 2 to assembly line 1 through the fastest route of assembly station S2 and j-1, and then through assembly station S1, j. So looking for the fastest route through any assembly station j on the assembly line, we can plan first looking for the fastest route through the assembly station J-1 on the two assembly lines. 2.2 Step 2: Use the final solution of the problem to recursively define the value of an optimal solution fi [j] to indicate the shortest possible time for a car chassis from the starting point to the assembly station Si; f∗ indicates the shortest time for the chassis to pass through all assembly stations in the plant. 2.3 Step 3: Calculate the shortest time the execution time of the recursive algorithm is about the exponential form of n, so we use the implementation method from the low to the top to calculate the shortest time. Note: li [j] indicates entering the assembly station Si. The first assembly station of j comes from which assembly line; l branch indicates from which assembly line leaves the factory. Copy code FATEST-WAY (a, t, e, x, n) f1 [1] Using e1 + a1, 1 f2 [1] Using e2 + a2, 1 for j between 2 to n if f1 [j −1] + a1, j ≤ f2 [j −1] + t2, j −1 + a1, j then f1 [j] 1_f1 [j −1] + a1, j l1 [j] 1_1 else f1 [j] 1_f2 [j −1] + t2, j −1 + a1, j l1 [j] limit 2 endif if f2 [j −1] + a2, j ≤ f1 [j −1] + t1, j −1 + a2, j then f2 [j] 127f2 [j −1] + a2, j l2 [j] limit 2 else f2 [j] limit f1 [j −1] + t1, j −1 + a2, j l2 [j] limit 1 endif endfor if f1 [n] + X1 ≤ f2 [n] + x2 then f then 1_f1 [n] + x1 l then 1_1 else f then 1_f2 [n] + x2 l then 1_2 endifend Replication step 4 of code 2.4: construct the fastest route obtained by the factory based on the li [j] And l pair obtained by step 3 to print the route with the minimum scheduling time of the assembly line. Copy the code PRINT-STATIONS (l, l numbers, n) I got l got print 'line: 'I', station: 'n' for j then n downto 2 I then li [j] print 'line: 'I', station: 'j-1 endforend copy code 3 C language implementation validation now suppose there are two separate assembly stations with five assembly stations, and the scheduling time of each site in the assembly line is shown in Figure 1: assembly line sample diagram where, on the left side of the assembly line is the entrance, and on the right side is the exit. The numbers on the entrance and exit indicate the time consumed to enter the assembly line and to leave the assembly line respectively. The green circle indicates the assembly station, and the number in the circle indicates the assembly time on the assembly station. The number on the line between each assembly line indicates the time consumed by transferring from one assembly line to another. The verification code in C language is as follows: # include <stdlib. h> # include <stdio. h> void PrintPath (int *, int, int); void FastestWay (int *, int *, int [], int [], int); intmain (void) {int enterTimes [2] = {1, 2}; int exitTimes [2] = {2, 1}; int assemblyTimes [2] [5] = {4, 2, 3, 5, 3}, {7, 2, 4, 2, 4 }}; int transferTimes [2] [5] = {2, 1, 2, 2, 1 },{ 1, 1, 2, 4, 2 }}; FastestWay (& assemblyTimes [0] [0], & transferTimes [0] [0], enterTimes, exitTimes, 5); exit (0);} void FastestWay (int * assemblyTimes, int * transferTimes, int enterTimes [2], int exitTimes [2], int n) {int fastestTime = 0; int exitLine; int j; int * fastest, * lineTag; int temp1, temp2; fastest = malloc (sizeof (int) * 2 * n ); lineTag = malloc (sizeof (int) * 2 * n); * (fastest) = enterTimes [0] + * assemblyTimes; * (fastest + n) = enterTimes [1] + * (assemblyTimes + n); for (j = 1; j <n; j ++) {temp1 = * (fastest + (J-1 )); temp2 = * (fastest + (n + j-1) + * (transferTimes + (n + j-1); if (temp1 <= temp2) {* (fastest + j) = temp1 + * (assemblyTimes + j); * (lineTag + j) = 1;} else {* (fastest + j) = temp2 + * (assemblyTimes + j); * (lineTag + j) = 2;} temp1 = * (fastest + (n + j-1 )); temp2 = * (fastest + (j-1) + * (transferTimes + (j-1); if (temp1 <= temp2) {* (fastest + (n + j) = temp1 + * (assemblyTimes + (n + j); * (lineTag + (n + j) = 2 ;} else {* (fastest + (n + j) = temp2 + * (assemblyTimes + (n + j); * (lineTag + (n + j )) = 1 ;}} temp1 = * (fastest + (n-1) + exitTimes [0]; temp2 = * (fastest + (n + n-1 )) + exitTimes [1]; if (temp1 <= temp2) {fastestTime = temp1; exitLine = 1 ;}else {fastestTime = temp2; exitLine = 2 ;} printf ("The cost of the fastest path: % d \ n", fastestTime); PrintPath (lineTag, exitLine, n);} void PrintStation (int line, int station) {printf ("line: % d, station: % d \ n", line, station);} void PrintPath (int * lineTag, int exitLine, int n) {int I = exitLine; int j; PrintStation (exitLine, 5); for (j = 5; j> = 2; j --) {I = * (lineTag + (n * (I-1) + j-1); PrintStation (I, J-1) ;}} copy the code to compile the program, generate and execute the AssemblyLineSchedule file and copy the code lien000034: algorithm $ gcc-o AssemblyLineSchedule. clien000034: algorithm $. /AssemblyLineScheduleThe cost of the fastest path: 19 line: 2, station: 5 line: 2, station: 4 line: 2, station: 3 line: 1, station: 2 line: 1, station: 1

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.