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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

2 }, [+ n) Q; w4 {5 u合作协同进化已经引入协同进化算法,目的是通过分而治之的范式解决日益复杂的优化问题。理论上,协同改 变子成分的想法是十分适合解决大规模优化问题的。然而在实践中,没有关于问题的先验知识, 问题应如何分解是尚不清楚的。在本文中,我们提出一个自动分解策略,称为差分分组,可以揭示决策变量的底层交互结构和形成子成分,以使它们之间的相互依存关系保持到最低限度。我们在数学上展示这样一个分解策略如何从部分可分性的定义中产生。实证研究表明,这样的近最优的分解可以大大提高大规模的全局优化问题的解决方案的质量。最后,我们展示了这样一个自动分解是如何产生对多样的子成分的分布的更好的近似,导致一个对多样的子成分的计算预算的更高效的分配。 , S4 h7 @3 d6 }) C/ x
* ]) {& @; a+ c1 |- z- ?2 n
索引词:合作协同进化,大规模优化,问题分解,不可分性,数值优化 + K1 z* D# H% c4 @) T0 K

  q: l; `- q2 G0 L1 r. v! X0 q
$ h5 f8 e& `3 h0 T- Crun.m* J6 [9 v+ S3 ^4 Q% B

4 \2 G+ B; c1 v' B- Z% Author: Mohammad Nabi Omidvar
& g5 P" D& @! x" W% email address: mn.omidvar AT gmail.com
$ _4 N# s1 {" d9 A* ]. Q% S%7 E3 t& f. s8 x2 j. M; K, `
% ------------
9 a2 D% c. R7 r6 {! d% Description:, v( J2 q0 H3 g
% ------------
- X# \! I2 x3 S4 _3 u& I% u4 x4 t% This files is the entry point for running the differential gropuing algorithm.2 f: q/ Q, ~8 |4 r
/ R, ]4 d+ ?! T3 Y- L) m
clear all;
' K( X, k) B6 }+ e" j6 i  }
; t+ R1 ~% G0 a' g& v( z0 k: _. v8 B+ q% Specify the functions that you want the differential grouping algorithm to
& r4 N. {) q( A5 z9 Y& Q% identify its underlying grouping structure.& c7 I- j% Y+ y  B4 ~& e/ S! B+ O
func = [20:-1:1];
" Z: |* N/ Q4 Yfor i=func) E- J, z. `# l- M1 D  U
    func_num = i
& b+ j0 i: J0 x( o, r' S+ a6 x
( S* j5 ]& q" s0 Z: n/ G+ x/ J    t1 = [1 4 7 8 9 12 13 14 17 18 19 20];
( k. e( `9 r4 L& X% r6 a. Y    t2 = [2 5 10 15];7 V; f# _. m0 n' X& e" ?4 ]
    t3 = [3 6 11 16];
7 n/ }; h- B2 Q* B  S
8 H: b5 Q/ ?4 Z9 {    if (ismember(func_num, t1))
/ c- i  |/ v6 i+ _. e        lb = -100;
# N7 ~+ o" K$ u! S5 b  n        ub = 100;. e7 B% j3 }5 L7 U/ H0 ]# X( T& ^8 y# g" V
    elseif (ismember(func_num, t2))& b$ H; d5 M2 m
        lb = -5;
% a5 ]( t  V1 D' y        ub = 5;% k& i: |3 ]8 A2 |# U$ t5 [$ U# h
    elseif (ismember(func_num, t3))
" W) |# o8 |% ?3 |0 w; N: Q7 H! W        lb = -32;' `: g( b, H' v6 h* \5 d( B
        ub = 32;
0 ]$ h7 r1 N6 `; a    end
/ Q3 v" y+ `; s. I$ K* }
. i0 }/ {( J- |3 }. h" E    opts.lbound  = lb;
+ u' X% _( X; ~    opts.ubound  = ub;) I0 {+ `. v4 Q
    opts.dim     = 1000;
) K/ ?9 a8 Z- h+ g8 U( e% h4 r5 r    opts.epsilon = 1e-3;
: |  E9 y" i0 j3 U/ h, [2 X. l
- V! i3 ?- z. S3 x2 @1 _! x0 k6 m% x$ p    addpath('cec2010');
* w, \& Q, z( a6 N  I: s0 k2 z; r  L    addpath('cec2010/datafiles');
! a" g! j2 ]4 X! k1 {8 P    global initial_flag;
* L& m: W, o: T( s8 P    initial_flag = 0;# H4 h5 W8 }1 ~8 w) c

1 K. P; y5 X( f7 |/ q    [seps, nonseps, FEs] = dg('benchmark_func', func_num, opts);# R7 e6 V! W" B* M/ `" f" n" Z* W

; N3 b0 k/ G' d+ U    % filename = sprintf('./results/F%02d.mat', func_num);
8 @# A$ H9 K9 T) v% Q! W8 d2 O! U    % save (filename, 'seps', 'nonseps', 'FEs', '-v7');/ Y- t1 _8 Z8 V- ?: y# I; K
end
3 A+ q- t- P0 Z3 ^0 g( S, l% H* O& v/ v) N) Y* o: }

$ m5 w- o! H3 {dg.m
- _8 z) C* L2 \. i( \% a5 ], @( N/ P: l2 O' v& I1 X4 d
% Author: Mohammad Nabi Omidvar
9 I5 R5 k0 S: T. U% email : mn.omidvar AT gmail.com
) t: Z6 n8 I$ L%. Y0 K7 G$ F, w0 S* Q
% ------------; m& T! \" z% K1 v. J
% Description:
, k7 @! q/ g& I% o' {4 _0 v5 R3 @% ------------
, _8 W* d* _3 F! U: V% m. \' L" i- o% dg - This function runs the differential grouping( [& j" Q; W3 U7 T( C! Q1 K) E2 G4 [. D
%      procedure to identify the non-separable groups
! b; i5 z! V; V8 }) ^% K5 \# j1 F2 m%      in cec'2010 benchmark problems.o
0 b9 X) T" h8 _6 C) w%. h; v. P0 q2 m# e2 X! i9 Y: M
% -------! ]* L# [. W/ K- l5 s+ [  j, v) K
% Inputs:0 t, y$ H8 h3 |2 R: d* u
% -------. Y- I' U* g4 s; R- J0 L# u6 ]- j
%    fun        : the function suite for which the interaction structure ) [/ I& _# ~* R4 R
%                 is going to be identified in this case benchmark_func
  X. p& c! ?2 ]%                 of cec'2010.
! r' ?8 O5 F, U, k# r" P%
! E; B) _- S9 V6 N1 Z%    fun_number : the function number.
: P) L4 o: r2 E2 m' F3 X: t4 W, I%! R7 {6 x$ ^( V
%    options    : this variable contains the options such as problem
/ Y0 {* I, I" Q" V5 H4 @. x%                 dimensionality, upper and lower bounds and the parameter
1 \- J( B6 e* i6 e9 W* }) t6 z0 @- N%                 epsilon used by differential grouping.+ t- U1 K# x% O4 ?) c
%    input3 - Description# k0 ?4 V) c8 d  u0 ]# v9 U  A
%- r4 Z& j2 P6 M- a
% --------
% O. Q' y6 H$ Z, x% q% Outputs:
+ ^7 K0 @: {6 }: H' D" _% --------8 t) e% o2 g2 b; V' \
%    sep      : a vector of all separable variables.
( X5 d# V* z- N2 P( t8 l! ]%    allgroups: a cell array containing all non-separable groups.9 D0 Y4 j( |9 M5 v& L
%    FEs      : the total number of fitness evaluations used.9 K8 O/ b9 n, O/ d" N
%
& r5 r! Q( }% P# }2 f9 I% |% --------
, `8 }$ E* m$ X8 v% License:
0 l! Z0 @  J4 C9 O% --------! H% l* @% p1 z+ Q4 A1 f1 R0 n
% This program is to be used under the terms of the GNU General Public License
  c* u# n! ~6 V" y8 Q0 Y% (http://www.gnu.org/copyleft/gpl.html).
- Y* A, L4 K" i2 R: m4 E% Author: Mohammad Nabi Omidvar( _& x6 g, A# p
% e-mail: mn.omidvar AT gmail.com
. E$ |3 o0 U% d" T6 |% Copyright notice: (c) 2013 Mohammad Nabi Omidvar7 ^2 {$ x" ^, `8 G6 S
- I# I3 m1 b7 Y/ ]$ c2 b  Z' s

  S, M+ y. b- g1 ~" P: R# |; xfunction [seps, allgroups, FEs] = dg(fun, fun_number, options);
+ J: I; T8 x% w- p) Y   ub        = options.ubound;
) A8 r% R& C, t8 m: ?7 x8 f4 A) i' H   lb        = options.lbound;* z6 w' O" e8 J
   dim       = options.dim;- J; f8 k! s/ U
   epsilon   = options.epsilon;
