?About the author: A Matlab simulation developer who loves scientific research. He cultivates his mind and improves his technology simultaneously.
For code acquisition, paper reproduction and scientific research simulation cooperation, please send a private message.
Personal homepage: Matlab Research Studio
Personal credo: Investigate things to gain knowledge.
For more complete Matlab code and simulation customization content, click
Intelligent optimization algorithm Neural network prediction Radar communication Wireless sensor Power system
Signal processing Image processing Path planning Cellular automaton Drone
Content introduction
Intelligent optimization algorithm is an optimization method based on mathematical models and computer technology. Its purpose is to find the optimal solution or suboptimal solution under given constraints. Among them, the generalized quadratic interpolation algorithm is one of the intelligent optimization algorithms. It finds the local optimal solution by interpolating the objective function, and continuously iterates on this basis to finally achieve the global optimal solution.
The process of the generalized quadratic interpolation algorithm is as follows:
-
Determine the initial point
First, an initial point needs to be determined, which can generally be randomly generated or selected based on experience. This initial point is the starting point for the beginning of the algorithm and the basis for subsequent iterations.
-
Build an interpolation model
Next, a quadratic interpolation model needs to be constructed to approximate the objective function. In the generalized quadratic interpolation algorithm, the form of the interpolation model is:
f(x) = a0 + a1(x-x0) + a2(x-x0)^2 + a3(x-x1)(x-x2)
Among them, x0, x1, and x2 are three known points, and a0, a1, a2, and a3 are the coefficients to be found. What needs to be noted here is that x0, x1, and x2 need to meet certain conditions, such as not being collinear.
-
Solving coefficients
Next, we need to solve for the coefficients a0, a1, a2, a3. This can be obtained by differentiating the interpolation model and then solving the system of equations. Specifically, you can first derive the derivative of f(x) with respect to x, and get:
f'(x) = a1 + 2a2(x-x0) + a3(x-x2)
Then, differentiate f'(x) with respect to x, and get:
f”(x) = 2a2 + a3
Then, take x as x0, x1, and x2 respectively, and get three equations, namely:
f'(x0) = a1 f'(x1) = a1 + 2a2(x1-x0) + a3(x1-x2) f'(x2) = a1 + 2a2(x2-x0) + a3(x2-x2)
By solving this system of equations, we can obtain the values of coefficients a0, a1, a2, and a3.
-
Find the optimal solution
With the interpolation model and coefficients, the optimal solution can be found by solving the minimum value of the interpolation model. In the generalized quadratic interpolation algorithm, the position of the minimum value can be obtained by deriving the interpolation model, and then use this position as the next starting point to continue iteration until the stopping condition is met.
-
Stop condition
During the iteration process, a stopping condition needs to be set to prevent the algorithm from looping infinitely. Common stopping conditions include:
(1) The change in the objective function value is less than a certain threshold; (2) The number of iterations reaches a certain upper limit; (3) The global optimal solution has been found.
In general, the generalized quadratic interpolation algorithm is a simple and effective optimization algorithm that can find the local optimal solution in a short time and gradually approach the global optimal solution. However, due to the limitations of the interpolation model, this algorithm may fall into a local optimal solution and fail to find the global optimal solution. Therefore, in practical applications, different optimization algorithms need to be selected according to specific situations to achieve better results.
Part of the code
%% Clear environment variables</code><code>warning off % Close alarm information</code><code>close all % Close open figure window</code><code>clear % Clear variables</code><code>clc % clear command line</code><code>?</code><code>%% import data</code><code>res = xlsread('dataset.xlsx');</code><code>?</code><code>%% divide the training set and test set</code><code>temp = randperm(357);</code><code>?</code><code>P_train = res(temp(1: 240), 1: 12)';</code><code>T_train = res(temp(1: 240), 13)';</code><code>M = size(P_train , 2);</code><code>?</code><code>P_test = res(temp(241: end), 1: 12)';</code><code>T_test = res(temp(241 : end), 13)';</code><code>N = size(P_test, 2);</code><code>?</code><code>%% data normalization</code><code>[p_train, ps_input] = mapminmax(P_train, 0, 1);</code><code>p_test = mapminmax('apply', P_test, ps_input);</code><code>t_train = ind2vec(T_train) ;</code><code>t_test = ind2vec(T_test );