当前位置:   article > 正文

差分分组合作协同进化MATLAB代码_协同进化算法 matlab

协同进化算法 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95

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 ------------------------------------------------------
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124

更多内容访问omegaxyz.com

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/178972?site
推荐阅读
相关标签
  

闽ICP备14008679号