Keywords

1 Introduction

Combinatorial optimization problems have been the focus of many scientific research because of their complexity and practical importance in a wide variety of fields, and different algorithms have been developed for their resolution. These algorithms can be classified as complete and approximate algorithms [1], the former being algorithms that ensure to find the optimal solutions.

Nevertheless, when the problem is NP-hard [2], complete algorithms require an impractical amount of time, and thus approximate algorithms (i.e. metaheuristics) are the alternative commonly used in the real world. Approximate algorithms cannot guarantee to find the optimal solution but they notably reduce the amount of time required to provide good solutions [1].

The Job-shop Scheduling Problem (JSP) is “not only NP-hard, but it also has the well-earned reputation of being one of the most computationally stubborn combinatorial problems (…)” [3], and hence it is a problem that elicits interest in areas like planning and managing of manufacturing processes or operations research. In the JSP, there is a set of jobs that has to be performed and each job consists in a set of operations that must be processed in exactly one machine and the operations are subjected to precedence constraints. The goal of the JSP is to find a sequence of the operations that optimizes certain criteria, e.g. minimize the completion time, minimize the total machines’ workload, etc.

The Flexible Job-shop Scheduling Problem (FJSP) is an extension of the JSP in which, in addition to the sequencing, a further decision level is required, the assignment: the operations that make up each job can be processed by any machine from a given set of compatible machines, and thus it is required to assign each operation to one machine. This fact makes the FJSP even more complex than the JSP.

Many approaches have been proposed for the resolution of the FJSP, especially (meta)heuristics algorithms. To name a few within the most relevant ones, Brandimarte [4] described a hierarchical approach for the FJSP, solving separately the sequencing and the assignment problems, both tackled by a tabu search (TS) algorithm. TS was also used by Mastrolilli and Gambardella [5] where, additionally, two neighborhood functions are introduced. Kacem et al. [6] presented a hybrid approach combining evolutionary algorithms and fuzzy logic for solving the FJSP with multiple objectives. In Pezzella et al. [7], a genetic algorithm (GA) with different strategies for initializing the population and for the selection and reproduction of the individuals is presented. Regarding constructive metaheuristics, particle swarm optimization and ant colony optimization has also been applied for this problem (see [8, 9], respectively).

In this paper, we present a comparative study of the performance of different versions of the firefly algorithm (FA) in optimizing the total completion time (makespan) in the FJSP. With this purpose, we have developed a standard discrete version of the FA, another version in which some strategies to generate the initial population are used, and one hybrid version in which, together with this initialization, multiple local search procedures are integrated to increase the performance of the algorithm. These three versions have been tested with multiple state-of-the-art FJSP instances, providing a detailed analysis of the results.

The rest of the paper is organized as follows. In Sect. 2, a general description of the FJSP is provided. In Sect. 3, we describe the discrete version of the FA, the initialization procedure, and the local search strategies. The computational results of the tests and the comparative analysis are summarized in Sect. 4. Finally, Sect. 5 closes the paper with the conclusions obtained in the study.

2 Problem Definition

In the FJSP, there are n jobs, consisting each job Ji (1 ≤ i ≤ n) in a sequence of ni operations and m machines. An operation Oij (i = 1,2, …, n; j = 1,2, …, ni) needs to be performed on one machine mij from the set of available machines Mij. Each machine k ∈ Mij requires a certain processing time (Pijk) to perform an operation Oij.

Some assumptions are made: an operation cannot be interrupted (a1); there are precedence constraints defined for any pair of operations within a job (a2); machines are independent of each other (a3); there are no precedence relations between jobs (a4); transport and set-up times are already considered in Pijk (a5); and each machine can process at most one operation at any time (a6).

The mathematical model could be given as follows:

$$ \min f = \max _{{1 \le k \le m}} \left( {C_{k} } \right) $$
(1)

subject to

$${C}_{ij}-{C}_{i\left(j-1\right)}\ge {P}_{ijk}{X}_{ijk}, j=2,\dots , {n}_{i}; \forall i,j$$
(2)
$${[(C}_{hg}-{C}_{ij}-{P}_{hgk}){X}_{ghk}{X}_{ijk}\ge 0]\mathrm{V}{[(C}_{ij}-{C}_{hg}-{P}_{ijk}){X}_{hgk}{X}_{ijk}\ge 0], \forall i,j,h,g,k$$
(3)
$$ \sum\limits_{{k \in M_{{ij}} }} {X_{{ijk}} = 1,\forall i,j} $$
(4)
$${X}_{ijk}\in \left\{\mathrm{0,1}\right\}, \forall i,j,k$$
(5)

