# Optimizing Physics-Informed Neural Network in Dynamic System Simulation and Learning of Parameters
## 5 Computational Simulations of Dynamical Systems
### Lotka-Volterra Model
\begin{split} r_{1}(t)&=\frac{dP_{NN}(t_{n};\omega )}{dt}-\left(P_{NN}(t_{n};\omega)(a(t_{n};\Phi)-b(t_{n};\Phi)Q_{NN}(t_{n}; \omega))\right)\\ r_{2}(t)&=\frac{dQ_{NN}(t_{n};\omega)}{dt}-\left( Q_{NN}(t_{n};\omega)(c(t_{n};\Phi)P_{NN}(t_{n};\omega)-d(t_{n};\Phi)) \right)\end{split}  \tag{26}\]  
and  
\[\zeta_{t}(\omega;\kappa_{t})=\frac{1}{k_{t}}\bigg{(}\sum_{n=1}^{\kappa_{r}}|P _{NN}(t_{n};\omega)-P(t_{n})|^{2}+\sum_{n=1}^{\kappa_{r}}|Q_{NN}(t_{n};\omega )-Q(t_{n})|^{2}\bigg{)} \tag{27}\]  
To generate our measurement data, we numerically solve (23) and (24), utilizing an initial condition of \((P_{0},Q_{0})=(0.2,0.3)\). We selected parameter values as follows: \(a=1,b=2,c=1\), and \(d=0.3\). The problem was resolved over a period delineated by the interval \([0,T]\), where \(T\) is set to 13, a duration that approximately encapsulates one cycle. We employ a \(N_{x}=100\) points grid within this temporal scope. Our measurement data is procured by extracting the numerical solution vector at every alternate time step. As a result of this method, we obtain a dataset where \(N=50\)[33]. Finally, the Lotka-Volterra model parameters were obtained using PINN and the approaches from Scenario 2 with three hidden layers, 64 neurons per layer, 50,000 epochs, the sigmoid activation function, and a learning rate of \(10^{-3}\). The PINN Algorithm 4 for learning the optimal parameters of the Lotka-Volterra model is shown below. After the parameters were learned using the same initial condition used to produce the data, the results that are obtained are then compared with the true values of the parameters and the actual data. Figures are provided to visualize the predicted prey and predator populations, the phase space plot, and the absolute error between the target and predicted values. The tables present the initial and obtained parameters and error metrics such as MAE, MSE, and RMSE. ```
1: Construct PINNN  Specify the input: \(t_{n},n=1,\ldots,X\)  Initialize PINNN parameter: \(\omega\)  Output layer: \(P_{NN}(t_{n};\omega)\) and \(Q_{NN}(t_{n};\omega)\), \(n=1,\ldots,X\)
2: Construct neural network: \(a\)  Specify the input: \(t_{n},n=1,\ldots,X\)  Initialize PINNN parameter: \(\Phi\)  Output layer: \(a(t_{n};\Phi)\), \(n=1,\ldots,X\)
3: Construct neural network: \(b\)  Specify the input: \(t_{n},n=1,\ldots,X\)  Initialize PINNN parameter: \(\Phi\)  Output layer: \(b(t_{n};\Phi),n=1,\ldots,X\)
4: Construct neural network: \(c\)  Specify the input: \(t_{n},n=1,\ldots,X\)  Initialize PINNN parameter: \(\Phi\)  Output layer: \(c(t_{n};\Phi),n=1,\ldots,X\)
5: Construct neural network: \(d\)  Specify the input: \(t_{n},n=1,\ldots,X\)  Initialize PINNN parameter: \(\Phi\)  Output layer: \(d(t_{n};\Phi),n=1,\ldots,X\)
6: Specify the training set \(\kappa=\kappa_{r}\cup\kappa_{b}\) of the NN
7: Train the neural network  Specify a loss function \[\zeta(\omega;\kappa) =\zeta_{t}(\omega;\kappa_{t})+\zeta_{r}(\omega;\kappa_{r})\] \[r_{1}(t) =\frac{dP_{NN}(t_{n};\omega)}{dt}-\left(P_{NN}(t_{n};\omega)(a(t _{n};\Phi)-b(t_{n};\Phi)Q_{NN}(t_{n};\omega))\right)\] \[r_{2}(t) =\frac{dQ_{NN}(t_{n};\omega)}{dt}-\left(Q_{NN}(t_{n};\omega)(c(t _{n};\Phi)P_{NN}(t_{n};\omega)-d(t_{n};\Phi))\right)\] Minimize \(min_{\kappa}\zeta(\omega;\kappa)\) using Adam Optimizer. 8: Return PINNN solution \(P_{NN}(t_{n};\omega)\) and \(Q_{NN}(t_{n};\omega)\), \(n=1,\ldots,X\)
9: Return Parameter a: \(a(t_{n};\Phi),n=1,\ldots,X\)
10: Return Parameter b: \(b(t_{n};\Phi),n=1,\ldots,X\)
11: Return Parameter c: \(c(t_{n};\Phi),n=1,\ldots,X\)
12: Return Parameter d: \(d(t_{n};\Phi),n=1,\ldots,X\)
```  
**Algorithm 4** PINNN algorithm for learning the parameters of Lotka-Volterra model  
Figure 16 displays the resulting solution of the actual and predicted output of the Lotka-Volterra model. Figure 17 shows the phase space plot of the anticipated output of species \(P(t)\) versus species \(Q(t)\) and the actual output of species \(P(t)\) against species \(Q(t)\).