# An ANN-GA Framework for Optimal Engine Modeling

Authors: Khaldoun K. Tahboub; Mahmoud Barghash; Mazen Arafeh; Osama Ghazal
Journal: Mathematical Problems in Engineering
 (2016)

---

## Abstract

Internal combustion engines are a main power source for vehicles. Improving the engine power is important which involved optimizing combustion timing and quantity of fuel. Variable valve timing (VVT) can be used in this respect to increase peak torque and power. In this work Artificial Neural Network (ANN) is used to model the effect of the VVT on the power and genetic algorithm (GA) as an optimization technique to find the optimal power setting. The same proposed technique can be used to improve fuel economy or a balanced combination of both fuel and power. Based on the findings of this work, it was noticed that the VVT setting is more important at high speed. It was also noticed that optimal power can be obtained by changing the VVT settings as a function of speed. Also to reduce computational time in obtaining the optimal VVT setting, an ANN was successfully used to model the optimal setting as a function of speed.


---

## Body

## 1. Introduction

Internal combustion engines have been a major power source throughout the history of ground vehicles. The two dominating combustion concepts, the Otto engine and the Diesel engine, were developed in the late 1800s. The introduction of electronic ignition and fuel injection systems in the 1980s have given the engineers far more capability of engine control than before. Since then, both fuel economy and emissions have improved, but still more progress can be expected in the future. One of the limitations in engine control development lies in the scarce online information about the controlled process, the combustion [1].Variable valve timing (VVT) is used in spark ignition automotive engines to improve fuel economy, reduceNOx gases, and increase peak torque and power [2]. Valve control is one of the most important parameters for optimizing efficiency and emissions, permitting combustion engines to conform to future emission targets and standards. Thermodynamic conditions during the closed cycle (compression, combustion, and expansion) can be directly controlled by adjusting the intake valve opening (IVO) and intake valve closing (IVC) angle, which defines the total intake mass flow rate and the effective compression ratio of the engine [3]. Control of the intake valve provides optimal filling of the cylinder at all engine speeds. This natural supercharging, and the improved engine torque and power that accompany it, makes it possible to downsize engine capacity and thus reduce fuel consumption at all operating conditions [4]. Variable valve timing (VVT) relates to both the opening time and the duration of the valve’s open interval. Controlling valve timing can improve the torque curve, the brake power curve, or the indicator-power curve of a given engine. Variable valve timing can also be used to reduce the fuel consumption and, to a small extent, the engine emissions [5]. The adoption of a continuous variable valve timing (VVT) system is able to optimize engine torque and efficiency [6].Genetic algorithm (GA) as an optimization technique is widely used for optimization of engineering problems. Many engineering design problems are very complex and therefore difficult to solve with conventional optimization techniques [7]. There are some studies in the literature about using GA for optimization of engine characteristics [8–11]. There is no guarantee that a GA will give an optimal solution or arrangement; there is only a guarantee that the solution will be near optimal in the light of the specific fitness function used in the evaluation of the many possible solutions generated. By near optimal, it is implied that a more optimal solution may exist; however, the stochastic approach is by nature nondeterministic and therefore global optima cannot be guaranteed, and some hybrid techniques exist to combine “hill-climbing” deterministic approaches to stochastic GA approaches to determine the best solution to the accuracy required after the GA method has determined the best region of space to investigate. However, this refinement is not necessary in this study [12].Artificial Neural Network (ANN) models may be used as an alternative way in engineering analysis and predictions. They are recently used also in engine optimization regarding engine operating parameters and emissions [13–16]. ANN models mimic somewhat the learning process of a human brain. They operate like a “black box” model, requiring no detailed information about the system. Instead, they learn the relationship between the input parameters and the controlled and uncontrolled variables by studying previously recorded data, similar to the way a nonlinear regression might perform. Another advantage of using ANNs is their ability to handle large and complex systems with many interrelated parameters. They seem simply to ignore excess data that are of minimal significance and concentrate instead on the more important inputs [12, 17]. Also the neural networks can be used in the form of an ensemble which highly adds to the accuracy of these ANNs [18].Several methodologies for analysis and optimization of diesel engines including DoE [19], Support Vector Machine (SVM) [20], fuzzy modeling [21], particle swarm optimization [22], and specialized modeling software such as MATLAB [23] have been reported or can be used. In this work, different techniques are applied in the form of a multistage methodology. ANNs are used for engine modeling as a tool for optimization using GA. This GA is run for the purpose of determining the optimal power conditions at each speed. The ANN is used in reverse to dictate the optimal conditions according to speed.