Equation (1) ensures the minimization of the objective, the makespan (i.e. the maximal completion time of all the jobs). Constraint a2 is ensured by Inequality (2) and constraint a6 by Inequality (3). Equation (4) indicates that, for each operation, only one machine can be selected. Equation (5) is the binary decision variable (“1” if operation Oij is assigned to machine k, “0” otherwise).

3 Firefly Algorithm

The firefly algorithm (FA) is a swarm intelligence algorithm inspired by the social behavior of the fireflies. The fireflies use their flashing lights to attract others with predation or mating purposes. It was originally developed for solving continuous optimization problems by Yang [10].

The main aspect of the FA is the association of the fireflies’ light intensity with the objective function of the optimization problem. It is assumed that the firefly brightness (I) determines its attractiveness (\(\beta\)), both being in turn linked with the encoded objective function [11], the makespan in this study. If the aim is to minimize an objective, the objective function value of a firefly at a position x can be inversely associated with its brightness \(I\left( x \right)\, \propto \,1/f(x)\).

Fireflies are initially spread over the search space and each position stands for a solution to the optimization problem. At each iteration of the algorithm, the fireflies will move toward the brighter ones (i.e. for minimization problems, solutions with lower objective function value) within a certain region of the search space, depending on their distance and visibility. The fireflies’ movement driven by its brightness, plus a random movement component, allows efficiently exploring the search space. A more detailed explanation of the original FA can be found in [10, 12].

This section is focused on the discrete version of the FA, which is required for the FJSP. The main aspects of the FA that need to be adapted are the representation of the solutions, the calculation of the distance, and how the movement is performed. The discrete approach presented in this paper is based on [11].

Fig. 1
figure 1

Solution representation and decoding

Solution Representation and Decoding. Each solution of the problem is obtained from two different vectors, one for each FJSP subproblem. The Sequencing Vector (SV) indicates the sequence of the operations and each job number Ji appears ni times. The Assignment Vector (AV) denotes the machine assigned to each operation, an item AV[i] being a machine index. Both vectors have a length equal to the total number of operations, \({\sum }_{i=1}^{n}{n}_{i}\). Figure 1 shows the decoding of a solution from its AV and SV.

First, SV gives the sequence of the operations. The jth operation of Ji (Oij) corresponds to the jth time a job index Ji appears. Then the machines mij assigned for each operation Oij are obtained from the AV. The combination of these two vectors provides the final solution of a firefly: {(O11, M1), (O12, M1), (O31, M3), (O21, M1), (O32, M2), (O33, M3), (O13, M4), (O22, M2), (O23, M3), (O24, M1)}.

Measurement of the Distance Between Two Fireflies. The distance between the SVs of two fireflies can be carried out as the minimum number of swaps required to bring one SV closer to the most attractive one (|dsv|). For AV components, the distance is the number of non-corresponding items in the sequence, known as the Hamming distance (|dav|). Table 1 shows how both distances between the AVs and the SVs of two fireflies (P and Pbest) are calculated.

Fireflies’ Movement. The movement of the original FA is divided into two not interchangeable steps: First, the β-step and then the α-step. The β-step is an insertion and pair-wise exchange mechanism used to bring the AV and SV of a firefly closer to the global best firefly. The β-step consist in the following sub-steps: all necessary pair-wise exchanges in SV and insertions in AV are found and stored in dsv and dav, respectively; the distances |dsv| and |dav| are stored in R; the probability β(r) = βo/(1 + γr2) is computed; a random number rand ∈ [0,1] is generated for each element of dav and dsv; and then the corresponding insertion/pair-wise exchange is performed if Rand ≤ β. The α-step is a swapping mechanism in which two non-equal element positions are chosen at random and swapped. Table 1 shows how the different steps of a firefly movement are performed, with βo = 1, γ = 0.1, and α = 1.

Table 1 Distances and movement

3.1 Initialization Module

In order to study how the initial population can impact the performance of the FA, we have implemented an initialization module. This module aims to initially locate the fireflies in promising areas of the search space instead of doing it randomly. The initialization rules explained below are the same used in the GA of Pezzella [8] who, in turn, follow the approach by location of Kacem et al. [13].

For AVs, two different rules are used: Ar1 and Ar2, both considering the processing times and the machines’ workload. Ar1 works as follows: the minimum processing time Pijk is selected, and the machine k is assigned to the operation Oij. Then all the columns corresponding to machine k are updated with Pijk, and the process is repeated until all the operations have been assigned to a machine. Ar2 works similarly but, before starting, all rows (i.e. operations) and columns (i.e. machines) are randomly shuffled. Then, instead of selecting the minimum of the table, the minimum Pijk of the new first row is selected, then the minimum of the second row, and so on, updating the columns as it was explained for Ar1. The advantage of Ar2 is that different assignments can be obtained in different runs of the algorithm.

