Next Article in Journal
Possibility of Isolated Mung Bean Protein as a Main Raw Material in the Production of an Extruded High-Moisture Meat Analog
Previous Article in Journal
Fatty Acids Profile and Consumers’ Preferences of Pecorino Cheese Manufactured from Milk of Sheep Supplemented with Flaxseed and Ascophyllum nodosum
Previous Article in Special Issue
Effect of Tea Tree Essential Oil on the Quality, Antioxidant Activity, and Microbiological Safety of Lightly Processed Lily (Lilium brownii var. viridulum) during Storage
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Dynamic Compressive Stress Relaxation Model of Tomato Fruit Based on Long Short-Term Memory Model

by
Mengfei Ru
1,3,
Qingchun Feng
2,3,*,
Na Sun
2,
Yajun Li
2,
Jiahui Sun
2,
Jianxun Li
2 and
Chunjiang Zhao
1,3,*
1
College of Agricultural Engineering, Shanxi Agricultural University, Jinzhong 030801, China
2
Intelligent Equipment Research Center, Beijing Academy of Agriculture and Forestry Sciences, Beijing 100097, China
3
Beijing Key Laboratory of Intelligent Equipment Technology for Agriculture, Beijing 100097, China
*
Authors to whom correspondence should be addressed.
Foods 2024, 13(14), 2166; https://doi.org/10.3390/foods13142166
Submission received: 28 May 2024 / Revised: 30 June 2024 / Accepted: 2 July 2024 / Published: 9 July 2024

Abstract

:
Tomatoes are prone to mechanical damage due to improper gripping forces during automated harvest and postharvest processes. To reduce this damage, a dynamic viscoelastic model based on long short-term memory (LSTM) is proposed to fit the dynamic compression stress relaxation characteristics of the individual fruit. Furthermore, the classical stress relaxation models involved, the triple-element Maxwell and Caputo fractional derivative models, are compared with the LSTM model to validate its performance. Meanwhile, the LSTM and classical stress relaxation models are used to predict the stress relaxation characteristics of tomato fruit with different fruit sizes and compression positions. The results for the whole test dataset show that the LSTM model achieves a RMSE of 2.829 × 10 5 Mpa and a MAPE of 0.228%. It significantly outperforms the Caputo fractional derivative model by demonstrating a substantial enhancement with a 37% decrease in RMSE and a 36% reduction in MAPE. Further analysis of individual tomato fruit reveals the LSTM model’s performance, with the minimum RMSE recorded at the septum position being 3.438 × 10 5 Mpa, 31% higher than the maximum RMSE at the locule position. Similarly, the lowest MAPE at the septum stands at 0.375%, outperforming the highest MAPE at the locule position by a significant margin of 90%. Moreover, the LSTM model consistently reports the smallest discrepancies between the predicted and observed values compared to classical stress relaxation models. This accuracy suggests that the LSTM model could effectively supplant classical stress relaxation models for predicting stress relaxation changes in individual tomato fruit.

1. Introduction

The tomato is one of the most widely cultivated vegetables in the world. Particularly, China emerges as a major producer and consumer of tomatoes. In 2022, tomato yields reached 69.71 million tons, accounting for 34.7% of the total worldwide production [1]. Given that the harvesting, sorting, and packing of tomatoes currently rely heavily on manual labor, and with the increasing cost of labor, there is an urgent need to develop automated machines to replace human efforts. These involved harvest machines, sort machines, pack machines, etc. A common component of these machines is the end effector. For fresh tomato fruit, the mechanical gripping end-effector must ensure reliable holding during the gripping process while also avoiding damage.
The current end-effector for tomato fruit can be divided into three categories as follows: rigid underactuated gripper, soft gripper, and compliance gripper [2]. The rigid underactuated gripper refers to an end-effector whose number of actuators is less than its degrees of freedom, allowing it to passively adapt to the shape of tomatoes [3]. A soft gripper typically operates using a pneumatic drive, which has a long response time and is difficult to control in real time [4]. Compliance gripper can be divided into active and passive compliance. Active compliance achieves grasping action through compliant control methods, while passive compliance adapts to different tomatoes passively through the deformation of materials [5]. Due to the significant differences between tomatoes, passive compliance control faces greater challenges. However, regardless of the gripping method used, all approaches treat tomatoes as rigid bodies and only consider the moment of grasping, thus overlooking the study of viscoelastic properties. While ignoring viscoelasticity, the gripper usually increases the extent of compression to meet the stability of the grasp, which can crush the tomato. On the contrary, it can cause the tomato to slip within the gripper, resulting in abrasions.
The tomato fruit consists of living tissues, such as the locule, pericarp, and septum [6] as the typical parts, with non-uniform viscoelastic properties. Viscoelastic properties, which describe a material’s viscosity and elasticity when subjected to external forces, are particularly important for living tissues. Its typical characteristics are stress relaxation and creep properties. Stress relaxation refers to studying the law of change of stress with time under constant strain conditions [7]. Tomato fruits are subjected to grasping action with typical stress-dynamic relaxation properties [8]. Its magnitude is also related to deformation and contact positions, which also makes the design and control of the end-effector a major challenge.
The traditional viscoelastic mechanical properties of agricultural materials are determined by the standard sampling method. First, experimental data are obtained from standard samples, and then a classical stress relaxation model is fitted to determine the parameters. But its assumption is that agricultural materials are homogeneous and isotropic, such as carrots, cantaloupe, apples, and pears [9,10]. The constitutive law of classical stress relaxation models can be classified into two types as follows: the generalized Maxwell model and the Caputo fractional derivative model [11]. The effectiveness of the generalized Maxwell model in fitting the experimental data, as well as the number of parameters requiring estimation, increases with the number of Maxwell elements [12]. Incorporating more Maxwell elements not only enhances accuracy but also increases model complexity and parameter redundancy, complicating both interpretation and prediction [13,14]. To address the shortcomings, the Caputo fractional derivative model is proposed. The key difference between the two models is that the Caputo model incorporates new viscous elements with fractional derivative characteristics, offering the advantages of high precision and fewer parameters [15].
However, living tissues like tomatoes consist of non-uniform and anisotropic composite materials. This composition makes it difficult to calibrate their relaxation model parameters through standard sampling methods. In recent years, the ability of machine learning models to fit complex relationships has received widespread attention and has been continuously applied to the construction of viscoelastic has received widespread attention and has been continuously applied to the construction of viscoelastic mechanical models for complex materials, which include both biomaterials and non-biomaterials.
The neural network (NN) and generalized KNN, both trained using data generated from stress relaxation tests under different loading conditions, are used to predict the dynamic changes of the force for porcine kidneys [16]. Multilayer perceptron (MLP) is applied to predict the stress relaxation properties of three cultivars of pomegranate at three fruit sizes [17]. Random Forest (RF) is used to predict the displacements of different tissues, such as the liver and breast, under different external forces [18,19]. The radial Basis Function Network (RBFN) is used to predict the relaxation modulus, which is an important parameter in the stress relaxation process [20]. The Recurrent Neural Network (RNN) is used to study the constitutive law of the viscoplastic material [21].
The machine learning model retains the structural anisotropy and non-homogeneous properties of the material and avoids the use of standard sampling methods to calibrate the classical stress relaxation model parameters. The stress relaxation characteristics directly affect the magnitude of gripping force, and its data have typical time series properties. Therefore, we use the LSTM model, which can handle time series data well, for modeling. It can use whole fruit size as the model input parameter, thus making it possible to directly estimate the mechanical properties of various whole fruits.
In view of the need for reliable and safe grasp of tomatoes, this paper proposes a machine learning model based on long short-term memory, where the inputs are time, force, and strain, with the output being stress. It is trained with the dataset from the stress relaxation test to study the dynamic process of stress relaxation characteristics in the whole tomato during grasping. Simultaneously, its accuracy is determined by optimizing the hyperparameters and compared with the classical stress relaxation models (the triple-element Maxwell model and the Caputo fractional derivative model). Different models are also used to predict the stress relaxation characteristics of different single tomatoes, which are compared with each other. The results of this study provide technical support for the development of a tomato fruit end-effector.

