MODELING A HYBRID FLOW SHOP PROBLEM APPLIED TO THE PRODUCTION LINE OF A HAIR COSMETICS FACTORY

Many industries have a complex manufacturing line, which complicates the planning of their productions. One possible solution to this problem is the optimization of the production line. In this work, mixed integer linear programming models are capable of representing the productive organization of the production line of a hair cosmetics factory, characterized by hybrid flow shop problem. The proposed models can be solved using CPLEX® Optimization Studio for real cases of the studied industrial production line. The objective was the minimization of the production makespan and the completion time. The innovation of this work is the application of the mixed integer linear programming method in complex cases, which are often found in industries and are solved by heuristic methods, simulations, or approximations of analytical methods.


INTRODUCTION
There are several strategies that can be implemented to increase the productivity of a company; for example, the purchase of more equipment, upgrade to more efficient machinery, and the production line optimization. The optimization strategy has the advantage of obtaining the maximum production possible using the equipment and resources already available, making it widely applied in the industrial sector (Belfiore & Fávero, 2013; Rau, 2005; Ribas, Leisten & Framinãn, 2010). Used within operational research, mixed integer linear programming is an exact method capable of solving complex optimization problems (Vielma, 2015). According to Batalha et al. (2008), with the use of mixed integer linear programming, it is possible to create a mathematical model that represents industrial problems, such examples include the production line of a company, the distribution of products, the ways of providing services, and the control of resources, etc. (Midgley, Johnson & Chichirau, 2018). Using a mathematical model, it is possible to apply solution methods in order to obtain an optimized answer of the proposed problem (Vielma, 2015). A very common problem in many industries is hybrid flow shop scheduling (HFS), where a production line consists of several stages and more than one machine at each stage (Ribas, Leisten & Framinãn, 2010; Ruiz & Vázquez-Rodríguez, 2010).
In this paper, mixed integer linear programming models were developed to represent and optimize a production line of a hair cosmetics factory, using the CPLEX Optimization software. The goal was to minimize the makespan of daily production and the completion time of equipment for the best production organization.

LITERATURE REVIEW
In the industrial environment, there are several optimization problems related to production systems due to the organizational complexity in different sectors. Scheduling on parallel machines is a classic problem that occurs in many industries. In this case, there are n jobs that must be processed in m parallel machines, each task must be processed on only one machine (Özpeynirci, Gökgür & Hnich, 2016), and the objective is usually to minimize the task completion time, the so-called makespan (Fanjul-Peyro, Perea & Ruiz, 2017).
The flow shop problem is also very common in many industries. In this case, each task must pass through a production line which is composed of a sequence of m machines (Pessoa & Andrade 2018). A solution to this problem is given by the best production order, allowing the production demand to be completed in the shortest time.
The flow shop on parallel machines, known as hybrid flow shop is a more complex case that is the combination of the problems mentioned above. It is characterized by the existence of K steps, m k machines in each step k, and n products, which must be processed correctly in the order of the production line (Bozejko, Pempera & Smutnick, 2013; Fernandez-Viagas, Perez-Gonzales & Framinan, 2019). Since the production line of the studied factory has three production stages and several machines in each one, the hybrid flow shop scheduling (HFS) is characterized in the present study. In this problem, the best manufacturing route for the products to supply a given demand must be chosen in order to obtain the shortest production time. Therefore, it is necessary to determine in which equipment (of each step) and when the tasks will be processed (Ribas, Leisten & Framinãn, 2010; Ruiz & Vázquez-Rodríguez 2010).
In the literature, it is possible to find studies that deal with HFS, more commonly in some industries. Nabli, Khalfallah, & Korbaa (2018) studied the optimization of a hybrid flow shop model containing two stages of production in order to minimize the makespan in an industrial production line. They used mathematical models and three heuristics to solve the problem, and they obtained promising results. Engin & Güçlü (2018) also studied a hybrid flow shop problem with 3 the same objective, but the hybrid ant colony method was used. Yu, Semeraro, & Matta (2018) used a genetic algorithm to minimize the total delay of the tasks and by Nejati et al. (2014) in order to minimize the completion times. Wang, Liu, & Chu, (2015) showed that the Branch-and-Bound is also used to solve the HFS problem. Pan et al. (2011) and Cui & Gu (2015) used the bee colony method in their respective studies to solve the same problem, where the objectives were to minimize delays and makespan, respectively.
In several real-world contexts, there are some additional constraints and characteristics that must be included in the basic hybrid flow shop problem, making the resolution of the problem more complex. In their work, Li et al. (2018) considered that the tasks have different sequence orders in the production line and used heuristic methods to minimize the makespan. Kim & Lee (2019) also used heuristic methods to optimize a flow shop problem, where tasks had a time limit to be processed in the next steps, making the decisions more difficult. Also using heuristics, Figielska (2014) studied a production line containing one machine in the first stage and many in the second, aiming to minimize the makespan. To solve this complex problem, Figielska (2014) divided the problem into two parts, a technique that was also used in the present study.
Some studies have restrictions and methods that are also considered in this work, such as the need to perform the equipment's setup after processing the tasks. Many studies are carried out with the intention of solving the hybrid flow shop problem in a more simplified way. They considered that the capacities and the processing times of the machines of the same stage are the same and that each product is manufactured only once, which may not represent the industrial reality (Oliveira & Turrioni 2012; Ruiz & Vázquez-Rodríguez 2010). In addition, they mostly used heuristic methods to solve the problem (Oliveira and Turrioni 2012). This fact favors the present work, since the linear model developed is innovative, considering that each equipment has different characteristics and that each product can be manufactured more than once, in addition to other limitations that occur in the real case studied.

