1 Introduction

The Optimal Multivariate Mixture Problem (OMMP) involves the selection of an optimal mixture or combination of elements from a given set of items described by a set of variables. The objective is to obtain a mixture that closely approximates the characteristics of a desired item across the variables. Generally, problems of this nature can be tackled using conventional methods from Operations Research (OR) (Seyedmohammadi et al., 2019; Saderova et al., 2021; Gilani et al., 2020; Aazza, 2021). However, in recent decades, meta-heuristic approaches, which belong to the field of Artificial Intelligence (AI), have gained increasing prominence (Jones et al., 2002). Meta-heuristic techniques are general algorithmic frameworks that draw inspiration from nature and aim to find reasonable solutions to complex problems by combining different strategies that exploit a dynamic balance between accumulated search experience and exploration of the search space (Bianchi et al., 2009). In other words, meta-heuristics are intelligent procedures that identify and explore regions of high-quality solutions while minimizing time spent elsewhere in the search space (Bianchi et al., 2009). Examples of meta-heuristics include ant colony optimization (ACO), evolutionary computation (EC), simulated annealing (SA), and tabu search (TS). Among the EC family, which encompasses algorithms inspired by biological evolution for global optimization, genetic algorithms (GA) are particularly well-suited for solving multi-objective problems (Konak et al., 2006).

Genetic algorithms (GA) are optimization methods inspired by the natural selection mechanism of evolution, which simulate the natural evolution process by three significant operations: crossover, mutation, and reproduction (Chen & Chen, 1997; Chang & Chen, 1998). The problem of choosing the best combination of elements to achieve an optimal mixture is a complex and challenging task (Thongsook et al., 2014) with applications in various real-life contexts, including food, agriculture (Seyedmohammadi et al., 2019), chemistry (Aazza, 2021; Shirneshan et al., 2021; Jacob & Ashok, 2021), materials science (Monteagudo et al., 2011; Mirzahosseini et al., 2015; Gilani et al., 2020), medicine (Balamurugan et al., 2012), and pharmaceuticals (El-Hagrasy et al., 2006). In the domain of mixture experimental design, various studies have been proposed using GA-based mathematical models to generate optimal designs for conducting mixture experiments (Thongsook et al., 2014). For instance, experimental applications have been carried out to characterize pharmaceutical powder blending processes using D-optimal design (El-Hagrasy et al., 2006). Additionally, prediction models have been developed to investigate the rutting phenomenon in asphalt mixtures using linear genetic programming (LGP) and artificial neural network (ANN) techniques (Mirzahosseini et al., 2015). Furthermore, genetic algorithms have been employed to explore and optimize biodiesel-ethanol blends, simultaneously reducing emissions and enhancing performance (Shirneshan et al., 2021). Lastly, in the context of asphalt mixtures, the effects of nano-hydrated lime (NHL) as a bitumen modifier on moisture and fatigue damages have been investigated using multivariate regression (MVR), group method of data handling (GMDH), and genetic programming (GP) (Gilani et al., 2020). These studies highlight the potential and effectiveness of genetic algorithms in addressing various challenges in mixture experimental design, including pharmaceutical processes, asphalt mixtures, and fuel blending.

This paper aims to propose a genetic algorithm-based model called Genetic Algorithm for Optimal Multivariate Mixture (GA-OMM), which, in a generalized context, can select both items and corresponding percentage values optimally to obtain a mixture with feature values as close as possible to the ones of an ideal desired composition. Due to the intrinsic nature of this problem, to the best of our knowledge, this study represents the second investigation addressing this specific problem, as most previous research in mixture studies has focused on optimal experimental design (Thongsook et al., 2014; Mirzahosseini et al., 2015; El-Hagrasy et al., 2006) or multi-objective optimization (Shirneshan et al., 2021; Aazza, 2021; Gilani et al., 2020; Jones et al., 2002).

This work describes the algorithm within its general framework and conducts a test case with 8 items and 5 features to evaluate its efficiency by exploring various combinations of hyperparameters. Additionally, we establish test cases for the previous version (GA-1) (Sgarro & Grilli, 2023) and a Linear Programming (LP) approach. The need for a new version stands for the findings of some critical issues found in it, like the percentage generation process and the variable coding used, processes that will be analyzed afterward in Sect. 3.6. The data experiments demonstrate that the proposed GA exhibits high efficiency, consistently converges towards the global optimum, outperforms its predecessor, and delivers highly competitive results. Although the problem of selecting optimal multivariate items for multivariate mixtures has not been extensively studied in the literature, it is not limited to theoretical considerations and holds practical applications. The inspiration comes from a widespread problem that companies employed in the durum wheat processing sector have. The underlying problem can be defined as follows: “Given a set of n grains, each characterized by m features, is it possible to obtain one or more mixtures that closely approximate an ’ideal optimal solution’?”

