An Improved particle swarm algorithm to find optimal scheduling in two-stage hybrid flow shop problem

This paper deals with the two-stage hybrid flow shop problem , in which the first stage consists of three machines , the second stage consists of two machines . The aim is to find out the optimal scheduling for n jobs when processing in this environment when the makespan is minimum. Therefore we propose a particle swarm algorithm which consists of a new procedure to calculate the makespan and a new stopping criteria .Also, we added improvement to the proposed algorithm , by using one of the components of the genetic algorithm (crossover operation) in order to obtain initial swarm particles instead of random obtaining. After applying the two algorithms on several problems which were generated randomly by uniform distribution , the results showed that the improved proposed particle swarm algorithm was the best in finding out the optimal scheduling for jobs and in cpu time to reach the solution.

solve the HFS scheduling problem . Yue-wen et al [19] present a Multi-agent Particle Swarm Optimization (MPSO) based on multi-agent system (MAS) and pso for hybrid flow shop scheduling problem.Liao et al [9] present an approach using particle swarm optimization and bottleneck heuristic to solve hybrid flow shop scheduling problem.Wang and Liu [12] proposed a heuristic method for two-stage hybrid flow shop with dedicated machines,they consider the first stage contains a single common critical machine and the second stage contains several dedicated machines.Wang and Liu [17] present a genetic algorithm for two-stage no-wait hybrid flow shop scheduling problem.

2-Two-stage hybrid flow shop scheduling problem
The two-stage hybrid flow shop scheduling problem may be formulated as follows :A set J of n jobs has to be scheduled in a manufacturing system with two stages (machining centers) S 1 and S 2 .Each stage S i (i=1,2) has m i identical machines in parallel. Each job j (j=1,2,….,n) has to be processed first for a j units of time by one machine of S 1 , and then for b j units of time by one machine of S 2 . These operations must be processed without preemption .Moreover , a job cannot be processed by more than one machine at the same time and each machine processes at most one job at one time . All processing times are assumed to be deterministic and integer and all machines are ready from time zero onwards [6].
In this paper, a special case of two-stage hybrid flow shop has been studied , in which stage1 consists of three machines and stage2 consists of two machines. In order to clarify this case , we will take the following simple example as shown in Figure (

[
As depicted in Fig.(1) , the solution (2,3,6,1,4,5) gives the schedule for the three machines in stage1 , where jobs are arranged to in machines by the sequence to the first available machine. The schedule in stage2 is arranged as soon as jobs are completed by the preceding stage.

3-The background of particle swarm optimization
Particle Swarm Optimization (PSO) is a population-based swarm intelligence algorithm that was first presented by Kennedy, J. and Eberhart, R. in 1995 [8] .The PSO concept is based on observations of the social behavior of animals.
The basic procedure for implementing PSO is described as follows:-[7] [9] Step1: generate the initial swarm of particles with random positions and velocities on D dimensions in the search space.
Step3: compare particle's fitness values with their pbest , if the current particle is better than pbest ,then set pbest to the current particle.
Step4: update particle velocities according to the following equation: Where t is the iteration number,w is inertia weight which used to balance between global and local searches,c 1 is the cognition learning factor,c 2 is the social learning factor, rand 1 and rand 2 are random numbers uniformly distributed between 0 and 1.
Step5: particles are changed to their new positions according to the following equation: Step6: stop the algorithm if the stopping criterion is satisfied ; else,return to step2 .

4-A proposed PSO algorithm for the two-stage hybrid flow shop problem
When applying PSO to a scheduling problem there is an obvious practical difficulty.We need a different string representation,an approach for converting the continuous postion values in to permutation of the job sequence and other component of the PSO algorithm,including swarm size,fitness function and stopping criterion.These are shown below in detail.

Solution representation
A solution is simply represented by a string of numbers consisting of a permutation of n jobs denoted by (1,2,...,n). To decode the solution for a specific problem, the jobs are arranged to in machine by priority rules to the first available machine [9].To illustrate the decoding , see the example in paragraph (2). As depicted in Fig.(1) ,the string (2,3,6,1,4,5) represents the decoding of the scheduling.
Initial swarm and swarm size Randomly arrange the jobs to each particle. These particles will generate the initial population. The swarm population size ranging from 20 to 50 are the most common one for lower dimensional problems , and for higher dimensional problems it is better to select swarm size equal to 50 [11] , therefore we use swarm population size equal to 50.At the initialization of algorithm we set the velocities of the particles equal to zero.

Fitness function
We use the makespan criteria as the fitness function. In this paper ,we proposed a new approach to calculate the makespan for n jobs when processed at two-stage hybrid flow shop in which the stage1 consists of three machine and stage2 consists of two machines, this approach depends on the processing of all jobs in stage1 one by one within the available machine firstly, then we will obtain the completion time of each job processing within stage1.Then we start of jobs processing within stage2 for the jobs which finished recently from stage1 within the available machine too. We will obtain the time for each machine in stage2, then we will choose the longest time as a makespan.

SPV rules
We use a heuristic approach called Smallest Position Value (SPV) [2] for converting the continuous position values to in permutations of the job sequence .This is the key to enable the continuous pso algorithm be applied to sequencing issues. The SPV rule is effectively used for the flow shop sequence problem(PFSP) [7] , following the successful applications of the above , we use this rule. Table (1) illustrates the process of decoding a particle using the SPV rule.  0.25 4.14 2 Proposed stopping criteria In this paper ,we proposed a new stopping criteria based on the lower bound of the makespan , because of the lower bound consider as "effective tool for estimating the optimal makespan and for evaluating the quality of suboptimal heuristics" [15].Because of the optimal makespan unknown , but we know that ,where is the optimal makespan [18] , so the proposed stopping criteria tries to obtain optimal makespan .Otherwise, it will try to obtain the best makespan when it's deviation about LB is minimum ,this criteria is : Where is the fitness value for gbest , LB is the lower bound of the makespan and we depended on the LB presented by Santos,D. et al [16] because of this LB is strong .
The aim is to find out the optimal makespan by tring to get equal to zero (g=0) ,if we get it before to completing of 50 repetition ,pso will stop in this case C max will be optimal because of .
Otherwise, we try out to get less than or equal to 0.5 (g=0.5) to find the makespan C max where it's difference about LB is minimum. In case of 50 repetition is completed and we couldn't get , we increase g by 0.5 in order to get and continue with the same steps until g reaching 5 , where 5 is the allowed percentage difference of the solution from the lower bound of the makespan.

Proposed PSO algorithm
Now,we are at the position to present the steps of our proposed PSO algorithm for two-stage hybrid flow shop problem.

]
An Improved particle swarm algorithm to find……….

Step1:(Initialization)
Determine the initial swarm population as described in an earlier section.The size of the swarm population is 50.

Step2:(Fitness)
Evaluate the fitness of each particle solution in the population using the proposed approach to calculate the makespan.

Step4: (Update)
Update the velocity of each particle according to eq.(1) , and update the position of each particle according to eq.(2).

Step5:(SPV rules)
Apply the SPV rules for converting the continuous position values to in permutation of job sequence.

Step6: (Fitness)
Evaluate the fitness of the new particle position.

Step7: (Find)
Compare particle's fitness values with their pbest , if the current value is better than pbest ,replace the pbest value ,then find gbest (particle which has better fitness value in the swarm).

Step8:(Termination)
Stop the algorithm if the proposed stopping criterion is satisfied. else, return to step4.

Improvement of proposed pso algorithm
We add improvement on the proposed algorithm,by adding it to the initial swarm. Instead of the jobs arrangement in each particle randomly,we arrange the jobs in the first particle according to the processing time in stage1 increasingly and arrange the jobs in the second particle according to the processing time in stage1 decreasingly,then we generated 24 particles by job arrangement in each particles randomly , then we entered one of the genetic algorithm component (crossover) in order to obtain variable particles.We made crossover operation between the 24 particles in order to produce another 24 particles by using linear order crossover (LOX),which was presented by Flalkenauer,E. and Bouffouix,S. [4] because (LOX) has the best performance between other crossover operations. Steps of (LOX) [3] are :-1-Choose an interval by selecting two random cut points at each parent structure .In our example cut points are at the third and fifth position of the parent structures.

5-Computational results
In order to evaluate the success of the two algorithms on HFS problems , it was run on different problems with wide range of jobs. Five different problem were examined , they correspond to the different job number 10,30,50,100 and 200, respectively. For each problem , 10 tests are generated by setting different processing time randomly and at the same interval , so all together 50 tests are performed.
The job processing time p ij of job j on stage i are uniformly distributed integers in the range between 1 and 30 , we have generated the values of p ij by the following way [13]: For i = 1 to 2 For j = 1 to n P ij = U [1,30] The proposed pso can be compared to the improved proposed pso on the basis of cpu time because the computational environment of the two algorithms is the same. Also a comparison is made based on the solution quality , measured by the percentage difference between the solution and the lower bound as follows: ] An Improved particle swarm algorithm to find……….

