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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

5 i/ S( g2 s/ H+ ~& z5 v合作协同进化已经引入协同进化算法,目的是通过分而治之的范式解决日益复杂的优化问题。理论上,协同改 变子成分的想法是十分适合解决大规模优化问题的。然而在实践中,没有关于问题的先验知识, 问题应如何分解是尚不清楚的。在本文中,我们提出一个自动分解策略,称为差分分组,可以揭示决策变量的底层交互结构和形成子成分,以使它们之间的相互依存关系保持到最低限度。我们在数学上展示这样一个分解策略如何从部分可分性的定义中产生。实证研究表明,这样的近最优的分解可以大大提高大规模的全局优化问题的解决方案的质量。最后,我们展示了这样一个自动分解是如何产生对多样的子成分的分布的更好的近似,导致一个对多样的子成分的计算预算的更高效的分配。
: ?" w4 l9 ^& c, F' R8 E4 e0 N6 z- M& u9 W8 A- S( w
索引词:合作协同进化,大规模优化,问题分解,不可分性,数值优化
' h$ G- R9 |! d" O# m7 o7 G( W1 J
9 y5 U7 g  `8 g$ X' v& x
run.m
8 g8 ^8 ^9 }& {# |0 y  ?- _( l. Q) e: N3 }. ~8 I7 v
% Author: Mohammad Nabi Omidvar- n" [6 l( ?. }
% email address: mn.omidvar AT gmail.com' i! I4 C5 y1 [
%' s) k: N2 O6 t
% ------------5 i3 i1 b4 d/ O7 [" r+ s( j# |
% Description:
5 \4 [# b- M% f0 D3 P% ------------" E9 q  H9 d2 |+ g- S
% This files is the entry point for running the differential gropuing algorithm.( I& k& g) B8 _9 _2 R% ~9 K

' w4 q/ J7 h' W0 h. c3 V% J; q- C2 \clear all;
& g, ^1 z5 X: \' x
/ y9 f( z6 N& o1 i) h$ ~! _; F! Y  k7 D% Specify the functions that you want the differential grouping algorithm to
; t$ t+ \/ o! B) D4 g; S4 ?8 a% identify its underlying grouping structure.% Y4 _' J! d1 G4 S3 i
func = [20:-1:1];! f4 `% e3 |" k7 j7 D7 E
for i=func$ d! r: @6 G% p7 J0 c) g
    func_num = i
( j$ `( h; D( y0 M) D
1 _- N7 g) s- X7 l    t1 = [1 4 7 8 9 12 13 14 17 18 19 20];
* A  U$ i3 x% \" j1 d; D    t2 = [2 5 10 15];5 c6 o) ~$ ^2 \, d, {2 {+ t( ~- ]) I
    t3 = [3 6 11 16];' n0 S2 r, W  M& G% v
# q0 ]) ]0 h3 l, A
    if (ismember(func_num, t1))1 F# L8 S% ~: b1 j  @( b: A2 e
        lb = -100;
3 \9 T1 C& F8 Q+ j! P$ Y, Q6 n4 g# i        ub = 100;/ l; x# D! h8 [$ n% @3 P0 t
    elseif (ismember(func_num, t2))
/ T) u* ^0 r' i! W- J) p; J4 c3 Y( R        lb = -5;
  V2 L$ |3 A! C/ W2 [        ub = 5;
! w* k. e( K4 s5 N- G6 j: f' }% J" t    elseif (ismember(func_num, t3))
* G2 n9 f" Y3 _1 N5 q/ h% D        lb = -32;6 [/ `; a- E7 s1 l8 u
        ub = 32;9 U/ }. q( l; K* A- D- ]9 c
    end
- S, a8 J2 y9 F* f5 D0 ^! u
6 V5 h7 ^2 T! b' x    opts.lbound  = lb;
: M# y. A, P+ L3 x    opts.ubound  = ub;& ~/ w, J3 q6 m6 m  M- X4 ?6 R- x
    opts.dim     = 1000;7 `6 O) }* B- f
    opts.epsilon = 1e-3;
: M5 Q8 B0 }7 h3 k2 T" {$ s- h
0 n: z2 ]& G4 M) w1 T. |, p% h% y    addpath('cec2010');
5 E/ j" h0 I( L- z    addpath('cec2010/datafiles');
. x9 p- X4 g+ |" J9 v8 @% g    global initial_flag;6 T+ M2 ]! M; c8 ~8 l: r
    initial_flag = 0;
0 y/ ?) W; ^0 G- l4 d7 E5 p
1 c9 q  I$ w; R# O    [seps, nonseps, FEs] = dg('benchmark_func', func_num, opts);
7 o8 o; G. ], C: X; S5 O
$ U8 `* q. Z* ^: m# k. X4 b    % filename = sprintf('./results/F%02d.mat', func_num);0 l; h5 B+ i1 {2 i* v' g
    % save (filename, 'seps', 'nonseps', 'FEs', '-v7');
