# Real-Time Sea State Estimation for Wave Energy Converter Control via Machine Learning
## 4 Control Design
### Neural Network Modeling  
In this study, we used a deep learning model named Long Short-Term Memory (LSTM) network, which is a class of recurrent neural networks (RNNs). This model can handle sequential data by addressing the vanishing gradient problem encountered in traditional RNNs. Unlike conventional feedforward neural networks, LSTMs maintain an internal memory state, allowing them to capture long-range dependencies in time-series data. This makes them particularly well suited for problems involving temporal patterns, which is much needed in our study of incoming wave prediction. As shown in Figure 3, an LSTM cell consists of three primary gates: the forget gate, the input gate, and the output gate, which regulate the flow of information through the network. The LSTM cell updates its cell state \(C_{t}\) and hidden state \(h_{t}\) at each time step \(t\) based on the previous hidden state \(h_{t-1}\), the previous cell state \(C_{t-1}\), and the current input \(x_{t}\). The update process is given by the following equations:  
\[f_{t} =\sigma(W_{f}x_{t}+U_{f}h_{t-1}+b_{f})\] (Forget Gate) (15) \[i_{t} =\sigma(W_{i}x_{t}+U_{i}h_{t-1}+b_{i})\] (Input Gate) (16) \[\tilde{C}_{t} =\tanh(W_{c}x_{t}+U_{c}h_{t-1}+b_{c})\] (Cell State Candidate) (17) \[C_{t} =f_{t}\odot C_{t-1}+i_{t}\odot\tilde{C}_{t}\] (Cell State Update) (18) \[o_{t} =\sigma(W_{o}x_{t}+U_{o}h_{t-1}+b_{o})\] (Output Gate) (19) \[h_{t} =o_{t}\odot\tanh(C_{t})\] (Hidden State Update) (20)  
Here, \(\sigma(\cdot)\) represents the sigmoid activation function, \(\tanh(\cdot)\) is the hyperbolic tangent function, and \(\odot\) denotes element-wise multiplication. The weight matrices \(W_{f},W_{i},W_{c},W_{o}\) and \(U_{f},U_{i},U_{c},U_{o}\) along with the biases \(b_{f},b_{i},b_{c},b_{o}\) are learned parameters. LSTMs outperform traditional RNNs in sequence modeling due to their ability to selectively retain or forget information over long sequences. Unlike standard feedforward networks, which process inputs independently, LSTMs utilize a gating mechanism to control information flow, enabling them to learn dependencies over extended time horizons. This is crucial for applications where past inputs influence future predictions, such as ocean wave dynamics. A detailed optimization approach for the LSTM model is presented in Algorithm 1. Figure 3: Structure of an LSTM cell, showing the forget, input, and output gates [19]. ```
Raw WEC data \(\mathcal{D}=\{(z_{t},z_{t},F_{\text{PTO},t},T_{p,t})\}_{t=1}^{M}\), window length \(L\), learning rate \(\eta_{0}\), max epochs \(N_{\text{ep}}\)
```
0: Optimized LSTM parameters \(\theta^{*}\) Data Preparation: Partition \(\mathcal{D}\) into overlapping windows of length \(L\): \(\{X^{(i)},y^{(i)}\}\) Normalize features in \(X^{(i)}\) via min-max scaling Augment: \(X^{(i)}\gets X^{(i)}+\mathcal{N}(0,\sigma_{\text{noise}}^{2})\) Split into training, validation, and test sets Model Initialization: Initialize LSTM parameters \(\theta\) and optimizer with rate \(\eta_{0}\) Set best_val_loss \(\leftarrow\infty\) Training Loop: for epoch \(=1\) to \(N_{\text{ep}}\)do Shuffle training set into mini-batches for each batch \((X_{b},y_{b})\) in training set do \(\hat{y}_{b}\leftarrow\text{LSTM}(X_{b};\theta)\) \(\mathcal{L}\leftarrow\frac{1}{|b|}\sum(\hat{y}_{b}-y_{b})^{2}\) Backpropagate and update \(\theta\) end for \(\hat{y}_{\text{val}}\leftarrow\text{LSTM}(X_{\text{val}};\theta)\) val_loss \(\leftarrow\frac{1}{|\text{val}|}\sum(\hat{y}_{\text{val}}-y_{\text{val}})^{2}\) if val_loss \(<\) best_val_loss then best_val_loss \(\leftarrow\) val_loss \(\theta^{*}\leftarrow\theta\) endif  Adjust learning rate if necessary endfor return\(\theta^{*}\) ```  
**Algorithm 1** LSTM estimator training and optimization. In this work, we employ an LSTM-based control strategy to estimate sea states based on real-time WEC measurements. The sequential nature of WEC device data, including position, velocity, and force, makes LSTM an ideal choice for capturing temporal dependencies.