[
The two algorithms were programmed in MATLAB (R2011a) and run on a PC with Intel(R) core (TM) i5-2430M cpu 2.40 GHZ and RAM 4GB . The algorithm parameters were set as follows: We chose c 1 =c 2 =2 depending on the previous experiment [10] [14] ,also we chose w= 0.9 because when w=0.9 , the pso takes the least average number of iterations to find the global optimum [16].
The computational results are summarized in Table(2) , in which the "% difference " columns show the performance comparison among two algorithms.  The general performance of the two compared algorithms is summarized in Table(  The average percentage differences (from LBs) due to the number of jobs are given in Table ( 4) and are represented in Fig.(2).  .(2) The average percentage differences (from LBs) due to the no. of job 6-Conclusions 1-The results show that both of the algorithms applied successfully in this study on up the two-stage hybrid flow shop problem, also it shows that the improved proposed pso algorithm was the best in finding out the optimal makespan .Even in case this algorithm camot achieve what is mentioned above, also it is the best in finding scheduling jobs which have the best makespan because the average percentage difference from LB is minimum. 2-Depending on computational results , the improved proposed pso algorithm takes less cpu time of the proposed pso algorithm for finding out the solution, except three problems where cpu time for both algorithms were equal and just one problem the cpu time was maximum when we used the improved proposed pso algorithm (Table(1)), this shows that the proposed improvement of the initial swarm helps widely in reducing of cpu time to find the solution. 3-By recognizing Table(4) ,the improved proposed pso algorithm it's performance will be better when the no. of jobs is high where the average percentage difference from LB will be less.