4.2 Construction of optimal model for numerical solution
Hamilton Jacobi Bellman (HJB) equation in dynamic programming is a high-dimensional nonlinear partial differential equation. This section uses the proposed method to solve the 100 dimensional HJB equation, which is as follows:
$$u(T,x)=g\left(x\right).$$
13
And:
$$\frac{\partial u}{\partial t}(t,x)+\left({{\Delta }}_{x}u\right)(t,x)={∥\left({\nabla }_{x}u\right)(t,x)∥}_{{\mathfrak{R}}^{d}}^{2}$$
14
As shown in Table 1, it represents the numerical experiment results using Adam optimizer. When iteration step m reaches 2000, the loss function meets the requirements and the numerical solution is output.
Table 1
Results of numerical experiment of HJB equation with Adam optimizer
Iteration steps m | 0 | 700 | 1400 | 2100 | 2800 |
Objective function UѲm average | 0.386123 | 2.399754 | 4.169131 | 4.782336 | 4.828425 |
Loss function J(Ѳ m) Average | 18.000523 | 2.227252 | 0.43632 | 0.023735 | 0.023028 |
Operation time (s) | - | 37 | 64 | 91 | 118 |
It can be seen from the data in Table 1 that as the number of iteration steps increases from 0 to 2800, the average value of the objective function increases from 0.386123 to 4.828425, and the average value of the loss function decreases from 18.000523 to 0.023028, but the corresponding operation time also increases.
As shown in Table 2, it is the value of HJB equation when the new parameter optimization method is adopted.
Table 2
Table of numerical experiment results of HJB equation with new parameter optimization method
Iteration steps m | 0 | 700 | 1400 | 2100 | 2800 |
Objective function UѲm average | 0.792951 | 2.9019 | 4.542506 | 4.785456 | 4.8279 |
Loss function J(Ѳ m) Average | 14.605812 | 1.405213 | 0.082719 | 0.022119 | 0.021614 |
Operation time (s) | - | 46 | 78 | 111 | 143 |
The mathematical models in scientific research and engineering application are mostly ordinary differential equations and differential equations, but few special differential equations can be solved correctly, and it is difficult to obtain analytic expressions in most cases. Therefore, approximate solutions can be obtained by numerical approximation. Euler method, modified Euler method and Runge Kutta method are the numerical calculation methods with high frequency. Due to the existence of various complex factors, although people have studied for many years, there is still no one to solve complex and treatable functions, and there are also good results of numerical methods. Especially when large-scale problems occur, the search space for computational optimization expands rapidly. Therefore, the difficulty and the minimum possibility of finding the optimal solution strictly have also been gradually discovered, so the general algorithm for obtaining the optimal solution of numerical function approximation with high accuracy in a short time is urgently needed to be studied.
In this chapter, the solution of ordinary differential equations will be realized by genetic algorithm. The problem of solving differential equations will be transformed into the optimization problem of solving the minimum value of functions by using the principle of least square method to solve the optimization problem. Therefore, genetic algorithms can analyze and solve many nonlinear, multi model and multi-objective problems, and the most important is non differentiable or multimodal optimization problems. In order to transform the ordinary differential equation problem into an optimization problem, the analytical solution of the constructed equation must be solved first. This is why the Taylor extension of a function of one variable is the key to converting the solution of the equation constructed. Therefore, we use the space of polynomial functions to construct the solutions of ordinary differential equations. Since the function form of polynomial function space is very simple, and its essence is just a feature of the function space generated by a simple function (this feature is very important because it has the advantage of being convenient for computer implementation), all the more important functions are infinitely approximated by this function space, so we can also think that the function representation ability of this function space is very strong, so people often use this function space.
The boundary conditions are allowed to be treated in the penalty function. The following is to optimize the problem by solving ordinary differential equations, and transform it into a specific realization process: finding the least squares solution in the polynomial function space is the simplest method to approximate the solution of ordinary differential equations with polynomial functions. The specific implementation method is as follows: select N equidistant nodes xa, xb,.... In [a, b], Xn, the following functions are constructed:
$$E=\sum _{j=0}^{N-1} f{\left({x}_{j},M\left({x}_{j},{\omega }_{0},{\omega }_{1},\dots ,{\omega }_{k}\right),\dots ,{M}^{\left(n\right)}\left({x}_{j},{\omega }_{0},{\omega }_{1},\dots ,{\omega }_{k}\right)\right)}^{2}$$
15
The function of penalty function construction is to transform unconstrained optimization problems into each other by dealing with boundary conditions. The following formula is penalty function construction:
$$P\left(M\right)=\sum _{k=0}^{n} {g}_{k}{ }^{2}{\left(x,M,{M}^{{\prime }},\dots ,{M}^{(n-1)}\right)}_{\text{t}\text{x}={t}_{k}}$$
16
First of all, use the toolbox of genetic algorithm to compile M file, which receives the line vector and then returns it with scalar quantity. The optimal process of screening experimental parameters for this problem is shown in the following process:
Set the number of variables in the problem to 3, 5, 7, 9 in the MATLAB genetic algorithm toolbox, that is, construct the solutions of polynomial approximation equations of degree 2, 3, 4, and 8 respectively. The experimental results are shown in Fig. 1:
The experimental results are shown in Fig. 2:
4.3 Analysis of data simulation results
Figure 3 shows that in MATLAB software, the improved Euler method and trapezoidal Euler Maruyama method are used to compare the numerical solution with the accurate solution:
As shown in Fig. 3, the improved Euler method is used to compare the exact solution and numerical solution of the equation. The numerical fluctuation of the refined solution value is large, and the numerical solution is relatively stable, but the trend between the two is roughly the same. When the t value reaches 0.125, the X value of both has dropped to the lowest value. After data analysis, the average absolute error after comparison using this method is 1.159 × 10− 4。
The average absolute errors of trapezoidal Euler Maruyama method and improved Euler method are 1.159 respectively × 10 − 4 and 5.637 × 10 − 5。 Therefore, according to the average absolute error obtained by two different algorithms, the numerical solution obtained by the improved Euler method is close to the exact solution.
As can be seen in Fig. 4, the oscillation of the neural network output becomes stronger and stronger with the increase of depth, that is, the deeper the depth gives the neural network a stronger oscillation property.
Figure 5 shows the result of the change in the value of the loss function.