The previous example is just the one we were committed to. But willing to link to other fields, here we provide some examples: In the realm of food, for instance, it may pertain to crafting a new recipe by blending various ingredients to achieve a desired taste or nutritional profile. In agriculture, the problem could manifest in formulating optimal blends of fertilizers or pesticides tailored for specific crops and environmental conditions. In chemistry, the challenge could lie in combining different chemical substances to synthesize new materials with specific properties. This could be crucial in drug synthesis, where achieving the right mix of reactants is pivotal in obtaining the desired compound. Similarly, in the field of materials science, researchers might seek to blend different components to produce alloys or composites with desired properties, such as mechanical strength or electrical conductivity. In medicine, the problem may involve blending different medications or active ingredients to create formulations that maximize therapeutic efficacy while minimizing side effects for individual patients. Lastly, in the pharmaceutical industry, the challenge could involve mixing various components to manufacture drugs in tablet, capsule, or liquid form with optimal release characteristics.

The paper structure is the following: in Sect. 2, we present the problem of Optimal Multivariate Mixture. Section 3 provides a generic model of genetic algorithms (GA), including a description and comparison of meta-heuristics, along with an explanation of GA-1. Section 4 describes the GA-OMM algorithm within its framework. Sect. 5 presents the experimental application of the 8-items 5-features model, where GA-OMM is compared with GA-1 and LP-solver. Section 6 includes a detailed analysis of the consistency and performance of the experimental application. Finally, in Sect. 7, some conclusions are drawn.

2 Problem definition

The problem of selecting optimal multivariate items for optimal multivariate mixtures can be mathematically formulated as follows:

Given a set of n items, \(X_1, X_2, \ldots , X_n\), where each item \(X_i\) is represented by a vector of m features, i.e.,

$$\begin{aligned} X_i=(x_{i,1}, x_{i,2}, \ldots , x_{i,m}), \end{aligned}$$
(1)

and a desired “ideal optimal solution" denoted as:

$$\begin{aligned} \bar{X} = \{\bar{x}_1, \bar{x}_2, \ldots , \bar{x}_m\}, \end{aligned}$$
(2)

is it possible to obtain a mixture, denoted as \(X_{mix}\), that closely approximates the “ideal solution"?

In such a context, the mixture is obtained as a convex combination of the n items that is:

$$\begin{aligned} X_{mix}=\alpha _1 X_1 + \alpha _2 X_2, \ldots ,\alpha _n X_n, \ \ \alpha _i\ge 0, \ \ \displaystyle \sum _1^n \alpha _i =1. \end{aligned}$$
(3)

The objective of the problem is to determine the values of \(\alpha _i\) (for \(i=1,2,\ldots ,n\)) that minimize the distance \(d(\bar{X}, X_{mix})\) between the ideal solution \(\bar{X}\) and the obtained mixture. Formally, the problem can be expressed as follows, find:

$$\begin{aligned} X_{mix}=\alpha _1 X_1 + \alpha _2 X_2, \ldots ,\alpha _n X_n \end{aligned}$$
(4)

minimizing:

$$\begin{aligned} d(\bar{X},X_{mix}) \end{aligned}$$
(5)

subject to:

$$\begin{aligned} 0 \le \alpha _i \le 1, \ \ \sum _{i=1}^{n}\alpha _{i}=1 \end{aligned}$$
(6)

A graphical representation of OMMP is provided in Fig. 1.

Fig. 1
figure 1

Representation of OMMP. This involves determining the optimal percentage values \(\alpha _i\) for the items \(X_i\), such that their mixture \(X_{mix}\) closely approximates a desired mixture \(\bar{X}\) across the j variables

To provide some real-context examples in the context of food, let’s consider the task of developing a new type of granola bar. Here, the elements are the individual grains or ingredients used in the bar, such as oats, nuts, seeds, and dried fruits. The variables could include the nutritional composition of these ingredients, such as their fat, carbohydrate, protein, and water content. The ideal solution would involve selecting the right combination of grains and adjusting their proportions to balance flavors, textures, and nutritional benefits that align with the target market’s preferences and dietary requirements.

In agriculture, imagine a scenario where farmers need to optimize the composition of a fertilizer blend for a specific crop, say tomatoes, grown in a particular soil type and climate. In this case, the elements are the different types of fertilizers available, each containing varying amounts of nutrients like nitrogen, phosphorus, and potassium. The variables could include soil pH, nutrient levels, and environmental conditions. The ideal solution would entail selecting the right combination and proportions of fertilizers to meet the crop’s nutritional needs, enhance soil fertility, and maximize yield while minimizing environmental impact.

Moving to chemistry, let’s consider the synthesis of a new type of polymer for use in biodegradable packaging materials. Here, the elements are the different monomers or chemical building blocks available for polymerization. The variables could include monomer structure, molecular weight, and polymerization conditions. The ideal solution would involve selecting the appropriate combination of monomers and optimizing reaction parameters to achieve a polymer with the desired mechanical properties, biodegradability, and cost-effectiveness.

