|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
/ d8 c/ f2 S$ S$ {. r0 o& S
合作协同进化(Cooperative Coevolution)是求解大规模优化算法一个有效的方法。将大规模问题分解为一组组较小的子问题。而合作协同进化的关键是分解策略。% K( q# \) v2 s+ k/ E
% t7 U9 T2 Y7 [$ f4 `7 v2 y2 X. h
NSGA2算法是一种多目标遗传算法。此文章是随机固定分组的合作协同进化利用NSGA2来优化。
% Y% q8 F% |& G+ p+ Y$ G5 @$ ]: u
& L/ I$ P t- _6 E9 ]比如有12个决策变量,我们固定随机优化3个决策变量,那么就将决策变量分成了4组。3 Q5 g1 b$ J2 K' I
2 J; Q- b6 f- H4 i: n5 bMATLAB主函数代码:
. e( t3 f5 T8 U) S0 N% n! P1 `9 m* J3 B& s9 D9 F# ^
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- clc;
- clear;
- global pop
- pop = 500; %种群数量
- gen = 2; %迭代次数
- global M
- M = 2; %目标数量
- Dim=22; %搜索空间维数(未知数个数)
- sub_dim= 2 ;
- global min_range
- global max_range
- min_range = zeros(1, Dim); %下界
- max_range = ones(1,Dim); %上界
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- divide_datasets();
- global answer
- answer=cell(M,3);
- Dim_index = ones(1,1)*(1:Dim+4);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- chromosome = initialize_variables(pop, M, Dim, min_range, max_range, Dim_index);
- chromosome = non_domination_sort_mod(chromosome, M, Dim);
- result = 1;
- while gen ~= 0
- subgroup = rnd_divide(Dim, sub_dim);
- for i=1:length(subgroup)
- subgroup{i}(sub_dim+1)=Dim+1;
- subgroup{i}(sub_dim+2)=Dim+2;
- subgroup{i}(sub_dim+3)=Dim+3;
- subgroup{i}(sub_dim+4)=Dim+4;
- [temp_chromosome] = nsga2(chromosome(:,subgroup{i}), sub_dim, subgroup{i});
- chromosome(:,subgroup{i}(1:sub_dim)) = temp_chromosome(:,1:sub_dim);
- end
- chromosome = nsga2(chromosome, Dim, Dim_index);
- chromosome = non_domination_sort_mod(chromosome, M, Dim);
- gen =gen - 1;
- progress = 1-gen/10
- end
- plot(chromosome(:,Dim + 1),chromosome(:,Dim + 2),'*');
- xlabel('f_1'); ylabel('f_2');
- title('Pareto Optimal Front');
/ c& T8 }$ [- f: f 5 T N$ j. E0 N( [2 l6 k- Q& }$ R4 E
$ T4 y4 ?- M% w. I: {随机分组代码:
2 r7 X; G6 u7 \2 ]0 M) S! T9 S [5 H. G+ `0 f
- % random grouping
- function group = rnd_divide(dim, subdim)
- dim_rand = randperm(dim);
- group = {};
- for i = 1:subdim:dim
- index = dim_rand(i:i+subdim-1);
- group = {group{1:end} index};
- end
- end! @8 f2 M/ `" O
4 M3 G* h! k7 L: i$ }* ?' V/ F1 y/ L6 Z& o
6 o( @( _( n# m, h" w$ @
! v( h9 `& g( M5 C7 E' ~, W0 i. i
8 @; G+ i$ {# l" Q0 b |
|