2 @4 m. Q9 ]0 h- K6 {/ ~3 A  Z   r         = ub - lb;
; z. y6 T: O( V& D6 S, b   dims      = [1:1:dim];, F2 d9 q/ c1 d- P
   seps      = [];, r6 t8 o6 u1 Z6 E' ?
   allgroups = {};
9 E) Q+ H, q- k- M# s: X! w   FEs       = 0;
& }0 W8 i" \0 H; j- W: t1 a+ P: c8 D
   while (length(dims) >= 1)) I) Q' o; i( H7 E" J# Z! T
       allgroups;
# B1 A; J0 g* }, `8 N4 U       n = length(dims)
8 B2 Z$ L4 g8 q  v  R4 G- V       group = [dims(1)];! ?3 K% \. _) n' x4 B; @) j: ^
       group_ind = [1];, p, b, _+ h; ], a! N
/ |( U9 |5 W* A
       p1 = lb * ones(1,dim);, t) W+ D5 W- ~$ d/ s) ~
       p2 = p1;
1 E9 M9 l( a/ o       p2(dims(1)) = ub;
, g$ `9 @+ G% x  \6 D/ U& D% U4 g7 Z
       delta1 = feval(fun, p1, fun_number) - feval(fun, p2, fun_number);
# j& J2 a. ~2 p3 ?& ~
, r5 x- f( x$ S! ^5 t! S       FEs = FEs + 2;- `- ]5 T; K! |" l2 U, L* |3 H