In the realm of medicine, pharmaceutical researchers are developing a new cancer treatment regimen that combines multiple drugs to target different aspects of tumor growth and metastasis. The elements are the individual drugs, each with its own mechanism of action and side effect profile. The variables could include drug dosage, administration schedule, and patient-specific factors like tumor type and genetic makeup. The ideal solution would involve designing a treatment protocol that maximizes tumor response while minimizing toxicity and adverse effects on the patient’s overall health.

Lastly, in the pharmaceutical industry, let’s consider the formulation of a new pain reliever in tablet form. Here, the elements are the active pharmaceutical ingredients (APIs) and excipients used to create the tablet. The variables could include API concentration, tablet size, and excipient composition. The ideal solution would involve selecting the right combination and proportions of ingredients to ensure effective pain relief, optimal tablet disintegration and dissolution rates, and minimal gastrointestinal irritation.

3 General structure of a genetic algorithm

Genetic algorithms (GA) are a branch of Evolutionary Computing (EC), i.e., those techniques that solve optimization and search problems using biologically inspired operators (Wahde, 2008). More specifically, GA tries to imitate the biological processes of natural selection through revised versions of crossover, mutation, and reproduction processes (Sivanandam & Deepa, 2008). From the first formulation onward (Holland, 1992), numerous models were proposed by authors. In this context, we will describe a “simple model structure” that represents the base we used for the GA proposed.

Generally, a GA starts from a set of candidate solutions called population. Using genetic operators, it evolves through iterations towards better solutions in an optimization problem (Sivanandam & Deepa, 2008; Dwivedi et al., 2012). Specifically, during each iteration, the starting solutions, known as parents, are recombined through crossover and mutation operators to generate new solutions called children. Subsequently, through a reproduction operator, parents and children are evaluated first, and then new parents are selected and used in the following iteration (Whitley, 1994). The process continues until optimal solutions are reached (Konak et al., 2006; Chang & Chen, 1998; Thongsook et al., 2014). More specifically, a GA framework is represented in Fig. 2, encompassing the following steps: 1) Parents generation, 2) Crossover and Mutation operators, and 3) Evaluation and selection (Reproduction). The process of steps 2) and 3) is repeated for a fixed number of iterations or until a convergence criterion is satisfied (Konak et al., 2006; Chang & Chen, 1998; Chen & Chen, 1997; Thongsook et al., 2014; Dwivedi et al., 2012).

Fig. 2
figure 2

The workflow of the generalized GA model

3.1 Parents generation

An initial population of solutions is generated within the entire range of possible solutions, also called the search space. These solutions are often taken randomly and, in this context, are called chromosomes (Whitley, 1994). Chromosomes are commonly represented using an encoding rule, such as binary vector coding, where solutions are represented as arrays of 0 s and 1 s, or real vector coding, where solutions are arrays in which each component (gene) corresponds to a real number (Chang & Chen, 1998).

3.2 Crossover and mutation operators

Starting from the initial chromosomes, a subset known as parents is selected, and crossover and mutation operators are applied to generate children (Sivanandam & Deepa, 2008).

Crossover involves selecting two chromosomes, often randomly, and cutting their arrays at the same positions, then exchanging the cropped segments. There are various types of “cutting", with one example being the division of two chromosomes into two heads and two tails. Given a chromosome with \(m\in {\mathbb {N}}\) components \([1, \ldots , m]\), the head consists of \([1, \ldots , c]\), and the tail consists of \([c+1,\ldots , m]\) with \(1\le c \le m-1\). The first child is the head of the first and the tail of the second, and the second child vice versa.

Mutation involves modifying certain parts of a parent chromosome to create a child chromosome (Konak et al., 2006; Whitley, 1994; Dwivedi et al., 2012). For instance, in binary vector coding, the mutation operator could randomly select several components from a chromosome and exchange 0 s with 1 s, and vice versa (Chen & Chen, 1997). Typically, crossover and mutation are separate processes. Initially, chromosomes are selected for crossover, and then, in a subsequent step, considering all parents, chromosomes are selected for mutation. This allows some chromosomes to be utilized for crossover and mutation (Whitley, 1994).

3.3 Evaluation and selection (reproduction)

Parents and children are pooled together, and the entire set of chromosomes is evaluated using an objective function called as fitness function to assess them and create a ranking. Then, a specific logic of selection is applied for choosing certain chromosomes that will be the population for the next iteration (Konak et al., 2006; Thongsook et al., 2014; Dwivedi et al., 2012; Chen & Chen, 1997; Chang & Chen, 1998). This whole process, known as reproduction, is divided into two main parts: evaluation, which involves computing the fitness of each chromosome, and selection, which involves selecting the chromosomes that will compose the future population for the next iteration. During an iteration, the evaluation process typically involves calculating the fitness values for all individuals. Subsequently, the selection process is applied, which may utilize techniques such as roulette selection to select a specific number, denoted as P, of individuals as offspring. Roulette selection is a kind of selection in which the probability that one chromosome is selected is directly proportional to the value of fitness owned by the chromosome itself (Wahde, 2008). The fitness function is generally designed based on the specific context and objective, and various techniques have been proposed in the literature for the logic of selection. The choice of a particular technique depends on the specific context and objective at hand (Sivanandam & Deepa, 2008).

