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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

" j  z2 R+ J+ g" F+ r合作协同进化已经引入协同进化算法,目的是通过分而治之的范式解决日益复杂的优化问题。理论上,协同改 变子成分的想法是十分适合解决大规模优化问题的。然而在实践中,没有关于问题的先验知识, 问题应如何分解是尚不清楚的。在本文中,我们提出一个自动分解策略,称为差分分组,可以揭示决策变量的底层交互结构和形成子成分,以使它们之间的相互依存关系保持到最低限度。我们在数学上展示这样一个分解策略如何从部分可分性的定义中产生。实证研究表明,这样的近最优的分解可以大大提高大规模的全局优化问题的解决方案的质量。最后,我们展示了这样一个自动分解是如何产生对多样的子成分的分布的更好的近似,导致一个对多样的子成分的计算预算的更高效的分配。
- ?( I, x" d0 e" K/ R* [
  A- M% @5 x% w2 K+ s3 _# E5 ]  g索引词:合作协同进化,大规模优化,问题分解,不可分性,数值优化
' C! L. J  M( l1 A" z: q# q5 k. h4 M7 v

4 c8 J' h" a1 X2 S  j/ Z7 m0 crun.m9 J3 T9 Q! n: L% Q+ C- x9 x

9 f9 C0 ~* ?1 a6 n9 {% Author: Mohammad Nabi Omidvar
  z- p/ @9 ?: ]/ M; l% email address: mn.omidvar AT gmail.com, e9 q0 n3 R7 E/ \3 U2 s3 @  R
%3 Z. D$ }$ }& Z- @3 [2 L
% ------------
0 l8 `4 n3 j3 j- c4 |! `% Description:
6 h$ m/ J4 P8 ~3 q" R, w% ------------/ O& u! |; ]* P7 |- i- y" z
% This files is the entry point for running the differential gropuing algorithm.
1 e7 }5 g! h) t( t( p7 \6 O4 Z8 U3 ^
/ `% c  g/ D# m9 Z) g  t! W1 Q- Kclear all;
1 x/ J) G9 B( Q1 R5 y$ t4 I; I5 V3 n* I/ O1 Q1 {
% Specify the functions that you want the differential grouping algorithm to 5 L' U( g0 f& e
% identify its underlying grouping structure.
/ H3 J1 O" ?' C) Q! F- G: Efunc = [20:-1:1];
7 f% r+ L  `6 S7 \3 ~$ [9 S9 zfor i=func: K6 ~9 f$ }- a2 J$ T  I3 E
    func_num = i
3 \; |' p  @6 W% ?: X# U$ b1 s% }! ]# m* u& }
    t1 = [1 4 7 8 9 12 13 14 17 18 19 20];$ D6 {: b9 }) q+ E
    t2 = [2 5 10 15];
$ h  l/ n$ f: @2 q    t3 = [3 6 11 16];. Z, d$ _9 L* s( _- G# {
; [' F( z: \% O
    if (ismember(func_num, t1))
+ I, e4 X3 p, u) Z. ^" r) C        lb = -100;
/ C$ {( C# Q; _8 [! O  n6 X        ub = 100;
" B. e- k5 X$ X- W" P- {, J    elseif (ismember(func_num, t2))
8 O! m/ y* o0 J' M- |+ F, n% J        lb = -5;
: n" B# r% F: |7 k& G        ub = 5;9 [; `4 p% z7 ]# ]1 g
    elseif (ismember(func_num, t3))# W  E- k% y+ y3 H; B5 i
        lb = -32;" A- ~& e: i! h4 m% }; H
        ub = 32;
% o4 L0 l2 h# L( z5 j3 _    end- O) Y* B6 o, w: L/ \6 n
% K6 r. s- c! e: `
    opts.lbound  = lb;
& U8 \$ X6 a# b$ F/ d/ m# x" z3 `    opts.ubound  = ub;
; [2 |0 J$ M+ _$ c, }9 E, ^    opts.dim     = 1000;4 t: Q! n: M7 B/ V
    opts.epsilon = 1e-3;
& X1 `" X8 f1 c/ Z
7 W7 O; R0 K3 d; m% T/ A    addpath('cec2010');
" u- u* R4 l( q$ }4 M$ J! O6 h$ ~    addpath('cec2010/datafiles');$ [) f& Q' m7 \& X8 N" D
    global initial_flag;$ k' o! a+ M$ E# t, x6 g
    initial_flag = 0;) w/ }' `* J- K# m- i5 z. t" y) x
* e! \! M, t! f8 W) [
    [seps, nonseps, FEs] = dg('benchmark_func', func_num, opts);
9 f. D/ R$ _# g1 g
7 N8 X4 ?( g. z2 q  k2 u    % filename = sprintf('./results/F%02d.mat', func_num);
# L" {+ z% W/ }% c  d    % save (filename, 'seps', 'nonseps', 'FEs', '-v7');7 b! ?: e$ n. d* n5 ~
end% ]" a0 [+ {/ b* B
# S( x% P* m7 K
# B: \. N. S2 s. H/ H" D) c
dg.m 1 u; g$ `$ Q0 I# t9 A

6 H* y* u6 E' M% Author: Mohammad Nabi Omidvar
5 S4 h7 g2 w: U% email : mn.omidvar AT gmail.com6 A$ T6 U/ M5 ^6 C! H
%
. P" |. k! J* |7 L: M) m% ------------- b9 L1 a2 t4 ?
% Description:2 X7 a" l. u; q$ x. H7 G* _$ Y: L
% ------------
' T3 }* [! Y1 [2 ^2 O6 H* f  Z% dg - This function runs the differential grouping, d; f4 `( O; u6 m; i8 ?0 G9 ^
%      procedure to identify the non-separable groups& x8 Z3 D/ x1 A: I1 \# Y
%      in cec'2010 benchmark problems.o3 [& o  a  r8 Z3 x$ O6 ^
%+ }  }+ @- W% U2 i/ h# I9 o7 f2 l
% -------
" }8 a* v, G9 ]6 z: A% Inputs:) Q5 S: [4 I4 g) V) s# U
% -------
% k4 x# s8 Z% I7 F6 f%    fun        : the function suite for which the interaction structure
; }9 K3 ?& a1 D1 |' A4 \5 q%                 is going to be identified in this case benchmark_func : m: a, a$ B( w: q
%                 of cec'2010.
* ]( S5 P: R) Z( G) w%& O9 ^' `! ~7 A+ e& C
%    fun_number : the function number.
( |- D+ t5 k4 w* S2 r%
- l0 W& k$ u& O. y! {! o# t0 u%    options    : this variable contains the options such as problem
5 a6 {6 }+ j0 V8 S) F! M+ O# S%                 dimensionality, upper and lower bounds and the parameter 9 H% l, j1 t2 ]2 R9 o
%                 epsilon used by differential grouping.6 Z- Y: N: c2 N& Z/ `8 G8 Z3 o8 R+ s
%    input3 - Description: o1 a: Y1 p+ P, R6 D3 ~
%
- i7 E5 H7 d' J( }# k) w4 O% M( }% --------
4 {& t+ m; b+ J) k% Outputs:5 W" A! J/ ?; H. |& E7 H
% --------4 i' J. C7 @9 K2 q% A# y& N
%    sep      : a vector of all separable variables.
( }+ p9 k) R0 A%    allgroups: a cell array containing all non-separable groups.
- z  m+ i4 y. o4 O%    FEs      : the total number of fitness evaluations used.1 f9 m! k  r3 ^
%, g# Y8 j/ c0 B3 m. C! L
% --------
% ]! t$ [$ H. }! Y% License:: |* U' g+ S4 ]9 i
% --------
* W7 h5 }' q' n! ]! D2 V  G% This program is to be used under the terms of the GNU General Public License   n1 y8 Y5 ^5 ^* y6 {& G
% (http://www.gnu.org/copyleft/gpl.html).
+ x' e! o* P% j% Author: Mohammad Nabi Omidvar
5 t! Z: V" q2 k; d$ X% e-mail: mn.omidvar AT gmail.com# S5 z- c* b/ d  Y; \) g" ^
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar) c& U9 w- M# X8 m8 N# P6 q" k

+ G& _9 N* b1 \4 I8 `
; ~& k$ U* }: p, a  Y: |6 Ufunction [seps, allgroups, FEs] = dg(fun, fun_number, options);( @1 L) `/ x* W6 x: ^' ^. D% C
   ub        = options.ubound;; [0 N; h6 O; \  u, s) q
   lb        = options.lbound;3 l  s# d. Q% f1 }3 }" q5 ]: i& `
   dim       = options.dim;
% C; Y9 @& E. a% U   epsilon   = options.epsilon;
* U; I' @$ J# `; z: o4 k1 v   r         = ub - lb;
$ f8 s6 v9 H% X3 h( `# T   dims      = [1:1:dim];
+ G+ `4 ]/ W. Q& a; _   seps      = [];2 I( J4 l! y. {& i! M
   allgroups = {};0 c+ q- s; J( h# Z3 F* Y3 m8 y6 C- H7 |
   FEs       = 0;
* i/ W4 W, j( Z: W5 Z* i* q' h3 E7 K# h1 b" h$ K- S
   while (length(dims) >= 1)
! F/ Y9 T! U4 C7 u       allgroups;. Y( ~. u$ [: ~8 S$ f4 ?  O
       n = length(dims)
( l; z: Z$ ]  @       group = [dims(1)];8 @) W8 `1 r# Y8 m) C
       group_ind = [1];- i; h9 }) K( ?; A7 j

" b: q* Q: a8 L" u! `  K( P       p1 = lb * ones(1,dim);
* m8 o; f) H1 E. e" K# v, ~       p2 = p1;; ]9 s2 y3 K- U1 M' d5 e2 z0 A
       p2(dims(1)) = ub;# D+ }2 R! N+ J% L+ x' B( B% U

. C0 D9 F* j/ L( b+ d  V/ I) m" x' I       delta1 = feval(fun, p1, fun_number) - feval(fun, p2, fun_number);) \2 D& j8 Y% P2 d* c+ f3 I

2 @7 N: m/ [# h       FEs = FEs + 2;. l5 _  ~. e3 \) T" y) Y: p
& Q/ k6 y$ o% J6 W5 f
       for i=2:n9 I" X! W* t; I7 G: t( a) C7 ^
           p3 = p1;
! _1 ]; t! I) P" w           p4 = p2;
& {' [- a, t/ f" e  g' e! b$ C8 b: c
3 k; E( s3 e# F8 y- h+ i1 H           temp = 0;- _5 D  G8 T. S& U
           p3(dims(i)) = temp;; i" D8 K7 l4 F. x! j1 R4 y3 [
           p4(dims(i)) = temp;, m6 r* p9 r# @2 a* z- I
* N9 B6 r9 J# S3 \( K) C( J% @
           delta2 = feval(fun, p3, fun_number) - feval(fun, p4, fun_number);
  h* {+ z1 V! Y' T) R. @1 e$ r" K  K: F! ]' V- H# C/ ~+ T6 ]
           FEs = FEs + 2;
) g$ l1 ?4 q" z; B# D% N' }+ j; |- H3 B0 r. F1 V2 N
           if(abs(delta1-delta2) > epsilon)
! d  a2 z, L2 v% j               group = [group ; dims(i)];1 ~5 q2 k# S7 i$ w3 a5 w9 f
               group_ind = [group_ind ; i];
8 w! k% }. P0 I           end3 c( f; \2 W8 r
       end
) v& g5 |0 _8 h" q
* j! ?" x3 \( l- `" T* _1 @" I       if(length(group) == 1)
: X7 Q  |" m4 @; H8 B9 T/ `4 G           seps = [seps ; group];
4 \, c) m4 }6 [% X  `- [       else. `4 t+ i# B4 l6 b# B" v- y
           allgroups = {allgroups{1:end}, group};
; ?4 z) [2 c* O; X) R       end
/ c, a6 }3 Z% H4 d' [$ W" j% d( \. y9 f& J4 e5 B+ ]
       if(length(dims) > 0)
' b  ?" C! q: {8 O( ?           dims(group_ind) = [];& N( P4 k( E3 y5 u
       end; ?0 D7 X2 _" b. ]+ I  q0 k/ _
   end
* g5 S* D+ D4 i0 R! ]! I# iend: C2 Z* V, W1 B9 ?$ W. }5 g

- |+ f: @) z! g: |$ |* N& h1 N" k/ m8 d
analyze.m9 t, `- a: o" t2 G9 r) @
/ W" I" v  ?4 I
% Author: Mohammad Nabi Omidvar
1 K# b: X1 K% Q6 f) |% email address: mn.omidvar AT gmail.com
! C. D% ?6 s9 E0 D: b%& f3 ^+ X5 H- a0 p% @9 A5 _
% ------------4 B6 L3 S  P$ J/ U+ s+ X) Q1 M
% Description:7 i! _) J- h; [' c
% ------------8 P. Z3 \' \% Z  O
% This file is used to analyze the peRFormance of the differential9 p& k& Y( o7 _! H  v0 Y
% grouping algorithm on CEC'2010 benchmark problems.2 h5 G+ w+ c* T1 ^8 L
% This program reads the data files generated by differential * Q+ ?5 I) z" E3 `, H
% grouping and shows how many variables from each formed group7 Q$ p& A) Y) P7 {  f: }
% are correctly identified and to which permutation group they
; t% Z/ g/ D0 k" W$ |! g% belong.
' Y5 o$ \1 i+ S$ \%
" m7 Q6 e9 U2 u2 ?0 c%--------) U! R4 F# K+ W' ^- d
% Inputs:" I5 e! G- i* r* }9 x# x
%--------
5 B  V- F% U) n. \%    funs: a vector containing the functions ids the functions that you 9 E5 F5 r1 |9 Q4 e6 S; E
%          want to analyze.9 w8 J* A* R  D' k. A
%$ M$ U+ l7 q8 x5 l6 O
% -----------
7 u: A  D% {7 i% References:4 Z- G) }: S6 }- d) \
% -----------7 \& H: X% ~" n3 `! p6 p
% Omidvar, M.N.; Li, X.; Mei, Y.; Yao, X., "Cooperative Co-evolution with
$ b% K/ W" V* ]5 l5 B' \% Differential Grouping for Large Scale Optimization," Evolutionary Computation,
4 i0 K7 G* D6 `9 I! h% IEEE Transactions on, vol.PP, no.99, pp.1,1, 0
8 Q5 D( ?5 @* f& @: O% http://dx.doi.org/10.1109/TEVC.2013.22815436 K8 I7 ~( |. m
%+ Q$ H- v+ |9 s& U; y5 E1 x- a
% --------+ d! B& r* w- g: v
% License:* p8 q2 g* e% I% V. O  h
% --------
% R8 l7 K1 t) S2 Y" p% This program is to be used under the terms of the GNU General Public License
9 l6 O  B# y; l$ X" k' t- T% (http://www.gnu.org/copyleft/gpl.html).( |+ w. `0 {5 M5 m
% Author: Mohammad Nabi Omidvar
# {6 I+ i. s, }% e-mail: mn.omidvar AT gmail.com
: K/ f3 M! p1 C7 I3 @8 ?% Copyright notice: (c) 2013 Mohammad Nabi Omidvar4 ^+ @; V1 g5 d) {' z

3 u; ~- h0 C7 k! F$ u$ y$ p. R! Q- O
function analyze(funcs)
5 `. M* Y% r4 s; P9 V+ S! o! `    more off;0 w$ p' O, f7 q, n
' f) U6 q( k! k. D, z5 X# m7 l2 e* S3 `
    % Number of non-separable groups for each function in CEC'210 benchmark suite.
+ k( m2 v* }" T4 s7 `- ^4 m) m    numNonSep = [0 0 0 1 1 1 1 1 10 10 10 10 10 20 20 20 20 20 20 20];+ e; Q- a- n, N; e/ v

7 H8 g4 E; S- q  u/ F/ j* O2 V    for f=funcs
4 m# ?; G: P2 S* W8 Y9 C; W        filename = sprintf('./results/F%02d.mat', f);
1 f* M3 B9 y2 l3 R9 I5 s" @        p = 1:1:1000;
# e* I. A3 @$ P* {; J        load(filename);7 ]0 }' x+ N1 J: ~6 i& v
' A$ S( H' I% i" H5 J, R
        mat = zeros(length(nonseps), 20);
5 D5 {* O+ d2 I+ X/ {" w1 Y! ~9 ?. z        drawline('=');) Z# E; O) b4 }8 i. N- t7 g' E7 P
        fprintf('Function F: %02d\n', f);6 A$ |  s2 k: |$ M7 b/ z
        fprintf('FEs used: %d\n', FEs);9 A- R- I; U6 ^6 C5 y* C
        fprintf('Number of separables variables: %d\n', length (seps));) ^5 w; H8 \9 r  F+ Q( k) X2 ~: Q
        fprintf('Number of non-separables groups: %d\n', length (nonseps));
! {- A& z& M+ S' @( a1 Z& z9 s; K
# U( _1 }. ?7 |/ |- h  M! Q        filename1 = sprintf('./cec2010/datafiles/f%02d_op.mat', f);
. r. y- @, W( g8 p, ^# I$ e        filename2 = sprintf('./cec2010/datafiles/f%02d_opm.mat', f);5 W5 y) K9 |  [/ U9 ^. D
        flag = false;
. C2 ?; v% E! }        if(exist(filename1))% R! i2 o$ Y; ^3 b! B6 ?' L
            load(filename1);
& R1 u6 v( R5 g/ E            flag = true;
( k& k& g* G1 l- x/ I        elseif(exist(filename2))7 X  M6 X* D% I- ]& {% t5 g  p
            load(filename2);/ ?& Z5 I1 R: D8 U, {
            flag = true;& R0 ~% a0 C7 m7 m: u8 p4 j% [+ Q+ Y
        end' g/ r4 W; j& l7 E6 |5 Y
; }/ O# i: _2 S; S" }0 W3 l. \
        printheader();
% Q+ L  [, M5 `$ j8 `- f( Z% u
        for i=[1:1:length(nonseps)]- F3 m( u$ M+ C) Z3 l% m
            fprintf('Size of G%02d: %3d  |  ', i, length (nonseps{i}));
5 A+ e8 Y1 a' r% _, P8 `            m = 50;6 `, w; Z; i3 W/ W
            if(flag)
) l5 L! w7 G7 E+ c. l) h9 Y                for g=[1:1:20]
' w; W3 Z" ^2 t" W% L                    captured = length(intersect(p((g-1)*m+1:g*m), nonseps{i}));/ r* [! T) S5 |9 O8 V( A
                    fprintf(' %4d', captured);* r2 n' C- M  L3 J4 W1 V
                    mat(i, g) = captured;7 N; F$ Z$ n* e8 q
                end
# v  Z* J0 [0 L4 R# h            end
9 ~  J" u! {& b  O            fprintf('\n');# _2 V4 z8 k4 M& T) ~7 l3 A0 T
        end' h. O- O, `0 l; r2 a. F$ m

  W0 g8 r9 m7 w) ^        mat2 = mat;
( }8 S5 b6 {/ C! w, A8 z        [temp I] = max(mat, [], 1);+ T7 b% d- ~, o- t
        [sorted II] = sort(temp, 'descend');
% Z9 n6 c+ q; t        masks = zeros(size(mat));
1 u) N9 j) ^0 i  ^( v        for k = 1:min(size(mat))# x- d9 j  Z% ~# F# g( _
            mask = zeros(1, length(sorted));
& @# C4 m8 u  z* D0 H) r            mask(II(k)) = 1;/ U3 t7 g( F* q( A% C5 _" L/ \. [
            masks(I(II(k)), :) = mask;
. l" I% \; L7 I9 D            %point = [I(k) II(k)];$ u  d3 \0 O) Q- d
            mat(I(II(k)), :) = mat(I(II(k)), :) .* mask;% ^( ?; t( c! v9 m/ a
            [temp I] = max(mat, [], 1);
& I3 _; U* O1 p- Q0 a/ q) r            [sorted II] = sort(temp, 'descend');  w2 }! @* H% Z4 Y: m- h
        end
# i8 `# ], j5 a- q8 o2 k        mat = mat2 .* masks;
. o- h: g* W; H  y/ [- |3 G        [temp I] = max(mat, [], 1);! z( F  k1 y1 ^4 w
        if(ismember(f, [19 20]))
: f! {. Q' Y& t            gsizes = cellfun('length', nonseps);
0 t' Z" C" g9 f2 {' [            fprintf('Number of non-separable variables correctly grouped: %d\n', max(gsizes));
3 F7 S! J' w, ]# l8 @# R        else* \9 m% C  U; o/ l
            fprintf('Number of non-separable variables correctly grouped: %d\n', sum(temp(1:numNonSep(f))));
6 `" [! i+ e; |' p        end3 l: C( h$ u. p' e' {4 g
        drawline('=');
4 l5 |1 y" f: T0 H+ D6 W1 G$ s$ V        pause;& f( D" T  X7 {
end. h5 y& P) R8 r- b& ]/ R, X
: ]. C2 Q/ |4 V/ Y5 A+ ^$ n
end
* ?$ J% I' y, y6 x9 E% Helper Functions ----------------------------------------------------------2 U. F" Q1 x1 n0 `, t
function drawline(c): U, C3 h, F7 v5 b" t
    for i=1:121
1 @/ T: V# ~9 g' }! ^! ~- j9 d7 D        fprintf(1,c);- P, }& s5 x* l) v/ c! u  C
    end2 |: }) ^3 a- ^0 E: _, v
    fprintf('\n')
' t% ?% O. C; C& j: Gend
5 d6 X1 {) t0 M; J0 O3 ^9 h' E1 |& l2 o& \/ k
function printheader()' o6 C/ C) ]3 f
    fprintf('Permutation Groups|  ');
3 W8 k+ L0 v  `) F2 }. v6 X9 h. Z    for i=1:208 q! ]+ ?/ Y- q4 x- W5 ~+ A
        fprintf(' %4s', sprintf('P%d', i));
" ^+ ?3 n  x& u    end ; K  Z/ @4 a: T# P3 A8 W
    fprintf('\n'); Z% x& {5 x( Q$ _
    drawline('-');
" }1 \& W3 P5 {# [+ s: D" ?+ Hend* V& o1 K, |' u
% End Helper Functions ------------------------------------------------------
8 D! _& g' ^+ U9 Z
/ U+ P3 z0 m9 C1 j! p* ]. @) R4 z5 V* K5 p8 A
  • 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 12:57 , Processed in 0.140625 second(s), 23 queries , Gzip On.

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

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

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