; c) \- W2 l2 R2 O" l3 I       for i=2:n; n  Q' ?# L: S. l2 C# s* I, E
           p3 = p1;
* E8 C0 }: }  c8 z) R           p4 = p2;! ]- d9 y) y$ F7 }: J

: U/ e( _: u" N           temp = 0;
( m5 b0 e7 Q4 O# Q           p3(dims(i)) = temp;
( r+ |  M$ K  m$ t; b" {           p4(dims(i)) = temp;
& F& R- v) W6 T# M4 Z, q
! ~$ G5 o' G# G6 U( O/ l$ U8 B           delta2 = feval(fun, p3, fun_number) - feval(fun, p4, fun_number);8 D' x, L4 J! G  A' O. K
+ w& L! k  [  k9 Y6 s9 j/ S
           FEs = FEs + 2;% X0 ^8 B2 j& V4 d. F- O

( m3 }: N1 D6 o/ l( ?; F# G: }' w           if(abs(delta1-delta2) > epsilon)
1 x# m- P+ J* Q2 o               group = [group ; dims(i)];- m6 V' K0 f$ F
               group_ind = [group_ind ; i];
: h% e; |/ F2 ^5 ^, W' D% z( V           end0 y1 D/ e# \; W# g* o
       end8 o% x" k3 G& L8 R9 f) Z- W% U1 l2 s4 D
3 E2 F- [% S6 {  o
       if(length(group) == 1)# Z9 j- d& c. B5 X$ ?* H& {
           seps = [seps ; group];
5 O2 {8 _. @% {& f) M4 q       else
) F' i* w9 A* @           allgroups = {allgroups{1:end}, group};
1 k; I$ w: G7 }' y2 o       end5 \0 E* q4 M# [7 X

. G( j1 r# G8 F1 i& |/ t       if(length(dims) > 0)
; k2 g, r$ c. v4 b, `6 d           dims(group_ind) = [];
9 N: E3 s5 [- c+ l$ A- E       end
: O+ L$ ^0 i4 P1 H' G3 A   end
2 l3 d5 {+ @( z+ Eend* `3 I, b+ _# ^% P. p

5 K( u- D  A# b$ Q- Q1 {/ W4 s6 O/ }
# [. Q7 C! r2 I. u9 `9 P/ p1 {" fanalyze.m7 Q* V2 m9 P& G' S* _
( ~: F& `' i+ E6 [/ d  n
% Author: Mohammad Nabi Omidvar6 L5 x  e7 h+ g! C+ L; {
% email address: mn.omidvar AT gmail.com# F; S5 `- W4 m) F+ m
%
' z2 U% u; w- g7 ]6 z% ------------
: _/ |1 O2 Z9 \! [; I, M% Description:& @. G) F1 V: O
% ------------! q) O4 c9 z: G
% This file is used to analyze the peRFormance of the differential& t7 C3 @+ O+ y
% grouping algorithm on CEC'2010 benchmark problems.4 ~/ p) M4 D1 D# d( z, p# g
% This program reads the data files generated by differential 6 ?* `5 u  ~) R3 M9 ]: n+ J4 A/ N
% grouping and shows how many variables from each formed group
2 Q# Z6 c" X8 h+ \' j* s% are correctly identified and to which permutation group they
2 g+ F3 `  |8 Y1 ]0 q. y7 q$ n% belong.
9 _4 q" }1 k0 Q1 s+ L0 w: [%
; X- x/ h) L! V0 \9 j' q9 A: U/ x%--------3 p9 L( Y' R$ M3 z+ n" }
% Inputs:
( x3 F5 n0 u  T5 B% j+ w2 r& n# J% i%--------
8 L* _2 A) M& _. V' l* Y%    funs: a vector containing the functions ids the functions that you
9 J( {6 d- x# g9 s+ Y2 [' \/ s$ H% q%          want to analyze./ ^! e; ^# @( K; y  J" b
%$ H3 O- c1 S9 _2 p) g/ z
% -----------: ?  S: A8 z4 K$ m; V% x% f/ \- B
% References:
7 A% z5 G4 e! A: @+ g' y$ i6 P0 w% -----------
. V$ i% ~# x: e5 B% Omidvar, M.N.; Li, X.; Mei, Y.; Yao, X., "Cooperative Co-evolution with! s8 Y7 s* o0 S- s0 r
% Differential Grouping for Large Scale Optimization," Evolutionary Computation,) D9 z9 Z+ M0 g" g: f# a" B
% IEEE Transactions on, vol.PP, no.99, pp.1,1, 0
% x2 N1 [9 @. E: X% http://dx.doi.org/10.1109/TEVC.2013.2281543" D9 P- u* F8 \6 l
%
: s5 W2 w4 m, k; W% --------
8 h& ]* G/ l. ~7 g0 t9 x2 X; x* F, n. f% License:
$ h  ^7 Z" g! a( Y5 e, H% --------; z4 `% @' j; f: J% ^
% This program is to be used under the terms of the GNU General Public License
: A$ s% B7 q$ k' d% (http://www.gnu.org/copyleft/gpl.html).( x7 x5 x" F. k, |0 J$ d6 m
% Author: Mohammad Nabi Omidvar6 d6 v$ k0 l7 Z. a" @. {
% e-mail: mn.omidvar AT gmail.com
5 Z+ o* h, D1 Y. \4 `/ Q: p% Copyright notice: (c) 2013 Mohammad Nabi Omidvar6 c" u% ^! ]0 [& a- u- E! }
* [- I: V" M, N; r+ d) S0 ], F

- O+ N8 b( _, P, S' C) T/ ufunction analyze(funcs)% b+ v, ?; c$ V) \" @! `5 [5 X
    more off;
  L5 [* T6 G) `" C4 h( d
2 V; P. O( J0 R: M8 d5 n  B& d% y    % Number of non-separable groups for each function in CEC'210 benchmark suite.! Z4 e& e- v( ]2 N0 s" ~( M
    numNonSep = [0 0 0 1 1 1 1 1 10 10 10 10 10 20 20 20 20 20 20 20];- I6 T. \) k, U: x; k6 Y3 r+ B

. ]  \' y' w  z7 [1 Y9 F    for f=funcs# u1 C" M: B* x  f
        filename = sprintf('./results/F%02d.mat', f);
- s+ @" z7 ^8 d" t: Y6 d        p = 1:1:1000;
% a4 K' j$ E. \9 k- t        load(filename);  }) k2 P. Z% P! K5 ^
  }: l7 |8 H7 x* @7 C& M# y
        mat = zeros(length(nonseps), 20);3 E* z( p7 i* W  I4 v+ m
        drawline('=');0 {/ O1 Z# F/ c' ?5 Y. \- r
        fprintf('Function F: %02d\n', f);
. ~3 N8 N! w) y( X5 [4 u        fprintf('FEs used: %d\n', FEs);8 N2 d$ j' g4 B; _* A8 t
        fprintf('Number of separables variables: %d\n', length (seps));0 f& Q  {# A. i9 @
        fprintf('Number of non-separables groups: %d\n', length (nonseps));1 v0 k& O6 N: g( a* ?" w

! U9 S5 u5 t$ I: `9 G. y        filename1 = sprintf('./cec2010/datafiles/f%02d_op.mat', f);, y$ a% ?5 L3 G2 y1 D, z
        filename2 = sprintf('./cec2010/datafiles/f%02d_opm.mat', f);! u3 h4 E3 ~* Y; l# Q3 ~. R- m1 F5 ~: }
        flag = false;. [8 b  O* a$ H9 m
        if(exist(filename1))9 k0 P5 `0 m7 m; W% j4 A4 T$ A
            load(filename1);
7 C9 _% ~. \0 ]3 o! \            flag = true;8 @% u8 h6 z. @" k( V- b1 D
        elseif(exist(filename2))
7 ?( u! Q5 D4 {' a* O3 x1 Q            load(filename2);
* d1 c3 b2 `$ A0 a& a% I( u3 @" e            flag = true;+ S  X+ A8 ^( L( M0 ~* ^' q
        end
  [6 ?/ K- r5 m5 O& r/ I; O
. r% ^3 R9 [& q# |, i0 o8 A        printheader();
/ A) `8 t( e7 ?2 m/ j- Q8 x, i( `4 O9 p
        for i=[1:1:length(nonseps)]5 T2 v. G  p( y$ h0 A2 Q
            fprintf('Size of G%02d: %3d  |  ', i, length (nonseps{i}));. I8 h. h8 \& X' V+ j( R
            m = 50;/ ^& n- W1 z9 S
            if(flag)
7 \8 I8 a; {+ _* x5 B3 q8 h0 K- G. t. a                for g=[1:1:20]
& M  U& ~8 h7 J, N- Q                    captured = length(intersect(p((g-1)*m+1:g*m), nonseps{i}));
3 i6 ?, o$ Q& K! S& ?0 I                    fprintf(' %4d', captured);
' r8 W' i1 ~, b                    mat(i, g) = captured;( ~) ?) t: A- m. @- Z4 _) O
                end/ Y8 H' a$ z2 j. {' D& m
            end
% \6 u0 F5 V' Z& g" S- \            fprintf('\n');
/ p" `3 ]3 V, B6 q! E% ^  i        end
5 P; v: D2 o( p$ D4 K* R& n8 m, Z9 P5 D- e& r' w
        mat2 = mat;
+ x4 ?" C/ |% |        [temp I] = max(mat, [], 1);
5 Q, E, v5 D* Y4 y- h) C: z        [sorted II] = sort(temp, 'descend');6 L, T+ @) [  W% F% r7 a* C
        masks = zeros(size(mat));" g! V' }$ X) E3 h* R) s
        for k = 1:min(size(mat))
! Y, T8 M3 J5 C- E7 K" D            mask = zeros(1, length(sorted));2 Q- ]  c/ R0 v# E! z9 ~/ [4 S
            mask(II(k)) = 1;7 L( Z9 \' L  v9 Z3 ]
            masks(I(II(k)), :) = mask;
8 W9 z; ?7 \. h) {2 s            %point = [I(k) II(k)];/ B# i# P( Z9 t0 c5 `3 b1 a3 Q
            mat(I(II(k)), :) = mat(I(II(k)), :) .* mask;
( L( _/ s7 H$ d+ `* n7 Z% ~            [temp I] = max(mat, [], 1);- [2 ?) q% h( k6 ?3 m
            [sorted II] = sort(temp, 'descend');
7 a$ V0 {) B7 j+ E/ h* @        end
4 g6 x) l/ E; j        mat = mat2 .* masks;/ X5 k2 `% ]% e: I# O9 U
        [temp I] = max(mat, [], 1);
, r9 v. \1 V! {! p8 }  J2 c4 N        if(ismember(f, [19 20]))
. q& p$ O& a6 y! t            gsizes = cellfun('length', nonseps);) N: a& f4 |. O
            fprintf('Number of non-separable variables correctly grouped: %d\n', max(gsizes));2 A& K. r; f' ]9 P/ j0 u/ v1 t
        else' B& Q9 O9 F1 J, u6 ~% L7 h
            fprintf('Number of non-separable variables correctly grouped: %d\n', sum(temp(1:numNonSep(f))));
% R! X0 `. Q) T9 n' Z+ a        end1 u+ z( X& T& M- H  j  q8 r
        drawline('=');0 p6 u/ L# B% d4 v0 o, X0 v3 E; ~
        pause;
) `$ X! d* J  f- M6 o: C4 Jend/ b- W8 Y, `2 q# B3 J; s# `

& G+ p' ^, D  J$ U: y. `6 u9 r' {end
2 J( r+ Y/ L$ O% Helper Functions ----------------------------------------------------------
; c( D6 |4 C" x: a9 u* G* `! Sfunction drawline(c), C3 A: e" m* w! [/ q0 b
    for i=1:121+ ?8 P5 B4 u/ N6 x, D
        fprintf(1,c);
7 P' N, v: `$ M7 O4 L8 _7 J    end; Q5 @% r! o' E' `7 o5 I
    fprintf('\n')1 T, O& X% y- e$ _( q8 e
end
- g2 {! k; V2 i7 \
2 {( C; a- M/ R9 ?6 A6 ufunction printheader()% Y; V5 n( s& x! V& C0 i* t9 W% ]$ h
    fprintf('Permutation Groups|  ');
! E- g% L2 N8 ?# |0 y+ ]: ~    for i=1:20' p: d- H& k" m* z
        fprintf(' %4s', sprintf('P%d', i));
- i5 s& o) [/ u" h( q    end
/ \% l; D! F3 o7 Y1 j    fprintf('\n')
( g6 F; ?5 G3 |7 W    drawline('-');! T/ ]- I% E; |' z
end
$ x& I1 r# l7 o- x% y- Y5 a3 h% End Helper Functions ------------------------------------------------------, Z6 _8 W% t. C+ C! s  T. c1 R9 k
/ f' G7 l/ U5 b; T) j
" X# D+ c1 U2 C, 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-7-23 02:14 , Processed in 0.125000 second(s), 23 queries , Gzip On.

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

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

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