## 3 Genetic Algorithm and Fuzzy Logic for the FjSSP  
No efficient algorithm provides an optimal solution in short computing times to a combinatorial optimization problem such as the FJSSP, so it is necessary to use alternatives to complex and analytical methods [10; 17]. These models provide optimal solutions in reasonable computational times only for small instances, which is infeasible for realistic problems, so metaheuristics are suggested to find feasible solutions in reasonable computing times [24]. Adaptive algorithms for production scheduling in fuzzy environments have delivered good results and have provided excellent solutions; therefore, genetic algorithms have become one of the most used metaheuristics to generate efficient and high-quality job sequences in flexible job shop systems [20; 21; 29; 35]. Thus, this study proposes a genetic algorithm with fuzzy logic that follows the ones described in Figure 1 and detailed below. Step 1. Enter the weight of each job \(j\) (\(W_{j}\)), the due window of each job \(\left(d_{jA},d_{jB}\right)\), processing routes, available machines, processing times, sequence-dependent setup times, weight of tardiness (\(w_{T}\)) and earliness (\(w_{E}\)). Enter the genetic algorithm parameters such as Population (PB), Iterations (N), Elitism rate (ET), Crossover rate (PC), Mutation rate (MR). Step 2. Generate the initial population randomly (number of chromosomes) based on the parameter PB, then calculate the number of operations required to complete all the scheduled jobs. In this step, PB chromosomes are randomly generated and are called alpha chromosomes. Each alpha chromosome represents a solution to the proposed scheduling problem; each gene has an input to assign a job randomly and establish the sequence to perform the operations, and another input to store a random number between 0 and 1 to assign the machine that performs the respective operation. A representation of an alpha chromosome is shown below in Figure 2.  
Step 3. Since the alpha chromosome is used to perform the crossover and mutation operators, the beta chromosome facilitates the evaluation of the objective function (fitness value). This chromosome representation enhances offspring feasibility, only requiring the repair of chromosomes by the number of operations per job. The beta chromosomes result from the alpha chromosomes by assigning in input 2 of each gene the machine that performs the operation for the job assigned in input 1. The machine assignment shown in Figure 3 compares the value stored in input 2 of the alpha chromosome with the probability assigned to each machine enabled to perform the operation indicated in input 1. All machines enabled to perform an operation receive the same selection probability. As an example, Figure 4 indicates the sequencing of jobs corresponding to the beta chromosome from Figure 3, where job 3 is shown to be assigned three operations, the first operation is assigned to machine 2 (\(j_{3}\)-O\({}_{1}\)), the second operation is assigned to machine 4 (\(j_{3}\)-O\({}_{2}\)), and the third operation is assigned to machine 7 (\(j_{3}\)-O\({}_{3}\)). Figure 1: Flowchart for the genetic algorithm. Figure 2: Illustration of an alpha chromosome. Step 4. The fuzzy completion time \(\widetilde{C}_{j}\) of each job \(j\) must be calculated to assess the fitness of each beta chromosome. As shown in Equation (19), the completion time for a selected gene is calculated as the start time of the operation (maximum between the available time of machine \(i\)\(\widehat{TM_{i}}\) and the cumulative completion time of job \(j\) up to the evaluated gene \(\widetilde{C_{j}}\)) plus the setup time in machine \(i\)\(\widetilde{S_{ij}}\) and the processing time of operation \(o\) of job \(j\) in machine \(i\)\(\widetilde{P_{ju}}\). The available time of machine \(i\) will be updated with the completion time of job \(j\) that has been processed in this machine (\(\widehat{TM_{i}}=\widetilde{C}_{j}\)).