## 2 Dynamic Model Predictive Control
### Trajectory Tracker Design for Dynamic Model Predictive Control
#### 2.2.2 Dynamic Effects Design  
It can be seen from the model that with the increase in the prediction horizon \(N_{p}\), MPC will take into account more future states, and the control quantities obtained by optimization will develop towards reducing the prediction error so that it can improve the accuracy of trajectory tracking. But at the same time, the dimension of the matrix will increase significantly, which increases the computational complexity and the solution time [24]. To obtain a better control performance, a method of adjusting the prediction horizon can be introduced [25]. The minimum and the maximum prediction horizon are set as \(N_{pmin}\) and \(N_{pmax}\). In the process of trajectory tracking, the minimum and maximum curvature (\(\kappa_{min}\), \(\kappa_{max}\)) of the desired trajectory are calculated based on the given trajectory. It is assumed that there is an exponential-like functional relationship between the prediction horizon \(N_{p}\) and trajectory curvature \(\kappa\) of the reference trajectory. By setting parameters \(b_{0}\) and \(b_{1}\), the actual functional relationship is defined as:  
\[N_{\text{p}}=N_{\text{pmin}}+C^{*}\bigg{[}b_{0}\big{(}N_{\text{pmax}}\ -N_{ \text{pmin}}\ \big{)}\text{e}^{\frac{\kappa-\kappa_{\text{max}}}{b_{1}}}\bigg{]} \tag{27}\]  
Incorporating multiple trajectories with single curvature as reference trajectories into a closed-loop control system, \(N_{p}\) is determined through tuning to achieve relatively accurate tracking results. Using Equation (27) as the basis function, multiple sets of curvature trajectories and their corresponding \(N_{p}\) undergo offline nonlinear fitting to obtain specific values for parameters \(b_{0}\) and \(b_{1}\). Define a curvature sample set \(\kappa^{*}=\big{\{}\kappa_{1}\cdots\kappa_{i}\cdots\kappa_{N}\big{\}}\) and corresponding prediction horizon set under the trajectory curvature \(N_{p}^{*}=\big{\{}N_{p1}\cdots N_{pi}\cdots N_{pN}\big{\}}\). Considering that the C* operator is not differentiable, the equivalent functional relationship of the fitting Equation (27) is:  
\[N_{\text{p}}(\kappa)=N_{\text{pmin}}+b_{0}\big{(}N_{\text{pmax}}\ -N_{\text{pmin}}\ \big{)}\text{e}^{\frac{\kappa-\kappa_{\text{max}}}{b_{1}}}+\frac{\kappa}{ \kappa_{\text{max}}} \tag{28}\]  
Let the error function be:  
\[\phi=\frac{1}{2}\underset{i=1}{\overset{N}{\sum}}\big{(}N_{\text{p}}(\kappa_{ i})-N_{\text{pi}}\big{)}^{2} \tag{29}\]  
Taking the partial derivatives of the error with respect to parameters \(b_{0}\) and \(b_{1}\) yields:  
\[\left\{ \begin{array}{l}\frac{\partial\phi}{\partial b_{0}}=\underset{i=1}{ \overset{N}{\sum}}\tau_{1}(i)\tau_{2}(i)\\ \frac{\partial\phi}{\partial b_{1}}=\underset{i=1}{\overset{N}{\sum}}\tau_{3} (i)\tau_{4}(i)\end{array} \right. \tag{30}\]  
where  
\[\tau_{1}(i)=N_{\text{pmax}}+b_{0}\big{(}N_{\text{pmax}}-N_{\text{pmin}}\big{)} \text{e}^{\frac{\kappa_{i}-\kappa_{\text{max}}}{b_{1}}}+\frac{\kappa_{i}}{ \kappa_{\text{max}}}-N_{\text{pi}}\]  
\[\tau_{2}(i)=\big{(}N_{\text{pmax}}-N_{\text{pmin}}\big{)}\text{e}^{\frac{ \kappa_{i}-\kappa_{\text{max}}}{b_{1}}}\]  
\[\tau_{3}(i)=N_{\text{pmax}}+b_{0}\big{(}N_{\text{pmax}}-N_{\text{pmin}}\big{)} \text{e}^{\frac{\kappa_{i}-\kappa_{\text{max}}}{b_{1}}}+\frac{\kappa_{i}}{ \kappa_{\text{max}}}-N_{\text{pi}}\]  
\[\tau_{4}(i)=\frac{b_{0}\big{(}N_{\text{pmax}}-N_{\text{pmax}}\big{)}\text{e}^{ \frac{\kappa_{i}-\kappa_{\text{max}}}{b_{1}}}}{b_{1}^{2}}\text{e}^{\frac{ \kappa_{i}-\kappa_{\text{max}}}{b_{1}}}\]  
According to the gradient descent algorithm, in order to minimize the error:  
\[b_{0}=b_{00}-k_{1}\frac{\partial\phi}{\partial b_{00}}\text{, }b_{1}=b_{10}-k_{2}\frac{\partial\phi}{ \partial b_{10}}\]where \(b_{00}\) is the initial value of \(b_{0}\) and \(b_{10}\) is the initial value of \(b_{1}\). \(k_{1}\) and \(k_{2}\) are learning rates.