3.4 Re-iteration

Crossover and mutation are applied after selecting the best chromosomes through the reproduction procedure, often with the same number of individuals for each generation. This is followed by evaluation and selection steps, which are repeated for a predetermined number of generations or until a convergence criterion is satisfied (Konak et al., 2006; Chang & Chen, 1998; Chen & Chen, 1997; Thongsook et al., 2014; Dwivedi et al., 2012). The number of generations and the convergence criterion depend on the specific context and objective. Graphs depicting generation fitness are commonly plotted to assess the performance and progress of the genetic algorithm (GA) during iterations. These graphs allow for the observation of algorithm convergence over generations. Fitness can be represented in various forms, such as the average or best fitness value of each generation (to name a few). If the fitness converges to the best value over the iterations, the GA functions correctly (Chang & Chen, 1998). An example of a graph related to this work is provided in Fig. 9a and b.

3.5 Comparison with other meta-heuristics

GA can be compared with other meta-heuristic techniques, particularly Simulated Annealing (SA), Tabu Search (TS), and Swarm Intelligence (SI). Each of these techniques has peculiar characteristics:

  • Simulated Annealing is a probabilistic physics-inspired method (Kirkpatrick et al., 1983), which works by emulating the process of slow cooling of a solid until freezing. SA has the advantage of easy implementation and reduced consumption (e.g., time/space) compared to the Monte Carlo method, for example. However, it has the disadvantage of stacking the solution in local minima. Many real-life applications use this meta-heuristic, for example, in agriculture (Dong et al., 2013; Chen et al., 2023; Kuo et al., 2001), traffic mitigation (Oda et al., 1997; Lavandier et al., 2021; Xu et al., 2009), vehicle routing (Yu et al., 2022; Redi et al., 2020) or resources allocation (Tufano et al., 2020; Abuajwa et al., 2021). Simulated Annealing algorithms are well-suited for problems requiring exploration of a vast solution space and prevention of entrapment in local minima.

  • Tabu Search is an iterative method for building an extended neighborhood that allows you to escape local minima through worsening steps, which are subsequently referred to as “Tabu" (Glover, 1989). Although TS can avoid using already explored solutions, this meta-heuristic requires many iterations and suffers from strong conditioning due to the parameters’ choices. Many real-life applications use TS, such as for solving routing problems (Barbarosoglu & Ozgur, 1999; Gendreau et al., 1994; Cordeau et al., 2001), scheduling problems (Ben-Daya & Al-Fawzan, 1998; Adamuthe & Bichkar, 2012; Edwards et al., 2015) or DNA sequencing (Kwarciak & Formanowicz, 2014; Błażewicz et al., 2004). Tabu Search algorithms can effectively find high-quality solutions for combinatorial optimization problems. They are particularly suitable when the problem involves managing complex constraints.

  • Swarm Intelligence comprises a set of techniques that are based on the natural behavior of systems made up of a multitude of individuals, e.g., ants, bees, and birds, based on self-organization. The SI algorithms include Ant Colony Optimization (ACO), Particle Swarm Optimization (PSO), Evolutionary Algorithms (EA), and Artificial Swarm Intelligence (ASI). Swarm Intelligence algorithms are well-suited for problems requiring exploring various solutions and dynamic adaptation to problem conditions (Sgarro & Grilli, 2024).

Although they are widely used techniques, each of these requires strong modifications to be applied to the specific OMMP. For example, using SI, in this case, requires that the swarm be configured with specific parameters tailored to the characteristics of the grain mixture. While SA and TS excel in certain optimization contexts, their adaptation to the OMMP demands substantial adjustments to account for the unique constraints and complexities involved. SI algorithms, inspired by collective behaviors in natural systems, offer a promising approach but necessitate significant customization to address the intricacies of the grain mixture problem effectively. In contrast, GA emerges as the preferred choice for solving the OMMP due to its inherent adaptability and robustness.

Genetic Algorithms exhibit intrinsic advantages in managing complex combinatorial problems, such as the search for the optimal mixture, where exploring a vast array of possible combinations is essential. Drawing inspiration from natural selection and biological evolution, the GA approach facilitates efficient exploration of solution space by dynamically adapting the population of candidate solutions throughout iterations. Moreover, GAs are adept at handling complex constraints inherent in the OMMP, such as limitations on the quantity of each element type or constraints balancing desired mixture characteristics. By maintaining and propagating the best solutions over time, GAs ensure robust solution space exploration while satisfying imposed constraints.