% e- {; ^$ ?0 w) Q- Jend
3 i. H8 w6 h6 i; `% e
9 G7 b  V, V" R2 {! z4 P) X% O" ?% W7 f1 f; q7 E8 c
dg.m 1 x$ e( B5 R4 R$ ^9 M7 s

4 K* H9 J" u8 ~, s/ z% Author: Mohammad Nabi Omidvar! s7 o( j+ V% r
% email : mn.omidvar AT gmail.com
* y, f+ `0 h8 i7 y%# A& h% d/ x9 T& s$ o
% ------------/ t& e! I3 D: I0 e2 Y+ O
% Description:) ^  q+ v; f( z% e1 B7 `" ~
% ------------
: A8 D% S" _# q" ]7 A% dg - This function runs the differential grouping# u  Z# Q" {  I, b1 m4 u
%      procedure to identify the non-separable groups, h# j  O) V, H  Y0 I
%      in cec'2010 benchmark problems.o% q5 F2 F3 W; W2 Y% E+ Y
%
& {2 d/ v6 D, }7 O! h6 {, A% -------6 W1 K' n/ ^4 Y
% Inputs:2 ^1 I' ?; D/ r: S
% -------
" ]3 F: p8 {! j+ ?: i- l5 K. p7 w%    fun        : the function suite for which the interaction structure 7 N8 w4 d& T8 n) Y& r3 v) c
%                 is going to be identified in this case benchmark_func
* h( ~, {' c4 `: ^' x9 W%                 of cec'2010.
& ]/ c) \3 B* ]1 _%' V# P, j' k1 E4 R8 ~
%    fun_number : the function number.
" ~* {0 B0 ?0 b) {9 U# Y%- b- @8 f1 }; F6 Z" L
%    options    : this variable contains the options such as problem
  t8 n1 @# j. V8 u%                 dimensionality, upper and lower bounds and the parameter
