差分分组合作协同进化MATLAB代码

合作协同进化已经引入协同进化算法,目的是通过分而治之的范式解决日益复杂的优化问题。理论上,协同改 变子成分的想法是十分适合解决大规模优化问题的。然而在实践中,没有关于问题的先验知识, 问题应如何分解是尚不清楚的。在本文中,我们提出一个自动分解策略,称为差分分组,可以揭示决策变量的底层交互结构和形成子成分,以使它们之间的相互依存关系保持到最低限度。我们在数学上展示这样一个分解策略如何从部分可分性的定义中产生。实证研究表明,这样的近最优的分解可以大大提高大规模的全局优化问题的解决方案的质量。最后,我们展示了这样一个自动分解是如何产生对多样的子成分的分布的更好的近似,导致一个对多样的子成分的计算预算的更高效的分配。
更多内容访问omegaxyz.com

索引词:合作协同进化,大规模优化,问题分解,不可分性,数值优化
点击查看合作协同进化算法概述
run.m

% Author: Mohammad Nabi Omidvar
% email address: mn.omidvar AT gmail.com
%
% ------------
% Description:
% ------------
% This files is the entry point for running the differential gropuing algorithm.

clear all;

% Specify the functions that you want the differential grouping algorithm to 
% identify its underlying grouping structure.
func = [20:-1:1];
for i=func
    func_num = i

    t1 = [1 4 7 8 9 12 13 14 17 18 19 20];
    t2 = [2 5 10 15];
    t3 = [3 6 11 16];

    if (ismember(func_num, t1))
        lb = -100;
        ub = 100;
    elseif (ismember(func_num, t2))
        lb = -5;
        ub = 5;
    elseif (ismember(func_num, t3))
        lb = -32;
        ub = 32;
    end

    opts.lbound  = lb;
    opts.ubound  = ub;
    opts.dim     = 1000;
    opts.epsilon = 1e-3;

    addpath('cec2010');
    addpath('cec2010/datafiles');
    global initial_flag;
    initial_flag = 0;

    [seps, nonseps, FEs] = dg('benchmark_func', func_num, opts);

    % filename = sprintf('./results/F%02d.mat', func_num);
    % save (filename, 'seps', 'nonseps', 'FEs', '-v7');
end

dg.m
更多内容访问omegaxyz.com