2. Materials and Methods

2.1. Sample Preparation

Provence was selected as the fruit sample because it offered high economic benefits and had a lower hardness at the ripening stage, making it more prone to injury. The samples were selected from red, ripening tomatoes, which were suitable for picking, excluded those with apparent defects and malformed. The samples are shown in Figure 1. The picked tomatoes were kept in a constant temperature and humidity chamber at 5 °C and 80% humidity for more than 10 h to prevent them from ripening further, and the samples were taken out 4 h prior to the test to bring them back to room temperature [22].

2.2. Stress Relaxation Data Collection

Stress relaxation tests were accomplished by using a Texture Analyzer (TA.XT.PLUS, SMS, Glasgow, UK) equipped with a column-shaped probe. The contact position between tomatoes and probe was divided into the following two kinds: locule and septum, as shown in Figure 2. Stress relaxation data for the whole tomato was collected by the test along the calyx–stem axis in a vertical direction at 1 mm/s. When the tomato deformation reached 1 mm, the probe was kept for 60 s. The collected data involved the size of the tomato and compress force, and the rest of the parameters are shown in Table 1. The compression stress relaxation tests were repeated 35 times for different contact positions.

2.3. Long Short-Term Memory Model

2.3.1. Framework of LSTM and LSTM Unit

The LSTM model is a typical three-layer structure, including an input layer, a hidden layer, and an output layer. Among them, the hidden layer is connected by single or multiple LSTM units. We use two LSTM units [23] to predict relaxation stress, as shown in Figure 3. The model input is a three-dimensional matrix [ t , f , ε ] , and the output [ σ ] is a one-dimensional vector in this paper. The normalized input is represented by using [ t , f , ε ] ^ . It can be seen that [ t , f , ε ] ^ is transformed into the input layer to form I 0 and then passed into the LSTM unit, with the following equation:
I 0 = w I [ t , f , ε ] ^ + b I
where w I is the weight of the input layer, b I is the input layer bias column vector, I 0 is the output of the input layer, t is the sampling time, f is the contact force, and ε is strain, which is the reciprocal of the tomato sizes. Similarly, the output [ σ ] ^ is obtained by using h 2 , w 4 , and b 4 . Here w 4 is the weight of the output layer, and b 4 is the bias column vector. Then, the output [ σ ] is derived by using anti-normalization.
The LSTM unit is mainly composed of four parts, which are three “gates” and historical information states, as shown in Figure 4. The three gates are the forget gate, the input gate, and the output gate. The primary function of the forget gate is to modulate the magnitude of information to be eliminated within the context of historical state, a process executed via a sigmoid activation function. The design objective of the input gate is to regulate the scale of information to be added to the historical information state through a sigmoid function and candidate information state. Information to be added comes from the candidate information state. The output gate aims to determine the scale of the updated hidden layer of memory, operating based on the sigmoid function. The history information state aims to keep and carry information before the current time step.

2.3.2. Forward Propagation of the LSTM Unit