For SVs, the well-known sequencing dispatching rules, the Most Work Remaining (MWR), and the Most number of Operations Remaining (MOR) are applied. In addition, to enhance diversity, some of the initial SVs are randomly generated.

3.2 Local Search Module

To enhance the search performance of the FA and to avoid common problems of the metaheuristics such as premature convergence or local optima stagnation, we have introduced several local search procedures into the algorithm. These local search (LS) strategies are based on the neighborhood structures used in the variable neighborhood search (VNS) algorithm presented in [14].

LS Strategy 1. Two element positions of the SV are selected at random and swapped, ensuring that no precedence constraint is violated. This is repeated multiple times depending on the total time of operations.

LS Strategy 2. A random operation is selected from the AV, and a different machine of the set of available machines for that operation is assigned, randomly as well. This step is repeated depending on the total time of operations. It can be noticed that LS strategies 1 and 2 are very similar to the α-step of the discrete FA.

LS Strategy 3. Two jobs are selected at random, and the positions of all its operations are swapped maintaining the precedence relations within each job, while the machine assignments remain the same.

LS Strategy 4. One operation assigned to the machine with the maximal workload (e.g. the sum of the processing times of the operations assigned to that machine) is randomly selected, and then it is assigned to the machine with the least workload, if possible. If not, it is assigned to any random available machine.

LS Strategy 5. One random operation assigned to the machine spending the maximum time to complete its assigned operations (equal to makespan) is selected, and then it is assigned to the machine spending the minimum time, if possible. If not, it is assigned to any random available machine.

4 Results and Comparative Study

This section describes the computational study conducted to compare how differently the FA performs with the initialization and the local search. We implemented three different versions of the FA: a standard discrete FA (VS), another version integrated with the initialization module (VI), and one more version with both the initialization and local search modules (VLS). The algorithms were implemented in Python 3 and the tests were run on an Intel Core 7 2.1 GHz PC with 8 GB RAM memory.

Table 2 shows the average results (Cmax-Av.), the best results (Cmax-Best), and the average and best relative time of 30 runs of the three FA versions (VS, VI, and VLS) for six different FJSP instances. Nxmxni stands for the number of jobs (n), the numbers of machines (m), and the total number of operations (ni). Large instances were selected for the study because it is where more differences in the performance of algorithm’s versions exist. Behnke and Geiger [15] provide a detailed explanation of the instances, from where we took the best-known results (BKR). Av.Rel and Best.Rel were calculated as (tVxtVs)/tVs, tVx being the time spent by version x (x = VI, VLS) in reaching the maximal numbers of generations allowed (MaxGen), which is the termination criteria. The parameters of the FA are number of fireflies nf = 200, MaxGen = 50, βo = 1, γ = 0.1, and α = 1. For the initialization module: Ar1 = 20%, Ar2 = 80%, MWR = 40%, MOR = 40%, and random = 20%.

Table 2 Comparative study

It can be noticed how VLS notably and consistently outperforms VS and VI (Table 2), both in average and best values, reaching the BKR for almost all the tested instances. It was expected since VLS is the most complete version, using both the initialization and local search modules. Nevertheless, what catches our attention is that the time spent by VLS is almost the same or lower than for VS and VI. As a preliminary hypothesis, we believe a possible reason is that the more different the fireflies are, the more computational time for the distance calculation and movement is required. Hence, when applying local search, many solutions are neighborhood solutions of others, and the distance between them is very low, requiring less time to compute it and perform the movement. Another explanation may be how we apply the local search to the firefly’s population. To each solution from the first nf/2 set (better fireflies), we randomly apply one of the LS strategies. But, at each iteration, the second nf/2 (worse fireflies) is renewed with solutions obtained after applying one of the LS strategies to the best solution obtained so far, and thus half of the population are neighborhood solutions of the best one (more focused in the exploitation), while the other half is used for the exploration of promising areas.

5 Conclusions

It is common to look for improvements in the efficiency of metaheuristics algorithms by adding some kind of problem-specific strategies or knowledge. This allows to better explore the search space obtaining quality solutions to the optimization problem in a shorter time. In this work, the original Firefly Algorithm was enhanced with an initialization phase and some different local search procedures for solving the FJSP, aiming to analyze how these two upgrades affect its performance. With this purpose, we have explained and implemented three different versions of the FA—the original discrete version, another version with an initialization phase, and one more version with both the initialization and the local search modules—and compared them in the resolution of some middle- and large-sized state-of-the-art FJSP instances.

Computational results confirmed that the most complete version, the one that starts the search from solutions obtained from the initialization phase and that uses the different local search strategies during the search, consistently outperforms the other two versions, reaching the best known results in most of the tested cases. Future work will be focused on expanding this study to more FJSP instances and on studying further techniques to speed up the algorithm.