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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

: |) o6 r2 [! J4 i0 X合作协同进化已经引入协同进化算法,目的是通过分而治之的范式解决日益复杂的优化问题。理论上,协同改 变子成分的想法是十分适合解决大规模优化问题的。然而在实践中,没有关于问题的先验知识, 问题应如何分解是尚不清楚的。在本文中,我们提出一个自动分解策略,称为差分分组,可以揭示决策变量的底层交互结构和形成子成分,以使它们之间的相互依存关系保持到最低限度。我们在数学上展示这样一个分解策略如何从部分可分性的定义中产生。实证研究表明,这样的近最优的分解可以大大提高大规模的全局优化问题的解决方案的质量。最后,我们展示了这样一个自动分解是如何产生对多样的子成分的分布的更好的近似,导致一个对多样的子成分的计算预算的更高效的分配。
! U) X0 @. T6 g9 o" E, N$ O( a+ O5 a3 W. W# b- I/ _
索引词:合作协同进化,大规模优化,问题分解,不可分性,数值优化 # E% O  o" B  L

7 B. X, J) {& b3 k
' P) G! L9 v4 a* Mrun.m
8 _9 C) m  f* l  E3 }! O7 h) o- \/ q
% Author: Mohammad Nabi Omidvar$ R% v; k7 Q+ O: f: t" `
% email address: mn.omidvar AT gmail.com
0 y( x2 s, a! Y$ A) t%
6 _$ E& t. }' s; a( r: w4 Q4 W. z% ------------) b1 y& H0 l  E3 Q1 c
% Description:( T3 w0 W9 R5 p9 _$ M! t4 G& }
% ------------% _+ b6 b2 d2 ]
% This files is the entry point for running the differential gropuing algorithm.
" y. A$ B3 c- I, }4 I5 I# P
7 I& \" e4 I! P: E' q# u/ e9 y; ]clear all;8 s: K  d2 c  a$ E# @% l: c) E