Furthermore, GAs are renowned for their ability to effectively navigate the entire solution space without becoming trapped in local minima, mitigating the risk of stagnation encountered with SA and TS. Leveraging mechanisms like selection, crossover, and mutation, GAs sustain genetic diversity within the population, facilitating the exploration of solution regions otherwise left unexplored. Additionally, GAs offer greater flexibility and scalability compared to SA, TS, and SI when it comes to problems like this one. They can be readily adapted and configured to address the specific requirements of the OMMP, allowing for enhanced customization and optimization of performance.

In conclusion, Genetic Algorithms emerge as the most suitable approach for solving the OMMP, offering a combination of adaptability, robustness, and scalability that effectively addresses the complexities and challenges inherent in this optimization task.

3.6 Genetic algorithm 1 (GA-1)

The previous version of GA for solving OMMP worked in this way: a double coding was applied for the solutions, a binary encoding for choosing the items, and a percentage coding for percentage generation.

During the first iteration, a parents generation was applied, first generating binary chromosomes, then by creating percentage chromosomes by them in this way: first, a percentage value was computed by choosing a random number \(x_{p,1}\) between [0, 1] with distributed uniform probability, then the second percentage a value of probability between \([1-x_{p,1}, 1]\) and so on up to the last percentage to compute. Lastly, each percentage chromosome was explored a certain number of times. All the solutions were evaluated at the end of the iteration, and the best ones were selected for the next iteration.

From the second iteration onwards, a part of the d best binary solution of the previous iteration was used to generate new percentage values; each one explored a certain number of times. Following evaluation, only the d best solutions among all the existing solutions and the newly generated ones were retained for the subsequent iteration.

This algorithm, despite its effectiveness, shows some criticisms. First of all, the double coding could be outdone by only representing non-taken items as having zero percentage value, thus lightening the code and the computing. Moreover, the way percentages are generated can suffer from biases; that is, the expected percentage assigned to the first feature risks being greater than the following ones. For this reason, a safer method for obtaining more uniform probabilities would be generating them all within a fixed range [0, 1] and then normalizing them. Overcoming these issues lays the foundation for a more probable and efficient algorithm.

4 Genetic algorithm for optimal mixture

Let X indicate the chromosome, P the parent, and C the child. Our Genetic Algorithm for Optimal Multivariate Mixture (GA-OMM) is described as follows. In the initial iteration, a designated quantity of chromosomes \(X_p\) is generated, denoted as \(P_{start}\). From this set of chromosomes, a specific percentage \(p_c\) and a percentage m are selected to apply crossover and mutation operators, aiming to discover novel solutions. The resulting solutions obtained from these two genetic operators, combined with the original parents, are collectively considered and subsequently subjected to a percentage exploration operator for further exploration. Every Percentage Chromosome \(X_p\) is “explored” \(N_{Expl}\) times randomly moving the percentage points within a fixed neighborhood of the starting percentage values, ensuring that the total sum of the new percentage values is one. Finally, the fitness value of each solution within the iteration is computed, and the best P chromosomes are chosen through the implementation of elite selection to be part of the new generation. The workflow of GA-OMM is indicated in Fig. 3 while its working scheme in Fig. 4.

Fig. 3
figure 3

The workflow of the generalized model of GA-OMM. The red boxes represent the starting and the end points of an iteration

Fig. 4
figure 4

The working scheme of the GA-OMM during an iteration involves several steps. First, mutation and crossover operations are applied to the starting population. Then, percentage exploration is performed on all the solutions that have been explored. Finally, the reproduction phase, which includes evaluation and selection, determines the population for the next iteration

4.1 Encoding (Genotype)

In the GA, each combination of items is represented using percentage vector coding. This direct vector coding scheme expresses the proportion or percentage allocation of the n components. Consequently, a mixture is represented by a Percentage Chromosome \((X_p)\) defined as:

$$\begin{aligned} X_{p}=\left\{ x_{p,1},x_{p,2},\dots ,x_{p,i},\dots ,x_{p,n} \right\} , \end{aligned}$$
(7)

where \(x_{p,i}\in [0,1]\) and \(\sum _{i=1}^n x_{p,i} =1\). Each solution \((X_p)\) can serve as either a Parent or a Child during an iteration. Chromosomes assume the role of parents when employed to generate new chromosomes, which in turn are designated as Children. Consequently, chromosomes may take \(P_p=X_p\) as parents or \(C_p=X_p\) when serving as children. Alternatively, they may remain in the form \((X_p)\) when not selected by crossover or mutation operators during the generation process.

During chromosome generation, the \(\texttt{PercentageGeneration}\) function is applied to generate their percentage values. This function assigns percentages to a chromosome \(X_p\) by utilizing random values within the range of \(\texttt{min}\) and \(\texttt{max}\), then normalize all the generated values by using:

$$\begin{aligned} x_{p,i} \leftarrow \frac{x_{p,i}}{\displaystyle \sum _{i} x_{p,i}} \end{aligned}$$
(8)

4.2 Mutation