In Figure 3, the input of the LSTM model enters the first LSTM unit, so this paper takes it as an example for illustration. Its input is composed of two parts, namely, the gate input and the history information state, that is, Equation (2):
i n l s t m ( t ) = [ i n g a t e ( t ) , C 1 ( t 1 ) ]
where i n l s t m ( t ) is the input of the LSTM unit at time t. The gate input i n g a t e ( t ) is composed of two parts, which involve I 0 ( t ) and h 1 ( t 1 ) . h 1 ( t 1 ) is the hidden layer state of the first LSTM unit at time t 1 . Both h 1 ( t 1 ) and C 1 ( t 1 ) are concurrently zero at the initial condition. It means that the unit lacks a hidden state and any previously accumulated information at that moment.
First, i n g a t e ( t ) and C 1 ( t 1 ) need to be submitted to all gates and a historical information state, respectively, and f ( t ) , i ( t ) , o ( t ) , and C _ ( t ) are obtained by using Equations (3)–(6). Then, the historical information state C 1 ( t 1 ) is updated by using Equations (7) and (8). The last, hidden state h 1 ( t 1 ) is refreshed by using Equations (9) and (10). Within the current LSTM framework, the refreshed historical information state C 1 ( t ) is retained for the input of the ensuing time step, as opposed to propagating to the successive unit. The updated historical state information h 1 ( t ) will perpetuate within the current LSTM unit, providing the input for the ensuing time step while simultaneously being relayed to the successive unit.
f ( t ) = S [ w f I I 0 ( t ) + w f h h 1 ( t 1 ) + b f ]
i ( t ) = S [ w i I I 0 ( t ) + w i h h 1 ( t 1 ) + b i ]
o ( t ) = S [ w o I I 0 ( t ) + w o h h 1 ( t 1 ) + b o ]
C _ ( t ) = T [ w c _ I I 0 ( t ) + w c _ h h 1 ( t 1 ) + b c _ ]
C 1 ( t ) = f t C 1 ( t 1 ) + p ( t )
p ( t ) = i ( t ) C _ ( t )
h 1 ( t ) = o t k ( t )
k ( t ) = T [ C ( t ) ]
where f ( t ) , i ( t ) , o ( t ) , and C _ ( t ) are the output of forget gate, input gate, output gate, and candidate information state at time t, respectively; C 1 ( t ) and h 1 ( t ) are the history information state and hidden state of the first LSTM unit at time t, respectively; S and T are different active functions, which are sigmoid and tanh, as shown in Equations (11) and (12), respectively; f t C 1 ( t 1 ) denote the discarded historical information at time t, and p ( t ) is the newly incorporated information at the same temporal juncture; w f I and w f h are the weights of forget gates, which are used to deal with different gate inputs, similarly, the meaning of other weights can be achieved; and b f , b i , b o , and b c _ are the biases of different gates and candidate information states.
y = 1 1 + e x
y = e x e x e x + e x
From Equation (11), the range of the sigmoid function is the interval (0, 1). Furthermore, its gradient increases as an input closes to the coordinate origin, indicating a non-symmetrical graph with respect to the origin. From Equation (12), the range of the tanh function is the interval (−1, 1), and its graph is symmetric with respect to the origin. The tanh function can be regarded as a rescaled version of the sigmoid function, and both functions are nonlinear.

2.3.3. Backpropagation of the LSTM Unit

The LSTM model executes the backpropagation mechanism utilizing the BPTT algorithm [24], which is indexed in a reverse temporal direction. Its main purpose is to optimize the training results by continuously changing the weights and biases to bring the loss function down to the desired value. In this paper, the mean square error (MSE) is defined as the loss function, as shown in Equation (13):
l o s s = 1 n t = 1 n ( [ σ t ] ^ σ t ) 2
where n is the time step.
The backpropagation procedure commences with the calculation of gradients for the loss function relative to the trainable parameters. This is essential, given that the antipodal direction of the gradient delineates the most rapid decrease in the loss function. Then, these gradients are transmitted into the network to update the parameters. However, there are many gradients in the LSTM model, for example, the output gate. Its gradients can be divided into three parts, namely, the hidden layer weight, the input layer weight, and the bias, as shown in Equations (14)–(16).
l w o h = l h 1 ( t ) h 1 ( t ) o ( t ) o ( t ) m o ( t ) m o ( t ) w o h
l w o I = l h 1 ( t ) h 1 ( t ) o ( t ) o ( t ) m o ( t ) m o ( t ) w o I
l b o = l h 1 ( t ) h 1 ( t ) o ( t ) o ( t ) m o ( t ) m o ( t ) b o
where m o ( t ) is the output of the information preliminarily processed through distinct weights and bias within the forget gate, as shown in Equation (17). So the partial derivatives of m o ( t ) with respect to w o h , w o I , and b o can be obtained by using Equations (18)–(20).
m o ( t ) = w o I I 0 ( t ) + w o h h 1 ( t 1 ) + b o
m o ( t ) w o h = [ h 1 ( t 1 ) ] T
m o ( t ) w o I = [ I 0 ( t ) ] T
m o ( t ) b o = 1
Given that o ( t ) is the result of a sigmoid function with m o ( t ) as the independent variable, as shown in Equation (21). The derivative of the sigmoid function is shown in Equation (22). Therefore, its partial derivative with respect to m o ( t ) can be obtained, as shown in Equation (23). Similarly, its partial derivative with respect to h 1 ( t ) can be obtained, as shown in Equation (24).
o ( t ) = S [ m o ( t ) ]
d S ( Z ) d Z = S ( Z ) [ 1 S ( Z ) ]
o ( t ) m o ( t ) = S [ m o ( t ) ] [ 1 S ( m o ( t ) ) ]
h 1 ( t ) o ( t ) = k ( t )
By substituting Equations (18), (23) and (24) into Equation (14), we can derive Equation (25). In a similar manner, Equations (26) and (27) are also formulated.
l w o h = l h 1 ( t ) k ( t ) S [ m o ( t ) ] [ 1 S ( m o ( t ) ) ] [ h 1 ( t 1 ) ] T
l w o I = l h 1 ( t ) k ( t ) S [ m o ( t ) ] [ 1 S ( m o ( t ) ) ] [ I 0 ( t ) ] T
l w o h = l h 1 ( t ) k ( t ) S [ m o ( t ) ] [ 1 S ( m o ( t ) ) ]
The update of weights and biases depends on the gradient, as shown in Equation (28).
w o h n e w = w o h o l d l w o h α
where w o h n e w is the updated weight, w o h o l d is the weight before being updated, and α is the learning rate. Based on the above equation, the learning rate is used to update the network weights. To achieve better and faster model convergence, it is necessary to reduce the learning rate during training. The learning rate drop period is used to show the mean, where the learning rate is decreased after a certain number of epochs. The learning rate drop factor indicates the extent to which the learning rate decreases each time. Epochs are defined as the number of times the entire dataset is processed by the model. The neurons in the hidden layer are used to construct the LSTM layer. The mini-batch size refers to the amount of data fed into the model at each iteration. In machine learning, data need to be divided into multiple batches and sequentially fed into the model for training, which can improve computational efficiency.

