1. Introduction
The textile industry is responsible for around 17–20% of industrial water pollution around the world. This pollution is mostly produced by dyeing processes that consume large amounts of synthetic dyes. A considerable amount of the consumed dyes remain in the wastewater, leading to several environmental and health problems. Removal of these dyes using various technologies is the approach usually considered in the industry to reduce their effect on the environments [
1]. Another approach that has recently attracted a lot of attention is the revival of natural dyes in the textile industry [
2,
3]. Natural dyes are obtained from plant, animal or fungi origins and are mostly non-toxic. They are considered eco-friendly alternatives to synthetic dyes [
4,
5]. Some natural dyes impart functional properties, such as antibacterial and anti-odor properties, to the dyed textiles [
6].
Besides their important advantages, such as their non-toxic nature (in most cases), environmental friendliness, functionality and biodegradability, natural dyes have several drawbacks, such as low affinity toward the textile fibers and medium to low fastness properties. To overcome these problems, several approaches have been investigated. The use of ultrasonic [
7,
8] and microwave [
9,
10,
11] energy; mordanting with metal salts [
12,
13] and biological agents, such as tannin-rich plants, etc. [
14,
15]; plasma treatment [
16,
17]; cationization [
7]; and pretreatment with chitosan [
18] or dendrimer [
19] are among the various methods that have shown potential for the improvement of natural dyeing of textile fibers, especially wool and cotton.
Cotton is the most widely used natural fiber in the textile and fashion industry owing to its unique properties, such as absorbency, comfort and soft handle [
20,
21]. Natural dyeing of cotton is difficult due to the low affinity and weak fastness of the natural dyes in this fiber. Generally, metal salts are applied on cotton to improve the dye-binding and fastness properties. However, some of the commonly used mordants, such as chromium and stannous, are considered toxic and their usage on textiles is restricted. Aluminum salts are considered safe and can be used as mordants in natural dyeing [
22].
Another problem in natural dyeing of textiles is the reproduction of the obtained hues, especially when a mixture of colorants or mordants is applied. To ensure the levelness of the hues and the reproducibility of the results, natural dyes require careful extraction and optimization of the dyeing procedure [
3]. Artificial intelligence (AI) is one of the emerging soft computing techniques used in recent years for reliable dye formulations, color matching and fault detection in the coloration of textiles with synthetic dyes [
23].
Artificial neural networks (ANNs), one of the sub-branches of AI, are one of the best tools for modeling nonlinear engineering systems and, so far, they have been successfully used in many cases in textile engineering, such as for the prediction of the properties of fibrous composites, the handle and comfort of clothing, wastewater treatment, thermal conductivity and the degradation of fibers [
24,
25,
26,
27,
28,
29,
30,
31,
32,
33]. They have also been employed in the prediction of the color coordinates of textiles dyed with natural colorants [
34,
35,
36]. In all the mentioned cases, the goal was to predict one or more responses from the study system and, for this purpose, ANN models were used alongside conventional approaches, such as regression or theoretical models, and the reported results prove that ANNs are always more accurate than other models in predicting system responses. Of course, like other models, ANN models have parameters with variations that can change the output accuracy. The number of hidden layers, the number of neurons in each hidden layer and the weights and biases of the neurons can be considered the most important parameters of neural networks. To obtain the highest accuracy with ANNs, the final numbers of hidden layers and the neurons in them are usually determined using a trial and error method or with optimization algorithms, such as the genetic algorithm (GA) [
37]. On the other hand, the initial weights and biases of ANNs are selected randomly at first and then, during the training stage of the ANN, their final values are determined by a training algorithm, such as error back-propagation (BP), which is one of the most widely used training algorithms [
38]. It is worth mentioning that some researchers have even successfully used optimization algorithms, such as the GA, to determine the initial values of ANN weights and biases in order to further improve ANN performance [
34,
35,
39,
40]. This means that they tried to optimize the starting point of BP to obtain higher accuracy with an ANN, and the reported results from comparing the use of BP with random weights and biases show that they were indeed successful.
Now, the question arises whether optimization algorithms can determine the final values of ANN weights and biases directly in such a way that the ANN prediction accuracy becomes acceptable or even better than that obtained using BP. In other words, is it possible to obtain good accuracy for ANNs without using BP? Recently, Hadavandi et al. [
41] used different optimization algorithms for this purpose in the prediction of the strength of siro-spun yarns with an ANN and reported promising results, such as that gray wolf optimization (GWO) can produce fairly better results than BP. However, to the best of the authors’ knowledge, there is no published work that encompasses the scope of color coordinate prediction for cotton fabrics dyed with natural colorants and one mordant simultaneously by using an ANN model directly weighted with optimization algorithms. Therefore, in this study, we tried to evaluate the ability of different optimization algorithms in directly determining the final values of ANN weights and biases for the prediction of the color coordinates of cotton fabrics dyed with blends of two natural dyes.
2. Material and Method
2.1. Materials
Yazdbaf Co., Yazd, Iran, provided the cotton fabric used in this study. The fabric had a plain weave with a mass per unit area of 110 g/m2. Non-ionic surfactant (Triton X-100), sodium hydroxide and aluminum potassium sulfate were purchased from Sigma-Aldrich, St. Louis, MO, USA. Two natural dyes—namely, madder (Rubia tinctorum) and weld (Reseda luteola)—were purchased from a local market in Ardakan, Iran.
2.2. Methods
Pretreatment: Before mordanting and dyeing, the cotton fabric was scoured in a bath containing 2 g/L Triton X-100 and 1 g/L NaOH. The liquor-to-goods ratio was 40:1, and the fabric was scoured for 30 min at 60 °C. Finally, the fabric was rinsed with distilled water thoroughly, dried at ambient temperature and cut to the required size.
Mordanting: The affinity of natural dyes toward cellulosic fibers is low compared to protein fibers. Mordanting with metal salts or tannin can improve the adsorption of natural dyes by cotton. Among the various metal salts traditionally used as mordants, alum is considered the safest from the ecological and human friendliness point of view [
42]. In the mordanting process, cotton samples were added to baths containing 2, 5 or 10%owf of alum (according to the experimental design) at 40 °C (L:G = 40:1). The temperature was increased to boiling point at a rate of 2 °C/min and kept constant at a boil for 1 h. Finally, the bath was cooled and the samples were rinsed and air-dried.
Dyeing: Among the diverse range of dye-yielding plants traditionally used for natural dyeing in Iran, weld and madder are known as the most important sources for yellow and red colorants, respectively. They are usually used in blends with various concentrations to obtain a wide range of shades on wool and cotton. In this study, the concentration of each dye was varied in the range from 0 to 100%owf and dyeing was performed on non-mordanted and mordanted (2–10%owf) cotton samples. No auxiliary (acid, alkali or salt) was used in the dyeing stage and the dyeing was started at 40 °C. The rate of heating was 2 °C/min until boiling, at which level the samples were kept for 1 h. Finally, the dyed samples were scoured and dried.
Color measurement: A total of 120 samples with varying concentrations of alum, madder and weld were dyed. The colorimetry analyses were performed using a reflectance spectrophotometer (Color Eye 7000A, X-rite, Grand Rapids, MI, USA). The color coordinates (l*, a*, b*) and reflectance of the dyed samples in the range from 400 to 750 nm were measured under illuminant D65 and 10° standard observer. The concentrations of alum, madder and weld were considered as the inputs and the color coordinates of the dyed samples (l*, a*, b*) were considered as the outputs of the ANN.
2.3. ANN
A neural network is basically a data processor, the smallest unit of which is called a neuron. The neurons are located in three layers: input, hidden and output layers. The communication of each neuron with the neurons of the next layer is accomplished through weights and biases.
Figure 1 shows a schematic view of an ANN model with two, three and one neurons in the input, hidden and output layers, respectively. The final answer of the network is calculated according to Equation (2).
where
xi is the
ith input signal;
f(x) is the activation function;
wij is the associated weight between the
ith and
jth neurons in the input and hidden layers, respectively; smf
wjk is the associated weight between the
jth and
kth neurons in the hidden and output layers, respectively. Hyperbolic tangent and linear functions are two of the most widely used activation functions.
2.4. GA
The genetic algorithm (GA) is one of the most well-known optimization algorithms and it is used in many engineering applications. In this method, all the parameters that are used in solving the problem are considered as a string called the chromosome. Then, a set of possible chromosomes is created and the problem is evaluated for each one through the objective function; consequently, each chromosome is scored according to its performance. In the next step, GA operators, such as crossover and mutation, are applied to the chromosomes to reproduce a new population of them, which is scored again. This process continues until the stop condition is reached [
43].
2.5. PSO
In this method, each set of problem-solving parameters is called a particle. A set of particles is first created randomly and each one is assigned a velocity and scored by the objective function. The particles are then assigned new velocities and re-scored after being moved. This process continues until the stop conditions are met [
44].
2.6. GWO
This algorithm has recently been introduced and is inspired by the behavior of gray wolves [
45]. The strongest wolf, who is also the leader of the group, is called the alpha wolf and the next positions belong to the beta, delta and omega wolves, respectively. In GWO, alpha, beta and delta wolves estimate the prey’s position; the omega wolves accordingly update their positions, the prey’s position is re-estimated and the omega wolves’ positions are updated again. This cycle continues until the prey’s change in position stops [
41]. Finally, the position of the alpha wolf is presented as the best obtained solution.
2.7. FMINCON
Unlike the algorithms mentioned above, which are all nature-inspired, the FMINCON algorithm (FMIN), is a gradient-based mathematical method available as a built-in function in Matlab software [
46]. It can be used to minimize a function under certain conditions, such as input values at specified intervals. It starts with an initial guess and, according to the update scheme, it stops at a point where the first-order optimization and other conditions are fulfilled. In this study, the interior-point method was used as an update scheme to approximate the optimization problem based on the Lagrangian method and Karush–Kuhn–Tucker equation [
47].
2.8. Weighting ANN
As mentioned in the introduction, this study tried to determine the final values of ANN weights and biases (Equations (1) and (2)) with the mentioned optimization algorithms without using BP. For this purpose, all ANN weights and biases were considered in one vector and, on the other hand, the objective function was defined in such a way that it took that vector and distributed it to the neurons on different layers of the ANN. Then, the mean squared error (
MSE), as the output of the objective function, was calculated according to Equation (3) for the ANN outputs (ANN prediction) and the corresponding actual values (the lower the
MSE, the better the solution):
where
yi and
ti are the ANN output and corresponding actual value, respectively. It is worth mentioning that, in the objective function, only the ANN structure was used and there was no training step where BP was applied to determine the weights and biases. Therefore, we tried to obtain a vector using the GA, PSO, GWO and FMIN that led to the minimum
MSE. In light of the literature, this study used an ANN structure with just one hidden layer, and one to seven neurons in that layer were considered for investigation. Therefore, using three inputs for the ANN model (mordant, weld and madder) and one neuron for the output (a color coordinate), the vector length would range from 6 to 36 elements, respectively.
Figure 2 presents a schematic view of the weights and biases vector for the ANN with seven neurons in hidden layer.
The activation functions for the hidden and output layers were the hyperbolic tangent and linear functions, respectively. In addition, to investigate the effects of combining optimization algorithms on the weighting of the ANN, PSO and FMIN were used in hybrid mode so that the end point of the PSO was used as the starting point of FMIN (PSO-FMIN). It should be mentioned that a separate ANN model was considered for each color coordinate, and all the required codes in this study were developed using MATLAB R2016a software.
3. Result and Discussion
In the first step in data interpretation, one-way analysis of variance (ANOVA) can be used to investigate the statistical significance of the relationship between independent and dependent parameters. At a 90% confidence interval, if the P-value is higher than 0.1, it means that the independent parameter statistically affects the dependent one. The results of the ANOVA for all color coordinates are presented in
Table 1,
Table 2 and
Table 3. As can be seen, all
p-values were higher than 0.1, so it can be said that the three independent parameters considered were statistically effective in determining the color coordinates and each color coordinate could be modeled based on them.
One of the most common methods for modeling is the linear regression method. An attempt was thus made to model the relationship between dyeing parameters and color coordinates separately using this method. All data were used to determine the regression coefficients presented in Equations (4)–(6), and the
MSEs between the regression outputs and corresponding actual values calculated for the
l*,
a* and
b* coordinates were 22.55, 28.70 and 28.59, respectively. It is quite clear that
MSE values close to zero are ideal; therefore, the accuracy of the regression method was not acceptable. In other words, the regression equation was not even able to accurately predict the data used to derive its own equation and the relationship between the considered parameters was highly nonlinear, so a more efficient model, such as a neural network, is certainly required.
As mentioned above, the purpose of this study was to investigate the efficiency of optimization algorithms compared to BP. Thus, at first, a neural network was trained with BP as a benchmark. When using BP, the data are usually divided into three different groups called the training, validation and test sets. The training and validation sets are used only in the training step of the ANN and the test set is used to assess the ANN performance by means of indexes, such as the MSE (the lower the MSE, the higher the accuracy in prediction). In this study, 70% of the data were randomly selected as the training group, 15% as the validation group and 15% as the test group. In the first step, ANN models were weighted by BP (ANN-BP) and, afterward, the same ANN models were weighted using the GA, PSO, GWO, FMIN and PSO-FMIN and referred to as the ANN-GA, ANN-PSO, ANN-GWO, ANN-FMIN, ANN-PSO-FMIN models, respectively. To make the conditions equal for BP and the other optimization algorithms, the same training group was used for the weighting of all the ANNs.
Due to the random initial selection of weights and biases in all optimization algorithms, for each number of neurons in the hidden layer, the
MSEs obtained for the ANNs weighted with different optimization algorithms were higher than the
MSE of the ANN trained with BP. As a result, the weights and biases obtained for the ANN-BP model were considered as the starting point for the search with the optimization algorithms. Since the operators of optimization algorithms, such as crossover, use random variables, each optimization algorithm was run three times and the best results were considered for these runs. If an optimization algorithm worked successfully, a lower
MSE than the
MSE of the ANN-BP model should have been obtained. For example, in predicting the
l* coordinate, the
MSE of the training group for the ANN-BP model with three neurons in the hidden layer was 12.76, while the
MSE values for the same ANN weighted with the GA, PSO, GWO, FMIN and PSO-FMIN were 10.17, 6.30, 6.41, 5.51 and 4.11, respectively.
Figure 3 demonstrates the reduction in the
MSE value for each of the optimization algorithms in successive iterations (at each iteration, the lowest
MSE obtained (best answer) is plotted).
The final evaluation of the ANN was determined by the accuracy of the test group prediction, and, in this case, the
MSE values of the ANN-BP, ANN-GA, ANN-PSO, ANN-GWO, ANN-FMIN and ANN-PSO-FMIN models for the test group were 3.60, 4.55, 7.02, 7.97, 10.76 and 2.02, respectively. The chart displayed in
Figure 4 indicates the applied approach for weighting the ANN with different algorithms. The same approach was applied for each color coordinate and for different number of neurons.
Table 4,
Table 5 and
Table 6 show the obtained
MSE values of ANN models with different numbers of neurons in the hidden layer weighted with various algorithms.
A closer look at
Table 4,
Table 5 and
Table 6 reveals several points. Firstly, as the number of neurons in the hidden layer increased, the BP error decreased first and then increased. The lower
MSE values with BP were obtained with the presence of three or four neurons in the hidden layer. Secondly, the use of optimization algorithms did not necessarily reduce the
MSE, such as with the ANN with five neurons in the hidden layer when predicting the
l* color coordinate (
Table 4). Thirdly, considering the positive numbers of the
MSE change column, it can be said that the use of optimization algorithms led to more accurate prediction for the training group. However, the presence of negative numbers in the
MSE change column for the test group indicates that, in those cases, the final performance of the optimization algorithms was weaker than BP. This was due to the fact that BP has several mechanisms, such as the maximum number of failures in the validation group, to control the training process and determine weights and biases [
48], while in the optimization algorithms the goal is only to minimize the amount of the objective function. Fourthly, in predicting all color coordinates, although the performances of optimization algorithms and BP were close to each other, ultimately the performance of the hybrid algorithm PSO-FMIN led to a smaller
MSE than other cases. Not only did the prediction accuracy of the test groups increase remarkably (by almost 44%, 23% and 26% for
l*,
a* and
b* coordinates, respectively) compared to the use of BP but the prediction accuracy of the training groups was also higher (by almost 68%, 6.5% and 15% for
l*,
a* and
b* coordinates, respectively). Therefore, the best prediction of
l*,
a* and
b* color coordinates was achieved by the ANN models weighted by PSO-FMIN with three, four and three neurons in the hidden layer, resulting in
MSEs of 2.02, 1.68 and 1.39 for the test group, respectively.
Figure 5 illustrates the outputs of the best values obtained with the ANNs and corresponding actual values for the test groups.
4. Conclusion
Dyeing of cotton with two natural dyes was investigated as an ecofriendly and sustainable approach for coloration of cellulosic fibers. In this study, 120 samples of cotton fabrics were dyed with various combinations of weld and madder natural dyes after mordanting with different concentrations of alum. In the first step, the statistical analysis revealed that there was a significant relationship between the mordant, weld and madder, as the independent parameters, and all color coordinates. In the next step, the color coordinates of the samples were modeled using linear regression, but the results did not present acceptable accuracy. Hence, an ANN, which is a more powerful model, was applied. To prepare the ANN model to predict the color coordinates, BP and other optimization algorithms were used to determine the final weights and biases of the ANN structure. The results indicated that using only optimization algorithms to set the final weights and biases of the ANN model did not present high accuracy, which can be considered a limitation of the presented method. However, when the final weights and biases of BP were used as the starting point of the search in the optimization algorithms, the prediction accuracy of the color coordinates increased significantly compared to using only BP or optimization algorithms. Finally, it was revealed that using PSO-FMIN in weighting the ANN model with three, four and three neurons in hidden layer led to the highest accuracy in the prediction of l*, a* and b* color coordinates, respectively. In comparison with BP, using PSO-FMIN increased the accuracy of prediction for test groups by at least 20% and by at least 6.5% for training groups, which indicates the flexibility of the ANN model, as well as the combination power of optimization algorithms.
In the future, we intend to collect the color coordinate data of other fabrics, such as polyester, viscose, etc., and, based on the results obtained in this study (weighing the ANN using PSO-FMIN), a comprehensive model to predict the color coordinates before the dyeing process will be presented. Furthermore, we intend to use other artificial intelligence methods, such as fuzzy logic and support vector machines, to predict the color coordinates and compare the outcome with the current results.