% T7 B4 S1 x1 A" O* q( A' y, w% Specify the functions that you want the differential grouping algorithm to 7 t2 X% j. [* H( X4 q
% identify its underlying grouping structure.: S- B# W1 g9 E1 z
func = [20:-1:1];4 K/ M- ?% a3 E5 Y4 G$ ^: n5 |
for i=func( G% k6 Q6 n4 @( J, n
    func_num = i
* w. k& H( o. {7 M3 B
& z2 c* j3 g/ B0 r/ I6 Y    t1 = [1 4 7 8 9 12 13 14 17 18 19 20];
0 P, Q3 ^1 K  K8 L% {    t2 = [2 5 10 15];- y6 e6 z/ ^! I8 v
    t3 = [3 6 11 16];6 R) _6 `, ]8 g0 H% J" y' H1 q
  E- i: }  m8 e6 g) i) l; t3 [8 w
    if (ismember(func_num, t1))
& g% B6 v& Q/ ~8 d' f        lb = -100;
, y- W3 k% |2 X4 q* D( x+ o        ub = 100;
3 ^1 a) c+ X* M    elseif (ismember(func_num, t2))$ E4 V# K8 p: x
        lb = -5;
. K, R/ Y3 B6 C3 D( u2 v& Z        ub = 5;
0 _6 J" a8 W2 N. N$ |  ]7 e5 j    elseif (ismember(func_num, t3))* g; t1 ~9 R& F6 ~. _7 n4 l& z8 i* |& M
        lb = -32;
$ @$ {  n! Y7 i1 c        ub = 32;
" z0 q) K1 e* U& t8 u    end1 U0 L6 y3 B; A3 R( r  v7 }
8 E" u- D4 O0 q+ Z- T0 P
    opts.lbound  = lb;3 S% q6 z4 C7 _  D4 Y
    opts.ubound  = ub;
  Y" ]4 ~# D4 p    opts.dim     = 1000;
4 v+ Y2 ~- ?# H4 c; n) {    opts.epsilon = 1e-3;- |' \* w5 M) ^7 |- C& ~: F0 w1 p9 B

; i0 [- V9 V' a    addpath('cec2010');
; e0 {3 E; U+ A5 i' S$ V0 ]6 T    addpath('cec2010/datafiles');# D9 d6 ~4 M. I  _- r& P
    global initial_flag;2 N& c8 x- z  J& E( I# t
    initial_flag = 0;& K3 j- J( K' M+ y. `
# p9 ?7 P* x( ^9 `# v% [
    [seps, nonseps, FEs] = dg('benchmark_func', func_num, opts);
% j; Z" [2 g; C: s" C' B& Q! r: ~9 v; N& D: ^
    % filename = sprintf('./results/F%02d.mat', func_num);
' R! x- U' Z3 D# d, m    % save (filename, 'seps', 'nonseps', 'FEs', '-v7');8 t8 {" M+ ^2 c9 n! q1 P9 {
end: [- T- ~0 f, O. |, s

/ r# L" w8 J. ]' l' q1 m% v9 i( T& v- n0 T
dg.m
, p6 u+ j  t: B0 u' M/ V. a5 p. y7 M. Z- I0 a# J! n; _6 w6 {& R3 `
% Author: Mohammad Nabi Omidvar% n9 M* n7 r( ~
% email : mn.omidvar AT gmail.com7 X- V/ k2 R0 H3 q7 K
%) R" G4 r* S7 I1 {9 z( [: @% m7 V5 X
% ------------8 m! O0 x) {# m8 L' i
% Description:
! T5 }$ d+ o. j. w- r% ------------4 V/ w+ l/ c% ?9 N& a4 q
% dg - This function runs the differential grouping
3 E0 _0 c) Z/ U2 E- Z  i0 U9 i%      procedure to identify the non-separable groups  c3 [" F) W1 J1 b3 ~
%      in cec'2010 benchmark problems.o
/ K- b" z3 y4 Y: W/ g%7 Y3 }1 _  B+ A- r' [/ {9 L3 s
% -------# _. ^  b( Z0 N" d. P
% Inputs:2 [6 x/ m7 i8 h4 }  t2 [
% -------8 c0 z% R2 Q+ j- P- I
%    fun        : the function suite for which the interaction structure 5 P  B7 u  v3 R
%                 is going to be identified in this case benchmark_func
3 n6 L. Y6 o3 f5 D%                 of cec'2010.
' i0 X" C* P3 [1 [%' N5 U4 M4 H& L/ d9 T
%    fun_number : the function number.
* i: K: R/ ^9 f4 j%+ R- k0 T- L: R
%    options    : this variable contains the options such as problem
  ]& h$ V# o! R. M/ W- J, i%                 dimensionality, upper and lower bounds and the parameter ' c. S+ d- R5 A1 N4 j
%                 epsilon used by differential grouping.% D8 [3 T. m6 y
%    input3 - Description7 y$ _9 [! W# _* i
%3 r% x* F6 g' I3 J
% --------8 _$ D" I, W. E
% Outputs:
8 Q8 j/ T1 j$ t* a# h# V5 W: w* [  [% --------8 O& H" ]4 ?& b; L
%    sep      : a vector of all separable variables., L4 u: g$ g3 d
%    allgroups: a cell array containing all non-separable groups.
: R. A7 Q3 e2 {. d+ m%    FEs      : the total number of fitness evaluations used.
0 Z* R, {' K, Y. ^+ i%
. f5 K$ }3 \/ C1 F4 O% --------4 k5 l$ |& y0 K( ~. r
% License:# m! `8 Z+ V5 A+ B7 n- V$ C
% --------: X8 R- ^% o0 w  N3 p
% This program is to be used under the terms of the GNU General Public License   s* u# K( h) n. G5 R( n; Y1 \! m0 x
% (http://www.gnu.org/copyleft/gpl.html).- u) j) H$ _! m. X
% Author: Mohammad Nabi Omidvar& o# r$ [% R' D5 c4 F
% e-mail: mn.omidvar AT gmail.com( m  s" ^! {9 r# j- p8 l
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar
; R/ O% k. x# U5 m! Q8 ~; j9 H5 f  p, _, S
. \0 a# V5 w& V
function [seps, allgroups, FEs] = dg(fun, fun_number, options);
  ~. k! n+ ]9 C( V6 j- B0 r   ub        = options.ubound;# z( x- o6 P8 m* m
   lb        = options.lbound;& Y8 w+ r" o3 b6 V3 O9 v
   dim       = options.dim;
+ \* {: D1 [" j   epsilon   = options.epsilon;# [* {7 L2 R5 N* M+ y1 Q3 [" L
   r         = ub - lb;
. i. H4 r9 M3 c- b   dims      = [1:1:dim];9 O' a7 O* U& W; B% ]; g7 o
   seps      = [];
% |9 s- Y2 l6 k- J  q$ k   allgroups = {};
5 x) k9 U6 g) {   FEs       = 0;
# m7 x; F) b1 ^' b4 T. z/ Z$ ?" k6 B7 @# ?9 a* V; z
   while (length(dims) >= 1)5 t4 Q% j, G+ j' r0 @& n
       allgroups;4 E- \( ~/ C1 d. f; i
       n = length(dims); B$ c% q# V( X0 ?8 L  A. E
       group = [dims(1)];
, K& d/ H; h4 [       group_ind = [1];4 [" d* Z' ?( V' G
% [" x7 I; w6 k( y: ?* }
       p1 = lb * ones(1,dim);  v9 Y' B) S8 \
       p2 = p1;! c) s6 t0 n* Z
       p2(dims(1)) = ub;* c8 N7 i( f, `+ o: E& H

# N, f# s# }+ D) V7 V       delta1 = feval(fun, p1, fun_number) - feval(fun, p2, fun_number);
+ V. ]( i5 t4 I- q- d# Y
: {3 w5 u# X6 x7 U& y7 G! J       FEs = FEs + 2;# p$ v* E  f) B
+ U1 q$ `' @  K1 Q: W- W# X1 `# j7 V4 Q
       for i=2:n
0 z4 T2 \  o3 i. r) x% B$ a: L           p3 = p1;
2 u" q0 a6 B; w; m- x           p4 = p2;
3 a3 e: x4 i5 |& V, y) V8 b/ J! E2 }8 v. W" Y
           temp = 0;: `; y# E/ J3 @7 ?7 W; p, e
           p3(dims(i)) = temp;* D- G1 A' R% \3 `$ N
           p4(dims(i)) = temp;
) e! G/ H) L6 T* n) s: E" V+ t" c2 R: w0 W6 H2 O6 k$ k& q
           delta2 = feval(fun, p3, fun_number) - feval(fun, p4, fun_number);+ _5 N6 G* G  V7 }

6 X* B/ G  a: H  D( o           FEs = FEs + 2;
* d# A1 {6 v: h+ Y. \9 R( M( @% x! G5 w' t' J
           if(abs(delta1-delta2) > epsilon)
- a9 h: V" V; I7 L6 e& Z0 j" Q1 _% H' _               group = [group ; dims(i)];5 u3 ^$ k* ]4 W. P. y9 _
               group_ind = [group_ind ; i];
2 t7 U3 G$ X1 T$ F, p" k           end" X) l+ q" ]. X4 L& S: I; ^3 y8 H
       end0 E: b5 k" \* a( S" ?& X( y! W

  {* f2 V5 V; B0 d+ O% v: W% {9 X       if(length(group) == 1)7 A( v, d% H6 n5 d
           seps = [seps ; group];3 V9 P  y8 U) X% h- }* h* o
       else+ T+ V( D8 [8 ?$ s" F9 i" y
           allgroups = {allgroups{1:end}, group};
& n( Y4 m5 d( f: k       end( Z3 B3 o+ m% r( c* {: x+ L
- v/ J$ [( S+ }3 x
       if(length(dims) > 0)
; o/ T4 U, D# M2 \: P           dims(group_ind) = [];
. k' u( }( {. R+ O; t       end
& ~: j6 v; [1 P  u   end
( @2 X2 f$ }" A& }9 y" a, tend
& }& L$ [3 E$ l. W' V
5 D# k  E0 v: _- J' v! R2 v5 p9 ?5 T: T# f. W
analyze.m
# Y3 B$ W7 Y/ L/ E8 N/ ?
1 q7 q  C; T6 ?+ p2 a" B% Author: Mohammad Nabi Omidvar
; l4 V$ F8 X- P( |) D, {% email address: mn.omidvar AT gmail.com2 d1 O6 g$ h- l$ m8 V7 ]& Q; |
%
& c) a$ c/ C. D- a, h% ------------, D4 v. Q9 M: X% k/ O3 e$ a) k; @
% Description:. l& l9 Z# |, o) {7 B$ U$ ^
% ------------1 N" E9 F1 x3 f: d* ~0 X
% This file is used to analyze the peRFormance of the differential, Y* u/ C+ `. w
% grouping algorithm on CEC'2010 benchmark problems.
" O/ X# m, L+ X% This program reads the data files generated by differential
, [0 o3 M# Q* b, ?7 j% grouping and shows how many variables from each formed group
: A! j  `; \7 @3 Z% are correctly identified and to which permutation group they3 G; e! c2 |: K* E! f4 B, e" j
% belong.7 S8 ~# |" v( ~
%8 C8 }! r0 t, H2 Q$ {- B
%--------# w7 w' d' J4 {9 A
% Inputs:$ d# q2 p/ W! G' Y* t* ~; E
%--------
" D* y6 l2 j6 s; N3 v%    funs: a vector containing the functions ids the functions that you ! d7 a; c1 a& ~1 J
%          want to analyze.; s$ @$ F8 H! Q" T" N
%0 ^# ?  U% e$ W2 ?4 s  u; J- @  v8 x
% -----------
( \+ z; U9 S/ v- e3 `/ A9 Y% References:9 I& Y' @/ R& ]! M1 T7 V0 E) l- R
% -----------
/ g; J5 t: R0 K; [% Omidvar, M.N.; Li, X.; Mei, Y.; Yao, X., "Cooperative Co-evolution with
' o# x' t* W. q* K4 F+ ^8 N% Differential Grouping for Large Scale Optimization," Evolutionary Computation,
3 I/ I$ w4 L" F% F( i% IEEE Transactions on, vol.PP, no.99, pp.1,1, 0
* q" V" t) K1 X# K5 O% http://dx.doi.org/10.1109/TEVC.2013.2281543, ~9 l2 d: D$ M! C! }) k
%2 @! `0 u+ E, {. l- N: ]  A
% --------
6 _3 R8 ~& z1 F$ Z* v& j6 v% License:6 x! Q* d( C3 O, H$ w/ y: j. h
% --------* X+ Q& z) A- X7 s3 T: q. B
% This program is to be used under the terms of the GNU General Public License
- g4 ]6 b! z9 X- \7 X& h' U/ p7 Z% (http://www.gnu.org/copyleft/gpl.html).
$ W2 h1 P% k/ N  V% Author: Mohammad Nabi Omidvar
6 i1 e% ]: m% K1 T1 x1 y% e-mail: mn.omidvar AT gmail.com
3 q, d- t# I; L& S5 ~3 G% Copyright notice: (c) 2013 Mohammad Nabi Omidvar7 ?8 ~! C, G- Z9 X/ n# x3 ^
2 ^, ]3 F- F% F( ^5 X9 V
- L$ e) }$ E) L6 E
function analyze(funcs)7 P& X( M( M' B% X5 f) g2 h
    more off;
, Z3 e% J: C4 i' B  z1 ^& C0 i8 s: ]- Y0 l3 W& ^& R' i! l( |4 V
    % Number of non-separable groups for each function in CEC'210 benchmark suite.
! S" o! D# R' S    numNonSep = [0 0 0 1 1 1 1 1 10 10 10 10 10 20 20 20 20 20 20 20];* L' X5 F& U% C+ j8 l$ G( j

' c; x. ?( `7 ^" K6 D  I    for f=funcs
% c  U; d2 G' N! [! e! y        filename = sprintf('./results/F%02d.mat', f);  G* G1 y* z( U* H, q
        p = 1:1:1000;
5 f3 ]" j2 P6 I0 |/ D        load(filename);3 l) F: Y- w4 A, j
; I, f/ \! j# m0 L7 G
        mat = zeros(length(nonseps), 20);
; r. n4 j% q: s1 u- Y6 m        drawline('=');) g& g9 r, I4 c! d. e, F9 Q7 E3 Y7 I
        fprintf('Function F: %02d\n', f);9 S( C3 x1 H1 [8 s3 P1 X- A7 Y8 w
        fprintf('FEs used: %d\n', FEs);& X7 [+ K( q0 X8 {
        fprintf('Number of separables variables: %d\n', length (seps));
  }& F# ~9 M$ z1 n5 e4 E8 q5 U        fprintf('Number of non-separables groups: %d\n', length (nonseps));% O5 f) d8 T- V) r
8 I+ E: {3 p" m, T
        filename1 = sprintf('./cec2010/datafiles/f%02d_op.mat', f);
4 H9 ]! {. P' e5 R5 W5 I% M+ L        filename2 = sprintf('./cec2010/datafiles/f%02d_opm.mat', f);" R; M) Q  G4 B/ v4 J4 W
        flag = false;& O/ r) {- \% N; ~
        if(exist(filename1))5 a) r  b" U: p3 Y; S; Q3 A
            load(filename1);, E# T" C+ K( g$ O6 C
            flag = true;# n0 X8 l$ u' s& S% i0 o# W9 q
        elseif(exist(filename2))
* m3 E# G& J  x% H' `3 |/ Z            load(filename2);
; [) F$ |. I& Q2 u/ {5 K9 d9 f% @            flag = true;
& L( {. P0 i# ]5 f4 A. V: S$ z        end
1 {+ N% _% }* w" d( l/ z- k6 m% x0 a5 L0 l
        printheader();( |) w4 }( k/ N8 Y( j

2 h8 X! C' W; y+ m+ R3 c3 L: o6 Y0 x' a        for i=[1:1:length(nonseps)]
" W: U: P/ j& g" q1 z0 C# X! i            fprintf('Size of G%02d: %3d  |  ', i, length (nonseps{i}));
+ ~) }; K" t6 z+ x3 t1 t& G            m = 50;( g  O5 Y) C/ S/ q/ m
            if(flag)
& J! L# w, i* ]$ c9 x0 K1 Z% v& ]' [                for g=[1:1:20]
0 `0 d3 ?# s; W% j/ s                    captured = length(intersect(p((g-1)*m+1:g*m), nonseps{i}));
3 d: H2 X7 Q0 t# a                    fprintf(' %4d', captured);
! y- r/ ]4 O. |                    mat(i, g) = captured;
0 w8 j: d. s9 s! @5 G" Q                end# F* z  e8 U5 H" ^' b, X3 [
            end
: p( U8 I) |4 s, {$ H            fprintf('\n');
2 t- T' j4 y! x8 \' g6 m        end2 F+ r: {/ f1 Z! J% Y8 U
4 M: W# P& L- r0 N( R( h
        mat2 = mat;
6 x0 G$ t$ z0 i5 z% i( ~        [temp I] = max(mat, [], 1);, A: f! O. P3 K: E% J. C; S
        [sorted II] = sort(temp, 'descend');( J, R+ e6 |: u: X" R9 w( z& e
        masks = zeros(size(mat));
0 u" _8 h* I: y' N# i        for k = 1:min(size(mat)): ]+ w0 ?2 {& D  ~7 i* _
            mask = zeros(1, length(sorted));
. B& l; P$ i- d* V' d; e# G$ m% I            mask(II(k)) = 1;; V2 Z/ \( G6 t# d
            masks(I(II(k)), :) = mask;. p6 R6 Y; w; l: C6 y" T2 Z: b
            %point = [I(k) II(k)];
* t: a* F! v* [8 G' d) v' j" J            mat(I(II(k)), :) = mat(I(II(k)), :) .* mask;
( x& b* h( P' i- }, \9 d( O0 z( j            [temp I] = max(mat, [], 1);
; D9 q, E: o3 ^4 g! Y$ L4 q# `2 u            [sorted II] = sort(temp, 'descend');
& j% q0 u+ ~3 R; k, x        end& A, F2 g' p0 w
        mat = mat2 .* masks;
* G) O) d: [5 H' C' |0 B" d) P        [temp I] = max(mat, [], 1);
4 c3 h2 L. v6 M4 [/ E, B" K        if(ismember(f, [19 20]))! R- B6 E7 E' J5 M" n' Z' w
            gsizes = cellfun('length', nonseps);
) q7 T4 o8 s% d            fprintf('Number of non-separable variables correctly grouped: %d\n', max(gsizes));9 f6 Z8 b6 F) B7 N$ T  N5 `
        else% w0 {7 C& X: W; A
            fprintf('Number of non-separable variables correctly grouped: %d\n', sum(temp(1:numNonSep(f))));" j/ Y; V& x2 \8 C7 m$ j
        end
; c- v9 x6 T" d        drawline('=');
8 K8 j! M8 p* S$ T        pause;+ ~8 s. s! X- B3 I5 E# H
end" l; S. W$ Y: S/ Q4 ^+ v6 a) \
9 s; n5 \. @8 x5 E( u
end
0 F2 e( h% S1 n( y% Helper Functions ----------------------------------------------------------
5 D0 [) P1 @  [+ V/ W( pfunction drawline(c)  M  b4 I0 x/ s! s7 L& h
    for i=1:121
. p9 [. \6 g8 [2 D/ b        fprintf(1,c);
- a- Y: C% d+ s! F- f    end! f, S, f, t" g2 B% k
    fprintf('\n')! ]! T/ V. k( @; R6 j
end, r+ L0 r6 F* c4 ?( @' D' H* o$ U

- m) t: Z' ^8 S( x6 }6 W) Q, Ifunction printheader()
2 G' Y8 Y; C- o; |$ \! I    fprintf('Permutation Groups|  ');
+ Z2 e( z* H- T    for i=1:20
# ]. W8 T( ~, d0 z; k        fprintf(' %4s', sprintf('P%d', i));' b- F! _; Z& a: L$ D9 |6 k* A" H
    end
7 ?' [# F8 F# q: }6 w  f0 ^    fprintf('\n')
4 R! K2 s* C: W6 I: ]# s    drawline('-');
. P, H' r6 ]7 A7 i4 G/ `9 }end  v2 U9 B' [# h1 G2 X. t
% End Helper Functions ------------------------------------------------------1 h6 ]$ m& l$ }: N+ v& b

; G6 }- r% S" i2 F+ W! Q
# g/ w" R- m1 e- p' w! B; c% V
  • 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-5 00:34 , Processed in 0.140625 second(s), 23 queries , Gzip On.

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

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

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