# "Dynamic Programming" flow-shop scheduling problem and Johnson rule

Source: Internet
Author: User

1, problem description:

N Jobs {1,2,...,n} to be processed on a line consisting of 2 machines M1 and M2. The order of each job is processed first on the M1 and then processed on the M2. The time required for M1 and M2 processing operations I is AI and bi respectively. The flow-shop scheduling problem requires determining the optimal processing sequence of the N-jobs, so that the first job starts machining on the machine M1, and the last job takes the least time to complete the machine M2 .
2, problem analysis

Intuitively, an optimal dispatch should make the machine M1 without idle time, and the machine M2 the least idle time. In general, there are 2 cases of machine idle and job backlog on machine M2. Set the set of all jobs to n={1,2,...,n}. S is a subset of the jobs of N. In general, the machine M1 start processing s In the work, the machine M2 is still processing other operations, to wait until the time t can be used. The minimum time required to complete a job in S in this case is recorded as T (S,t). The optimal value of the flow-assembly scheduling problem is T (n,0).

Setting π is an optimal dispatch of the N-flow-shop, which requires aπ (1)+t '. where T ' is the time required to arrange the operation π (2), ...,π (n) when the waiting time for the machine M2 is bπ (1) .

Remember s=n-{π (1)}, then there is T ' =t (s,bπ (1)).

Proof: In fact, the definition of T is known as T ' >=t (s,bπ (1)). If T ' >t (s,bπ (1)), set π' is an optimal dispatch of the operation set S in the case of a machine M2 waiting time of Bπ (1) . Then π (1),π ' (2), ...,π ' (n) is a dispatch of N, and the time required for the dispatch is aπ (1)+t (s,b π (1)) <aπ (1 )+t '. This is in contradiction with the optimal dispatch of π N. So T ' <=t (s,bπ (1)). Thereby T ' =t (s,bπ (1)). This proves that the flow-shop scheduling problem has the properties of the optimal substructure.

The optimal substructure properties of the flow-shop scheduling problem are as follows:

From the formula (1) It can be seen that the problem is similar to a permutation problem, the optimal scheduling problem of n operations, the use of its sub-structural properties, the set of each job in the test scheduling, in all the test scheduling, taking the shortest processing time of the operation as a choice scheme. Reduce the problem size. The formula (2) shows that in general, the job set S scheduling, waiting time on the M2 machine, in addition to the need to wait for the part on the M1 machine to complete the time, but also to offset some of the original waiting time, if the offset has become negative, nature still need to wait for M1 to finish the job, so the formula takes max{t-ai,0}.

3, dynamic programming method to solve the idea

Suppose there is a set of jobs that need to be M1 and M2 two machines, their working time on M1 and M2 is as follows:

The problem is how to arrange their processing order so that the last job will take the least amount of time to complete the machine M2. That is, the minimum time required for all operations to be completed on both machines.
ideas are as follows : consider that if there is only one job, the time required is the sum of the processing time that it needs on M1 and M2; if there are two jobs to consider in two different processing sequence to choose the best one as a candidate, three jobs will appear three combinations (0, ( )); (1, (0,2)); (2, (0,1)), take the first example, it represents the first processing operation 0, and then according to Job 1 and the optimization sequence of job 2 is processed, the three job time is calculated, the minimum value, that is, the optimization results of three jobs, the same way more jobs can be sorted optimization. In particular, using a matrix-like method, the bottom-up of all the energy can be calculated, and a table for the subsequent calculation, to reduce the workload of repeated calculations.

For the J1 job M2 wait time is b0, in fact, M2 processing j0 work at the same time, M1 parallel processing J1, actually it needs to wait for b1-a0 time.

2+4+ (5-4) +2=9

From the J0 and J1 two jobs of the processing sequence, it can be seen that the first processing J0 after J1, the shortest time for 9, fill it in the table, and so on, to obtain the optimal solution.

a4+a0+a2+a1+a3+[(B4+B0+B1+B2)-(A0+A1+A2+A3)]+b3

=1+2+3+4+6+[(7+5+2+3)-(2+4+3+6)]+1

=16+[17-15]+1=19

Select the shortest processing time as a candidate, and the non-optimal subset should not be considered in the specific calculation, thus reducing the number of calculations.

4. The Johnson rule of flow-shop scheduling

The M2 is any optimal dispatch when the waiting time of the operation set S is t at the machine. In this dispatch, the first two assignments are I and J, i.e. π(1) =i,π(2) =j. Dynamic programming recursion is available.

which

If the jobs I and J meet Min{bi,aj}≥min{bj,ai}, the jobs I and J are called to satisfy Johnson inequalities. If the jobs I and J do not satisfy the Johnson inequality, the switching jobs I and J satisfy the Johnson inequality.

Proof: In the job set S, the waiting time for the machine M2 is the dispatch of the T, the processing order of the switching job I and J, and the other dispatch π' of the operation set S, the processing time required is

When Jobs I and J meet Johnson inequality Min{bi,aj}≥min{bj,ai}, there is

Thus

This will get

Therefore, for any T, there is

