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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

, o- E$ s6 d  j& k5 V8 I! w合作协同进化已经引入协同进化算法,目的是通过分而治之的范式解决日益复杂的优化问题。理论上,协同改 变子成分的想法是十分适合解决大规模优化问题的。然而在实践中,没有关于问题的先验知识, 问题应如何分解是尚不清楚的。在本文中,我们提出一个自动分解策略,称为差分分组,可以揭示决策变量的底层交互结构和形成子成分,以使它们之间的相互依存关系保持到最低限度。我们在数学上展示这样一个分解策略如何从部分可分性的定义中产生。实证研究表明,这样的近最优的分解可以大大提高大规模的全局优化问题的解决方案的质量。最后,我们展示了这样一个自动分解是如何产生对多样的子成分的分布的更好的近似,导致一个对多样的子成分的计算预算的更高效的分配。
( T2 G, i$ A) k# I2 \* E" @2 {; G7 I. ^: {% B* D
索引词:合作协同进化,大规模优化,问题分解,不可分性,数值优化 ( p: i( O' D3 i4 O/ Q
# j' z6 Z# C7 F

+ q* l! f( q3 \run.m
/ }! G3 g- @" k  m. G* [/ p
0 ]% V0 ^2 q/ k0 Y. a! U; K. T% Author: Mohammad Nabi Omidvar
! N  g$ E; t) \6 G4 f! T% Y* ]% email address: mn.omidvar AT gmail.com
# E0 C6 W# m) q% f+ K: e; B/ Q+ p%
4 z/ z' D# f- M! n" b; \, J% ------------
" C' B( n0 v6 D% N7 [# i( n) H% Description:
7 \5 Q7 b7 S5 m5 e1 J# l- i  h. R3 k% ------------
6 b( C; ~/ `) R; h  K% This files is the entry point for running the differential gropuing algorithm.
. d# T8 J6 o, T
" x+ Q& f# |& _: o, q2 Lclear all;+ }* L9 o  q2 ]4 Z  y: Z
, S) B7 Y" O0 |5 M
% Specify the functions that you want the differential grouping algorithm to # U' e6 M  s1 f  v. G. p- C9 \
% identify its underlying grouping structure.. V- V5 A. c1 t- g) u, E
func = [20:-1:1];
! `. ~0 [! v' E) E( G# s& l) ^for i=func) k/ }9 m, N1 V! e7 r$ L% k
    func_num = i
2 z/ N8 {) L$ ?( E
" U5 I3 u( u& U  ^4 w# T2 N: s    t1 = [1 4 7 8 9 12 13 14 17 18 19 20];
2 V: H& H# B, w* i$ w9 e) ^' y, P3 F    t2 = [2 5 10 15];
, n; r7 m2 a8 g/ [7 ^# U( ]0 }    t3 = [3 6 11 16];4 a3 }' I; S7 ~& W
  K0 C  {+ i3 S8 o
    if (ismember(func_num, t1))
8 d9 u# T4 {3 \3 s( y        lb = -100;2 I8 v& y9 b1 s) w+ J
        ub = 100;3 G$ c, h' l' {$ l2 M; W: |
    elseif (ismember(func_num, t2))
) y  b3 p1 C8 p        lb = -5;
: D* N% J' D1 |% y        ub = 5;
2 W( ]" i4 t& a) d    elseif (ismember(func_num, t3))3 Q/ q! O; Z/ u1 e  k
        lb = -32;
) C9 U1 V* n4 P; ]        ub = 32;9 B6 I$ r9 Z; _, g; }9 R) d: U: R
    end# ]3 B, N% g5 O

  a$ E! c8 y' F" y    opts.lbound  = lb;
' U  g/ t! l9 I7 z9 y7 Q8 N, r- I    opts.ubound  = ub;
( b, A4 i% b/ Q* C    opts.dim     = 1000;0 j. R5 n' y- D4 L
    opts.epsilon = 1e-3;
+ W% [! G. j, E8 h. u: i& }& Q- `$ G( g$ O) U! K
    addpath('cec2010');
+ A0 ]% C) }1 B! i+ _    addpath('cec2010/datafiles');
. {% X% B$ c8 C: D' @: G    global initial_flag;
2 V" v5 S. N9 y0 U* B8 ~- V    initial_flag = 0;8 H4 {" R0 b' d* T9 q; _% [& T

, I/ Q' A, T8 v- S    [seps, nonseps, FEs] = dg('benchmark_func', func_num, opts);
& x) M! d& \! }8 F9 S0 z) o4 s6 B
& q8 b; _8 }4 o# D/ i    % filename = sprintf('./results/F%02d.mat', func_num);
% u0 G! \% v0 Z9 I4 C2 ?    % save (filename, 'seps', 'nonseps', 'FEs', '-v7');
2 r4 c- o* y- }7 |- J# Send8 P5 M/ ~1 `; Z& ~) p) {
# k( w0 }. D, U- G# C3 f

9 ?% ]% j0 L4 x6 c& d8 v, xdg.m
4 J$ h7 l. w0 ]7 L, K6 u
$ e2 B5 G2 |4 r) C% z2 ~! T) Z% Author: Mohammad Nabi Omidvar
( w; @# V* r2 |! N7 p/ g  I% email : mn.omidvar AT gmail.com
4 o) A0 @4 h( x3 R7 h%5 _  V2 I( v! S) ~( e8 V! W
% ------------. k- F0 M; I$ p" u0 D- ]2 C7 E
% Description:" P' H+ Y; h# s
% ------------& E5 Y9 Z9 t! a4 J: V+ B! ^
% dg - This function runs the differential grouping5 p: j0 P# @3 W* r
%      procedure to identify the non-separable groups
: M* Y* o5 D; @. M' g+ k. D%      in cec'2010 benchmark problems.o
: `6 }# }" ~% d6 H0 v%
* `: _3 F& j' A4 g% -------
; X8 ^6 u0 g' _1 g  r% Inputs:
6 P' e, h" {0 f% Y* N% -------+ c! P/ Q: I* R: k2 Z
%    fun        : the function suite for which the interaction structure
+ [4 I+ b+ Q7 U# m# b9 I0 T- E. S%                 is going to be identified in this case benchmark_func
" ^" L7 G" @: y/ N0 [( |  b( R%                 of cec'2010.; f  u4 M; s& _8 z9 p
%# F1 R6 T  D; q
%    fun_number : the function number.
! y# u3 _; h- b& y: s%5 O8 ^4 o1 Z8 T* }; K! ?
%    options    : this variable contains the options such as problem$ z6 Z$ [% e1 X! d( g2 t* h
%                 dimensionality, upper and lower bounds and the parameter 3 y# b, r' j$ T/ l
%                 epsilon used by differential grouping./ C) ^; ^1 j+ F+ R
%    input3 - Description8 @8 t( X, M3 A) d+ H! M
%1 F! s/ Q. Y6 a9 g# ~: {6 [7 R
% --------
: H- O/ u! V0 l! {" h& B" @" D% Outputs:6 {& r0 [3 b% Q( g4 o" m, _
% --------
0 T3 @+ z0 x  N' g0 n2 K! T%    sep      : a vector of all separable variables.
* w  p. q/ |: N$ M  t, V%    allgroups: a cell array containing all non-separable groups.
. w- R+ e' [7 i& ?+ W%    FEs      : the total number of fitness evaluations used.- V1 i& Q% n& t# z+ w4 r0 q
%
  ~: [7 l+ V$ B* n' T% --------" S" K& D  O/ G* T  C: g
% License:+ Q: {; M, D* o! n5 a  |' o
% --------- [$ q2 z" @0 Q: f! _
% This program is to be used under the terms of the GNU General Public License
* f* H5 j% k6 `0 r! h- p% (http://www.gnu.org/copyleft/gpl.html).1 \) m- v+ Y7 D% A+ c) x
% Author: Mohammad Nabi Omidvar
8 u9 |" {1 m5 [% e-mail: mn.omidvar AT gmail.com
  W, m9 D9 s" K- u% Copyright notice: (c) 2013 Mohammad Nabi Omidvar
! I$ K) Q/ L  ?" Q( l+ B: ^5 A& U. k4 x7 M' X

- z% X# U( q/ ]3 ?: a' Wfunction [seps, allgroups, FEs] = dg(fun, fun_number, options);/ `; J1 H% p3 G& x) q& b
   ub        = options.ubound;
1 ?# ~/ q& N" v7 F   lb        = options.lbound;: V% L8 L, `. ?& \, i' Q& q9 s! b9 l' z5 U
   dim       = options.dim;
- s8 Q. \% h3 y/ d   epsilon   = options.epsilon;
/ J; A, H" `' N  F; s   r         = ub - lb;& C( G/ P) ~' c+ s  T9 I
   dims      = [1:1:dim];0 T! @- m" V! Q0 q% B4 G! k
   seps      = [];
( C8 o9 ?1 x) ]& }   allgroups = {};
5 V( ?7 F9 q8 f% l   FEs       = 0;( o1 W& x; t8 r, ^, b

% m" o' @) c% |   while (length(dims) >= 1); E# q% H- a- Q; c0 z) g
       allgroups;1 r3 {2 M! t, Q: e! j( y
       n = length(dims)
, q; W# Q4 S" I, A' |# _* m       group = [dims(1)];2 F8 f+ M  ~( [2 b; N' d' ^4 G
       group_ind = [1];
! J* G- V* v9 _% q0 N$ f& [
# `) N6 D& |! `+ Q4 j; B& o. T       p1 = lb * ones(1,dim);
1 |" n0 O) q/ l' G" B       p2 = p1;4 S, G( w# R( [; g( @' J8 a- X( W
       p2(dims(1)) = ub;
. q6 D& w. _; u  A
6 t. N3 _' b# A8 L       delta1 = feval(fun, p1, fun_number) - feval(fun, p2, fun_number);, m  v9 U2 _6 [" X

4 o3 P" |+ ~* u1 W* H* E       FEs = FEs + 2;
5 X* L9 o8 |3 D5 P- P) c& N4 F% t4 B$ }7 e/ R
       for i=2:n9 c6 ~  Z, E* a; Z1 S
           p3 = p1;
8 T( w7 F& s" J6 z  b& t9 {           p4 = p2;& n2 [0 {7 d1 P; T: f$ A6 c

9 z) M% n( b8 }2 F! [1 h           temp = 0;' h5 g0 P, R$ ^$ U
           p3(dims(i)) = temp;+ |+ N  ~6 L9 d- l( l" w7 v/ S* q
           p4(dims(i)) = temp;  @% A9 E  ~3 [2 G& H5 Z9 I
' F1 t/ ~+ e0 {  |  }8 b! K* F
           delta2 = feval(fun, p3, fun_number) - feval(fun, p4, fun_number);& B, n2 C+ N$ t- X

" q4 \" p/ d  s           FEs = FEs + 2;5 G: I5 \) e1 l( |, f+ a

4 w' `6 ^" X  Q) ]/ v3 L- X( q           if(abs(delta1-delta2) > epsilon)
3 _  M/ G- p% O: ?, c- ]! z               group = [group ; dims(i)];
/ c/ h; G; N* K               group_ind = [group_ind ; i];
, w, f2 q' O6 }8 b  h: `6 j% A           end; L( ~9 x* r4 c
       end% X* q. W- ?1 U$ ^# h  q

/ m: h! G. \- E6 T0 y9 s6 _  R       if(length(group) == 1)) s0 c, a/ E/ _/ B: F7 f
           seps = [seps ; group];- e# Q0 K( m  q9 Q
       else
9 ^4 p, k% ]2 v8 N% @3 Z3 I  P$ y           allgroups = {allgroups{1:end}, group};
: D5 N  P, ]* L9 R  m       end
7 {* D$ P9 Y: t( x" z2 N
$ n  A1 B) p, @0 }" p5 O$ l+ K% Y9 ^* |       if(length(dims) > 0)
4 s3 F8 a7 [- t/ P# g8 w8 n0 e           dims(group_ind) = [];  H$ _/ k9 y. a: i7 B, N7 q
       end
! J: v2 c2 v$ O. K1 f" J   end& H3 q* Y% n$ }0 p
end
2 u5 N4 l# a2 e9 u. }9 K) r
: ]$ j1 j1 z1 G3 N! g4 R0 u- A5 O8 V( W- \8 s$ g- @; J0 i
analyze.m
+ }: @7 F( ]' l, J0 ~3 S
+ m% c, S" ^. S+ C' B% Author: Mohammad Nabi Omidvar: a; R+ I8 G! h3 g
% email address: mn.omidvar AT gmail.com
: @+ f+ I5 q( {9 _) h. O%
! v% X5 e  _( S* J% ------------
2 `) g- t9 t$ W2 f3 C% Description:
. `0 _0 d( ~2 z- L% ------------2 F$ ~1 a$ h3 W# G& |  X
% This file is used to analyze the peRFormance of the differential
. G: q8 j" r9 N; Y7 Q% grouping algorithm on CEC'2010 benchmark problems.
' X( N7 ~& B6 ^5 ~, ^, a% This program reads the data files generated by differential 7 l6 ~* z8 b6 p/ H; c
% grouping and shows how many variables from each formed group
% `# Y0 n8 P) F7 @) |& L! l% are correctly identified and to which permutation group they! D) I& Q. b! R% d0 Y
% belong.
7 M: P+ k1 T- j% `/ x  E( ^%/ }! {. P: }2 U& r! K
%--------
* `9 R; Y; M8 k/ {; N* K" P. [! ?% Inputs:
7 x9 a+ \0 k8 }%--------
0 Q/ @* m- ~" b! D/ Y3 d1 m%    funs: a vector containing the functions ids the functions that you
3 L9 o' _  ?! _8 A2 a' F5 J%          want to analyze.* x6 O) n' p  L/ Z1 x) I/ q1 o( ?3 ~
%
1 C: D+ T: x; |8 \/ D5 ?: H+ {# R% -----------/ E2 p" e9 f& C% U1 {& {, e" P* S
% References:; w# p; P% l/ j- G0 k6 [
% -----------( `" o( r5 {  i) F. @5 U
% Omidvar, M.N.; Li, X.; Mei, Y.; Yao, X., "Cooperative Co-evolution with2 V! y% i* Z: N$ o* w; R! `, K9 _
% Differential Grouping for Large Scale Optimization," Evolutionary Computation,
% C* O6 z$ \+ m1 E, R; H& K% IEEE Transactions on, vol.PP, no.99, pp.1,1, 0$ W0 k1 f/ w' N' Q" Y
% http://dx.doi.org/10.1109/TEVC.2013.22815434 A# G* A. Y) \) X
%1 o2 W# b( ?2 r* M  c. m% y9 @
% --------
- [. a7 v* ~+ l* I1 D" |: A5 k% License:& i1 M6 b4 t' \" X
% --------' P: s4 h6 B, ^2 k8 G( ?6 P( ^4 S
% This program is to be used under the terms of the GNU General Public License   X' d4 |7 P* g4 g5 j, y: v
% (http://www.gnu.org/copyleft/gpl.html).
4 ~/ i/ v; E* ^  b0 l. c" S# F% Author: Mohammad Nabi Omidvar3 p  C& k7 I# y
% e-mail: mn.omidvar AT gmail.com
7 D5 k/ a3 B/ r4 p& e% Copyright notice: (c) 2013 Mohammad Nabi Omidvar
; W3 @9 [: I6 O0 i2 P1 g4 X' P& n6 R2 g0 }! ^) k
$ N+ \/ Z+ _( K& {
function analyze(funcs)7 B  {, F* S& E! N) ]% z4 o
    more off;
# P9 R' ?3 g5 {# l1 X  @) U
- m7 Z; @# O9 z/ |! ]9 j6 R5 d    % Number of non-separable groups for each function in CEC'210 benchmark suite.
1 F7 F# g* y& x  E( t1 x    numNonSep = [0 0 0 1 1 1 1 1 10 10 10 10 10 20 20 20 20 20 20 20];( {/ B* d& T1 p, f
' Z) P. ^% |4 n3 S  A# i9 s
    for f=funcs
+ N2 c4 g! u, f        filename = sprintf('./results/F%02d.mat', f);7 p9 i! \- L! x6 ~9 P0 x( m
        p = 1:1:1000;/ _$ V5 ?  Y8 W  S
        load(filename);
& v0 D) z) I1 a. S' o9 s, o' Z1 t
        mat = zeros(length(nonseps), 20);
. \: }8 [1 u3 f  d        drawline('=');
6 y' w- u' P8 }4 V8 `        fprintf('Function F: %02d\n', f);
( L* g* i7 `0 v0 M5 Z9 H        fprintf('FEs used: %d\n', FEs);% Z9 B" ^. F& |- o+ l6 _' y
        fprintf('Number of separables variables: %d\n', length (seps));
" s- F" f4 R( {* T% t        fprintf('Number of non-separables groups: %d\n', length (nonseps));
) z( D8 K& \9 f. W5 i. z6 I; |8 r% V" U- R3 C$ ?, S3 l% D
        filename1 = sprintf('./cec2010/datafiles/f%02d_op.mat', f);
5 N1 U. d: \! p1 f        filename2 = sprintf('./cec2010/datafiles/f%02d_opm.mat', f);" q. `; T) r, ]7 W5 f
        flag = false;
9 Y; ^* w! z- z2 f  i        if(exist(filename1))
4 S' z$ s: \' J            load(filename1);6 F* \5 Z8 K1 t) G  [4 D
            flag = true;  n6 p7 B' i/ y9 S6 V* @7 y/ w
        elseif(exist(filename2))* ]% l! d2 v1 q+ l
            load(filename2);& @  ]% s* [! W7 ?( h( S
            flag = true;
. l) Q* U/ K" Q        end
1 E1 j, U4 K+ V6 d
8 L5 A0 Z: [( M& c* P$ n- G8 u) m        printheader();
/ J3 F) V+ t# p* r  d1 O( I
6 D- O$ T9 t1 F6 D1 M7 k        for i=[1:1:length(nonseps)]
4 M, i0 G5 O, s" _5 j+ O* c            fprintf('Size of G%02d: %3d  |  ', i, length (nonseps{i}));
/ B$ Y2 E, J* Y& N) F            m = 50;/ J% h1 V% |+ [$ Z+ k9 Y3 e( N" ~2 N
            if(flag)5 F/ T/ {3 Z1 ?
                for g=[1:1:20]
( f4 l! l& R& ]- M5 V6 v% U3 g: d                    captured = length(intersect(p((g-1)*m+1:g*m), nonseps{i}));
- m1 J- A& I# m                    fprintf(' %4d', captured);
6 V4 d. [. H$ ]* x                    mat(i, g) = captured;
. F& q1 N! h$ ?; X8 @. ?                end
+ i& t2 K* L7 G. L$ `( i8 s            end+ M% Y# \  v3 b9 s% f3 s
            fprintf('\n');
+ ^2 O; M# e* t+ W        end. K5 a1 d3 |) ?* V

  ?/ m6 J# G8 d* y  v6 m) ]7 w        mat2 = mat;* ?% [+ d: j' y, X; f5 w* n
        [temp I] = max(mat, [], 1);. e/ i- h4 m* U# R3 K! o' g
        [sorted II] = sort(temp, 'descend');
6 q& e; c: Y9 @, b/ s$ U        masks = zeros(size(mat));
) \! l2 i3 p( F' S& a/ ]$ V        for k = 1:min(size(mat))! u/ b' F' \. y/ i
            mask = zeros(1, length(sorted));
* W# f6 C- ?& S+ t3 v. I! x8 X3 z            mask(II(k)) = 1;
0 {0 X) H) l3 }2 @            masks(I(II(k)), :) = mask;, f* u! ?# u' e5 M2 b- F6 T
            %point = [I(k) II(k)];9 k5 [7 j- x% e
            mat(I(II(k)), :) = mat(I(II(k)), :) .* mask;- O" G' d  t" H2 S, [  v
            [temp I] = max(mat, [], 1);1 _) ]# ]+ p6 R/ j
            [sorted II] = sort(temp, 'descend');+ E- R$ c0 D; B/ g9 o
        end9 W' s) D( X" F7 W' G
        mat = mat2 .* masks;
% Y) w6 n  Z, w        [temp I] = max(mat, [], 1);" X- [+ g1 _& \
        if(ismember(f, [19 20]))
: x- Y3 W9 o# b  t2 G( _            gsizes = cellfun('length', nonseps);% F* O, H$ `0 N0 X. z' B6 \
            fprintf('Number of non-separable variables correctly grouped: %d\n', max(gsizes));
0 G: r. x6 `$ r( K6 e        else) B" o1 o$ J- W( H5 j, [
            fprintf('Number of non-separable variables correctly grouped: %d\n', sum(temp(1:numNonSep(f))));7 z9 [! D$ J$ G1 Z
        end
7 s) h$ u0 T- B# ~/ j7 Z3 [, e! ^        drawline('=');
8 \$ x; C+ C8 \3 V1 N9 Q) `; n/ ?6 Y        pause;/ [! p: m  A, ^
end" T* y+ o: @4 \' p: l( H
, j& A1 k& M: d- H3 s# w) U; m
end/ {  D; @6 K0 i1 ~+ s- ]3 }
% Helper Functions ----------------------------------------------------------
4 E0 S, p+ k8 bfunction drawline(c)
' C1 z, U: b1 |  b, O7 f    for i=1:121
  k% @  N9 V2 G- P6 x        fprintf(1,c);
( n: C0 C( t: F6 V/ \' O    end! n4 f7 i8 L. b4 U: @. ?
    fprintf('\n')
9 b" g: @6 t+ m7 J2 ?end3 z- r8 s0 t3 Z! Y) T7 `- a  Y$ N6 u/ C

# R$ e+ E6 p3 P, m& yfunction printheader()
3 G8 U& N+ e  {) m  X6 p) T    fprintf('Permutation Groups|  ');
4 b4 ?, O( X9 J    for i=1:20
9 P( o4 B. d* g- V- I  d/ S        fprintf(' %4s', sprintf('P%d', i));1 \! w2 P4 M% k/ e7 H7 k' p
    end * i7 K) A8 k9 r+ m( T" h# o7 h2 l
    fprintf('\n')
' X+ ^) R6 c# h3 J* _0 {5 L    drawline('-');
- l9 t7 w2 B. {, uend
$ b* X! N. B+ v. x: w- g; J% End Helper Functions ------------------------------------------------------/ M' [4 |, Z! `$ _' l4 e0 p) l
: e$ g" y9 q; s6 \' n9 @; I' t
' Z" X; b+ G3 Y# H) o/ X( y+ ~
  • 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-24 07:38 , Processed in 0.171875 second(s), 23 queries , Gzip On.

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

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

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