## 2. Mathematical Background

### 2.1. Artificial Neural Networks

An Artificial Neural Network is based on the biological neural networks (nervous system) and is composed of “neurons” or “neurodes,” which are artificial nodes, processing elements, or “units.” A neural network is a mathematical model that is based on interconnection of the neurons and the strength of the connections (weights and biases) to model the majority of not all possible known functions. Neural networks in that respect are a generalized function that can be used to model complex relationships between inputs and outputs or to classify patterns in data.A schematic diagram of a typical multilayer feed-forward neural network architecture is shown in Figure1(a). The network usually consists of an input layer, some hidden layers, and an output layer. In its simple form, each single neuron is connected to other neurons of a previous layer through adaptable synaptic weights. Knowledge is usually stored as a set of connection weights (presumably corresponding to synapse efficacy in biological neural systems). Figure 1(b) shows how information is processed through a single node. The node receives weighted activation of other nodes through its incoming connections. First, these are added up (summation). The result is then passed through an activation function; the outcome is the activation of the node. For each of the outgoing connections, this activation value is multiplied with the specific weight and transferred to the next node [24].Figure 1
(a) The basic schematic of an Artificial Neural Network. (b) The basic information processing in a neural network unit [24].
(a)
(b)Training of the neural network is done using back propagation where the error value and the local gradient of the error are used to estimate the new value of the weights and biases(1)ΔWji=ηδjnyin,where Wji is synaptic weight connecting the nodes, η is learning rate, δj(n) is the local gradient for the error in output neuron j at iteration n, yi(n) is the output of the network at neuron i at iteration n, and n is iteration number.Several types of neuron activation functions from logsig, tansig, and sigmoid functions were used as activation functions for the neural network.


### 2.2. Genetic Algorithm

Genetic algorithm (GA) is one type of evolutionary algorithms (EA) that mimics natural evolution as search heuristic to evaluate the global optimal in functions. This is opposed by the traditional optimization which may suffer from long time or local optimum. GA uses biological methods such as inheritance, mutation, selection, and crossover to generate solutions to optimization problems.In a genetic algorithm, a population of candidate solutions (called individuals, creatures, or phenotypes) to an optimization problem is evolved toward better solutions. Each candidate solution has a set of properties (chromosomes or genotype) which can be mutated and altered; traditionally, solutions are represented in binary as strings of 0 s and 1 s, but other encodings are also possible.The evolution usually starts from a population of randomly generated individuals and happens in generations. In each generation, the fitness of every individual in the population is evaluated, the more fit individuals are stochastically selected from the current population, and each individual’s genome is modified (recombined and possibly randomly mutated) to form a new population. The new population is then used in the next iteration of the algorithm. Commonly, the algorithm terminates when either a maximum number of generations have been produced or a satisfactory fitness level has been reached for the population.The basic GA is shown in Algorithm1 and in Figure 2.Algorithm 1
Genetic algorithm.
Begin
t=0
Initialize PopulationP(t) (random initialization)
Evaluate fitness
While (Generations < Total number)
t=t+1
Select Population for crossover
Apply crossover
Apply mutation
End
EndFigure 2
Graphical schematic of the genetic algorithm.


## 2.1. Artificial Neural Networks

An Artificial Neural Network is based on the biological neural networks (nervous system) and is composed of “neurons” or “neurodes,” which are artificial nodes, processing elements, or “units.” A neural network is a mathematical model that is based on interconnection of the neurons and the strength of the connections (weights and biases) to model the majority of not all possible known functions. Neural networks in that respect are a generalized function that can be used to model complex relationships between inputs and outputs or to classify patterns in data.A schematic diagram of a typical multilayer feed-forward neural network architecture is shown in Figure1(a). The network usually consists of an input layer, some hidden layers, and an output layer. In its simple form, each single neuron is connected to other neurons of a previous layer through adaptable synaptic weights. Knowledge is usually stored as a set of connection weights (presumably corresponding to synapse efficacy in biological neural systems). Figure 1(b) shows how information is processed through a single node. The node receives weighted activation of other nodes through its incoming connections. First, these are added up (summation). The result is then passed through an activation function; the outcome is the activation of the node. For each of the outgoing connections, this activation value is multiplied with the specific weight and transferred to the next node [24].Figure 1
(a) The basic schematic of an Artificial Neural Network. (b) The basic information processing in a neural network unit [24].
(a)
(b)Training of the neural network is done using back propagation where the error value and the local gradient of the error are used to estimate the new value of the weights and biases(1)ΔWji=ηδjnyin,where Wji is synaptic weight connecting the nodes, η is learning rate, δj(n) is the local gradient for the error in output neuron j at iteration n, yi(n) is the output of the network at neuron i at iteration n, and n is iteration number.Several types of neuron activation functions from logsig, tansig, and sigmoid functions were used as activation functions for the neural network.