The \(\texttt{Mutation}\) operator operates in the following manner: given the initial/selected population, a random number within the range [0, 1] is generated for each individual. Then, individuals with a value lower than m are selected for mutation. For each selected individual, a random value between 0 and 1 is created for each gene. A new random percentage value is generated for genes with values less than \(p_m\). Subsequently, the entire \(X_p\) is normalized to ensure that the sum of the new \(x_{p,i}\) values aligns with the required criteria.

4.3 Crossover

Through the \(\texttt{Crossover}\) operator, for each chromosome within the initial/selected population, a random number between the range of [0; 1] is generated. The corresponding chromosome is selected for crossover if this value is less than \(p_c\). Additionally, if the number of solutions is odd, one of them is randomly removed from the batch. Two chromosomes are randomly chosen from the set at a time for the crossover operation, ensuring that each chromosome is chosen only once. Initially, a cut point is defined by randomly generating the index of a gene. Then, an exchange of genes is performed from that gene index onwards. This process ensures that the number of children is the same as the number of parents. Identically to the mutation process, it is necessary to normalize the percentage values obtained as children after the crossover operation.

4.4 Percentage exploration

The \(\texttt{Percentage Exploration}\) operator involves exploring \(N_{Expl}\) times all the chromosomes of an iteration by randomly moving their percentage points within a fixed neighborhood around the starting percentage values. A modified chromosome can be represented using Eq. 9.

$$\begin{aligned} X_{p}=\left\{ x_{p,1}+\Delta x_{p,1},\dots ,x_{p,n}+\Delta x_{p,i},\dots ,x_{p,i}+\Delta x_{p,n} \right\} \end{aligned}$$
(9)

where the value of \(\Delta x_{p,i}\) is determined by the function \(\texttt{rand}(-\alpha ;+\alpha )\) as shown in Eq. 10.

$$\begin{aligned} \Delta x_{p,i} = rand(-\alpha ;+\alpha ) \end{aligned}$$
(10)

NOTE: each time a new percentage change value \(\Delta x_{p,i}\) is generated, the algorithm ensures that the following condition is satisfied:

$$\begin{aligned} \Delta x_{p,i}+x_{p,i}>0, \end{aligned}$$
(11)

After this step, a normalization process is applied to the percentages to ensure that their sum remains equal to 1, as shown in Eq. 12:

$$\begin{aligned} \displaystyle \sum _{i=1}^n x_{p,i}+\Delta x_{p,i} =1 \end{aligned}$$
(12)

The percentage exploration operator in GA-1, as in GA-OMM, helps exploration because it concentrates the exploration of solutions within a limited area of the search space by contributing to the local search part of the algorithm. Differently, mutation and crossover in this context behave as global search operators because they explore the solution space in a broader and more diverse way.

4.5 Evaluation and selection (reproduction)

The reproduction process in our algorithm considers all the solutions of a given iteration. It begins by evaluating each individual’s fitness through an objective function, then through a selection function, indicates the best individuals that will serve as parents \((X_p)\) for the subsequent iteration. During the evaluation step, the fitness function is applied to each individual to determine the percentage values \(\bar{X}_p\) that closely approximate the desired chemical composition \(\bar{X}\). The equation represents this approximation:

$$\begin{aligned} X^T \cdot \bar{X}_p \rightarrow \bar{X} \end{aligned}$$
(13)

To achieve this, a common metric is used to compare all the solutions in the iteration. Our experiment employs an objective function that minimizes the difference between the mixture represented by the chromosome \(X_{mix}\) and the desired final composition \(\bar{X}\). Specifically, the fitness function used in our study is expressed as a form of weighted sum approaches (Konak et al., 2006), i.e.:

$$\begin{aligned} Fitness=\sum _{j=1}^{m}\frac{\mid x_{mix,j}-\bar{x}_j\mid }{r_{j}} \end{aligned}$$
(14)

where \(r_{j}\) represents the range of the j-th component calculated as:

$$\begin{aligned} r_{j} = (\max _{j\in [1;m]} x_{i,j}) - (\min _{j\in [1;m]} x_{i,j}) \end{aligned}$$
(15)

In the second step, the selection process is performed using elite selection. This strategy selects the P best-fit solutions from the current iteration to be part of the next generation. Specifically, it chooses the P chromosomes with the lowest fitness values.

5 Experimental settings

To evaluate the proposed GA-OMM approach, we conducted experiments using a set of items characterized by \(n=8\) items and \(m=5\) features. These features can be interpreted as properties such as proteins, fats, carbohydrates, fibers, and water content, expressed in grams per 100 gs of the product. Alternatively, other variables such as price or quality level can be considered (Table 1). Several reasons justify the selection of these specific numbers in the table. One crucial consideration is ensuring the algorithm’s ability to handle heterogeneous features in terms of their absolute values and ranges, as well as fostering competition among different features. For instance, Feature 1 exhibits very small values and range, while Features 2 and 3 are closely matched in terms of values and ranges, as are Features 4 and 5.