PROBLEM CHARACTERIZATION
In this work, the production line of a hair cosmetics factory was studied. The production line consists of three stages: stage I, the reactors (R); stage II, the storage tanks (S); and stage III, the packing machines (P). In the reactors, the products are processed and, later, can be stored in tanks.
The packing machines are used to put the products in their respective bottles, completing the production line. The production is made by batch processes, which are rechargeable processes.
In stage I, the products are manufactured in batches, performed by operators. The batches are stored in step II if necessary and, then, transferred to the stage III, where the operators of this stage complete the manufacturing process.
Steps I and III are required in every production because they are indispensable in the processing of the desired product. However, step II is only used when intermediate storage is required between stages I and III. Thus, storage tanks are not required, but their use can streamline production since the use releases the reactor to a new production before the packaging stage is completed.
Physical limitations in the production layout were considered, as they restrict the connection between the equipment. These limitations are represented as reactor-storage compatibility (R-S), reactor-packer compatibility (R-P), and storage-packer compatibility (S-P). There is also incompatibility between products and equipment, since some products (divided into classes A and B and subdivided into types 1, 2, and 3) need to be processed in specific equipment.
The batches are processed in the reactors and are transferred to the storage tanks or directly to the packing machines. The equipment can only be released for setup when the whole batch has been transferred and completed in the next step, since during transfer and processing they are connected. The transfer time to a tank is shorter than the packing time, which stresses the importance of storage tanks. Therefore, if a storage tank is used, the reactor can be released for setup prior to packaging. Figure 1 represents the factory production line described and used in this work, where it is possible to observe the number of equipment used in each stage, the arrangement of the production line, and the product-equipment and equipment-equipment compatibility.

MILP FORMULATIONS
The production line studied in this article can be modeled as a problem similar to hybrid flow shop, because there is more than one stage and more than one piece of equipment per stage. However, there was a need to add more complex constraints to better represent the reality of the factory studied. Furthermore, due to complexity, the resulting model was decomposed in two models that are used sequentially. Instead of deciding simultaneosly the assignment of products to batches and the schedule of the batches into the equipments, we first determine the minimum number of batches to satisfy the demand (by a first model) and then we solve the whole model considering only this minimum number of batches. This reduce the complexity of the model, as no useless batch are considered.

Considerations for models
The production is done by means of batch; therefore, the model was based on determining how many batches are produced, which products are present in each one of them, in which pieces of equipment they are allocated, and when they are processed. The size of a batch depends on the capacity of the reactor used to process it, and the total demand of a product may be divided into multiple batches. Moreover, each batch can contain at most one product and must be allocated in the machinery to complete the demand.
In the reactors, the batch is allocated according to the compatibility between the product and the route that each reactor can be connected. Each reactor can only contain one batch at a time, and the number of operators available must be respected because there is a limit on the number of workers, which generates a limit on the number of reactors that can be used at the same time. The capacity of the reactors is nominal, that is, each one processes the maximum mass of product possible. After the manipulation of each batch and the transfer to a storage tank or the directly packing, a setup must be performed. However, when processing the same item in consecutive batches in the same reactor, the setup is only 10% of the normal setup, due to easier clean up and preparation.
After the manipulation, the batches can be transferred to the storage tanks (step II) or processed directly into the packers (step III). When the transfer occurs, the R-S compatibility must be respected. The reactor and the storage tank are busy during the transfer, and it is necessary to wait for the conclusion of one stage to start the next one. Each tank can contain only one batch at a time, and the processing time is the transfer time required for the product, which is directly proportional to the mass transferred. After filling the tank (step II), step III must be completed before starting the setup, which consists of cleaning the tank. And just like in reactors, if the next product to be allocated to a tank is the same as the previous batch, the setup is only 10% of the normal setup.
In step III, only one batch can be processed at a time. Also, the limit of operators in this sector and the compatibility R-P, S-P, and product-P must be respected. The packing time depends on the mass of product contained in the batch and the number of workers, which has a lower and higher limit. After this step, both the storage tank (or the reactor in the case of direct packaging) and the packaging machine are released to the setup step, which is 10% of normal setup if the next product is the same as the previous one. At the end of this phase, the manufacture of the product in the batch is completed.
From these considerations, two mathematical models of mixed integer linear programming were created, consisting of parameters, variables, objective functions, and constraints. Model I was used to determine the allocation of products into the batches and Model II was used to determine the batch processing route. Thus, the problem was divided into two parts, making it easier to solve.