## 2.2. Genetic Algorithm

Genetic algorithm (GA) is one type of evolutionary algorithms (EA) that mimics natural evolution as search heuristic to evaluate the global optimal in functions. This is opposed by the traditional optimization which may suffer from long time or local optimum. GA uses biological methods such as inheritance, mutation, selection, and crossover to generate solutions to optimization problems.In a genetic algorithm, a population of candidate solutions (called individuals, creatures, or phenotypes) to an optimization problem is evolved toward better solutions. Each candidate solution has a set of properties (chromosomes or genotype) which can be mutated and altered; traditionally, solutions are represented in binary as strings of 0 s and 1 s, but other encodings are also possible.The evolution usually starts from a population of randomly generated individuals and happens in generations. In each generation, the fitness of every individual in the population is evaluated, the more fit individuals are stochastically selected from the current population, and each individual’s genome is modified (recombined and possibly randomly mutated) to form a new population. The new population is then used in the next iteration of the algorithm. Commonly, the algorithm terminates when either a maximum number of generations have been produced or a satisfactory fitness level has been reached for the population.The basic GA is shown in Algorithm1 and in Figure 2.Algorithm 1
Genetic algorithm.
Begin
t=0
Initialize PopulationP(t) (random initialization)
Evaluate fitness
While (Generations < Total number)
t=t+1
Select Population for crossover
Apply crossover
Apply mutation
End
EndFigure 2
Graphical schematic of the genetic algorithm.


## 3. Methodology

In this work we have followed the methodology shown in Figure3. The engine data are obtained using suitable experimentation. The untrained ANN which is properly sized in terms of functions and neurons is trained for the experimentally obtained data. The result of this training process is trained ANN which can be used to predict the power of the considered engine at any given speed and valve timings. This ANN model is then used together with a genetic algorithm to evaluate the optimal engine parameters for a selected speed. Thus, the GA results are the optimal settings for each engine speed. The data (speed versus optimal engine parameters) are then used to train the final ANN model.Figure 3
Proposed optimization methodology for SI engine timing settings.The validation of the results is done using visual inspection, Root Square Mean Error (RSME), that is,(2)RSME=∑i=1nXobs,i-Xmodel,i2n,and the Nash-Sutcliffe model efficiency coefficient (NSE), that is,(3)NSE=1-∑i=1nXobs,i-Xmodel,i2∑i=1nXobs,i-Xobs¯=1-MSEσ2.The NSE can range from -∞ to 1. An efficiency of 1, that is, NSE = 1, corresponds to a perfect match between model and observations. An efficiency of 0 indicates that the model predictions are as accurate as the mean of the observed data. An efficiency less than 0, that is, -∞<E<0, implies that the observed mean is a better predictor than the model. The Nash-Sutcliffe model efficiency coefficient (NSE) is commonly used to assess the predictive power of hydrological discharge models. However, it can also be used to quantitatively describe the accuracy of model outputs in other applications such as the one in this research [25].


## 4. Engine and Experimental Practice

For the purpose of analyzing the engine characteristics the dimensions were considered with a specially designed program used to predict the gas flows, combustion, and overall performance of internal combustion engines. Engine speed was varied between 1000 and 6000 rpm. Ignition was taken 10° bTDC. The specifications for the engine are in Table1.Table 1
Engine specifications.
Bore
83 mm
Stroke
80 mm
Displacement volume
0.4328 liters
Con rod length
129.8 mm
Compression ratio
10.5 : 1
Intake valve diameter
30 mm
Exhaust valve diameter
25 mm
Maximum intake valve lift
9.5 mm
Maximum exhaust valve lift
9.5
Intake valve opening
21°
Intake valve closing
75°
Exhaust valve opening
68°
Exhaust valve closing
32°


## 5. Results and Discussion

The initial step is to train the untrained ANN for the experimentally obtained engine data (see Section5.1). GA is used to select the optimal VVT settings for each speed (Section 5.2). The data (speed versus optimal engine parameters) are then used to train the final ANN model (Section 5.3).


### 5.1. Training Accuracy of the ANN