Table 1 Items used for the experiments

To assess the algorithm’s consistency, we performed a set of 10 tests, in which a random desired mix was specified for each test, as indicated in Table 2.

Table 2 The desired mixes randomly generated to compare different combinations of P and \(t_g\) in the second set of experiments

Each test consisted of 30 executions, and the mean and standard deviation of the best objective functions from each test were calculated. Subsequently, the means and standard deviations of the best objective function were averaged across all the tests. These results, i.e., the averaged means and standard deviation of the 10 tests, averaged 30 times per test, were then compared with those obtained from the GA-1 and an LP solver. The purpose of considering the averages of two consecutive means and the average of standard deviations is to assess the algorithm’s stability and its ability to address problems with varying initial data. To conduct the experiments, we utilized MATLAB software and employed the linear programming problem solver \(\texttt{linprog}\), a function that finds the minimum of a linear objective function using a dual-simplex optimization algorithm. Specifically, the experiments were performed on a machine equipped with a 2.8 GHz Intel i7 quad-core with 6MB shared L3 cache and 16GB 2133 MHz LPDDR3 RAM. To test the consistency and reliability of the GA, we conducted a series of experiments comparing GA-OMM results using different hyperparameter values with the results obtained from the other methodologies. Specifically, two types of settings were established:

  • \(p_c\), \(p_m\), and m settings: each experiment was executed with the following hyperparameter values: \(p_c = [0.8, 0.85, 0.9, 0.95]\), \(p_m = [0.1, 0.15, 0.2, 0.25]\), and \(m = [10, 20, 30, 40]\). The values of P and \(t_g\) were constant at 200 and 100, respectively.

  • P and \(t_g\) settings: the experiments were performed with the following hyperparameter values: \(P = [20, 70, 140, 200]\) and \(t_g = [10, 35, 70, 100]\). The values of \(p_c\), \(p_m\), and m were held constant at 0.9, 0.25 and 30, respectively. The initial population size, \(P_{start}\), was always set to P/2. For the experiments where \(P = 20\), the parameter m could not be set to 30; therefore, we decided to use \(m = 10\).

Thus, the hyperparameters tested during the experiments are shown in Algorithm 1.

Algorithm 1
figure a

The GA-OMM tested hyperparameters.

6 Results

The first set of experiments resulted in the findings presented in Table 3. This table displays the difference in fitness between the average GA-OMM fitness and the fitness obtained through LP, as well as the average standard deviations of the GA-OMM fitness values. The same data are also graphically represented from Figs. 5a, 6, 7 and 8b.

Table 3 Fitness difference between the average GA-OMM and LP, along with the average standard deviations of the GA-OMM fitness values. These values are shown for various configurations of the hyperparameters \(p_c\), \(p_m\), and m
Fig. 5
figure 5

a Displays the fitness difference between the average GA-OMM fitness and the fitness obtained through LP. b shows average standard deviations of the GA-OMM fitness values. These values are presented for \(m = 10\) and different hyperparameters \(p_c\) and \(p_m\) configurations

Fig. 6
figure 6

a Displays the fitness difference between the average GA-OMM fitness and the fitness obtained through LP. b shows the average standard deviations of the GA-OMM fitness values. These values are presented for \(m = 20\) and different hyperparameters \(p_c\) and \(p_m\) configurations

Fig. 7
figure 7

a Displays the fitness difference between the average GA-OMM fitness and the fitness obtained through LP. b shows the average standard deviations of the GA-OMM fitness values. These values are presented for \(m = 30\) and different hyperparameters \(p_c\) and \(p_m\) configurations

Fig. 8
figure 8

a Displays the fitness difference between the average GA-OMM fitness and the fitness obtained through LP. b shows the average standard deviations of the GA-OMM fitness values. These values are presented for \(m = 40\) and different hyperparameters \(p_c\) and \(p_m\) configurations

Table 3 demonstrates that the choice of hyperparameters \(p_c\) and \(p_m\) does not affect the results significantly. Furthermore, the parameter m does not impact the outcomes significantly. In most cases, the average difference between the GA fitness results and the LP fitness and standard deviation with a magnitude ranges between \(10^{-6}\) to \(10^{-4}\). However, certain combinations of hyperparameters exhibit superior performance. One such combination is \([p_c, p_m, m] = [0.85, 0.15, 40]\), which achieves a precision in the order of \(10^{-7}\). Additionally, combinations like [0.9, 0.25, (10, 30)] and [0.95, 0.2, 30] achieve a precision in the order of \(10^{-8}\). It is noteworthy that, when analyzing the convergence graphs of setting one, it was observed that GA-1 generally converges faster than GA-OMM (Fig. 9a). However, in all cases, GA-OMM yielded better results than GA-1 and remained very close to the values obtained from LP (Fig. 9b). One possible explanation for why GA-1 converges more rapidly to a solution than GA-OMM lies in the greater emphasis the former places on local search over global search, thereby increasing the likelihood of falling into local optima. GA-1 solely employs the binary mutation operator as its global search operator, whereas GA-OMM utilizes both mutation and crossover, which are further applied to percentages, enabling a more efficient solution space exploration. In this context, \(t_g = 10\) was a suitable metric for measuring the algorithms’ convergence towards the optimum since, in all cases, beyond that threshold, the best optimum found by both algorithms remained stable at the same value. Due to the high frequency of positive results and the best overall performance, we have decided to continue the process of hyperparameter testing by selecting the values [0.9, 0.25, 30].