Parameters
The data of a production line is represented by the following parameters, which are defined as integer (int), real (real), or binary (bin): N (int) = Estimated number of batches required (equal to 11 for a daily production in the factory studied, because it is the maximum number of batches that can be produced in one day); TIOI oi (real) and TIOIII oiii (real) = Initial times of the activity of the operator oi of step I and operator oiii of step III; 7 TIR r (real), TIS s (real) and TIP p (real) = Initial operating times of the reactor r, storage tank s, and packing machine p; TFR r (real), TFS s (real) and TFP p (real) = Final operating times of reactor r, storage tank s, and packing machine p; TLR pd,r (real), TLS pd,s (real) and TLP pd,p (real) = Setup times of the product pd in the reactor r, in the storage tank s, and in the packing machine p; PRM pd,r (real) = Processing time of the product pd in the reactor r (medium value); PSM pd,s (real) and PPM pd,p (real) = Processing time of the product pd in the storage tank s and in the packing machine p (medium value per unit mass); MR pd,r (real) = Mass of the product pd that can be produced in the reactor r; XIR pd,r (bin), XIS pd,s (bin) and XIP pd,p (bin) = Compatibilities between pd and r, between pd and s, and between pd and p; XRS r,s (bin), XSP s,p (bin) and XRP r,p (bin) = Compatibilities between r and s, between s and p, and between r and p; XB pd,i (bin) = Allocation of the product pd in the batch i (1 if allocated and 0 otherwise) (used only in Model II).

Variables
The optimal solution is defined according to the values found for the following variables, which are also defined as integer (int), real (real), or binary (bin): xtr i,j (bin), xts i,j (bin) and xtp i,j (bin) = Precedence rules between batches i and j in reactors, in storage tanks, and in packing machines (0 if i precedes j, otherwise 1).

Model I
The first model assigns products to batches. Usually, several products have a demand that may not be fully obtained by one only batch, due to reactor capacities. The production must then be divided into more than one batch. As reactors have different capacities, batches are of different sizes, and the first decision was to define the minimum number of batches necessary to fulfill the demand of all products. This was decided by Model I, defined as shown below, starting from an estimated upper bound N on the number of batches.
Each batch may contain only one product (constraint 2).
The products were organized in the batch according to the constraint (3), where the products of smaller numbers were destined for the batch of larger numbers. This rule exists in order to organize allocations, avoid unnecessary searches due to simmetry, and ensure that only the minimum number of batches is filled.
A production route must comply with the compatibility rules, which is assured by constraints (7)- (9). For example, (7) states that, if a batch i is allocated to a reactor r and a storage tank s, the product inside the batch must be compatible with both reactor and storage tank, and they must be compatible to each other.
The sum of the mass produced of a product must be at least its demand. The constraint (10) is not linear, but the CPLEX is able to automatically linearize the equation modules. In order to do so, we used the term ((xr i,r + xb pd,i ) -(|xr i,r -xb pd,i |))/2 instead of xr i,r . xb pd,i .

Model II
The second model (Model II) was created to decide a production route for each batch. This model used the solution obtained from Model I in order to consider only batches to which a product is allocated. Thus, the decision variable xb pd,i of the first model was transformed into an array of parameters to be used in the second model, which indicates whether pd is inserted in i (XB pd,i ). Only constraints regarding production routes were considered in this model. The goal was to minimize the makespan, but in order to speed up the process while avoiding different solutions with the same makespan, the objective function considered also the minimization of the completion time of each batch (multiplied by a very small weight, so the main objective remains the minimization of makespan). Besides that, the minimization of the reactor release time to the following day was also considered, so the production may start as soon as possible (11).
And constraint (13) ensures that the production makespan is the maximum among the completion time of all batches in the packing machine.
The release time of the reactors must be greater than or equal to the completion time of the packer connected to it, or to the completion time of the storage tank if it is used (constraints 14 and 15).
The production route must comply with the compatibility rules, which is assured by constraints (16)- (18). According to the constraint (19), the demand must be met. In this model, the batches will be allocated to reactors of different capacities, so it is necessary to verify if the demand is being met.
MR pd,r . xr i,r + XB pd,i -xr i,r -XB pd,i 2 ≥ D pd ; ∀ pd = 1, . . . , PD The processing time pr i of a batch depends on the reactor used and the product (constraints 20 and 21).
The start time of each batch must be greater than or equal to the start time of the equipment used, as indicated in constraints (26), (27), and (28).
The order of batch processing in steps I, II, and III are defined by constraints (32) to (40), as well as feasible completion times accorting to the processing order.
The constraints (49) and (51) implies that each worker can accumulate at most one task more than the others. Also, constraint (50) ensures that a batch can only be started when its respective worker is released.