2.4. The Classical Stress Relaxation Model

2.4.1. Generalized Maxwell Model

The generalized Maxwell model, which is employed to study the stress relaxation properties of fruit and vegetables, is composed of multiple Maxwell elements arranged in parallel [25]. To balance accuracy and parameter quantity, this paper adopts the triple-element Maxwell model from among the classical stress relaxation models, with its governing equation presented in Equation (29) [26]. The parameters of the triple-element Maxwell model were determined by fitting the experimental data using the least squares method.
σ ( x ) = [ E 1 exp ( x / T 1 ) + E 2 exp ( x / T 2 ) + E 0 ] ε 0
where σ ( x ) is the relaxation stress, Mpa; E 1 , E 2 , and E 0 are the decay elastic modulus and the equilibrium modulus, respectively, Mpa; T 1 and T 2 are the relaxation times, s; and ε 0 is the initial strain.

2.4.2. Caputo Fractional Derivative Model

The Caputo fractional derivative model has a multivariate structure analogous to the generalized Maxwell model, and its single configuration exhibits a level of fitting accuracy commensurate with that of the triple-element Maxwell model [27]. It has only two parameters less than the five parameters of the triple-element Maxwell model, as shown in Equation (30). The parameters of this model are also determined using the least squares method by fitting the experimental data.
σ ( x ) = χ α Γ ( 1 α ) x ( α ) ε 0
where χ α is the relaxation modulus, Mpa; Γ ( ) is the Gamma function; α is the fractional order, which ranges from 0 to 1; and ε 0 is the initial strain.

2.5. Performance Evaluation Criteria

The performances of different models were judged by using different criteria, which were root mean square error (RMSE) and mean absolute percentage error (MAPE). These criteria are shown in Equations (31) and (32).
R M S E = 1 N t = 1 N ( x t y t ) 2
M A P E = 1 N t = 1 N | x t y t x t | × 100
where x t is the observed data; y t is the predicted data; and N is the number of predicted data.
Although there are many criteria for representing error, including RMSE, MSE, etc., the RMSE is chosen as a criterion because its unit is consistent with the stress, making it convenient to know. The MAPE is used to measure the relative magnitude of the error.

2.6. Model Training

The hyperparameters of the LSTM model are the initial learning rate, learning rate drop period, epoch, the mini-batch size, the learning rate drop factor, and the number of hidden layer neurons. The initial learning rate used for upgrading the weight and bias ranged from 0.001 to 0.009. To better converge the model, it is necessary to reduce the learning rate in the training process. This paper adopts the fixed-epoch reduction method for decreasing the learning rate, within the range of [70, 90]. The epoch is assigned values within the range of [400, 900]. The number of neurons in the hidden layer varies from 40 to 60. The mini-batch size is 128. The learning rate drop factor is 0.9. The model runs on a computer with a 3.0 GHz main frequency.

2.7. Data Preprocessing

