先说结论,从趋势结果曲线图来看,足球队训练算法不易陷入局部最优,寻优效果不错,且原理简单,大家可以借鉴该算法原理用于别的算法的改进。
足球队训练算法(Football team training algorithm,FTTA)是一种全新的元启发式优化方法,其灵感来源于足球队中球员集体训练课的安排与进步过程。该算法通过配合模拟足球课,分阶段训练球员,提高球员的能力,通过模拟足球队的训练模式,不断提高算法的收敛能力,最终得到全局最优解。FTTA具有进化能力强、搜索速度快、寻优能力强的特点。这一成果由Tian等人于2024年发表在中科院1区顶级SCI期刊《Engineering Applications of Artificial Intelligence》上。
足球队训练算法(FTTA)是一种利用模拟高水平足球训练课上球员行为的方法,以达到训练效果的目的。传统足球训练课通常包括集体训练、小组训练和个人额外训练三个主要部分,每部分的具体内容如下:
1、算法原理
(1)集体训练
训练开始时,队员们会在教练的指导下进行集体训练,教练首先会通过一系列的测试(体能机能)让队员们了解自己的水平。然后球员们根据自己的水平制定自己的集体训练计划。我们将玩家分为四种不同的类型:追随者,反对者,思考者和波动者。在每次迭代中,玩家将随机改变自己的类型。
追随者是当前最佳玩家的狂热追随者,他朝着每个维度的最佳玩家努力,希望达到当前最佳玩家的水平,但由于实力的限制,往往每个维度只能随机移动到最佳玩家。计算公式如下:
其中当前最佳玩家被定义为Fk Best,其中k是迭代次数,Fk Best,j是其在维度j上的值;当前玩家被定义为Fk i,i是其玩家编号,Fk i,j是其在维度j上的值,Fk i,j new是训练后玩家在维度j上的状态。
发现者比追随者更理性。他们不仅看到最好的球员,也看到最差的球员,所以他们不仅努力争取最好的球员,而且尽最大努力避免成为最差的球员。计算公式如下:
其中,当前最差的玩家被定义为Fk Worst,k是迭代次数,其中Fk Worst,j是其在维度j中的值。Fk i,j new是训练后玩家在维度j上的状态。
思考者比眼前的人更警觉,他们直接看到最好的玩家和最差的玩家之间的差距,并努力在每个维度上达到差距,方程如下:
在维度j中,Fk Best,j − Fk Worst,j是当前最佳玩家和最差玩家之间的差向量,k是迭代次数。反复无常的人拒绝向任何人学习,他们自己做训练,所以状态会有一定的波动。当然,随着训练次数(迭代次数)的增加。运动员状态的波动会越来越小,我们定义运动员状态的波动如下:
其中,t(k)是一个具有t分布的随机数,其自由度为当前迭代次数,随着自由度的增加,t分布接近中间值(0)的概率越来越高,两端分布逐渐减小,将越来越接近正态分布。因此,随着迭代次数的增加,波动的程度会越来越小,并逐渐从全局搜索转变为局部搜索。
(2)集体培训
集体训练结束后,足球训练过程就到了分组训练的阶段,教练员根据球员的特点将球员分为四类(每个维度都是一个特征值):前锋、中场、后卫和守门员。
教练完成分组后,队员们将与组内其他队员进行学习或交流。我们将群体训练定义为三种状态:最优学习、随机学习和随机交流。我们将学习概率定义为pstudy,通信概率为pstudy,参与者将在每次迭代中随机选择状态。
最优学习:在每个维度中,玩家都有一定的概率直接学习到群体中最优秀玩家的能力值。公式定义如下:
式中,Fk, teambest为第l组中最优秀的选手,k为迭代次数,teaml代表第l组,Fk, teambest,j为第l组中最优秀选手的第j维,Fk, teami,j new为第j维选手经过最优学习后的状态。
随机学习:在每个维度中,玩家都有一定的概率直接学习到小组中任意一个随机玩家的能力值。公式定义如下:
式中,Fk,teaml Random为第l组中的随机参与者,k为迭代次数,teaml代表第l组,Fk,teaml Random,j为第l组中随机参与者的第j维,Fk,teaml i,j new为随机学习后参与者在第j维中的状态。
在训练中,学习只是一部分,两名队员之间的交流对于能力的提高更为重要。在每个维度中,玩家都有一定的概率与小组中的任何玩家进行交流。
当rand≤pcomm时,公式定义如下:
式中,Fk,teaml Random为l组中的随机玩家,k为迭代次数,teaml代表l组,Fk,teaml Random,j为l组中随机玩家的第j维,两名玩家在j维交换能力,Randn为正态分布的随机数,乘以(1 + randn)表示两名玩家对其他玩家能力的理解。
当rand > pcomm时,公式定义如下:
我们假设在群体训练过程中,有一定的概率会出现错误,即他们不小心学习了别人的其他维度的内容。这种情况发生的概率很低,但却是真实客观的。我们将错误概率定义为perror。
(3)个人额外训练
在集体训练结束后,需要重新计算新的体能值,用较好的体能值代替较差的体能值来更新球员的状态。更新后,教练会选择最好的球员,让他练习,让他变得更好,这样他就能更好地带动别人的训练状态,训练的公式如下:
Cauchy和Gauss联合变分用于描述单个额外训练,k为迭代次数。之所以选择高斯-柯西分布,是因为在训练初期,一般每个人的水平都不高,所以最优秀的选手有更大的概率获得更大的提升,此时,柯西分布-分布函数占据了很大的比例,这可以有效地为玩家提供大范围的提升,有利于全局搜索。
所提出的FTTA流程图如下图所示。
所提出的FTTA伪代码如下所示。
2、结果展示
3、MATLAB核心代码
clc
clear
pop = 100; %%Population
maxGen = 1000; %%Maximum iterations
stu = 0.2; %%Study Operator
com = 0.2; %%Communication Operator
error = 0.001 %%Error Operator (No higher than 0.001)
teamnumber = 2 %%Team Number Operator(team number>=2 & team number<=pop/4)
F = 'F7';
[lb,ub,dim,fobj] = Get_Functions_details(F);
objective= fobj; %Objective Function
[init,Upnew,Lownew] = Initialization1(pop,dim,ub,lb);
Z = 0;
for Iter = 1:maxGen
%%Calculate All Fitness Values
for i = 1:pop
a1 = objective(init(i,:));
sol(i,:) = [a1];
end
%%Find out the Best and the Worst.
a = find(sol == min(sol));
b = find(sol == max(sol));
Best = init(a,:);
Best = Best(1,:);
Worst = init(b,:);
Worst = Worst(1,:);
init2 = init;
%% Collective Training
for i = 1:pop
a = rand;
if a>=3/4
%%Status 1: Moving towards the difference vector between Yourself and the Best
A = init2(i,:)+rand(1,dim).*(Best-init2(i,:));
init3(i,:) = [A];
else if a>=1/2 && a<3/4
%%Status 2: Moving towards the difference vector between Yourself and the Best and Worst
A = init2(i,:)+rand(1,dim).*(Best-Worst);
init3(i,:) = [A];
%%Status 3: Moving towards the difference vector between Yourself and the Best while escaping the Worst
else if a<1/2 && a>=1/4
A = init2(i,:)-rand(1,dim).*(Worst-init2(i,:))+rand(1,dim).*(Best-init2(i,:));
init3(i,:) = [A];
else if a<1/4
%%Status 4: Player status fluctuation
%%(You can change it to the sin-function which is in the SCA method)
%A = init2(i,:).*(1+(1-Iter*(1/maxGen))*sin(rand*2*pi));
A = init2(i,:).*(1+trnd(Iter,[1,dim]));
init3(i,:) = [A];
end
end
end
end
end
%%Limit Range (Control Boundary)
for i = 1:pop
for j = 1:dim
if init3(i,j)>=Upnew(:,j);
init3(i,j) = Upnew(:,j);
else if init3(i,j)<=Lownew(:,j);
init3(i,j) = Lownew(:,j);
end
end
end
end
%% Group training (Striker, Midfielder, Gguard, Goalkeeper)
X = init3';
zubie = 4;
%%EM cluster for grouping
[label, model, llh] = mixGaussEm(X, zubie);
Label = label';
Team1 = init3(find(Label==1),:);
Team2 = init3(find(Label==2),:);
Team3 = init3(find(Label==3),:);
Team4 = init3(find(Label==4),:);
%%Calculate the size of each group
[M1,N1] = size(Team1);
[M2,N2] = size(Team2);
[M3,N3] = size(Team3);
[M4,N4] = size(Team4);
M5 = [M1,M2,M3,M4];
%%We assume that if the number of people in a group is less than teamnumber, we cannot communicate.
for k = 1:4
if M5(:,k)<=teamnumber
%%Do the random grouping at this time
[Team1,Team2,Team3,Team4] = suijifenzu(init3,pop);
break
end
end
%%Update the size of each group
[M1,N1] = size(Team1);
[M2,N2] = size(Team2);
[M3,N3] = size(Team3);
[M4,N4] = size(Team4);
%%Learning and communication within each group (communication and learning)
[team1] = study(Team1,M1,stu,com,error,dim,objective,Upnew,Lownew,teamnumber);
[team2] = study(Team2,M2,stu,com,error,dim,objective,Upnew,Lownew,teamnumber);
[team3] = study(Team3,M3,stu,com,error,dim,objective,Upnew,Lownew,teamnumber);
[team4] = study(Team4,M4,stu,com,error,dim,objective,Upnew,Lownew,teamnumber);
%%Regroup
init4 = [team1;team2;team3;team4];
%%Calculate fitness
for i = 1:pop
a6 = objective(init4(i,:));
sol2(i,:) = [a6];
end
%%Update players and update corresponding fitness
for i = 1:pop
if sol(i,:)<=sol2(i,:);
init4(i,:) = init(i,:); sol2(i,:) = sol(i,1);
end
end
sol3 =sol2;
%%Find the best player.
d = find(sol3 == min(sol3));
d = d(1,:);
Best2 = init4(d,:);
Best2 = Best2(1,:) ;
best2 = min(sol3);
best2= best2(1,:);
% For random objective function
if Iter>1
if best2>M(Iter-1,:)
best2 = M(Iter-1,:);
Best2 = N(Iter-1,:);
end
end
%% Individual extra training
%(You can change it to the sin-function which is in the SCA method)
%Best3 = Best2.*(1+(1-Iter*(1/maxGen))*sin(rand*2*pi));
Best3 = Best2.*(1+(1-1/Iter)*randn+(1/Iter)*cauchy(1));
%%Boundary control
for i = 1:dim
if Best3(:,i)>=Upnew(:,i);
Best3(:,i) = Upnew(:,i);
else if Best3(:,i)<=Lownew(:,i);
Best3(:,i) = Lownew(:,i);
end
end
end
%%Calculate the target value
best3 = objective(Best3);
%%Best player replacement
if best3<best2
best2 = best3;
Best2 = Best3;
init4([d],:) = [Best3];
end
Z = Z+1;
M(Z,:) = [best2];
N(Z,:) = [Best2];
%%Update the team members
init = init4;
%%Printout
disp(['In iteration ' num2str(Iter) ': Best solution = ' num2str(M(Z,:))]);
end
%%Draw a convergent image
figure(1)
semilogy(M,'Linewidth',2)
figure(2)
func_plot(F)
参考文献
[1]Tian Z, Gai M. Football team training algorithm: A novel sport-inspired meta-heuristic optimization algorithm for global optimization[J]. Expert Systems with Applications, 2024, 245: 123088.
完整代码获取方式:后台回复关键字:
TGDM877