ANN of four layers and three neurons per layer is trained for the experimental engine data. Figure4 shows the ANN power prediction versus the actual values. ANN results fall well within 5% prediction error. The Root Mean Square Error (RMSE) for the model is 0.414. Thus one can conclude that ANN can predict the power of the engine accurately. The Nash-Sutcliffe coefficient E for the results is 0.995 (close to 1). Thus the ANN prediction is very close to the practical results.Figure 4
ANN prediction of engine power versus actual break power.


### 5.2. Optimal Break Power and Break Power Spread

The genetic algorithm is then used to obtain optimal power VVT setting at each speed. 150 generations are used to achieve the results. Figure5 shows the obtained optimal power versus engine speed. As expected the power increases with speed, but the curve is slightly quadratic. Within the range 2500–6000 rpm we can approximate the curve with a linear line with little information lost in that respect. The break power generally increases as the speed increases. As the speed increases friction power increases and the volume of air swept in the engine is reduced; thus the curves tend to increase but with less slope to reflect these two important perspectives.Figure 5
Optimal power in KW as predicted by NN-GA framework versus speed in RPM.Figure6 shows the optimal and nonoptimal power in one curve versus engine speed. The x-points are the break power at any parameter settings. One important criterion is noticed from the curve which is the importance of the setting is variable with speed. At a speed of 1000 rpm, there is ample time for enough air to flow in and thus the parameter settings are not as important as those for the higher speed where bad setting can lead to unignorable reduction in break power.Figure 6
Power spread drawn for all the experimental VVT settings at different engine speeds in addition to optimal power (highest).


### 5.3. GA Optimization of Break Power at Each Engine Speed

Figure7 shows the VVT optimal setting as a function of speed. The optimal oven valve intake has two main modes; at low speed the optimal setting increases as speed increases; thus we need more open valve intake time to achieve the optimal power. But the value of this parameter is stabilized at its maximum setting. The intake valve closing at low speeds is not of great importance; thus it is a low setting, but as the speed gets higher we need more time for the valve closing to achieve optimal power. The exhaust valve opening is set at a high initial value at low speed while at higher speeds, it will be fluctuating around its average setting, while exhaust valve closing is set at its highest time to achieve optimal power. The RMS error for the predictions is 0.0274 for the intake valve opening, 0.43 for the intake valve closing, 1.82 for the exhaust valve closing, 0.793 for the exhaust valve opening, and 0 for the exhaust valve closing. The latter is the highest prediction error because it can change with a higher range without affecting the optimal power.Figure 7
Optimal engine parameters as predicted by the GA-NN framework versus speed.The Nash-Sutcliffe coefficient is 0.99993 for the intake valve opening, 0.993 for the intake valve closing, 0.701 for the exhaust valve opening, and 1 for the exhaust valve closing.


### 5.4. Optimal ANN Model for VVT

The final stage of this work is to build an ANN model for predicting the optimal VVT settings at each speed. The ANN model is trained for the optimal settings at each speed. The ANN is trained to give the optimal VVT settings given the engine speed as the input. This model can be programmed using a suitable microcontroller or microprocessor and when measuring the engine speed it can estimate or predict the VVT and applies these settings on the engine. The predicted model is shown in Figure8. Figure 9 shows a comparison between the power obtained using the recommended settings and the actual optimal power. It shows that the achieved model predicts the right optimal power successfully. The RMS for the power prediction is 0.058 which shows the excellent prediction of the system proposed. The Nash-Sutcliffe coefficient is 0.99991 for the data.Figure 8
The optimal structure for the NN predicting the optimal engine parameters using speed.Figure 9
Validation of the final ANN; predicted optimal power versus actual optimal power.


## 5.1. Training Accuracy of the ANN

ANN of four layers and three neurons per layer is trained for the experimental engine data. Figure4 shows the ANN power prediction versus the actual values. ANN results fall well within 5% prediction error. The Root Mean Square Error (RMSE) for the model is 0.414. Thus one can conclude that ANN can predict the power of the engine accurately. The Nash-Sutcliffe coefficient E for the results is 0.995 (close to 1). Thus the ANN prediction is very close to the practical results.Figure 4
ANN prediction of engine power versus actual break power.


## 5.2. Optimal Break Power and Break Power Spread