% Author: Mohammad Nabi Omidvar
% email : mn.omidvar AT gmail.com
%
% ------------
% Description:
% ------------
% dg - This function runs the differential grouping
%      procedure to identify the non-separable groups
%      in cec'2010 benchmark problems.o
%
% -------
% Inputs:
% -------
%    fun        : the function suite for which the interaction structure 
%                 is going to be identified in this case benchmark_func 
%                 of cec'2010.
%
%    fun_number : the function number.
%
%    options    : this variable contains the options such as problem
%                 dimensionality, upper and lower bounds and the parameter 
%                 epsilon used by differential grouping.
%    input3 - Description
%
% --------
% Outputs:
% --------
%    sep      : a vector of all separable variables.
%    allgroups: a cell array containing all non-separable groups.
%    FEs      : the total number of fitness evaluations used.
%
% --------
% License:
% --------
% This program is to be used under the terms of the GNU General Public License 
% (http://www.gnu.org/copyleft/gpl.html).
% Author: Mohammad Nabi Omidvar
% e-mail: mn.omidvar AT gmail.com
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar


function [seps, allgroups, FEs] = dg(fun, fun_number, options);
   ub        = options.ubound;
   lb        = options.lbound;
   dim       = options.dim;
   epsilon   = options.epsilon;
   r         = ub - lb;
   dims      = [1:1:dim];
   seps      = [];
   allgroups = {};
   FEs       = 0;

   while (length(dims) >= 1)
       allgroups;
       n = length(dims)
       group = [dims(1)];
       group_ind = [1];

       p1 = lb * ones(1,dim);
       p2 = p1;
       p2(dims(1)) = ub;

       delta1 = feval(fun, p1, fun_number) - feval(fun, p2, fun_number);

       FEs = FEs + 2;

       for i=2:n
           p3 = p1;
           p4 = p2;

           temp = 0;
           p3(dims(i)) = temp;
           p4(dims(i)) = temp;

           delta2 = feval(fun, p3, fun_number) - feval(fun, p4, fun_number);

           FEs = FEs + 2;

           if(abs(delta1-delta2) > epsilon)
               group = [group ; dims(i)];
               group_ind = [group_ind ; i];
           end
       end

       if(length(group) == 1)
           seps = [seps ; group];
       else
           allgroups = {allgroups{1:end}, group};
       end

       if(length(dims) > 0)
           dims(group_ind) = [];
       end
   end
end

analyze.m

% Author: Mohammad Nabi Omidvar
% email address: mn.omidvar AT gmail.com
%
% ------------
% Description:
% ------------
% This file is used to analyze the performance of the differential
% grouping algorithm on CEC'2010 benchmark problems.
% This program reads the data files generated by differential 
% grouping and shows how many variables from each formed group
% are correctly identified and to which permutation group they
% belong.
%
%--------
% Inputs:
%--------
%    funs: a vector containing the functions ids the functions that you 
%          want to analyze.
%
% -----------
% References:
% -----------
% Omidvar, M.N.; Li, X.; Mei, Y.; Yao, X., "Cooperative Co-evolution with
% Differential Grouping for Large Scale Optimization," Evolutionary Computation,
% IEEE Transactions on, vol.PP, no.99, pp.1,1, 0
% http://dx.doi.org/10.1109/TEVC.2013.2281543
%
% --------
% License:
% --------
% This program is to be used under the terms of the GNU General Public License 
% (http://www.gnu.org/copyleft/gpl.html).
% Author: Mohammad Nabi Omidvar
% e-mail: mn.omidvar AT gmail.com
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar


function analyze(funcs)
    more off;

    % Number of non-separable groups for each function in CEC'210 benchmark suite.
    numNonSep = [0 0 0 1 1 1 1 1 10 10 10 10 10 20 20 20 20 20 20 20];

    for f=funcs
        filename = sprintf('./results/F%02d.mat', f);
        p = 1:1:1000;
        load(filename);

        mat = zeros(length(nonseps), 20);
        drawline('=');
        fprintf('Function F: %02d\n', f);
        fprintf('FEs used: %d\n', FEs);
        fprintf('Number of separables variables: %d\n', length (seps));
        fprintf('Number of non-separables groups: %d\n', length (nonseps));

        filename1 = sprintf('./cec2010/datafiles/f%02d_op.mat', f);
        filename2 = sprintf('./cec2010/datafiles/f%02d_opm.mat', f);
        flag = false;
        if(exist(filename1))
            load(filename1);
            flag = true;
        elseif(exist(filename2))
            load(filename2);
            flag = true;
        end

        printheader();

        for i=[1:1:length(nonseps)]
            fprintf('Size of G%02d: %3d  |  ', i, length (nonseps{i}));
            m = 50;
            if(flag)
                for g=[1:1:20]
                    captured = length(intersect(p((g-1)*m+1:g*m), nonseps{i}));
                    fprintf(' %4d', captured);
                    mat(i, g) = captured;
                end
            end
            fprintf('\n');
        end

        mat2 = mat;
        [temp I] = max(mat, [], 1);
        [sorted II] = sort(temp, 'descend');
        masks = zeros(size(mat));
        for k = 1:min(size(mat))
            mask = zeros(1, length(sorted));
            mask(II(k)) = 1;
            masks(I(II(k)), :) = mask;
            %point = [I(k) II(k)];
            mat(I(II(k)), :) = mat(I(II(k)), :) .* mask;
            [temp I] = max(mat, [], 1);
            [sorted II] = sort(temp, 'descend');
        end
        mat = mat2 .* masks;
        [temp I] = max(mat, [], 1);
        if(ismember(f, [19 20]))
            gsizes = cellfun('length', nonseps);
            fprintf('Number of non-separable variables correctly grouped: %d\n', max(gsizes));
        else
            fprintf('Number of non-separable variables correctly grouped: %d\n', sum(temp(1:numNonSep(f))));
        end
        drawline('=');
        pause;
end

end
% Helper Functions ----------------------------------------------------------
function drawline(c)
    for i=1:121
        fprintf(1,c);
    end
    fprintf('\n')
end

function printheader()
    fprintf('Permutation Groups|  ');
    for i=1:20
        fprintf(' %4s', sprintf('P%d', i));
    end 
    fprintf('\n')
    drawline('-');
end
% End Helper Functions ------------------------------------------------------

更多内容访问omegaxyz.com

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值