**3. Genetic algorithm for production and selection of goods**

#### **3.1 Economic lot quantity with multiple items**

In manufacturing, an important aspect is the supply of resources such as raw materials, sub-assemblies, end/final products, etc. The availability of these resources must comply with time and cost restrictions.

Within this aspect, the Economic Lot Quantity (EOQ ) models are aimed to estimate the lot size *Q* which minimizes operational costs associated to inventory management. In general, *Q* minimizes the following cost function:

$$T = \left(\frac{D}{Q}\right)\mathbf{C}\_\circ + \left(\frac{Q}{2}\right)\mathbf{C}\_h. \tag{1}$$

Where *C*o is the ordering cost per lot, *C*h is the holding cost per unit of product, and *D* is the cumulative demand through a planning horizon [22]. As presented in **Figure 11**, *Q* can also be understood as the lot size that equals the total order cost with the total holding cost through a planning horizon (and this leads to minimize *T*):

$$
\left(\frac{D}{Q}\right)\mathbf{C}\_{\circ} = \left(\frac{Q}{2}\right)\mathbf{C}\_{h}.\tag{2}
$$

Note that Eq. (2) leads to define:

$$Q = \sqrt{\frac{2DC\_o}{C\_h}}.\tag{3}$$

Which computes the optimal value for Q. Now, if *N* items with independent orders are considered, then:

$$T = \sum\_{i=1}^{N} \left( \left(\frac{D\_i}{Q\_i}\right) \mathbf{C}\_{oi} + \left(\frac{Q\_i}{2}\right) \mathbf{C}\_{hi} \right). \tag{4}$$

**Figure 11.** *Inventory management costs associated to the EOQ model.*

Under the assumption of independence, *Q*i can be optimally computed by using Eq. (3) for each item [22]. Thus, for the present case, the GA is only developed to verify its efficiency to solve the EOQ to optimality with a large *N*.

The GA follows the standard structure presented in **Figure 2**. As the solution consists of a set of *Q*i values, the restrictions associated to permutations (such as in the case of TSP/CVRP) are not present. Thus, a simpler crossover operator can be used.

**Figure 12** presents an overview of the linear crossover operator used for the GA. On the other hand, **Table 5** presents the configuration settings of the GA.

The average results for different randomly generated sets of *N* products are presented in **Figure 13**. As this is a simpler problem than both, the TSP and the CVRP, optimality can be reached within 100–200 generations. Note that it is always recommended to select an exact method if it is available and results can be obtained within very reasonable time.

**Figure 12.**

*Linear crossover operator for the multiple-item EOQ (α = 0.5).*

#### *Search Algorithms on Logistic and Manufacturing Problems DOI: http://dx.doi.org/10.5772/intechopen.96554*


#### **Table 5.**

*GA settings for the multiple-item EOQ.*

**Figure 13.** *Mean error gap across all multiple-item EOQ with the GA.*

#### **3.2 Knapsack problem**

The Backpack or Knapsack Problem (KP) is a binary multicriteria problem of NP-hard computational complexity and it is frequently considered as a strategy to select items to maximize profits without affecting capacity restrictions [23, 24].

The KP can be mathematically formulated as a vector of binary variables where = 1 if the item *j* is selected, and = 0 otherwise. Then, if *p*j is a measure of importance (in this case, profit) for an item *j*, *w*j represents the size of said item, and cv is the size of the backpack, the problem refers to the selection of the quantity of all elements whose binary vectors *x*j satisfy the following restrictions [24]:

$$\sum\_{j=1}^{n} w\_j \mathfrak{x}\_j \le c\upsilon \tag{5}$$

$$\mathbf{x}\_{/} \in \{\mathbf{0}, \mathbf{1}\}, j = \mathbf{1}, \dots, n \tag{6}$$

#### **Figure 14.**

*Uniform crossover operator for the KP.*


#### **Table 6.**

*GA settings for the KP.*

#### **Figure 15.**

*Mean objective function values across all KP instances with the GA.*

These must contribute to maximize the following objective function:

$$T = \sum\_{j=1}^{n} p\_j \mathcal{X}\_j \tag{7}$$

*Search Algorithms on Logistic and Manufacturing Problems DOI: http://dx.doi.org/10.5772/intechopen.96554*

The KP also can be extended to consider more restrictions. In example, if *cv* is the volumetric capacity of the backpack, *cz* can be added to include its weight capacity. Thus, if *w*j represents the volume of the item *j*, *z*j can be used to represent its weight, leading to the following restriction:

$$\sum\_{j=1}^{n} \mathbf{x}\_{j} \mathbf{x}\_{j} \le \mathbf{c} \mathbf{x} \tag{8}$$

**Figure 14** presents an overview of the reproduction operator for the GA considered to solve a large KP instance. Note that, due to the binary nature of the decision variable, the crossover and mutation operators can be implemented faster. Then, the configuration settings of the GA are reviewed in **Table 6**.

Based on the instance reported in [24], six random test instances with *N* = 250 items were generated. **Figure 15** presents the mean results for these instances. Error gap assessment was performed with the optimization software Lingo. This led to an error gap of 4.0% which is consistent with the results reported in [24].

## **4. Genetic algorithm for production scheduling problems**

This chapter ends with an application of GA for solving one of the most useful models for manufacturing planning. This model, known as the Permutation Flow-Shop Scheduling Problem (PFSP), consists of finding the optimal sequence of *N*-jobs to be processed on *M*-machines [25]. The optimal sequence of jobs is the one that minimizes the make-span of the *N*-jobs through the *M*-machines, thus, minimizing the completion time of the last job on the last machine. Note that this sequencing implies two important restrictions: (a) no job can be started on the following machine until it is finished in the previous machine; and (b) a job cannot be started on a machine if it is busy processing another job. As consequence, this is one of the main strategies to reduce idle and waiting times within a workshop [26].

For illustration purposes, **Figure 16** shows an example of a solution for a 5-jobs (a, b, c, d, e) and 3-machines (1, 2, 3) PFSP. Note that each job may take different processing times depending of the assigned machine, and the established sequence remains the same for all machines. Thus, the established sequence has a direct effect on the completion time or *makespan*.

Thus, the information (i.e., processing times) of a PFSP with *N*-jobs and *M*-machines is frequently presented as shown in **Table 7**. As in the case of the TSP/ CVRP models, the PFSP is also of NP-hard computational complexity, thus, metaheuristic methods are frequently considered to solve it within reasonable time.

**Figure 16.** *Example of a 5-jobs, 3-machines PFSP.*


**Table 7.** *Data of the PFSP.*

### **Figure 17.**

*Mean error gap across 30 randomly selected 20 × 20 PFLP test instances with the GA.*

As it is a permutation-based problem, the structure and settings considered for the TSP GA (see **Figure 2** and **Table 1**) were considered for the PFSP with 500 generations. For testing purposes, the library and best results reported in [27] for 30 randomly selected 20-jobs, 20-machines PFSP instances were considered. The results are presented in **Figure 17**.

As observed, the mean error gap reaches the 10% mark at the beginning of the GA, with a final mean error gap of 0.005% by the 500th generation. Thus, the GA can provide near-optimal results for the PFSP.
