随机固定分组合作协同进化NSGA2算法(CCNSGA2)

2021-05-21 16:40:17 浏览数 (1)

合作协同进化(Cooperative Coevolution)是求解大规模优化算法一个有效的方法。将大规模问题分解为一组组较小的子问题。而合作协同进化的关键是分解策略。

合作协同进化算法请见:https://www.omegaxyz.com/2017/10/14/cooperative_coevolution/

NSGA2算法是一种多目标遗传算法。此文章是随机固定分组的合作协同进化利用NSGA2来优化。

比如有12个决策变量,我们固定随机优化3个决策变量,那么就将决策变量分成了4组。

MATLAB主函数代码:

MATLAB

代码语言:txt复制
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
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');

随机分组代码:

MATLAB

代码语言:txt复制
% 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

其它的算法依赖函数与自定义优化函数的NSGA2算法相同https://www.omegaxyz.com/2018/01/22/new_nsga2/

0 人点赞