; Y' Y' Q8 C2 N%                 epsilon used by differential grouping.
% ?" ?; X: ?3 a7 p+ ]%    input3 - Description& m0 }! g! R8 }( a+ f7 s. i
%1 b) S( e( k# Y, H5 K! j. V" I
% --------
2 s6 j, {& A2 j% Outputs:- z  ]" ?  q: p8 F
% --------( W8 ]- r/ W6 c& A  ~7 @/ z6 d  X
%    sep      : a vector of all separable variables.! a: j; S, s5 C3 r' Z
%    allgroups: a cell array containing all non-separable groups.
3 C  G+ n! `# f%    FEs      : the total number of fitness evaluations used.
0 c: l2 @0 G+ F' z%
0 e9 b) g! l' z# f! \, w% --------
2 }# T: t1 z4 v: W3 o% License:4 P& H4 Y7 H3 a* X8 K( B6 p
% --------
: I# k6 m6 u+ Q- f3 K8 e. |% This program is to be used under the terms of the GNU General Public License
$ b/ ?* Q; d( |6 k/ E" y; J% (http://www.gnu.org/copyleft/gpl.html).
2 n4 O* w* P3 [% Author: Mohammad Nabi Omidvar
& U! G+ E( y) o8 M) X% e-mail: mn.omidvar AT gmail.com5 x3 d9 m( f0 o- D9 U5 B) U
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar
# ~& [# D8 h* l9 _5 c, \, \( o+ D0 W9 E% ^1 R

0 B. i) |' ~* k* H' V0 E) T7 n9 mfunction [seps, allgroups, FEs] = dg(fun, fun_number, options);
! L* k( l5 g. r4 z9 Z   ub        = options.ubound;
1 U2 C3 q8 D' p0 s- v. A4 i( F* _2 L   lb        = options.lbound;
! s$ {6 ^# q8 |   dim       = options.dim;8 e5 I: B3 n& Z; E
   epsilon   = options.epsilon;/ Q$ n* Z  A8 ^0 R
   r         = ub - lb;
' @0 z/ Z1 D# H- y- j   dims      = [1:1:dim];
% j8 e* ]2 w2 {- L1 d   seps      = [];
. H- h. j/ b% L% [1 u   allgroups = {};' d) d1 T+ d( z
   FEs       = 0;4 P  I& }5 r6 D& E
, Z, d' I8 S$ T& h* S2 ?* G( ~
   while (length(dims) >= 1)$ W1 P6 L; w* W5 c/ ~
       allgroups;7 o# T- O/ S5 b9 w- U
       n = length(dims)
% b- o) T0 e' `6 B- o8 R       group = [dims(1)];
, `3 a% O2 U& @4 D: U       group_ind = [1];
3 R; G, r3 Y9 l1 b3 x/ m* X- z0 o
       p1 = lb * ones(1,dim);
6 q9 X" ?2 {; }2 @       p2 = p1;- |5 ~; M0 C; X+ l1 V( ~3 t, R0 l5 r* q
       p2(dims(1)) = ub;$ c/ f; I  ~; d+ n
# N9 k' P9 j, @- t( \  Y
       delta1 = feval(fun, p1, fun_number) - feval(fun, p2, fun_number);2 k3 y( M# x' ~% Z

$ k; s% H; X( d+ [; ~4 E. W       FEs = FEs + 2;. ~- C8 q* u; y# i2 P- A1 N
9 F6 J' b# a9 m5 e( x9 \5 c: Q2 O
       for i=2:n
$ @- ?( J0 A( |           p3 = p1;. }- L' m( M2 M; k/ H7 M" J
           p4 = p2;
; H; G, D! x) l. J
; i: q( ~4 o2 V- S$ F  n# \" c1 V           temp = 0;* _  T0 j' I! y. p
           p3(dims(i)) = temp;8 V2 ?  {! y! _! `
           p4(dims(i)) = temp;
0 f4 [+ A) c7 R6 @
# s3 G% M* v9 k1 b& I( `           delta2 = feval(fun, p3, fun_number) - feval(fun, p4, fun_number);
8 j+ W7 x6 T+ |* S
+ ^8 }5 b! ^& @& N/ I  P! m- N4 Q/ m           FEs = FEs + 2;2 X" ~% X- C& a% }( f
) y  A* h" S4 t# }' {, M- |8 _7 z
           if(abs(delta1-delta2) > epsilon)+ l* p. b& b; B: K1 w: [; ^
               group = [group ; dims(i)];
; ^! m8 C2 E$ V6 S  a               group_ind = [group_ind ; i];
) P; N4 z3 [2 X* `+ M0 w' q9 v           end; p, e/ @3 R# Y3 o  l) ?
       end: t: F; ]5 z! {9 a4 ?& l. M# M5 C$ O
. T* G+ _) g- N* N8 R) R
       if(length(group) == 1)8 O$ t8 X: {0 w, c
           seps = [seps ; group];+ N( a- V9 [( N- B3 B
       else1 R4 s2 }* O/ |' c
           allgroups = {allgroups{1:end}, group};- E: ]8 ~, I; M2 M. Q, T$ P6 t
       end
$ l8 X( Y( f- Z  Y5 c0 ~, A
( i, o, M/ |' E" S: o- M+ v       if(length(dims) > 0)
, i- p- ~! v9 f1 _: F' D9 R/ ^           dims(group_ind) = [];# t4 b" ~+ n  D/ S9 g% \/ n
       end  R+ B! G1 e0 U8 w. g
   end$ B* R% f5 O( H1 l
end  t. u' p; g- G; O
: C+ T% j2 w6 G9 T0 V  \" F

/ Z8 n* o$ u( Y) |1 ^8 Kanalyze.m
, z5 S" i4 }( S* Y* }2 u% M" @+ v; d  x
% Author: Mohammad Nabi Omidvar5 {8 h2 ]( L# c% S
% email address: mn.omidvar AT gmail.com
5 \, N9 h# Q* q% }- O/ y%
0 w  ^5 z& {1 {. N. d- W" X% ------------
' U; Y% f( b0 K) c0 S% Description:- ~! q: G* I+ X, ]( {. f, j
% ------------* g5 `: {! e8 Q# V& i
% This file is used to analyze the peRFormance of the differential
( A1 j, b  C* z% grouping algorithm on CEC'2010 benchmark problems.6 K6 E- j# P1 j) f9 d
% This program reads the data files generated by differential
5 M  E5 t# K5 O% j% grouping and shows how many variables from each formed group# V+ Z! e% Y. z
% are correctly identified and to which permutation group they
6 v$ W5 P9 O) L4 v2 v% belong.
8 J* v' M8 \& j1 z6 N+ K%2 j) o. @# I- p
%--------
" D+ N7 |7 s8 S. M  \1 G% Inputs:1 z- u  ]/ R1 p' t
%--------. T$ S5 n7 E2 k; |" P- ?2 [
%    funs: a vector containing the functions ids the functions that you
# |; M- @& ]" |; _9 |/ v" d%          want to analyze." _" g" T6 G* W. e) F
%7 a) n+ r7 }! U0 r( e- v
% -----------1 i7 J  h0 S0 I/ \- A" k
% References:
. [: z6 z; w- D' V% -----------
" ]- O8 _  @2 {* n% Omidvar, M.N.; Li, X.; Mei, Y.; Yao, X., "Cooperative Co-evolution with* h$ [: z) o" C  N) X
% Differential Grouping for Large Scale Optimization," Evolutionary Computation,
" ?" C4 t0 y* n+ R! @% IEEE Transactions on, vol.PP, no.99, pp.1,1, 0
* N  R, Y8 g: \# p% http://dx.doi.org/10.1109/TEVC.2013.22815439 \4 [0 T# ?0 f; r9 |2 A& L
%
' q9 }+ p9 ]0 L% --------4 U- `: ?5 P9 W' L1 s1 ~& {
% License:# a; ^3 [* O8 s1 o
% --------  Q2 g$ D" D5 R1 w
% This program is to be used under the terms of the GNU General Public License 6 f  _' n( }0 m( w* @0 L1 w
% (http://www.gnu.org/copyleft/gpl.html).
6 H+ w/ j! Q4 T# \2 T) L% Author: Mohammad Nabi Omidvar% \5 d8 R9 \, G3 Z6 j
% e-mail: mn.omidvar AT gmail.com; |$ @; J$ r2 T! [5 m7 E+ ~) g
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar
1 @  s* ]4 ~% K6 K
% u' a/ B/ z1 d- U2 `$ a" u% r, {/ j4 D6 t4 X) ?6 r+ s
function analyze(funcs)
9 e0 V9 x2 K, x. w2 N; _    more off;+ i* K8 p- ]: V& K& N% m& H! W- p
) g' M* N( |3 q
    % Number of non-separable groups for each function in CEC'210 benchmark suite.3 L6 q. f. K. y* n4 b; z
    numNonSep = [0 0 0 1 1 1 1 1 10 10 10 10 10 20 20 20 20 20 20 20];" S8 o+ d' o* t1 O' Y  O7 T; o, I5 ^

9 n3 f( A2 `: e( [4 s  X  K$ c    for f=funcs
3 t, S$ w. i5 r  z6 }/ K        filename = sprintf('./results/F%02d.mat', f);: ^1 `2 T  G% j0 r
        p = 1:1:1000;8 a. ]9 H4 a" o' J. q  u
        load(filename);+ I  I# K1 m( n

, K! b. d! t6 [        mat = zeros(length(nonseps), 20);
/ {7 z" \0 V0 Q, m& m3 Q5 b9 s        drawline('=');2 \: b# {1 K; t) @) C2 s) \
        fprintf('Function F: %02d\n', f);' k% C& M  u  B3 s4 r
        fprintf('FEs used: %d\n', FEs);
5 N$ O! B/ N3 W9 {& ^        fprintf('Number of separables variables: %d\n', length (seps));) {+ z7 y1 ?' _& s/ ^3 f( K
        fprintf('Number of non-separables groups: %d\n', length (nonseps));
+ R6 F2 P% s5 o0 Z+ S  D" X9 p' b6 n2 `% U" V/ L1 {: M  Z
        filename1 = sprintf('./cec2010/datafiles/f%02d_op.mat', f);
* S7 f5 @; z# M/ a        filename2 = sprintf('./cec2010/datafiles/f%02d_opm.mat', f);
, V* f$ s* z0 `6 G1 J4 x        flag = false;
% h; }: l) f  Z) R8 i        if(exist(filename1))
. `  {, ^2 C8 X' Q  y1 @; q            load(filename1);
8 t# r- A0 R/ `0 ]' ?& F            flag = true;" ?6 P6 |( G0 a6 m/ i
        elseif(exist(filename2))
+ `  f7 r- G3 m" A& C3 u            load(filename2);
4 @9 V9 r; m5 C: e$ h            flag = true;# C! `6 ^8 N/ i# c
        end) G  W0 y! c+ B# n' ^! {3 L; e

; p1 l1 Z7 g' E5 w        printheader();
$ \5 _. l0 ~1 g! X+ O7 |; A* w2 ]+ b8 _- D1 ^4 |2 u# I) i
        for i=[1:1:length(nonseps)]# ?' R7 X4 @$ Y5 C  F& l' l
            fprintf('Size of G%02d: %3d  |  ', i, length (nonseps{i}));. }! x! A. F% K9 {6 ^
            m = 50;
$ Z: R+ K+ {6 @# S- A. \$ z* t            if(flag)+ [$ k- D* B/ H- J* {7 U+ L, ]
                for g=[1:1:20]3 [9 o, |  E% y) H6 @5 w$ M7 D
                    captured = length(intersect(p((g-1)*m+1:g*m), nonseps{i}));6 _* U+ g0 O6 F5 P0 ~5 K) e& b
                    fprintf(' %4d', captured);
, x6 {1 \/ P# ^' r& d8 N0 V                    mat(i, g) = captured;9 {9 a$ Y" E$ P7 T. c
                end/ n: _" O8 R9 \4 n
            end
2 ^5 l9 J% ?; l6 q; I2 m' I            fprintf('\n');
0 P. l6 x9 q, a+ |9 c        end
3 q2 ?9 Y% s% E" {7 O) J, s7 E5 Z! ?+ w; L9 P% z/ F
        mat2 = mat;4 D& n1 I! v2 r/ h
        [temp I] = max(mat, [], 1);
5 g6 K$ z' H- R; X- x        [sorted II] = sort(temp, 'descend');
7 N+ V2 ~5 t! v2 Y9 v; d. H        masks = zeros(size(mat));$ w# s. x- J6 b2 T
        for k = 1:min(size(mat))
! D' G2 u2 V2 ?. k            mask = zeros(1, length(sorted));& a4 H+ D# N- Q7 y
            mask(II(k)) = 1;! U8 z3 w% [- x7 [+ U' i( F+ @
            masks(I(II(k)), :) = mask;
" t+ B- _, ]5 z, v* k            %point = [I(k) II(k)];
; \5 ]* a$ H' L. ]' _            mat(I(II(k)), :) = mat(I(II(k)), :) .* mask;
0 o7 v( R+ V% I+ J            [temp I] = max(mat, [], 1);! r& G! ^( N/ R' g; ~2 u  s
            [sorted II] = sort(temp, 'descend');
5 k! C( f; F5 b0 y8 b1 p0 T        end
" f+ S& d% I& Q+ }$ r7 U        mat = mat2 .* masks;
, f% E* p" S: _0 x1 T        [temp I] = max(mat, [], 1);, O# M. |8 ?2 |6 T* O
        if(ismember(f, [19 20]))1 z5 \+ N7 i* y4 D. l5 p5 o& ^
            gsizes = cellfun('length', nonseps);
) F. N. @$ }1 i4 G0 V; k5 q! r- d            fprintf('Number of non-separable variables correctly grouped: %d\n', max(gsizes));+ K) n3 y$ F4 X  k) N; h0 t' y
        else' U) j9 t# C5 p. U- ^
            fprintf('Number of non-separable variables correctly grouped: %d\n', sum(temp(1:numNonSep(f))));
4 i! Z; E8 r! g* P8 a        end5 ^6 d$ I; C0 r/ A* G! m2 {
        drawline('=');
1 D# L6 i  j# B* b4 s+ b# ?        pause;
0 z: X3 ^4 b/ y6 t( B  q( pend# g" y3 o6 d# c
2 {, ^/ G( x8 \' F$ j: o- U
end
. m# s6 Z& f4 @  T$ |" ^. Q$ L% Helper Functions ----------------------------------------------------------
: C4 a( u+ d5 L) G1 Yfunction drawline(c)
6 [/ Y3 o2 }8 s: D/ [    for i=1:121! W" F6 W2 K! B. L8 N
        fprintf(1,c);  D$ E" O- E- O0 x) w; P
    end
8 D* p; m$ I) O. X/ p- w( Z    fprintf('\n')1 }8 e0 ?3 ^7 E- l7 }
end7 N' s/ O6 {, I* n; ^& V8 G

) M. H# f  o& }1 R1 R& Ffunction printheader()! v$ O& b5 o/ _0 D) E- z) {1 H9 A0 H
    fprintf('Permutation Groups|  ');
7 n- U: e9 F3 M, k# w$ T* S    for i=1:20
( S! q9 }2 o+ p& P        fprintf(' %4s', sprintf('P%d', i));
1 E1 t- }, f$ t' i    end
3 p! n0 s) }( ]( k* Q# x    fprintf('\n')& e* Z# F( |% _% j, R
    drawline('-');8 M: h( U( `8 d/ ^7 ]0 h; F
end
9 d7 C# U! U) q' y5 K2 E' m6 ?) \% End Helper Functions ------------------------------------------------------4 O, A7 t) x, w

4 J  G: B; J  h& X: S" J! f1 P4 y0 S8 }6 B0 a: F
  • 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-11-6 04:27 , Processed in 0.156250 second(s), 24 queries , Gzip On.

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

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

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