The data exported from the texture analyzer includes three stages as follows: loading, relaxation, and unloading, and the data format is time and force. However, this paper only studies the stress relaxation stage, so it is necessary to eliminate the data from the loading and unloading stages. In the stress relaxation model, stress is the output; therefore, it is necessary to use Equation (33) to convert force into stress [28].
{ E = 3 F ( 1 μ 2 ) 4 D 1.5 ( 1 R ) 0.5 ε = D 2 R σ = E ε
where E is the modulus of elasticity of the tomato, MPa; D is the deformation of the tomato, mm; F is the applied load, N; R is the radius of the tomato, mm; σ is the relaxation stress of the tomato, MPa; and ε is the strain of the tomato.
The dataset is divided into a training set (80%) and a test set (20%), where the test set contains data from large, medium, and small fruit, with different loading positions. The dataset needs to be normalized and anti-normalized. The purpose of normalization is to eliminate the impact of different units and ranges of features on the training results, which include the training speed, stability, generalization ability, and weight updating of the model. All data are transformed into the range of [0, 1] because they do not have negative values during the stress relaxation process. Taking the compression force as an example, the normalization is carried out using the following equation:
y = ( f f min ) × y max y min f max f min + y min
where f is the original compression force, f min is the minimum value of original compression force in the whole dataset, f max is the maximum value of original compression force in the whole dataset; and y is the value after normalization, where y max and y min are 1 and 0, respectively. Then, they are substituted into the above formula to obtain Equation (35), which is used for the other features to repeat this process to complete the normalization.
y = ( f f min ) f max f min

3. Results and Discussion

3.1. Different Models Performance for the Whole Dataset

3.1.1. LSTM-Based Evaluate Performance

Figure 5 shows the results of different hyperparameters on the train and test sets. Figure 5 illustrates the LSTM model’s robust generalization capability, as evidenced by the minimal disparity between its training and testing outcomes. Specifically, in Figure 5a,b, the model’s MAPE and RMSE demonstrate fluctuating trends with the increment of neurons in the hidden layer. Notably, at 40 neurons, both MAPE and RMSE attain their peak values. In contrast, the testing RMSE forms troughs at 4.941 × 10 5 Mpa and 4.389 × 10 5 Mpa when neuron counts are adjusted to 48 and 56, respectively. However, a neuron count of 56 results in a MAPE of 0.666%, which surpasses the lowest observed MAPE of 0.499%. Consequently, this study identifies 48 as the optimal neuron count for the hidden layer.
In Figure 5c,d, the model’s MAPE and RMSE show a saddle and fluctuating trend as the learning rate drop period extends, respectively. The highest RMSE and MAPE values are observed when the learning rate drop period is set to 84 and 72, respectively. In contrast, a learning rate drop period of 90 results in the lowest RMSE and MAPE, at 2.964 × 10 5 Mpa and 0.231%, respectively. Thus, this study determines that the most effective learning rate drop period for optimizing model performance is 90.
In Figure 5e,f, the model’s RMSE and MAPE show a fluctuating trend with the increment of the initial learning rate. Notably, setting the initial learning rate to 0.004 leads to peak values for MAPE and RMSE. Conversely, for the test set, setting the initial learning rate to 0.008 leads to the lowest observed values of RMSE and MAPE, which are 2.964 × 10 5 Mpa and 0.231%, respectively.
In Figure 5g,h, both RMSE and MAPE generally show a decreasing trend as the increment of epochs increases, with the notable exception occurring at 550 epochs, where this trend does not hold. For the test set, when the epoch is 550, RMSE and MAPE reach peak values of 8.377 × 10 5 Mpa and 1.301%, respectively. Conversely, at the 850 epoch, both RMSE and MAPE reach the minimum values of 2.829 × 10 5 Mpa and 0.228%, respectively. Therefore, the optimal epoch in this study is 850. In summary, the optimal hyperparameter combination for the LSTM model includes a learning rate drop period at 90, an initial learning rate of 0.008, 850 epochs, and 48 neurons.

3.1.2. Parameters of the Classical Stress Relaxation Model

The parameters of the triple-element Maxwell model and Caputo fractional derivative model were obtained by using the nonlinear custom fitting method through a dataset, and the optimal parameters were determined through low RMSE and MAPE. The custom equations were Equations (29) and (30). The specific parameters of the triple-element Maxwell model and the Caputo fractional derivative model are shown in Table 2 and Table 3. Analysis of both tables reveals that the number of parameters in the triple-element Maxwell model, which amounts to five, is 2.5 times that of the Caputo model. This signifies that the former model exhibits greater complexity.

3.1.3. Comparison of Different Models

The performances of different models are shown in Table 4. Compared with other models, both RMSE and MAPE of the LSTM model are the smallest, according to Table 4. Consequently, the LSTM model outperforms all others across the entire dataset, showcasing superior performance. The Maxwell model exhibits a RMSE 1.3 times greater and a MAPE 3.8 times higher than those of the LSTM model, while the Caputo model’s RMSE and MAPE are 1.6 times the LSTM model’s index, respectively. Hence, it can be inferred that the RMSE of the Maxwell model is comparable to that of the Caputo model. However, due to the significant difference in MAPE between them, the Caputo model is considered superior to the Maxwell model. By comparing the approximation complexities of the models, we found that the complexity of the LSTM model is 40 times that of the traditional model. However, the time it takes to predict each time step is less than 1 ms. Therefore, we believe that the real-time performance of this model meets our requirements.

3.2. Prediction of Different Models for the Whole Fruit of Single Tomatoes

3.2.1. LSTM Prediction

Figure 6 presents a comparison of the LSTM model’s predicted values against the actual values in the stress relaxation process of tomatoes, taking into account various compression positions and sizes. A significant deviation is observed between the multiple predicted values by the LSTM model and the actual values at t = 0.005 s, except for the predictions at the middle fruit septum. This discrepancy is not exclusive to the moment at t = 0.005 s but extends throughout the time interval of t < 0.3 s.
The phenomenon can be attributed to the following two primary causes: sampling issues in plotting and inherent flaws in the model itself. Initially, the limited number of samples represented in the graph results in significant discrepancies between predicted and actual values being evident only at 0.005 s. Furthermore, in the time interval of t < 0.3 s, the model suffers from a lack of sufficient historical information to rely on, leading to deviations. As time progresses and the model accumulates more historical information, these deviations gradually diminish.
Upon analyzing all the curves depicted in Figure 6, it is noticeable that the maximum relaxation stress observed in Figure 6b,e appears abnormal. A comparison across Figure 6c–f reveals that the maximum relaxation stress at the locule position is consistently lower than at the septum position. However, Figure 6a shows a higher maximum relaxation stress compared to Figure 6b, and their contact force and strain are similarly matched. An examination of Figure 6a,c,e indicates that the maximum relaxation stress initially decreases and then increases as the size of the fruit reduces. In contrast, Figure 6b,d,f exhibit an opposite trend, with the maximum relaxation stress increasing and then decreasing as the fruit size diminishes.
Considering the contact force, the abnormality observed in Figure 6b may stem from the fact that the actual compression location for the tomato is not at the septum, as presumed, but rather at the locule. This misidentification leads to the recorded stress being lower than the actual stress experienced by the fruit. When the compression is applied at the septum, the discrepancies in the maturity levels of the tomatoes depicted in Figure 6a,b could account for the observed phenomena. Specifically, the tomato in Figure 6b might be at a more advanced stage of maturity than the one in Figure 6a, exhibiting a softening effect. This results in its maximum relaxation stress approaching the levels observed at the locule position. Conversely, the phenomenon observed in Figure 6e can be attributed to the tomato’s lower maturity level compared to those in Figure 6a,b, leading to a higher maximum relaxation stress.
In this study, the ripeness of the samples used in the experiment is determined by the color comparison method. Although this method is simple and non-destructive to the tomatoes, it cannot serve as a quantitative feature input to the LSTM prediction model, thus affecting the prediction results of the LSTM. Therefore, in subsequent experiments, we will seek a method to quantitatively represent ripeness that is non-destructive to tomatoes and use it as an input to the LSTM model. This will help reduce the prediction error caused by the difference between the expected and actual ripeness of the tomatoes, thereby further improving the prediction accuracy of the LSTM network.
Table 5 reveals that when the compression position is the locule, the medium fruit exhibits the highest RMSE of 2.631 × 10 5 Mpa. And the small fruit has the largest MAPE at 0.192%. However, changing compression to septum, the medium fruit demonstrates the smallest RMSE, measured at 3.438 × 10 5 Mpa and exceeding the former by 31%, and the small fruit demonstrates the lowest MAPE, marked at 0.375% and exceeding the former by 95%. Comparing the results from the entire dataset reveals that the RMSE and MAPE for the locule are lower than those for the entire dataset, while the results for the septum are opposite. Further, in conjunction with Figure 6, it becomes clear that the elevated RMSE and MAPE at the septum position are primarily due to the model’s predictions being consistently higher than the actual values. Additionally, the noticeable fluctuation of the predicted values at the septum position for the large fruit around 0.555 s is another factor contributing to the abnormal RMSE and MAPE.

3.2.2. Comparison of the Predicted Values of Different Models

Figure 7 shows the stress relaxation curves for a single tomato fruit, along with the predictive curves from the LSTM and classic stress relaxation models. In the figure, the predictions made by the triple-element Maxwell model exceed the actual values, with the difference reaching its peak at 0.005 s, and these model predictions enter the plateau phase earlier relative to the actual values. The predictions made by the Caputo fractional derivative model are below the actual values, aligning closely only at 0.005 s and following the same downward trend as the actual values. The predictions of the LSTM model deviate the least from the actual values, with most predictions overlapping the actual values, except at 0.005 s, where the difference is greater.
The observed phenomenon in classical stress relaxation models can be attributed to the fact that, once the parameters of the model are set, the predicted stress magnitude becomes solely dependent on time and strain, neglecting the specific mechanical properties of the sample. Furthermore, according to the formula used in classical stress relaxation models, it is clear that the model is incapable of predicting stress relaxation at different compression locations. This oversight results in a significant discrepancy between the model’s predictions and the actual stress relaxation behavior of the samples, rendering it incapable of accurately depicting the stress relaxation characteristics of different tomatoes.
Therefore, it can be concluded that classical models are not suited for simulating the stress relaxation process of whole tomatoes but are more appropriate for the stress relaxation of standard samples. Among the three models, the difference between observed and predicted values is the smallest for the LSTM model. Therefore, the LSTM model is suitable for predicting the stress relaxation of tomatoes under various conditions, including different compression locations and strains. Currently, our research is centered on tomatoes, and we have not yet studied the adaptability of the LSTM model to other fruits and vegetables with unique configurations, such as apples, pears, berries, and peppers.

4. Conclusions

The paper studies the whole fruit of tomatoes, which have non-uniform complex viscoelastic characteristics, and addresses the unclear problem of stress changes when compressed. It proposes a LSTM model to predict the stress relaxation process of whole tomato fruit. Through stress relaxation tests, a dataset of whole fruit compression stress relaxation is established, leading to the following conclusions:
The proposed LSTM model achieved fitting of the stress relaxation characteristics of whole tomato fruits, avoiding the use of standardized sampling methods. Through optimization of the model hyperparameters, the RMSE of the LSTM model reached 2.829 × 10 5 Mpa, and the MAPE reached 0.228%. Since the highest accuracy among comparison models is the Caputo fractional derivative model, the RMSE of the LSTM model improved by 37%, and the MAPE improved by 36% compared to it. The results indicate that the LSTM model achieved better prediction accuracy for tomatoes at the locule position than at the septum. Specifically, the RMSE for the septum position was recorded at 3.438 × 10 5 Mpa, which is 31% higher than the maximum RMSE observed at the locule position. Furthermore, the minimum MAPE at the septum was 0.375%, surpassing the maximum MAPE at the locule position by 90%.

Author Contributions

Conceptualization, writing—original draft, data curation, writing—review and editing, M.R.; conceptualization, writing—original draft, funding acquisition, writing—review and editing, Q.F.; writing—original draft, N.S.; writing—original draft, Y.L.; writing—original draft, J.S.; data curation, visualization, J.L.; conceptualization, writing—original draft, writing—review and editing, C.Z. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the Beijing Nova Program (grant number: 20220484023) and the BAAFS Innovation Capacity Building Project (grant number: KJCX20240502).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Informed consent was obtained from all subjects involved in the study.

Data Availability Statement

The data presented in this study are available on request from the corresponding authors. The data are not publicly available due to privacy or ethical restrictions.

Acknowledgments

Besides financial support, we, the authors, would like to acknowledge the support of all involved persons and employees involved in the research tasks, without whom this project would not have been possible.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Li, W.; Ren, L.; Zhang, X.; Fang, W.; Yan, D.; Li, Y.; Wang, Q.; Cao, A. Evaluation of ethylicin as a potential soil fumigant in commercial tomato production in China. Sci. Total Environ. 2023, 854, 158520. [Google Scholar] [CrossRef] [PubMed]
  2. Chen, W.; Feng, Z.; Lu, Q.; Hung, M.; Zhang, P.; Zhang, Q. Design, analysis and experimental test of a multi-mode rigid-flexible underactuated grasping mechanism. Robot 2022, 44, 139–152. [Google Scholar] [CrossRef]
  3. Ling, P.P.; Ehsani, R.; Ting, K.C.; Chi, Y.T.; Ramalingam, N.; Klingman, H.M.; Draper, C. Sensing and End-Effector for a Robotic Tomato Harvester. In Proceedings of the 2004 American Society of Agricultural and Biological Engineers annual meeting, Ottawa, ON, Canada, 1–4 August 2004; p. 043088. [Google Scholar] [CrossRef]
  4. Yaguchi, H.; Nagahama, K.; Hasegawa, T.; Inaba, M. Development of an autonomous tomato harvesting robot with rotational plucking gripper. In Proceedings of the 2016 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), Daejeon, Republic of Korea, 9–14 October 2016; pp. 652–657. [Google Scholar] [CrossRef]
  5. Zhao, Y.; Gong, L.; Liu, C.; Huang, Y. Dual-arm Robot Design and Testing for Harvesting Tomato in Greenhouse. IFAC-Pap. OnLine 2016, 49, 161–165. [Google Scholar] [CrossRef]
  6. Li, Z.; Wang, Y. A multiscale finite element model for mechanical response of tomato fruits. Postharvest Biol. Technol. 2016, 121, 19–26. [Google Scholar] [CrossRef]
  7. Krokida, M.K.; Maroulis, Z.B.; Saravacos, G.D. Rheological properties of fluid fruit and vegetable puree products: Compilation of literature data. Int. J. Food Prop. 2001, 4, 179–200. [Google Scholar] [CrossRef]
  8. Liu, Z.; Li, Z.; Yue, T.; Elien, D.; Yang, Y. Differences in the cell morphology and microfracture behaviour of tomato fruit tissues during ripening. Postharvest Biol. Technol. 2020, 164, 111182. [Google Scholar] [CrossRef]
  9. Xia, X.; Xu, Z.; Yu, C.; Zhou, Q.; Chen, J. Finite Element Analysis and Experiment of the Bruise Behavior of Carrot under Impact Loading. Agriculture 2021, 11, 471. [Google Scholar] [CrossRef]
  10. Xu, Z.; Chen, W. A fractional-order model on new experiments of linear viscoelastic creep of Hami Melon. Comput. Math. Appl. 2013, 66, 677–681. [Google Scholar] [CrossRef]
  11. Shaw, M.T.; MacKnight, W.J. Introduction to Polymer Viscoelasticity; John Wiley & Sons: Hoboken, NJ, USA, 2018; pp. 51–52. [Google Scholar]
  12. Zhao, W.; Fang, Y.; Zhang, Q.-A.; Guo, Y.; Gao, G.; Yi, X. Correlation analysis between chemical or texture attributes and stress relaxation properties of ‘Fuji’ apple. Postharvest Biol. Technol. 2017, 129, 45–51. [Google Scholar] [CrossRef]
  13. Zhang, J.; Wang, J.; Gu, S.; Zheng, C.; Du, D. Relaxation characteristics for quality evaluation of Chinese cabbage. J. Food Eng. 2021, 306, 110635. [Google Scholar] [CrossRef]
  14. Di Paola, M.; Pirrotta, A.; Valenza, A. Visco-elastic behavior through fractional calculus: An easier method for best fitting experimental results. Mech. Mater. 2011, 43, 799–806. [Google Scholar] [CrossRef]
  15. Shen, L.J. Fractional derivative models for viscoelastic materials at finite deformations. Int. J. Solids Struct. 2020, 190, 226–237. [Google Scholar] [CrossRef]
  16. Hu, L.; Zhou, W. Biomechanical modelling of tissues at relaxation stage based on neural network. J. Med. Biomech. 2021, 36, 238–244. [Google Scholar] [CrossRef]
  17. Saeidirad, M.H.; Rohani, A.; Zarifneshat, S. Predictions of viscoelastic behavior of pomegranate using artificial neural network and Maxwell model. Comput. Electron. Agric. 2013, 98, 1–7. [Google Scholar] [CrossRef]
  18. Martínez-Martínez, F.; Rupérez-Moreno, M.J.; Martínez-Sober, M.; Solves-Llorens, J.A.; Lorente, D.; Serrano-López, A.J.; Martínez-Sanchis, S.; Monserrat, C.; Martín-Guerrero, J.D. A finite element-based machine learning approach for modeling the mechanical behavior of the breast tissues under compression in real-time. Comput. Biol. Med. 2017, 90, 116–124. [Google Scholar] [CrossRef]
  19. Pellicer-Valero, O.J.; Rupérez, M.J.; Martínez-Sanchis, S.; Martín-Guerrero, J.D. Real-time biomechanical modeling of the liver using Machine Learning models trained on Finite Element Method simulations. Expert Syst. Appl. 2020, 143, 113083. [Google Scholar] [CrossRef]
  20. Aulova, A.; Govekar, E.; Emri, I. Determination of relaxation modulus of time-dependent materials using neural networks. Mech. Time-Depend. Mater. 2017, 21, 331–349. [Google Scholar] [CrossRef]
  21. Han, M.; Li, H.; Yang, X.; Liu, Z.; Li, X. Study on Constitutive Relation of Nickel-Base Superalloy Inconel 718 Based on Long Short-Term Memory Recurrent Neural Network. Metals 2020, 10, 1588. [Google Scholar] [CrossRef]
  22. Liu, J.; Peng, Y.; Faheem, M. Experimental and theoretical analysis of fruit plucking patterns for robotic tomato harvesting. Comput. Electron. Agric. 2020, 173, 105330. [Google Scholar] [CrossRef]
  23. Chen, G. Recurrent neural networks (RNNs) learn the constitutive law of viscoelasticity. Comput. Mech. 2021, 67, 1009–1019. [Google Scholar] [CrossRef]
  24. Sherstinsky, A. Fundamentals of Recurrent Neural Network (RNN) and Long Short-Term Memory (LSTM) network. Phys. D Nonlinear Phenom. 2020, 404, 132306. [Google Scholar] [CrossRef]
  25. Zhang, W.; Capilnasiu, A.; Sommer, G.; Holzapfel, G.A.; Nordsletten, D.A. An efficient and accurate method for modeling nonlinear fractional viscoelastic biomaterials. Comput. Methods Appl. Mech. Eng. 2020, 362, 112834. [Google Scholar] [CrossRef]
  26. Zhang, J.; Wang, J.; Hao, Y.; Zheng, C.; Du, D. Effects on relaxation properties of Chinese cabbage (Brassica campestris L.) subjected to different compression directions. Biosyst. Eng. 2021, 207, 81–91. [Google Scholar] [CrossRef]
  27. Mahiuddin, M.; Godhani, D.; Feng, L.; Liu, F.; Langrish, T.; Karim, M.A. Application of Caputo fractional rheological model to determine the viscoelastic and mechanical properties of fruit and vegetables. Postharvest Biol. Technol. 2020, 163, 111147. [Google Scholar] [CrossRef]
  28. Zhou, Z.E. Agricultural Material Science; Agriculture Press: Beijing, China, 1994; pp. 47–49. [Google Scholar]
