tags: Dynamic planning algorithm
1 Problem Description
There are two assembly lines in a car factory.,Each one has n Assembly stations. Assembly line i First jAssembly stations are indicated as Si,j ,The assembly time at the station is ai,j . A car chassis enters the factory,Then enter the assembly line i(i for 1 or 2),Spend time ei . In the first line j After assembly station,This chassis came to the first of any assembly line(j+1)Assembly stations. If it stays on the same assembly line,There is no movement overhead. but,If it moves to another line,Take time for ti,j . On the first line leaving an assembly line n After assembly station,The completed car chassis takes time xi Leave the factory. The problem to be solved is,Determined should be in the assembly line 1 Which stations are selected?,In the assembly line 2 Which stations are selected?,In order to make the total time of the car through the factory the shortest.

2 Algorithm analysis
The following is a step-by-step analysis of the assembly line scheduling problem through dynamic programming ideas.
2.1 step 1:Describe the characteristics of the optimal solution structure
Observe one through the assembly station S1,j Fastest route,Found that it must be through the assembly line 1 or2 Assembly station(j-1). therefore,By assembly station S1,j The fastest route can only be one of the following:
• By assembly station S1,j−1 Fastest route,Then directly through the assembly station S1,j 。
• By assembly station S2,j−1 Fastest route,From the assembly line 2 Transfer to assembly line 1,Then through the assembly station S1,j 。
So looking for an assembly station through any assembly line j Fastest route,We can plan to find the assembly station through the two assembly lines first. j-1 The fastest route.
2.2 step 2: Defining the value of an optimal solution using the most recursive problem of the problem
Remember fi [j] Represents a car chassis from the starting point to the assembly station Si,j The fastest possible time;f ∗ Indicates the fastest time for the chassis to pass through all assembly stations in the factory.

2.3 step 3:Calculate the fastest time
The execution time of the recursive algorithm is about n Index form,So we use the low-up implementation method to calculate the fastest time. Remember li [j] Indicates entering the assembly station Si,j Which assembly line from the previous assembly station;l∗ Indicates which assembly line leaves the factory.
FATEST-WAY(a, t, e, x, n)
f1 [1] ← e1 + a1,1
f2 [1] ← e2 + a2,1
for j ← 2 to n
if f1 [j − 1] + a1,j ≤ f2 [j − 1] + t2,j−1 + a1,j
then f1 [j] ← f1 [j − 1] + a1,j
l1 [j] ← 1
else f1 [j] ← f2 [j − 1] + t2,j−1 + a1,j
l1 [j] ← 2
endif
if f2 [j − 1] + a2,j ≤ f1 [j − 1] + t1,j−1 + a2,j
then f2 [j] ← f2 [j − 1] + a2,j
l2 [j] ← 2
else f2 [j] ← f1 [j − 1] + t1,j−1 + a2,j
l2 [j] ← 1
endif
endfor
if f1 [n] + x1 ≤ f2 [n] + x2
then f∗ ← f1 [n] + x1
l∗ ← 1
else f∗ ← f2 [n] + x2
l∗ ← 2
endif
end
2.4 step 4:Construct the fastest route through the factory
According to the steps 3 acquired li [j] with l∗ To print out the route that takes the smallest assembly line schedule.
PRINT-STATIONS(l, l∗ , n)
i ← l∗
print ’line:’ i ’, station:’ n
for j ← n downto 2
i ← li [j]
print ’line:’ i ’, station:’ j-1
endfor
end
3 C Language implementation verification
Now suppose that there are two 5 Assembly line assembly line,The scheduling time of each assembly line is as shown in the figure below.,

Figure 1: Assembly line example diagram
among them,The left side of the assembly line is the entrance,On the right is the exit,The numbers on the entrance and exit indicate the time spent entering the assembly line and leaving the assembly line, respectively. Green circle indicates assembly station,The number in the circle indicates the assembly time at the assembly station. The numbers on the lines between the various assembly lines indicate the time it takes to transfer from one assembly line to another.
use C The language verification code is as follows,
View Code
Compile the program,Generate and execute files AssemblyLineSchedule,
lienhua34:algorithm$ gcc -o AssemblyLineSchedule AssemblyLineSchedule.c
lienhua34:algorithm$ ./AssemblyLineSchedule
The 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
then,The shortest path takes a total of time 19,Its path is as follows in the red line,

Figure 2: Example line of an assembly line with the fastest path
Required to obtain the fastest time route assembly and assembly. Input: six one-dimensional array. Output: shortest time-consuming as well as through the assembly line site. Directly to the code impor...
Thanks to the discussion of Jingxing children's shoes I don’t even say, the topic: Process two jobs with two processors A and B. It is assumed that the time required for the i-th job to b...
The focus of the idea algorithm Complete code The working time on M1 is regarded as the preceding process time, and the working time on M2 is regarded as the subsequent process time. If...
"1" Assembly line scheduling: Problem Description An automobile company produces cars in a factory with 2 assembly lines. Each assembly line has n assembly stations. The corresponding ass...
Title description "Processing sequence problem" is also called "batch job scheduling problem". There are n workpieces that need to be processed on machines M1 and M2, and the proce...
1 Introduction Dynamic Programming Dynamic Programming (dynamic programming) is a branch of operations research, mathematical optimization method for solving the decision-making process (decision proc...
Experiment name: Pipeline job scheduling problem n jobs {1,2,...,n}, to be processed on 3 machines. Each job must be processed by machine 1 first, then by machine 2, and finally by machine 3. Ask how ...
1 Introduction At present, economic globalization continues to strengthen, and enterprises are pursuing cost advantages. As the last link in the production process, mechanical product assembly plays a...
Article Directory Understand: f i [ j ] f_i[j] fi[j]Has passed the site S i , j S_{i,j} Si,jYes, the cost of passing the site has been included. Output path process The result is this: from right to...