SOLVING A REAL CASE
Real instances were simulated to evaluate the usability and validity of the models presented. The simulation and optimization were performed considering the production line of the hair cosmetics factory studied, characterized by Figure 1, where there are seven reactors, four storage tanks, and six packaging machines. The manufactured products are presented in Table 1.
The factory operates from 8:00 AM to 5:15 PM, performing intervals from 9:00 AM to 9:20 AM, 11:30 AM to 12:35 PM, and 3:00 PM to 3:20 PM. Thus, based on this work period, simulations were performed for the case of three daily productions in order to comply with the demands presented in Table 2.
The processing time of the products in step I varies according to the reactor used and the product manufactured (regardless of product class and type), as shown in Table 3. In addition, setup time and the capacity of each reactor can be observed in Table 4, and the Product-R and R-S compatibilities used in this case are present in Tables 5 and 6, respectively. Observe that Reactor 2 is not compatible with any storage tank. In fact, it is connected only to packing machines, as may be seen in Figure 1.
In step II, the processing time in each storage tank is the same (0.005 minutes per kilogram of product transferred). The setup time is also the same for all tanks (60 minutes). In addition, the Product-S compatibility is equal to 1 for all cases and the S-P compatibility used in the factory can be seen in Table 7. In stage III, the processing and setup times are independent of the product manufactured, but they depend on the packaging machine used, as seen in Table 8. Each equipment in this step requires a number of operators between the minimum and maximum established, as shown in Table 9. And the product-P and R-P compatibilities used in this case are present in Tables 10 and  11, respectively. Therefore, three consecutive daily productions were simulated and optimized to demonstrate the operation and viability of the models developed in this work in real case of the studied factory. The simulations were performed using CPLEX Optimization Studio software (student version) on a computer with 8GB RAM and an Intel i7 processor.

RESULTS
For the first day demand, the results presented in the Gantt diagram of Figure 2 were obtained. In this diagram, it can be seen that the productions were organized and sequenced in the equipment in order to meet the demand of the day in the shortest time found. The model determined which batches should be stored in the tanks and which could be packed directly. The solution of Model I was obtained in 1.05 seconds with a GAP of 0.00%. Execution of Model II was performed in 1 minute and 31 seconds with a GAP of 0.57% (even with a longer search time, a lower GAP was not found).
Observing the result for the demand of the first day, in Figure 2, it is possible to conclude that it could not be fulfilled in just one day. Therefore, this demand is completed in the next day, generating a delay in the beginning of production of the second day.   The results for the production of second day demand can be observed in Figure 3. It was sequenced in the equipment in order to meet the demand in the shortest time found and respecting the end of the production of the previous day. Model I required 1.12 seconds of processing, ob-

REACTOR PRODUCT 1 2 3 4 5 6 7
Class A 1 0 1 1 1 1 1 Class B 0 1 0 0 0 0 0        The Model II was run for 1h, and finished with gap 12.5%. This gap was obtained after only 1 minute and 45 seconds, then we can state that after this short time the best solution we could get was already found.
Similar to the first day, demand for the second day could only be completed the day after, delaying the start of production on the third day. This fact can be observed in the results obtained for the simulation of the demand of the third day, presented in Figure 4. The execution of Model I was performed in 1.04 seconds, obtaining 0.00% of GAP, and Model II was performed in 1 minute and 42 seconds, reaching a GAP of 0.67%. The best sequencing was obtained, meeting  the demand in the shortest time found and determining which production routes would be the best.

CONCLUSION
In the present study, two mixed linear programming mathematical models that, by working together, represented the production line of a real case of hybrid flow shop were developed. The first model (Model I) was used to allocate the products in batches and the second model (Model II) to determine the batch processing route in the equipment of sectors I, II, and III. Both models were solved in the CPLEX Optimization Studio solver. Three consecutive daily productions of the hair cosmetics factory were simulated. From the results obtained, it was possible to prove the usefulness and the viability of the models created to obtain optimal solutions for the production of the studied factory. Though the results were achieved in a short time and the models worked well for the factory production scheme, the same functionality cannot be ensured for more complex problems. However, the use of this study by factories can reduce the production time (makespan and completion time), make the production line more organized, and increase the profitability of its productions.