Figure 1. Samples used for relaxation experiments.
Figure 1. Samples used for relaxation experiments.
Foods 13 02166 g001
Figure 2. Stress relaxation test. (a) is the process of stress relaxation test. (b) is its original curve.
Figure 2. Stress relaxation test. (a) is the process of stress relaxation test. (b) is its original curve.
Foods 13 02166 g002
Figure 3. Framework of the LSTM model.
Figure 3. Framework of the LSTM model.
Foods 13 02166 g003
Figure 4. Framework of the LSTM unit.
Figure 4. Framework of the LSTM unit.
Foods 13 02166 g004
Figure 5. Effect of different hyperparameters on the LSTM network. (a,b) refer to the hidden size; (c,d) refer to the learning rate drop period; (e,f) refer to the initial learning rate; (g,h) refer to the epoch.
Figure 5. Effect of different hyperparameters on the LSTM network. (a,b) refer to the hidden size; (c,d) refer to the learning rate drop period; (e,f) refer to the initial learning rate; (g,h) refer to the epoch.
Foods 13 02166 g005aFoods 13 02166 g005b
Figure 6. Comparison of predicted and true values for different tomato sizes and compression positions. The compression position of (a,c) and e is the locule, and the compression position of (b,d,f) is the septum. (a,b) are the curves of large tomatoes; (c,d) are the curves of medium tomatoes; and (e,f) are the curves of small tomatoes.
Figure 6. Comparison of predicted and true values for different tomato sizes and compression positions. The compression position of (a,c) and e is the locule, and the compression position of (b,d,f) is the septum. (a,b) are the curves of large tomatoes; (c,d) are the curves of medium tomatoes; and (e,f) are the curves of small tomatoes.
Foods 13 02166 g006
Figure 7. The comparison of predicted values from different models with the actual values.
Figure 7. The comparison of predicted values from different models with the actual values.
Foods 13 02166 g007
Table 1. The parameters of the texture analyzer.
Table 1. The parameters of the texture analyzer.
ParameterValue
Probe diameter50 mm
Speed of loading1 mm/s
Speed of loading20 Hz
Initial force of contact0.49 N
Note: Probe diameter should be noted so that the probe edge is not contacting the tomato during the test phase to prevent the probe edge from shearing the tomato.
Table 2. Parameters calculated by the triple-element Maxwell model (mean ± standard deviation).
Table 2. Parameters calculated by the triple-element Maxwell model (mean ± standard deviation).
MaterialsE0 (Mpa)E1 (Mpa)E2 (Mpa)T1 (s)T2 (s)
Tomato0.222 ± 0.01680.0681 ± 0.007990.0816 ± 0.01440.355 ± 0.05178.672 ± 0.353
Table 3. Parameters calculated by the Caputo fractional derivative model (mean ± standard deviation).
Table 3. Parameters calculated by the Caputo fractional derivative model (mean ± standard deviation).
MaterialsRelaxation Modulus (Mpa)α
Tomato0.388 ± 0.0250.072 ± 0.0012
Table 4. Performances of machine learning models.
Table 4. Performances of machine learning models.
ModelRMSE, (Mpa)MAPE, (%)
LSTM 2.829 × 10 5 0.228
Maxwell 3.758 × 10 5 0.867
Caputo 4.483 × 10 5 0.355
Table 5. Prediction results of the LSTM model for different tomatoes.
Table 5. Prediction results of the LSTM model for different tomatoes.
Data SetPerformance Criterion
SizePositionRMSE, (Mpa)MAPE, (%)
LargeLocule 1.142 × 10 5 0.161
Septum 7.128 × 10 5 0.621
MediumLocule 2.631 × 10 5 0.150
Septum 3.438 × 10 5 0.393
SmallLocule 2.039 × 10 5 0.192
Septum 4.513 × 10 5 0.375
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Ru, M.; Feng, Q.; Sun, N.; Li, Y.; Sun, J.; Li, J.; Zhao, C. Dynamic Compressive Stress Relaxation Model of Tomato Fruit Based on Long Short-Term Memory Model. Foods 2024, 13, 2166. https://doi.org/10.3390/foods13142166

AMA Style

Ru M, Feng Q, Sun N, Li Y, Sun J, Li J, Zhao C. Dynamic Compressive Stress Relaxation Model of Tomato Fruit Based on Long Short-Term Memory Model. Foods. 2024; 13(14):2166. https://doi.org/10.3390/foods13142166

Chicago/Turabian Style

Ru, Mengfei, Qingchun Feng, Na Sun, Yajun Li, Jiahui Sun, Jianxun Li, and Chunjiang Zhao. 2024. "Dynamic Compressive Stress Relaxation Model of Tomato Fruit Based on Long Short-Term Memory Model" Foods 13, no. 14: 2166. https://doi.org/10.3390/foods13142166

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop