mathematical expression
The kinematic equation of the first-order multi-agent can be described as
x ˙ i ( t ) = ui ( t ) , i ∈ { 1 , 2 , 3 , … , N } \dot x_i(t) = u_i(t),i \in\{1,2,3,\dots,N\}x˙i(t)=ui(t),i∈{
1,2,3,…,N }
insidexi ( t ) x_i(t)xiui _ _ __ui( t ) is the control quantity, and the final expected result is
lim t → T ∣ xi ( t ) − xj ( t ) ∣ = 0 \lim_{t\to T} |x_i(t) - x_j(t)| = 0t→Tlim∣xi(t)−xj(t)∣=0
∣ x i ( t ) − x j ( t ) ∣ = 0 , ∀ t ≥ T |x_i(t)-x_j(t)| = 0, \forall t \ge T ∣xi(t)−xj(t)∣=0,∀t≥T
Among them, the first equation in the above formula means that the time approaches TTAt T , the state of the agent tends to be consistent. The second equation expresses that when time exceedsTTAt time T, the agent's time has been consistent.
Express the first-order multi-agent consensus algorithm as
ui ( t ) = − ∑ j = 1 N aij ( xi ( t ) − xj ( t ) ) u_i(t) = - \sum_{j=1}^{ N}a_{ij}(x_i(t) - x_j(t))ui(t)=−j=1∑Naij(xi(t)−xj( t ))
Here is a little trick. If it is expressed in the form of a matrix, then directly use the Laplacian matrix to express
u (t) = − x (t) ⋅ L u(t) = - x(t) \ cdotLu(t)=−x(t)⋅L
simulation
Set the initial state of the agent to
x = [ 1 2 3 4 ] x = \begin{bmatrix} 1& 2& 3& 4 \end{bmatrix}x=[1234]
The connection of the agent is
智能体1 --- 智能体2
| |
| |
智能体4 --- 智能体3
Then the Laplacian matrix is
L = [ 2 − 1 0 − 1 − 1 2 − 1 0 0 − 1 2 − 1 − 1 0 − 1 2 ] L = \begin{bmatrix} 2 & -1 & 0 & - 1\\ -1 & 2 & -1 & 0\\ 0 & -1 & 2 & -1\\ -1 & 0 & -1 & 2\\ \end{bmatrix}L=
2−10−1−12−100−12−1−10−12
The simulation code is (matlab)
clc;clear;close
x = [1 2 3 4];
u = [];
A = [0 1 0 1;
1 0 1 0;
0 1 0 1;
1 0 1 0;];
B = [2 0 0 0;
0 2 0 0;
0 0 2 0;
0 0 0 2;];
L = B - A;
dt = 0.001;
k = 3;
lambda = 2;
mu = 0.1;
for i = 1:4000
u1 = -x(end,:) * L;
x1 = x(end,:) + u1 * dt;
u = [u;u1];
x = [x;x1];
end
Draw the curve of the control quantity and the curve of the state quantity
Fig1 = figure(1);
plot(0.001:0.001:4.001,x,'LineWidth', 1.5);
xlabel('t');
ylabel('x');
legend('agent1','agent2','agent3','agent4');
print(Fig1,'x','-dpng','-r600')
Fig2 = figure(2);
plot(0.001:0.001:4.000,u,'LineWidth', 1.5);
xlabel('t');
ylabel('u');
legend('agent1','agent2','agent3','agent4');
print(Fig2,'u','-dpng','-r600')
The change of state variables over time is shown as
The change of the control amount over time is as follows
. It can be seen that in the end, the states of the four agents are all consistent.