## 5 Computational Experiments
### Genetic Algorithm (Ga)
#### 5.4.2 Example of GA Individual and Operators  
Below is an example of the operations performed on the individuals generated for this problem, as follows:  
1. Individual: Each individual is randomly generated, with each gene representing the total delivery time for a product at the Distribution Center (DC), within a time window ranging from 1 to 30 days. For example, individual1 = [5; 2; 15; 20; 13; 7] indicates that the total delivery time for the first product is scheduled for day 5, the second product on day 2, and so on. The size of the vector corresponds to the number of products (six products in this case). Similarly, individual2 = [6; 12; 14; 18; 9; 21] represents another set of delivery days for the same products.
2. Crossover: We use the two-point crossover operator to combine two individuals and generate two new individuals. This operation exchanges segments between the two parents, creating hybrid offspring. Example: \[\text{offspring1}=[5; 2; 14; 18; 13; 17]\] \[\text{offspring2}=[6; 12; 15; 20; 9; 21]\]
3. Mutation: Mutation uses the _mutFlipBit_ operator, which randomly changes the delivery date of products on the DC with a probability of 30%. This operation introduces variations, exploring different solutions in the search space. Example: \[\text{offspring1}\_\text{after\_mutation}=[7; 2; 14; 18; 13; 17]\] 4. Repair: The repairing function ensures that individuals respect all the constraints, rules of precedence, and dependence between products. Example: \[\text{offspring1}\_\text{after\_repair}=[7; 8; 14; 18; 13; 17]\] 5. Selection: We employ the elitism method, where the best individuals from the current population are retained for the next generation without modification. The Hall of Fame (hof) structure is used to store these individuals, ensuring that the best solutions found across generations are preserved.  
* Fitness: The objective function seeks to minimize the maximum time of service of all demand in the DC (\(Tmax\)). Therefore, the best individual is the one with the lowest value of \(Tmax\). Example:
In the example above, each gene is evaluated based on the total time required to deliver the product, considering production, quarantine, and transportation times. In the case of offspring1, the delivery time of the second product, which is 2, was considered infeasible, resulting in a penalty of 60. On the other hand, offspring1_after_repair, after being corrected, obtained a \(Tmax\) of 18 and was selected as the best individual for the next generation.
* Population: The population size is 50 individuals. The initial population is made up of randomly generated individuals, with each individual representing a solution to the production and transportation scheduling problem. The evolution of the population occurs through crossover and mutation operations, creating new solutions and selecting the best ones to form the next generations
* Stopping Criteria: The GA ran for 20 generations, each composed of a new population of individuals generated by crossover and mutation. The objective was to minimize \(Tmax\) and ensure that all products were delivered in the DC in the shortest possible time.