找回密码
 注册
关于网站域名变更的通知
查看: 454|回复: 1
打印 上一主题 下一主题

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

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2020-5-25 11:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x

1 Z+ N5 D( g! F0 r合作协同进化已经引入协同进化算法,目的是通过分而治之的范式解决日益复杂的优化问题。理论上,协同改 变子成分的想法是十分适合解决大规模优化问题的。然而在实践中,没有关于问题的先验知识, 问题应如何分解是尚不清楚的。在本文中,我们提出一个自动分解策略,称为差分分组,可以揭示决策变量的底层交互结构和形成子成分,以使它们之间的相互依存关系保持到最低限度。我们在数学上展示这样一个分解策略如何从部分可分性的定义中产生。实证研究表明,这样的近最优的分解可以大大提高大规模的全局优化问题的解决方案的质量。最后,我们展示了这样一个自动分解是如何产生对多样的子成分的分布的更好的近似,导致一个对多样的子成分的计算预算的更高效的分配。
0 k9 c! |, u& ^/ @6 t! P9 N
1 B8 |/ }9 T' L索引词:合作协同进化,大规模优化,问题分解,不可分性,数值优化
2 V: R, R4 x# |3 N; {; Y: L! C; R$ n' j$ v" k: T

( i; k! S- q& r& g. e; |6 X  m; crun.m- f  i& E1 n  t# Y

$ ~, K1 [0 _6 ^6 Z* |- j% Author: Mohammad Nabi Omidvar/ E* l; A, {- S
% email address: mn.omidvar AT gmail.com/ ^2 N* b- f8 u2 `5 e2 ^8 E
%. t7 n; Z# V  H. r
% ------------
$ v2 ~; `# t% g, o# T; q% Description:
2 T, J1 J$ W3 @5 o+ F% ------------2 C! v( N. s% ~! w
% This files is the entry point for running the differential gropuing algorithm.+ u  n: X: F1 @9 k5 C3 R

! {7 O5 j- ~+ ~8 Sclear all;
, Z3 B4 e8 N' r
4 z9 T. J# ?1 `* Q* v) V6 @% Specify the functions that you want the differential grouping algorithm to 3 G- d1 p: L* k/ W
% identify its underlying grouping structure.
7 S  r8 ~3 J8 z" E' ~+ G: Lfunc = [20:-1:1];
8 |+ J; S% l2 I8 x+ M: D: O' Mfor i=func
- e8 h9 y$ |- g0 S6 k    func_num = i1 ^/ [/ y8 z! ^5 u
) Q) b/ H6 p6 z# {/ T
    t1 = [1 4 7 8 9 12 13 14 17 18 19 20];
; P6 N9 {" k6 ]1 b% e6 k2 `    t2 = [2 5 10 15];
3 P6 i6 s: _: N2 M5 K# ?# M    t3 = [3 6 11 16];
9 ?1 M  i: o  h! s- j8 y
/ b3 b5 n% X, z8 d' S! E3 w# M1 P    if (ismember(func_num, t1))
* Q# d1 W4 A( Y5 x! ]        lb = -100;/ w) ~9 {+ p  N% }/ ]( L5 W
        ub = 100;' Q. _: t7 e+ ^" q6 i" z/ ]% P
    elseif (ismember(func_num, t2))
5 c& k* M5 J4 j$ C2 M0 ^        lb = -5;
( B2 L& s; C, h2 T        ub = 5;
5 ~. z# m4 b- a  q/ v- I    elseif (ismember(func_num, t3))
: A7 o: Y9 W) a2 v. ?9 `5 ~/ U1 W5 A# G        lb = -32;1 O$ B! U/ k& O5 d& n! N  n2 a
        ub = 32;
* [9 L1 z4 t0 k* T' {; l    end
1 e3 N8 k4 }! R' v5 \
, Z6 B' M2 P) C5 H  x    opts.lbound  = lb;
! w$ Y# h1 g1 i0 f$ K' p" w    opts.ubound  = ub;( z6 D3 }! Y0 J" Q
    opts.dim     = 1000;6 l/ ]+ [( x% d, J
    opts.epsilon = 1e-3;
# V) K! R+ `. P) V- h& ^, ]
* q. N# A: a) o; Q3 o0 _    addpath('cec2010');1 P, n4 t4 O* S: G
    addpath('cec2010/datafiles');
5 D1 V2 e* |1 ]0 _& k/ A    global initial_flag;  J) s( a1 w4 j3 X- y
    initial_flag = 0;
4 y- Z8 Q! c- e; I" |% C  |# _+ r+ ^. k+ I1 u, o) n. l. l
    [seps, nonseps, FEs] = dg('benchmark_func', func_num, opts);+ C1 _! F0 I' I, i

/ |% r- E' w8 ?* y    % filename = sprintf('./results/F%02d.mat', func_num);" `2 D( i8 V5 n: M* z/ g
    % save (filename, 'seps', 'nonseps', 'FEs', '-v7');' l( @" e& n+ Z: V; ?- z
end; x: b4 H4 S) J2 q9 ^( S" A
6 j$ U1 X5 v0 B% w' s& i  D
. s. R; \- K0 Y8 C( b6 i# {  H
dg.m & f) y9 W0 J$ o- y% v
7 u6 ]1 C7 o" a( _
% Author: Mohammad Nabi Omidvar
, T% _* x7 a, g. L# u6 F) g% email : mn.omidvar AT gmail.com0 O2 k* O1 ^  W' U
%! ]1 }) _- r+ ]9 H9 F6 W! w
% ------------1 z- G& q5 G  Q( y1 W
% Description:
* Q8 c5 W9 b3 w! d% g3 w: `6 N( X% ------------
" b4 m. M( l& Z0 C% dg - This function runs the differential grouping
6 }" p2 M, ?4 J- H4 X: \%      procedure to identify the non-separable groups
4 Q9 f! r- L1 C6 {2 f2 E0 ~%      in cec'2010 benchmark problems.o1 z7 d1 L2 }2 k; r
%9 h2 o$ S  J3 Z; G4 j
% -------2 B6 M; v  j' M
% Inputs:
2 q5 o! \! C9 Q, P0 q% j2 N% -------
- |0 _' x8 [6 J  u0 c%    fun        : the function suite for which the interaction structure ) l( ?7 Z8 j' u* `+ ]
%                 is going to be identified in this case benchmark_func 0 i0 X0 y  n# C5 _, e
%                 of cec'2010.$ h& N- B2 _1 p3 ]' R
%* e* |/ L: S# C; ~
%    fun_number : the function number.1 ~/ ~( W4 m! [: Y& A' z1 r
%+ Q3 o* G6 t9 p& h& ]0 ?
%    options    : this variable contains the options such as problem- D/ K9 ?* x, {" E. U
%                 dimensionality, upper and lower bounds and the parameter 7 ]  \& Y2 d8 t: V- e) S) g9 d9 Z/ _
%                 epsilon used by differential grouping.
# ^- }) T# b; h* R8 g%    input3 - Description
2 P- n# B1 Z; a3 ?; e9 ^%
: w2 e! W# x) U8 S/ G  f% --------5 ?! j8 {) [0 w. X
% Outputs:* t. ~: Y& E! K* }3 m& v% L# I
% --------% k% K: i% T9 {. l
%    sep      : a vector of all separable variables.
9 [' ], v& D3 Y& v9 h6 H0 I%    allgroups: a cell array containing all non-separable groups.
# c( \2 E  F& P( ]%    FEs      : the total number of fitness evaluations used.
* [9 @2 C( v4 I$ T; H%* R6 d: T5 d" J% c2 r5 h5 p
% --------$ U, C7 A/ z6 U; Q: d% o
% License:- q* W0 n2 C( b  Q" k" z9 [
% --------
# i% e, |# d4 q1 Q% This program is to be used under the terms of the GNU General Public License
1 P) P. c# P; w- T! T7 `% (http://www.gnu.org/copyleft/gpl.html).
0 r  h: {1 Y& I9 o% Author: Mohammad Nabi Omidvar" ?0 ~" r: q% ~0 p) q
% e-mail: mn.omidvar AT gmail.com3 o% f8 c! B- \( F: o7 S0 v
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar
- m2 N/ W* l9 n+ r0 G. b8 G4 @& v3 V6 ]- i* a3 ~; D

' a* E  w2 e( |" e7 }function [seps, allgroups, FEs] = dg(fun, fun_number, options);
  b) a3 q9 m. y# W! L8 ?/ z% r   ub        = options.ubound;
6 L' l$ X. q+ p   lb        = options.lbound;; y# N9 D6 H( J" u- Y9 \9 q/ R
   dim       = options.dim;
. B7 n" D$ z9 k, i$ c- T   epsilon   = options.epsilon;/ M8 K3 ^' a( `5 w; M
   r         = ub - lb;
. a0 U4 O1 L7 n9 W* x3 L   dims      = [1:1:dim];& ?. \4 `% I! Q2 _% J$ d+ b5 h7 ^
   seps      = [];
! [$ J; a# ?. G0 a5 }2 @   allgroups = {};) T8 {4 _. t* o5 h* f: q8 H6 f
   FEs       = 0;
4 X$ j# r) \* ?3 @& c( v7 u; Y# ?  @2 w" c6 T
   while (length(dims) >= 1)2 }8 I% h  w4 S1 H8 Y3 n
       allgroups;7 ]+ K# D/ p7 f+ h1 I
       n = length(dims)
- a' p* [4 ^6 X4 P% Z* E2 b       group = [dims(1)];  d) t+ m- K# h( j
       group_ind = [1];1 I' N3 \0 l' v

9 _; ]9 \6 H  O       p1 = lb * ones(1,dim);4 O9 D1 B- o! c
       p2 = p1;
& X5 `/ D5 O2 ~, a       p2(dims(1)) = ub;
% t' k( G0 X1 }  x7 p+ x1 {4 `0 Y  v) q8 C. K, h! I6 M1 E
       delta1 = feval(fun, p1, fun_number) - feval(fun, p2, fun_number);( Y3 M. N' L+ C/ K

' l& V, s4 C* u6 O4 F( g2 f       FEs = FEs + 2;
% ]( [( K: [2 P4 j) h9 B
0 w8 h9 Y* U& G( _* x1 M       for i=2:n/ M/ C5 r, b! u; K
           p3 = p1;
5 `$ M; t# W) z' y) _1 n1 _           p4 = p2;
: w+ ?3 \+ O2 P% a$ n) e* j0 b- r! P- ^5 U* \! n5 j5 i( Q
           temp = 0;
, ~" C6 A+ l. {: q* u           p3(dims(i)) = temp;) y: {1 O+ l. g
           p4(dims(i)) = temp;0 i8 L# R! F$ f+ D4 y4 T) h
1 j! b! j, U2 ]
           delta2 = feval(fun, p3, fun_number) - feval(fun, p4, fun_number);
* `+ ~( [  Z) h( P5 \9 z% x; D
5 L) K/ c0 A( `! ~5 a& e           FEs = FEs + 2;7 A0 E( u1 |+ j8 T! d: C0 E, z

4 R5 |& i# v- O7 C( R           if(abs(delta1-delta2) > epsilon)
4 F6 |# ]. s( x; s               group = [group ; dims(i)];
; l/ ~; ]6 I' m: }1 x               group_ind = [group_ind ; i];4 f; |; I6 a& g7 d" J
           end
: z( m( f3 ~: w, }. A  I       end
. T5 z; Y- l4 M" G# y& ~1 C, \/ t  h
       if(length(group) == 1)
! {$ i  @- D+ I           seps = [seps ; group];
) b8 `) m4 G* m- q. f& X' [% x5 B7 U       else
8 H, P' b* [! g           allgroups = {allgroups{1:end}, group};
2 g: R) `0 |4 ^3 C2 W7 Y       end
, d( r5 j/ A, d, T* [$ A; F7 N3 q9 d) y4 F/ ]2 {
       if(length(dims) > 0)% v: s% D* j/ P9 F. ]6 p8 K
           dims(group_ind) = [];
- g3 L; w8 \% O. l& r0 j       end
! J2 {6 v1 [& Q+ t7 [& T5 f/ D   end
4 i& |$ _7 c0 T, pend
) Q, h3 O9 [1 }' l0 B
' m; j" {* X( t9 g$ o  w3 r
. i! j' o( ~) ]analyze.m3 }+ }7 r: C; O' v) \; `" m7 s

* k# b3 w& M  `  l1 N5 p% Author: Mohammad Nabi Omidvar% \& g" Y+ T& J" Z5 r  {9 I
% email address: mn.omidvar AT gmail.com, G, |7 G; f3 Q- {
%) h) _$ }! |2 T9 H5 Y, t# x% O* E
% ------------
% ]3 R3 y" y. V- ]% Description:. \6 u7 r- H' D# r
% ------------
4 P# K" c: D' b/ f( h  S% This file is used to analyze the peRFormance of the differential6 b, I$ l  J( o
% grouping algorithm on CEC'2010 benchmark problems.
: A! f" W" |! T8 `% z% This program reads the data files generated by differential * w/ M$ v3 L+ R! a
% grouping and shows how many variables from each formed group9 V# K1 m4 P& ^7 ^9 a" F
% are correctly identified and to which permutation group they
, u/ X+ Q- a- L- ~' X% belong.# m  Q3 E( b9 C$ A2 Q9 s
%
5 l6 c: \) Z! ^2 G3 q) o9 g%--------
2 i3 R$ ]6 V$ f& i3 \# t5 i% Inputs:# Y( C3 Q. V: O& }. @6 L
%--------
7 z2 ~3 X+ ^' |. \$ Y1 M%    funs: a vector containing the functions ids the functions that you
9 ]% P: ?  t5 h  o, a%          want to analyze.
* {) Z3 l5 ?2 _" J0 Q2 ?5 Q%" W0 a6 k4 W1 V% l3 M/ W  l
% -----------$ B# q1 Y" |5 e2 u! w/ ]6 {4 Q6 ?0 I
% References:
. b% M) n! K# i4 N7 H( I8 F; G2 \* p% -----------) X9 I( `& _5 s  O. O$ O1 I
% Omidvar, M.N.; Li, X.; Mei, Y.; Yao, X., "Cooperative Co-evolution with. q1 Y! h4 r2 j8 ^% E$ ]2 N4 i' H$ T
% Differential Grouping for Large Scale Optimization," Evolutionary Computation,
- e0 {/ t- Y" C% g# q% IEEE Transactions on, vol.PP, no.99, pp.1,1, 03 K+ `0 W+ n9 b0 {9 g0 Y1 {6 {
% http://dx.doi.org/10.1109/TEVC.2013.2281543
; f" F5 d/ ^) u3 h%" S0 {/ n% ~  T1 ?2 K1 i
% --------
) O2 b0 B  ]* I4 y# o8 e: v( C% License:: U; B& F* S6 d* z) T( t
% --------
. u9 b* v' u6 d8 J: d# \% This program is to be used under the terms of the GNU General Public License
! A, V4 i1 {. f- z+ p- j$ E1 _% (http://www.gnu.org/copyleft/gpl.html).
: L8 Q( B/ W0 L- r) O( ~) ?% Author: Mohammad Nabi Omidvar$ \6 p: @0 N3 x0 E1 N' d
% e-mail: mn.omidvar AT gmail.com% _$ d8 R2 G& y. Y9 D$ F
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar; @( h9 e$ R2 J. p0 H) T0 @( p/ f5 @
4 Z$ `: V* \( Z4 q$ K) n! v: n

0 `- H* J* ]2 L4 \% d4 pfunction analyze(funcs)
/ R4 B. r" l! W- \6 A    more off;
4 A! ?5 A" G, ~2 n  |* p2 D! t- l5 i( h' c
    % Number of non-separable groups for each function in CEC'210 benchmark suite.
! r% q5 g7 M% [$ L- i$ Y    numNonSep = [0 0 0 1 1 1 1 1 10 10 10 10 10 20 20 20 20 20 20 20];  U3 z( A4 d- ]4 d" M  _  l

: B' i. d) Q1 p    for f=funcs1 S* B, X7 a4 Z+ ]8 |
        filename = sprintf('./results/F%02d.mat', f);
# ^: U! s, l& n' _9 f7 q        p = 1:1:1000;6 D5 O5 L# \  m7 g3 N5 h  H# V1 p
        load(filename);. O% T" h  |$ Y9 g

% K. c( J* F0 r+ G% e! Q7 S' R        mat = zeros(length(nonseps), 20);
* O, ]# x2 n& |0 r- P- a8 c) S9 o        drawline('=');1 m8 d6 y' E2 \5 }; i  Y7 ?/ i: d
        fprintf('Function F: %02d\n', f);
0 Z+ o" ^) S% d1 y# v7 r) ]        fprintf('FEs used: %d\n', FEs);$ F$ w3 `4 U# R2 m
        fprintf('Number of separables variables: %d\n', length (seps));
! u# j; d8 P+ ?7 T0 M/ _) X* z        fprintf('Number of non-separables groups: %d\n', length (nonseps));
, v+ U! k  E& |* E$ f. S. W3 Y: A" Y; \+ s
        filename1 = sprintf('./cec2010/datafiles/f%02d_op.mat', f);3 W4 [" l2 ^& z5 J4 k
        filename2 = sprintf('./cec2010/datafiles/f%02d_opm.mat', f);- ~$ G" H# @6 r+ z/ t4 V0 s# T
        flag = false;
$ k! C# i& ^3 n" n9 j% W        if(exist(filename1))
* C+ q1 b' r9 Q% i2 E7 J3 R$ T* P            load(filename1);" G# n& Z  B/ Q. G; w) q
            flag = true;( ?1 H4 }" \7 N$ s
        elseif(exist(filename2)): {+ B3 `7 m4 ^  s4 f  n! a
            load(filename2);
) l) ?. R" _2 k- @4 j% V            flag = true;
; R  z  T& c* k9 S* I/ o: Y9 G        end' \& p0 h- q6 b1 M( ?1 j
7 z6 M8 ]. {) O, J1 ~8 V0 I" A
        printheader();/ A# @0 t: y1 ]

' v) s' N; ^5 Y* m5 J' j& q        for i=[1:1:length(nonseps)]
* Z9 t9 G* j  \1 b) |0 L( F            fprintf('Size of G%02d: %3d  |  ', i, length (nonseps{i}));
- r8 ~3 L; P! a9 j- y0 [+ w            m = 50;2 Q: X% _4 m- P
            if(flag). e- j7 x5 }" w. y
                for g=[1:1:20]
# ^+ S8 f- j: C# t0 b! y                    captured = length(intersect(p((g-1)*m+1:g*m), nonseps{i}));
6 }, y5 U3 X, x0 W                    fprintf(' %4d', captured);$ j: h5 A+ H7 e
                    mat(i, g) = captured;
% h& M: S/ m/ a' V1 N+ S                end
8 Z/ W/ {5 l5 n( M            end
+ y/ P, Z" @) b( Q  i4 R% `$ u            fprintf('\n');
) W) p$ V" v( ]: S4 @/ u        end# g# `8 S' ?& a8 C+ K! v+ \
6 z/ r. B. {/ Z5 c, `
        mat2 = mat;. z; b0 ]# Y7 ]$ `3 K
        [temp I] = max(mat, [], 1);  ~4 ]+ }  X+ I3 n* V% D
        [sorted II] = sort(temp, 'descend');1 Q1 Q1 n: X( Y
        masks = zeros(size(mat));
+ Q: T8 W4 |, z  F3 m        for k = 1:min(size(mat))
; J; _- \. T! `$ i( ^/ [* J            mask = zeros(1, length(sorted));9 z. s, O- h- P
            mask(II(k)) = 1;
6 H# w0 f9 @' t$ e9 r            masks(I(II(k)), :) = mask;
4 v" Y! f; h$ {2 i$ E; i5 E; o$ z            %point = [I(k) II(k)];
" x5 x! S7 ?( C% d            mat(I(II(k)), :) = mat(I(II(k)), :) .* mask;' Q, S5 v4 z2 P7 n5 I& ^7 C+ e
            [temp I] = max(mat, [], 1);
$ O: g9 D4 H7 F& O            [sorted II] = sort(temp, 'descend');
# _! s* G9 x. r. G        end/ W9 [4 B5 @& o4 J! R
        mat = mat2 .* masks;
. L0 H( U, @. S( _/ k+ N6 a  N        [temp I] = max(mat, [], 1);' d. ^! Z( W9 s$ s. J
        if(ismember(f, [19 20]))' W; f' ?% _* F# P6 r  j
            gsizes = cellfun('length', nonseps);& J, ^0 D! q! J8 G2 K9 N( O
            fprintf('Number of non-separable variables correctly grouped: %d\n', max(gsizes));9 G. B! n. u) e1 C; `% e. m/ T
        else
/ N! p  U6 z6 V4 X4 z. L0 u$ x            fprintf('Number of non-separable variables correctly grouped: %d\n', sum(temp(1:numNonSep(f))));
. H# `6 v+ L8 r4 X) x' U4 @        end  y! d6 l' Q. W5 X2 u2 X; Z2 X
        drawline('=');# D& r& V4 a' n
        pause;
' h( o$ G; t: B; Oend
' n& ], d: {- H/ W7 j8 s$ f$ j
/ ^1 R9 E; c9 d, Z4 ?$ {end( }+ Y; h% C4 E) }; x
% Helper Functions ----------------------------------------------------------
" g+ g$ D9 Y6 n. E* u1 ]4 L  q! Tfunction drawline(c)
( F' u" G2 b% }0 C- m$ \% r    for i=1:121
: j! u9 l6 H: y; Z& t3 w2 Q, {        fprintf(1,c);. O' D' w  n8 P/ q7 I, U
    end  V- W1 j$ L7 ~- w4 `2 N  f7 e  x$ I
    fprintf('\n')
8 R3 G& b! l2 {, S% uend
1 c7 i8 c2 j7 R* C: @+ v) h8 d* V2 g+ Q- O4 b
function printheader()
/ ?' ~5 o( U+ W, p3 U: E4 p, g7 p    fprintf('Permutation Groups|  ');4 `. v/ }* Z; E: c7 d& E
    for i=1:20( Q" ?. [0 D% U- m
        fprintf(' %4s', sprintf('P%d', i));5 V7 q# ?8 a/ q0 r
    end - [, a- i: L# h. i2 q
    fprintf('\n')
* t6 {, e! o* D1 T1 Q    drawline('-');. _- N/ d0 V0 k% R# r3 ~3 X
end! }* Z: G4 P, m: V& |+ [; F
% End Helper Functions ------------------------------------------------------
0 ]6 w! I5 H0 f* B
7 N% l7 W% ]1 o. n
+ _! v3 T: V, }7 K& F4 r
  • TA的每日心情

    2019-11-29 15:37
  • 签到天数: 1 天

    [LV.1]初来乍到

    2#
    发表于 2020-5-25 12:21 | 只看该作者
    差分分组合作协同进化MATLAB代码
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-6-25 11:47 , Processed in 0.109375 second(s), 23 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表