# Data and Knowledge-Driven Bridge Digital Twin Modeling for Smart Operation and Maintenance
## 4 Spatiotemporal Data Collection and Processing for Bridge Digital Twin
### Time Series Sensory Data Collection and Processing
#### 4.3.3 Sensor Data Processing Using Long Short-Term Memory  
LSTM networks are uniquely equipped to handle sequential data, making them ideal for analyzing time series data, where both short-term variations and long-term patterns are critical for making accurate predictions and issuing early warnings of structural issues [49]. LSTM models are an advanced variant of recurrent neural networks (RNNs), designed to address the challenge of retaining relevant information over long sequences of data [50]. Unlike standard RNNs, LSTM networks incorporate memory units that help them retain relevant information over extended time periods, enabling them to better capture patterns in time series data. The memory is regulated by several gating mechanisms, which allow the model to control the flow of information: deciding what to remember, what to forget, and what to output at each time step. At each time step \(t\), the LSTM updates its internal states--the hidden state \(h_{t}\) and the cell state \(C_{t}\)--based on the previous state and the current input \(x_{t}\). The process is governed by the following equations. The forget gate determines which parts of the previous cell state should be forgotten. It uses the hidden state from the previous time step \(h_{t-1}\) and the current input \(x_{t}\) as in Formula (16):  
\[f_{t}=\sigma\Big{(}W_{f}\cdot[h_{t-1},x_{t}]+b_{f}\Big{)}. \tag{16}\]  
The input gate decides which new information should be added to the cell state. This step also considers the previous hidden state and current input as in Formula (17):  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}). \tag{17}\]  
The cell state update computes the new candidate values \(\widetilde{C}_{t}\) for the cell state, which will be added to the existing cell state as in Formula (18):  
\[\widetilde{C}_{t}=\tan h(W_{C}\cdot[h_{t-1},x_{t}]+b_{C}). \tag{18}\]  
To update the cell state, the cell state \(C_{t}\) is updated by a combination of the old cell state (controlled by the forget gate) and the new candidate values (controlled by the input gate) as in Formula (19):  
\[C_{t}=f_{t}\times C_{t-1}+i_{t}\times\widetilde{C}_{t}. \tag{19}\]The output gate determines what the next hidden state \(h_{t}\) should be, based on the updated cell state and current input, as in Formulas (20) and (21):  
\[o_{t}=\sigma(W_{o}\cdot[h_{t-1},x_{t}]+b_{o}) \tag{20}\]  
\[h_{t}=o_{t}\times\tan h(C_{t}) \tag{21}\]  
where \(f_{t}\) is the forget gate, responsible for discarding irrelevant information from the previous cell state; \(i_{t}\) is the input gate, which selects new information to add to the cell state; \(\widetilde{C}_{t}\) is the candidate cell state, representing new data that could potentially update the memory; \(o_{t}\) is the output gate, determining the information to pass on to the next time step; \(\sigma\) represents the sigmoid activation function; and \(\tan h\) is the hyperbolic tangent function used to normalize the updates. Each gate plays a crucial role in regulating the flow of information, ensuring that the LSTM can retain significant historical data while forgetting less relevant details. This balance between memory retention and forgetting makes LSTM particularly effective for time series data, where patterns evolve over time but may also require attention to short-term fluctuations. For example, by analyzing previous readings of strain or displacement, an LSTM model can forecast future sensor values. Such predictions provide crucial insights into how the structure might respond to environmental changes or increased loads, allowing engineers to anticipate potential issues such as material fatigue, deformation, or abnormal stress accumulation. One of the key advantages of employing LSTM models in the BDT model lies in their capacity to generate early warnings by analyzing temporal patterns in sensor data. By continuously evaluating the outputs from multiple sensors and comparing them with predicted values, the model can identify deviations that may indicate structural deterioration.