MTGA
title:Multi-Tasking Genetic Algorithm (MTGA) for Fuzzy System Optimization
author:Dongrui Wu and Xianfeng Tan
journal:IEEE Transactions on Fuzzy Systems
DOI: 10.1109/TFUZZ.2020.2968863
code:https://github.com/drwuHUST/MTGA,MTO-Platform平台上的代码将会在文末给出。
1.主要贡献:
1)提出了MTGA;2)为模糊系统设计提出了一个新颖的基于MTGA的同步优化策略,此处为一个建模过程,略。
2.问题提出:
在统一搜索空间中,如果不同任务的最优解及其适应度范围明显不同,则MFEA可能得不到好的效果。本文的目的是设计一种多任务优化算法,它可以在任务显著不同的情况下,也能实现良好的性能。本文要解决的问题总结如下:
1)如何估计两个最优解之间的差异;
2)如何在两个种群之间转移更有效的个体。
3.MTGA:
1)MTGA的思路:
从下图中我们可以看到,两个任务的最优解之间存在很大的偏差,盲目的将任务 P 1 P_1 P1中表现好的个体转移到任务 P 2 P_2 P2中,可能不利于搜索。
估计偏差:MTGA会先计算每个种群中表现好的个体的均值,然后通过均值来估计两个任务最优解之间的差异。当有一个个体需要发生转移时,该个体会加上(或减去)这种偏差,使得它可以更符合新任务。
![image-20240304092802770](https://i-blog.csdnimg.cn/blog_migrate/cddd1b6c4a8ee83ecc8934c113c4371e.png)
顺序转移:先将 P 1 P_1 P1中表现好的个体转移到 P 2 P_2 P2,然后 P 2 P_2 P2交叉突变生成新的 P 2 P_2 P2。然后,将新的 P 2 P_2 P2中表现好的个体转移到 P 1 P_1 P1,然后 P 1 P_1 P1交叉突变产生新的 P 1 P_1 P1。这样,一个种群中更新的表现好的个体可以立即被同一代使用,加快收敛。
MFEA中两个任务将其表现好的个体同时转移到另一个任务上,然后分别进行交叉突变产生下一代。
![image-20240304092829577](https://i-blog.csdnimg.cn/blog_migrate/a9c46656a557d3f791c629643c6a102d.png)
2)偏差估计及个体迁移
首先,计算
P
1
,
P
2
P_1,P_2
P1,P2中前
n
t
n_t
nt个个体的均值
m
1
,
m
2
m_1,m_2
m1,m2,则
m
1
,
m
2
m_1,m_2
m1,m2之间的差异代表了两个任务之间的偏差。假设我们将
P
2
P_2
P2中的前
n
t
n_t
nt个个体转移到
P
1
P_1
P1中,以取代
P
1
P_1
P1中后
n
t
n_t
nt个个体。首先,将
P
1
P_1
P1和
P
2
P_2
P2中的个体分别根据适应度从小到大排序,
{
x
1
,
n
}
n
=
1
N
\{x_{1,n}\}^N_{n=1}
{x1,n}n=1N和
{
x
2
,
n
}
n
=
1
N
\{x_{2,n}\}^N_{n=1}
{x2,n}n=1N。然后均值计算如下:
m
1
=
1
n
t
∑
n
=
1
n
t
x
1
,
n
,
m
2
=
1
n
t
∑
X
=
1
n
t
x
2
,
n
m_1 = \frac 1{n_t} \sum^{n_t}_{n=1}x_{1,n}\ \ ,\ \ m_2 = \frac1{n_t} \sum^{n_t}_{X=1}x_{2,n}
m1=nt1n=1∑ntx1,n , m2=nt1X=1∑ntx2,n
接下来,我们使用临时种群
P
t
P_t
Pt来存储从
P
2
P_2
P2转移过来的个体
x
1
,
n
′
(
n
=
1
,
.
.
.
,
n
t
)
x'_{1,n}\ \ (n=1,...,n_t)
x1,n′ (n=1,...,nt),即
P
t
=
{
x
′
1
,
1
,
.
.
.
,
x
′
1
,
n
t
,
x
1
,
1
,
.
.
.
,
x
1
,
N
−
n
t
}
P_t =\{x′_{1,1},..., x′_{1,n_t} , x_{1,1},..., x_{1,N−n_t} \}
Pt={x′1,1,...,x′1,nt,x1,1,...,x1,N−nt}。新个体
x
1
,
n
′
x'_{1,n}
x1,n′计算如下:
x
′
1
,
n
(
i
)
=
x
2
,
n
(
I
(
i
)
)
−
m
2
(
I
(
i
)
)
+
m
1
(
i
)
,
x′_{1,n}(i) = x_{2,n}(I(i)) − m_2(I(i)) + m_1(i),
x′1,n(i)=x2,n(I(i))−m2(I(i))+m1(i),
其中,
x
1
,
n
′
(
i
)
x'_{1,n}(i)
x1,n′(i)是
x
’
1
,
n
x’_{1,n}
x’1,n中的第i个基因,
x
2
,
n
(
I
(
i
)
)
x_{2,n}(I(i))
x2,n(I(i))是
x
2.
n
x_{2.n}
x2.n中第
I
(
i
)
I(i)
I(i)个基因,
m
2
(
I
(
i
)
)
m_2(I(i))
m2(I(i))是
m
2
m_2
m2中的
I
(
i
)
I(i)
I(i)个基因,
m
1
(
i
)
m_1(i)
m1(i)是
m
1
m_1
m1中的第i个基因,
n
=
1
,
.
.
.
,
n
t
,
i
=
1
,
.
.
.
,
d
1
n=1,...,n_t,i=1,...,d_1
n=1,...,nt,i=1,...,d1。注意:
I
I
I通常是为每个转移的个体随机构建的,即
x
1
,
n
′
x'_{1,n}
x1,n′中的第i个基因与
x
2
,
n
x_{2,n}
x2,n中的一个基因(不一定是第i个基因)随机匹配。
3)MTGA的总体框架:
首先,为每一个任务都初始化一个种群,并评估个体。其次,根据2)计算偏差。接着,根据2)构建临时种群 P t P_t Pt。然后,在 P t P_t Pt中交叉突变产生子代。最后,环境选择下一代种群。当终止条件满足时,终止循环并返回每个任务的最优解。
![image-20240304095709375](https://i-blog.csdnimg.cn/blog_migrate/735eef9bc25e1c19fd02b2ce284e48d3.png)
4.思考
1)MTGA中个体迁移时,决策变量之间采用随机映射的方式可能会带来不好的效果,如G-MFEA的决策变量洗牌策略。这种问题可以使用MFEA-GSMT[1]以及KR-MTEA[2]中的基因相似性来解决。
[1] Ma, Xiaoliang & Zheng, Yongjin & Zhu, Zexuan & Li, Xiaodong & Wang, Lei & Qi, Yutao & Yang, Junshan. (2021). Improving Evolutionary Multitasking Optimization by Leveraging Inter-Task Gene Similarity and Mirror Transformation. IEEE Computational Intelligence Magazine. 16. 38-53. 10.1109/MCI.2021.3108311.
[2] Cui, Zhihua & Zhao, Ben & Zhao, Tianhao & Cai, Xingjuan & Chen, Jinjun. (2023). Adaptive Multi-task Evolutionary Algorithm Based on Knowledge Reuse. Information Sciences. 648. 119568. 10.1016/j.ins.2023.119568.
5. 平台上代码
将此代码加入到MTO-Platform中上即可,平台网址:https://github.com/intLyc/MTO-Platform,代码路径:“Algorithms\Multi-task\Multi-population”。
classdef MTGA < Algorithm
% <Multi-task> <Single-objective> <None/Constrained>
%------------------------------- Reference --------------------------------
% @article{Wu2018MultitaskingGA,
% title={Multitasking Genetic Algorithm (MTGA) for Fuzzy System Optimization},
% author={Dongrui Wu and Xianfeng Tan},
% journal={IEEE Transactions on Fuzzy Systems},
% year={2018},
% volume={28},
% pages={1050-1061},
% doi={10.1109/TFUZZ.2020.2968863}
% }
%--------------------------------------------------------------------------
properties (SetAccess = private)
pTransfer=0.4
MuC = 2
MuM = 5
end
methods
function Parameter = getParameter(Algo)
Parameter = {'pTransfer: Portion of chromosomes to transfer from one task to another', num2str(Algo.pTransfer), ...
'MuC: index of Simulated Binary Crossover', num2str(Algo.MuC), ...
'MuM: index of polynomial mutation', num2str(Algo.MuM)};
end
function Algo = setParameter(Algo, Parameter)
i = 1;
Algo.pTransfer = str2double(Parameter{i}); i = i + 1;
Algo.MuC = str2double(Parameter{i}); i = i + 1;
Algo.MuM = str2double(Parameter{i}); i = i + 1;
end
function run(Algo, Prob)
% Initialization
% population = Initialization(Algo, Prob, Individual);
population = Initialization_MT(Algo, Prob, Individual);
scale=ones(Prob.T,Prob.T); % adjust nTransfer dynamically
nTransfer0=round(Algo.pTransfer*Prob.N);
while Algo.notTerminated(Prob)
for t=1:Prob.T
for prevTask=1:Prob.T
if t~=prevTask
%从前一个任务中迁移一些染色体去繁殖
%迁移策略是迁移过去的变量减去前一任务的均值,加上当前任务的均值
nTransfer=round(scale(t,prevTask)*nTransfer0);
mPrev=mean(population{prevTask}(1:nTransfer).Decs);
mThis=mean(population{t}(1:nTransfer).Decs);
tempPopulation=population{t}(end:-1:1);
for i=1:nTransfer
ids=randsample(Prob.D(prevTask),Prob.D(t),Prob.D(prevTask)<Prob.D(t));
tempPopulation(i).Dec=population{prevTask}(i).Dec(ids)+mThis-mPrev(ids);
end
% 任务内交叉变异
offspring = Algo.Generation(tempPopulation);
% Evaluation
offspring = Algo.Evaluation(offspring, Prob, t);
% Selection
intpopulation=[population{t}, offspring];
Ep=0;
CV = intpopulation.CVs; CV(CV < Ep) = 0;
Obj = intpopulation.Objs;
[~, rank] = sortrows([CV, Obj], [1, 2]);
rnvec = intpopulation(rank).Decs;
population{t}=intpopulation(rank(1:Prob.N));
% Update scale by rank
[~,ia]=intersect(rnvec,offspring(1:2:2*nTransfer-1).Decs,'rows');
mRank=mean(ia);
scale(t,prevTask)=min(1.5,max(.6,(.3-(mRank/length(intpopulation)-.25*Algo.pTransfer))/.2));
scale(prevTask,t)=scale(t,prevTask);
end
end
end
end
end
function offspring = Generation(Algo, population)
indorder = randperm(length(population));
count = 1;
for i = 1:ceil(length(population) / 2)
p1 = indorder(i);
p2 = indorder(i + fix(length(population) / 2));
offspring(count) = population(p1);
offspring(count + 1) = population(p2);
[offspring(count).Dec, offspring(count + 1).Dec] = GA_Crossover(population(p1).Dec, population(p2).Dec, Algo.MuC);
offspring(count).Dec = GA_Mutation(offspring(count).Dec, Algo.MuM);
offspring(count + 1).Dec = GA_Mutation(offspring(count + 1).Dec, Algo.MuM);
swap_indicator = (rand(1, length(population(p1).Dec)) < 0.5);
temp = offspring(count).Dec(swap_indicator);
offspring(count).Dec(swap_indicator) = offspring(count + 1).Dec(swap_indicator);
offspring(count + 1).Dec(swap_indicator) = temp;
for x = count:count + 1
offspring(x).Dec(offspring(x).Dec > 1) = 1;
offspring(x).Dec(offspring(x).Dec < 0) = 0;
end
count = count + 2;
end
end
end
end