The genetic algorithm is then used to obtain optimal power VVT setting at each speed. 150 generations are used to achieve the results. Figure5 shows the obtained optimal power versus engine speed. As expected the power increases with speed, but the curve is slightly quadratic. Within the range 2500–6000 rpm we can approximate the curve with a linear line with little information lost in that respect. The break power generally increases as the speed increases. As the speed increases friction power increases and the volume of air swept in the engine is reduced; thus the curves tend to increase but with less slope to reflect these two important perspectives.Figure 5
Optimal power in KW as predicted by NN-GA framework versus speed in RPM.Figure6 shows the optimal and nonoptimal power in one curve versus engine speed. The x-points are the break power at any parameter settings. One important criterion is noticed from the curve which is the importance of the setting is variable with speed. At a speed of 1000 rpm, there is ample time for enough air to flow in and thus the parameter settings are not as important as those for the higher speed where bad setting can lead to unignorable reduction in break power.Figure 6
Power spread drawn for all the experimental VVT settings at different engine speeds in addition to optimal power (highest).


## 5.3. GA Optimization of Break Power at Each Engine Speed

Figure7 shows the VVT optimal setting as a function of speed. The optimal oven valve intake has two main modes; at low speed the optimal setting increases as speed increases; thus we need more open valve intake time to achieve the optimal power. But the value of this parameter is stabilized at its maximum setting. The intake valve closing at low speeds is not of great importance; thus it is a low setting, but as the speed gets higher we need more time for the valve closing to achieve optimal power. The exhaust valve opening is set at a high initial value at low speed while at higher speeds, it will be fluctuating around its average setting, while exhaust valve closing is set at its highest time to achieve optimal power. The RMS error for the predictions is 0.0274 for the intake valve opening, 0.43 for the intake valve closing, 1.82 for the exhaust valve closing, 0.793 for the exhaust valve opening, and 0 for the exhaust valve closing. The latter is the highest prediction error because it can change with a higher range without affecting the optimal power.Figure 7
Optimal engine parameters as predicted by the GA-NN framework versus speed.The Nash-Sutcliffe coefficient is 0.99993 for the intake valve opening, 0.993 for the intake valve closing, 0.701 for the exhaust valve opening, and 1 for the exhaust valve closing.


## 5.4. Optimal ANN Model for VVT

The final stage of this work is to build an ANN model for predicting the optimal VVT settings at each speed. The ANN model is trained for the optimal settings at each speed. The ANN is trained to give the optimal VVT settings given the engine speed as the input. This model can be programmed using a suitable microcontroller or microprocessor and when measuring the engine speed it can estimate or predict the VVT and applies these settings on the engine. The predicted model is shown in Figure8. Figure 9 shows a comparison between the power obtained using the recommended settings and the actual optimal power. It shows that the achieved model predicts the right optimal power successfully. The RMS for the power prediction is 0.058 which shows the excellent prediction of the system proposed. The Nash-Sutcliffe coefficient is 0.99991 for the data.Figure 8
The optimal structure for the NN predicting the optimal engine parameters using speed.Figure 9
Validation of the final ANN; predicted optimal power versus actual optimal power.


## 6. Conclusions

This work utilized ANN to model the break power and GA is used to obtain the optimal setting at each speed. Another ANN model is used to predict the optimal VVT settings at each speed. We can conclude the following:(1)
The ANN model can be successfully used to predict engine power using the VVT settings and the speed well within 5% error margin.(2)
Through using GA, optimal valve settings at low speeds (1000) are the intake valve opening low (13), intake valve closing low (42), exhaust valve opening high (52), and exhaust valve closing high (30). At intermediate speeds (3000) optimal valve settings are intake valve opening high (25), intake valve closing low (42), exhaust valve opening low (44), and exhaust valve closing high (30). At high speeds (6000) the optimal valve settings are intake valve opening high (25), intake valve closing high (57), exhaust valve opening low (44), and exhaust valve closing high (30).(3)
The ANN model is used to successfully model the optimal GA prediction for the VVT settings over speeds from 1000 to 6000 rpm to an accuracy less than 2%.(4)
It was noticed that open valve intake is optimal as low at low speed but is optimal at high value when the engine is at high speed.(5)
The intake valve closing is optimal as low at low speeds but we need to increase it gradually as speed is increased.(6)
The exhaust valve opening is optimal as high when the speed is low but it fluctuates around a certain average value at higher speed.(7)
The exhaust valve closing is optimal at high value at all engine speeds.(8)
Finally, RMSE and NSE measures were used to evaluate model accuracy and prediction efficiency. A NSE of higher than 0.99 was achieved in both ANNs which reflects the high prediction accuracy of these models in predicting optimal valve settings for maximum engine power output.



---

*Source: 6180758-2016-03-13.xml*