106 CHAPTER 8 FIREFLY ALGORITHM 8.1 INTRODUCTION The Firefly Algorithm (FA) is a nature - inspired algorithm which is based on the social flashing behavior of fireflies. A significant advantage of the algorithm is the fact that it uses mainly real random numbers, and it is based on the global communication among the swarming particles i.e., the fireflies, and as a result, it seems more effective multi objective optimization. In this algorithm, the flashing light helps fireflies for finding mates, attracting their potential prey and protecting themselves from their predators. The swarm of fireflies will move to brighter and more attractive locations by the flashing light intensity that associated with the objective function of problem considered in order to obtain efficient optimal solutions. The development of firefly-inspired algorithm was based on three idealized rules: i) Artificial fireflies are unisex so that sex is not an issue for attraction. ii) Attractiveness is proportional to their flashing brightness which decreases as the distance from the other firefly increases due to the fact that the air absorbs light. Since the most attractive firefly is the brightest one, to which it convinces neighbours moving toward. In case of no brighter one, it freely moves any direction 107 iii) The brightness of the flashing light can be considered as objective function to be optimized. The main steps of the FA start from initializing a swarm of fireflies, each of which is determined the flashing light intensity. During the loop of pair wise comparison of light intensity, the firefly with lower light intensity will move toward the higher one. The moving distance depends on the attractiveness. After moving, the new firefly is evaluated and updated for the light intensity. During pair wise comparison loop, the best-so-far solution is iteratively updated. The pair wise comparison process is repeated until termination criteria are satisfied. Finally, the best-so-far solution is visualized. In this work, the evaluation on the goodness of schedules is measured by the makespan, which can be calculated using equation (8.1), where Ck is completed time of job k. Minimize: Cmax = max (C1, C2…Ck) 8.2 (8.1) IMPORTANT DEFINITONS IN FIREFLY ALGORITHM There are some definitions in FA namely, Distance, Attractiveness and Movement. (a) Distance: The distance between any two fireflies i and j at positions xi and xj, respectively, can be defined as a Cartesian or Euclidean distance (rij) using equation (8.2), where xi,k is the kth component of the spatial coordinate xi of the ith firefly and d is the number of dimensions. rij = i - xj = ( , , ) (8.2) 108 (b) Attractiveness: The calculation of attractiveness function of a firefly is shown in equation (8.3), (r) (c) 0 × exp (- m ), with m 1 (8.3) Movement: The movement of a firefly i which is attracted by a more attractive (i.e., brighter) firefly j is given by the following equation (8.4), xi = xi + 0 × exp (- 2 ij ) × (xj – xi - ) (8.4) Where the first term is the current position of a firefly, the second term is used for considering a firefly’s attractiveness to light intensity seen by adjacent fireflies, and the third term is used for the random movement of a firefly in case there are not any brighter ones. The settings of FA parameters: Light absorption coefficient ( ) = 1.0, Randomization parameter ( ) = 0.3, Attractiveness value ( 0) = 1.0 and random number (rand) generator uniformly distributed in the space [0, 1] = 0.2. 109 8.3 GENERAL SCHEMA OF FA Objective function makespan, z = (C1, C2...Cn) Generate machines (i = 1, 2... m) Generate job sequences (j = 1, 2... n) Evaluate makespan (C1, C2, C3….Cn) for all population While Gen. < Max Gen. For each job sequence j = (1, 2, 3…, n) For each lot sizes (Xij) Move firefly in d-dimensional space Determine the attractiveness based on distance rij Evaluate makespan End For End For Assess light intensity Select job sequences and lot sizes for Gen. +1 End While Rank and choose the best job sequences and Sub lot sizes 8.4 FLOW CHART OF FA The frame work of the proposed FA is illustrated in Figure 8.1. The various steps involved in FA is explained in this section. 110 Start Initialize a population of fireflies xi (i = 1,2,…n) Define light absorption co- efficient ( ) Move firefly i towards j in all d dimensions Yes Is there is any good location? No Find location attractiveness Location found Evaluate new solutions and update light intensity Rank the fireflies and find the current best Stop Figure 8.1 Flow chart of FA Go to that location 111 8.5 NUMERICAL ILLUSTRTION OF FA (EQUAL SUB LOTS) The algorithm is illustrated with an example problem (5 jobs- 2 machines) in this section. Table 4.1 provides the data of the example problem. 8.5.1 (i) Calculation of Distance, Attractiveness and Movement For sequence 2-3-5-1-4 rij = i = (r) 0 ( - xj = × exp (- m , ), with m , ) = (0 1 ; (here, 0.6) = 0.6 0=1, = 1, m = 1) = 1× exp [- 1× (0.6)1] = 0.55 xi = xi + × exp (- 0 2 ij ) - ); (here, × (xj – xi 0.3, rand = 0.2) = 0.6 + 1× exp [- 1× (0.6)2] × (0.6 –0) + 0.3(0.2 -0.5) = 0.9986 (ii) For sequence 3-2-5-1-4 ri j = (r) = i 0 ( - xj = × exp (- m , ), with m , ) = (0.6 1 ; (here, 0=1, 1.3) = 0.7 = 1, m = 1) = 1× exp [- 1× (0.7)1] = 0.4966 xi = xi + 0 × exp (- 2 ij ) × (xj – xi - ); (here, = 1.3 + 1× exp [- 1× (0.7)2] × (1.3 –0.6) + 0.3(0.2 -0.5) = 1.6388 0.3, rand = 0.2) 112 (iii) For sequence 2-4-3-5-1 rij = (r) i = 0 ( - xj = m × exp (- , ), with m ) , = (1.3 1 ; (here, 0=1, 0.9) = 0.4 = 1, m = 1) = 1× exp [- 1× (0.4)1] = 0.6703 xi = xi + 0 × exp (- 2 ij ) - ); (here, × (xj – xi 0.3, rand = 0.2) = 0.9 + 1× exp [- 1× (0.4)2] × (0.9 –1.3) + 0.3(0.2 -0.5) = 0.4692 (iv) For sequence 1-5-2-3-4 rij = (r) i 0 ( - xj = × exp (- m , ), with m , ) = (0.9 1 ; (here, 0=1, 2.1) = 1.2 = 1, m = 1) = 1× exp [- 1× (1.2)1] = 0.3012 xi = xi + 0 × exp (- 2 ij ) × (xj – xi - ) ; (here, 0.3, rand = 0.2) = 2.1 + 1× exp [- 1× (1.2)2] × (2.1 –0.9) + 0.3(0.2 -0.5) = 2.2943 8.5.2 FA for makespan criterion The illustration of FA (for equal sub lots) is shown in Table 8.1 113 Table 8.1 FA Illustration (equal sub lots) Seed Distance Attractiveness Movement Sequence for next (xi) makespan Sequence (rij) r) 23514 0.6 0.55 0.9986 23514 48 32514 0.7 0.497 1.6388 32514 48 24351 0.4 0.6703 0.4692 24351 45 15234 1.2 0.3012 2.2943 12534 45* generation The final job sequence is 1- 2 -5 -3- 4, the corresponding makespan time is 45 and it is shown in Figure 7.2. 8.5.3 FA for total flow time criterion The method to find total flow time is illustrated in this section. The final result is 2-5-4-1-3 and the corresponding total flow time is 144. It is shown in Figure 8.2.Total flow time calculation for the sequence 2-5-4-1-3 = 14+22+27+35+46 = 144. The following Figure 8.2 shows the time schedule of the optimal solution. The following fig. shows the time schedule of the optimal solution. 114 Figure 8.2 Schedule for the sequence 2-5-4-1-3 in FA (total flow time objective for equal sub lots) 8.6 NUMERICAL ILLUSTRTION OF FA (VARIABLE SUB LOTS) The algorithm is illustrated with an example problem (5 jobs- 2 machines) in this section. Table 4.4 provides the data of the example problem. 8.6.1 FA for makespan criterion The illustration of FA (for variable sub lots) is shown in Table 8.2. Table 8.2 FA Illustration (variable sub lots) Seed Distance Attractiveness r) Movement Sequence (xi) for next makespan Sub lot size Sequence (rij) 54231 1.2 0.3012 2.2943 53124 85* {132}{543}{46}{3212}{1233} 31452 0.4 0.6703 1.2692 31452 88 {453}{64}{2133}{231}{2132} 45132 0.2 0.8187 1.2178 45132 89 {2133}{231}{64}{453}{2132} 34125 0.3 0.7408 0.8358 34125 89 {453}{2133}{64}{2132}{231} generation 115 The final result is 5-3-1-2-4, the corresponding makespan time is 85, sub lot size is {132}{543}{46}{3212}{1233} and it is shown in Figure 6.7. 8.6.2 FA for total flow time criterion The method to find total flow time is illustrated in this section. The final result is 3-1-4-5-2 and the corresponding total flow time is 299, sub lot size is {453}{64}{2133}{231}{2132}. Total flow time calculation for the sequence 3-1-4-5-2 = 22+44+64+79+90 = 299. The following Figure 8.3 shows the time schedule of the optimal solution. Figure 8.3 Schedule for the sequence 3-1-4-5-2 in FA (Total Flow Time objective for variable sub lots) 116 8.7 PERFORMANCE EVALUATION 8.7.1 Proposed methodology illustrated with makespan criterion The makespan results of FA algorithm for equal sub lots (Table 8.3 - Table 8.6) and for variable sub lots (Table 8.10 - Table 8.12) is given in this section. 8.7.2 Proposed methodology illustrated with total flow time criterion The total flow time results of FA algorithm for equal sub lots (Table 8.7 - Table 8.9) and for variable sub lots (Table 8.13 - Table 8.15) is given in this section. o Nt es mel bor P . 118 Table 8.4 Makespan value for three – machine cases in FA (equal sub lots) Problem set number 5 160 168 154 164 1 2 3 4 Table 8.5 10 380 388 378 384 Makespan Number of jobs 15 20 410 570 412 568 408 564 412 570 25 632 648 642 640 30 794 688 620 618 Makespan value for five – machine cases in FA (equal sub lots) Problem set number 5 180 188 180 174 1 2 3 4 Table 8.6 10 382 388 380 378 Makespan Number of jobs 15 20 410 650 428 670 420 668 415 664 25 700 698 700 702 30 842 744 622 674 Makespan value for seven – machine cases in FA (equal sub lots) Problem set number 1 2 3 4 5 200 202 198 200 10 202 204 208 198 Makespan Number of jobs 15 20 460 590 504 600 508 608 498 594 25 709 708 714 722 30 854 745 698 676 119 Table 8.7 Total flow time value for three – machine cases in FA (equal sub lots) Problem set number 1 2 3 4 Table 8.8 5 432 448 425 428 10 528 532 530 524 Total flow time Number of jobs 15 20 3012 5712 3152 5845 3098 5523 3124 5512 25 7498 7523 7618 7609 30 10878 8545 8417 8098 Total flow time value for five – machine cases in FA (equal sub lots) Problem set number 1 2 3 4 Table 8.9 5 478 460 500 502 10 2250 2276 2000 2068 Total flow time Number of jobs 15 20 3142 11285 3196 9512 3109 9004 3032 9325 25 11252 11318 11316 11312 30 12644 9618 9434 9518 Total flow time value for seven – machine cases in FA (equal sub lots) Problem set number 1 2 3 4 5 568 598 592 588 10 2200 2509 2404 2208 Total flow time Number of jobs 15 20 4027 9126 4008 9377 4002 9318 4012 9315 25 9812 9989 9787 9957 30 12756 10518 10275 10164 120 Table 8.10 Makespan value for three – machine cases in FA (variable sub lots) Problem set number 1 2 3 4 Table 8.11 5 608 1025 1002 975 10 708 3276 3289 3298 Makespan Number of jobs 15 20 818 918 3512 4012 3398 3998 3494 3889 25 1007 4098 4078 4099 30 1017 4909 4989 5004 Makespan value for five – machine cases in FA (variable sub lots) Problem set number 1 2 3 4 Table 8.12 5 704 3475 4004 4012 10 829 4004 4098 4095 Makespan Number of jobs 15 20 1121 1305 4712 7178 5008 7004 5012 7314 25 1508 7812 7409 7676 30 1699 8287 8256 8102 Makespan value for seven – machine cases in FA (variable sub lots) Problem set number 1 2 3 4 5 790 4134 4212 4018 10 1009 4927 4909 4927 Makespan Number of jobs 15 20 1212 1321 6334 7298 6289 7389 6209 7042 25 1908 9823 10245 10432 30 1878 9989 9993 9945 121 Table 8.13 Total flow time value for three – machine cases in FA (variable sub lots) Problem set number 1 2 3 4 Table 8.14 5 3342 15100 15212 15316 10 3972 15150 16356 15432 Total flow time Number of jobs 15 20 8324 9871 26547 69562 26542 73108 26321 72002 25 23102 91175 140004 130028 30 27564 142875 172121 166523 Total flow time value for five – machine cases in FA (variable sub lots) Problem set number 1 2 3 4 Table 8.15 5 3398 14323 14112 15002 10 4212 16024 18512 18316 Total flow time Number of jobs 15 20 8108 12457 24417 70034 26012 72389 27023 73451 25 24032 95089 154132 140997 30 30012 174623 192978 166421 Total flow time value for seven – machine cases in FA (variable sub lots) Problem set number 1 2 3 4 5 4189 14108 14235 14323 10 5027 20012 21000 19764 Total flow time Number of jobs 15 20 9285 14012 29112 72025 30089 73112 30004 73997 25 25188 96118 157225 163123 30 28098 165113 165580 167772 122 8.8 SUMMARY The numerical illustration and computational results of proposed FA for equal size sub lots (from Table 8.3 – Table 8.9) and variable size sub lots (from Table 8.10 - Table 8.15) are discussed.