Thus, Tij≤tji, in other words, when the jobs I and J do not meet the Johnson inequalities, after exchanging their processing order, the job I and J satisfies Johnson inequality, and does not increase the processing time. Thus, for the flow-shop scheduling problem, there must be optimal dispatch π, which enables the operation π (i) and π (i+1) to satisfy Johnson inequalities:

Such dispatching π is called the scheduling that satisfies Johnson's rule. Further, it can be proved that the scheduling satisfies Johnson's law when and only if any i<j are:

It can be concluded that any two of the scheduling that satisfies Johnson's rule has the same processing time, so all the scheduling that satisfies Johnson's rule is the optimal dispatch.

5. Johnson algorithm of flow-Shop scheduling problem

from the above analysis, the flow-shop scheduling problem must exist to meet Johnson's rules of optimal scheduling, and easily determined by the following algorithm:

Johnson algorithm for flow-shop scheduling problem:

(1) Make n1={i|ai<bi},n2={i|ai>=bi};

(2) The N1 is sorted by the non-decreasing order of AI, and the job in N2 is sorted by the non-increment of bi;

(3) The work in N1 N2 is the optimal scheduling to satisfy Johnson's law.

The role of classification and sequencing in Johnson's algorithm (validation inequalities) set array c[] for the sorted job arrangement, the result is as follows:

Red Line left to meet A[c[i]]<=b[c[i]] and a[c[i]]<=a[c[i+1]] [Johnson Inequality, Min (b[c[i]],a[c[i+1]]) >=min (B[c[i+1]],a[c[i]]) The scheduling order is optimal;
Red line to the right satisfies b[c[i]]<=a[c[i]] and b[c[i]]>=b[c[i+1]] [Johnson Inequality, Min (b[c[i]],a[c[i+1]]) >=min (B[c[i+1]],a[c[i]]) The scheduling order is optimal;

Intermediate transition Partial Horizontal comparison, left a[c[i]]< B[c[i]] [right b[c[i+1]]<=a[c[i+1]] [min (b[c[i]],a[c[i+1]]) >=min (B[c[i+1]],a[c[i]]) The scheduling order is also optimal;

The specific code of the program is as follows:

`//3d9 Dynamic Programming flow scheduling problem#include"stdafx.h"#include<iostream>using namespacestd;Const intN =5;classjobtype{ Public:        int operator<= (Jobtype a)Const        {            return(key<=A.key); }        intKey,index; BOOLjob;};intFlowshop (intNintA[],intB[],intc[]);voidBubblesort (Jobtype *d,intn);//This example uses bubble sortintMain () {intA[] = {2,4,3,6,1}; intB[] = {5,2,3,1,7}; intC[n]; intMintime =Flowshop (N,A,B,C); cout<<"The operating time of the job on machine 1 is:"<<Endl;  for(intI=0; i<n; i++) {cout<<a[i]<<" "; } cout<<Endl; cout<<"The operating time of the job on Machine 2 is:"<<Endl;  for(intI=0; i<n; i++) {cout<<b[i]<<" "; } cout<<Endl; cout<<"the shortest time to complete a job is:"<<minTime<<Endl; cout<<"numbering starts with 0, the order of job scheduling is:"<<Endl;  for(intI=0; i<n; i++) {cout<<c[i]<<" "; } cout<<Endl; return 0;}intFlowshop (intNintA[],intB[],intc[]) {Jobtype*d =NewJobtype[n];  for(intI=0; i<n; i++) {D[i].key= a[i]>b[i]?b[i]:a[i];//B[i] or a[i] values as keywords, respectively, by Johnson's LawD[i].job = a[i]<=b[i];//put to N1 subset of eligible A[i]<b[i] labeled TrueD[i].index =i; } bubblesort (d,n);//sort array d by keyword ascending    intj =0, k = n1;  for(intI=0; i<n; i++)    {        if(d[i].job) {c[j+ +] = D[i].index;//The array d that will be sorted out, where the job sequence number belongs to the front face of the N1.        }        Else{c[k--] = D[i].index;//belong to the N2 from the back into, thus realizing the N1 of the non-reduction order, N2 of the non-sequential ordering}} J= a[c[0]]; K= j+b[c[0]];  for(intI=1; i<n; i++) {J+ = A[c[i]];//M1 while executing c[i] job, M2 executes the c[i-1] job, the shortest execution time depends on M1 and M2 who have finished executingK = j<k?k+b[c[i]]:j+b[c[i]];//Calculate the optimal machining time    }    DeleteD; returnK;}//Bubble SortvoidBubblesort (Jobtype *d,intN) {    intI,j,flag;    Jobtype temp;  for(i=0; i<n;i++) {flag=0;  for(j=n-1; j>i;j--){              //If the previous number is greater than the next number, the interchange            if(d[j]<=d[j-1]) {temp=D[j]; D[J]= d[j-1]; D[j-1] =temp; Flag=1; }          }          //If this sort does not have an interchange, then break is reduced between executions.         if(Flag = =0){               Break; }      }}`

The results of the operation are as follows:

"Dynamic Programming" flow-shop scheduling problem and Johnson rule

Related Keywords:

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.