Fig. 9
figure 9

In a example is shown where GA-1 converges earlier than GA-OMM. In b, an example is presented where GA-OMM demonstrates a superior optimum found compared to GA-1. The average and minimum values of GA-1 for iteration are represented in blue and red, while the average and minimum values of GA-OMM are shown in green and purple, respectively

In the second set of experiments, the main objective was to compare the performances of the two Genetic Algorithms (GAs) by varying the hyperparameters’ P and \(t_g\) values. While m, \(p_c\), and \(p_m\) are parameters linked to the quality of search within the solution space, P and \(t_g\) are parameters associated with the quantity of solutions explored by the algorithm. For this reason, one of the aims of this experiment was to measure the optimal thresholds of solution quantity to explore to converge and fall into the optimum with high probability while simultaneously minimizing the total number of solutions explored. The bar diagrams in Fig. 10a illustrate the disparity in fitness between the average fitness of GA-1 and the average fitness achieved through GA-OMM. Additionally, Fig. 10b demonstrates the variance in average standard deviations of the fitness values between GA-1 and GA-OMM.

Fig. 10
figure 10

In a, the fitness difference is displayed between the average GA-1 fitness and the average fitness obtained through GA-OMM. In b, the difference in the average standard deviations of the GA-1 and GA-OMM fitness values

The bar diagrams demonstrate that GA-OMM consistently outperforms GA-1 in terms of performance, except the hyperparameter combination P and \(t_g\) equal [20, 10]. This specific combination suggests that when the number of solutions to explore is low, GA-1 converges faster toward the optimal solution, even if it means converging throughout a local optimum, as shown in Fig. 9b. When the number of solutions explored is enough to converge, i.e., as the number of solutions explored increases, GA-OMM consistently proves more effective than GA-1. Specifically, the difference in average fitness indicates that the performance gap between the two algorithms widens as \(t_g\) increases. Conversely, increasing the value of P leads to a reduction in these differences. The same pattern is observed for the standard deviations as well. As \(t_g\) increases, the differences tend to increase, while increasing P tends to decrease these differences. When examining the performance of GA-OMM itself, it is noteworthy to analyze the bar diagrams presented in Fig. 11a and b. Both figures illustrate how GA-OMM successfully reaches the global optimum and achieves this with greater precision and consistency as the values of P and \(t_g\) increase, with a slightly more pronounced influence observed with an increase in \(t_g\). Corresponding graphs for GA-1 can be found in Fig. 12a and b.

Fig. 11
figure 11

a Displays the fitness difference between the average GA-OMM fitness and the fitness obtained through LP. b shows the average standard deviations of the GA-OMM fitness values

Fig. 12
figure 12

a Displays the fitness difference between the average GA-1 fitness and the fitness obtained through LP. b shows the average standard deviations of the GA-1 fitness values

7 Conclusions

This research addresses the mathematical problem of the optimal selection of multivariate items for optimal multivariate mixtures. In this work, we propose a novel GA-based model called GA-OMM to solve this problem and evaluate its performance through experiments. Specifically, after providing a generalized algorithm description, we employ an 8-item, 5-feature model to assess algorithm consistency and performance. Two sets of experiments are conducted, involving the execution of 10 desired mix tests for 30 iterations, with different hyperparameter settings for each experiment. The results are compared with those of a previous version of the GA, referred to as GA-1, and a Linear Programming solver, and they demonstrate that GA-OMM outperforms GA-1, which is a significant improvement. Moreover, as the number of solutions explored increases, GA-OMM exhibits a convergence towards the global optimum, akin to the behavior of the LP solver. It’s evident that adding items enhances the likelihood of uncovering multiple optimal solutions, a goal that the algorithm should ideally strive to achieve comprehensively. However, augmenting the feature set inevitably complicates searching for the global optimum. Access to real-world data would significantly aid in validating and refining the model’s performance under practical scenarios. Furthermore, real-world scenarios often entail multiple simultaneous demands to fulfill, thus transforming the problem into a multicriteria challenge. As such, there arises a pressing need to adapt or integrate the algorithm to address these complex problem domains effectively. Future research endeavors will focus on modifying and adapting the model to equip the proposed GA with the capability to handle more intricate problems characterized by larger numbers of items, features, and the nuances inherent in multiple-criteria decision-making (MCDM).