EDA365电子论坛网
标题:
差分分组合作协同进化MATLAB代码
[打印本页]
作者:
baqiao
时间:
2020-5-25 11:18
标题:
差分分组合作协同进化MATLAB代码
8 A/ Z7 L& W$ A
合作协同进化已经引入协同进化算法,目的是通过分而治之的范式解决日益复杂的优化问题。理论上,协同改 变子成分的想法是十分适合解决大规模优化问题的。然而在实践中,没有关于问题的先验知识, 问题应如何分解是尚不清楚的。在本文中,我们提出一个自动分解策略,称为差分分组,可以揭示决策变量的底层交互结构和形成子成分,以使它们之间的相互依存关系保持到最低限度。我们在数学上展示这样一个分解策略如何从部分可分性的定义中产生。实证研究表明,这样的近最优的分解可以大大提高大规模的全局优化问题的解决方案的质量。最后,我们展示了这样一个自动分解是如何产生对多样的子成分的分布的更好的近似,导致一个对多样的子成分的计算预算的更高效的分配。
' P6 s: p1 M) v" h+ J5 x: U8 ~5 ?( M& _
% a2 o4 K: T- I5 C0 P
索引词:合作协同进化,大规模优化,问题分解,不可分性,数值优化
% n2 v& s' Q) O7 H& H
7 l2 |8 v& p5 g! |) n5 ~
" H5 w2 w* I. K9 {* F4 w
run.m
# f8 {& K( p6 F
2 H7 W) G; r# K7 T& o9 E
% Author: Mohammad Nabi Omidvar
6 ?( X' {, }: O2 E' ]) D: y
% email address: mn.omidvar AT gmail.com
* I- `. C" p8 E# i5 V2 A _
%
* M% p$ v0 {8 C4 c, i o
% ------------
2 [& a% v/ C9 Q+ t7 v! p0 P
% Description:
7 A7 s! B+ M( w* S! ~- Z) g
% ------------
S) P3 Z, _3 r2 n0 L' P. P+ W
% This files is the entry point for running the differential gropuing algorithm.
# z( l1 q! V. H2 {# I
% R) C( U% Z$ ^# s7 F
clear all;
( c) b+ R7 Q; H4 M" B
. o. T% H) I5 n% @2 i
% Specify the functions that you want the differential grouping algorithm to
5 b3 ]8 W0 P2 ^5 T" R Y
% identify its underlying grouping structure.
2 {$ t4 i7 ^( X7 R5 Y
func = [20:-1:1];
& W" B6 s3 x0 L J6 o
for i=func
" R7 T. N$ F( v% C9 M# z2 `' `+ |
func_num = i
* }5 { E1 B K
" ?. I& f8 C/ U+ Q9 \7 f
t1 = [1 4 7 8 9 12 13 14 17 18 19 20];
; }: k9 F6 L9 i- J& N
t2 = [2 5 10 15];
2 P% D3 @2 Z$ _- G/ l, o j
t3 = [3 6 11 16];
# G6 |9 t- @1 a0 [+ P/ p
4 \" R0 i" s2 o3 ?+ X7 ^
if (ismember(func_num, t1))
2 g# {4 b' V, h# k6 ?1 [
lb = -100;
0 q0 C5 N$ Q3 r% y' a" {
ub = 100;
; h0 Y4 A M$ J4 E9 W8 z' `
elseif (ismember(func_num, t2))
- C8 m9 U4 y! m: V8 |
lb = -5;
# ^. X- t2 X/ _' G" _
ub = 5;
0 O& o% P3 t5 `
elseif (ismember(func_num, t3))
4 T1 N# N0 J a0 y3 w) J( Z
lb = -32;
Q5 C- \ U' c9 O
ub = 32;
2 O+ a: S: {7 c# S% x* w6 ]- _; K
end
, {) @# m' [# L# |7 Z9 o
+ v8 @; F% | q0 v# t
opts.lbound = lb;
$ [- | |; k8 Z
opts.ubound = ub;
) z- ]# U3 R- R! o
opts.dim = 1000;
1 o! [# ]# z, T1 p, }
opts.epsilon = 1e-3;
8 Y3 ^5 m4 a: _; \5 ]
# Z: q1 ~" O5 J# c
addpath('cec2010');
4 `0 Q: w, j( h H
addpath('cec2010/datafiles');
7 Q1 W; n8 q3 Q$ L9 L- }) w" B
global initial_flag;
. e" I H3 B) k' C' @" _' j* N
initial_flag = 0;
7 g B" n% p- G9 R7 A6 Q
( n' m" U% f7 V( @( c
[seps, nonseps, FEs] = dg('benchmark_func', func_num, opts);
- e ^; p) M; K9 d1 \$ i8 M
4 N5 V( h; R$ V, k7 ? |
% filename = sprintf('./results/F%02d.mat', func_num);
# U* }0 W: @, ^% t/ Y
% save (filename, 'seps', 'nonseps', 'FEs', '-v7');
8 W/ Y; ?% m. f, ^" ]
end
9 ?/ `. S v' W/ ~
K9 \7 Q, \/ ?2 p6 T- O+ u$ V
/ ?# c$ n0 y- W7 ?
dg.m
' z+ s' ~1 m# D8 _5 ]
' }4 b# T/ l2 g8 o% O
% Author: Mohammad Nabi Omidvar
2 C P) W7 k G$ o3 o
% email : mn.omidvar AT gmail.com
9 c7 L( w3 `+ I
%
; p' v9 [( L# H( Y7 ?
% ------------
# U: e9 R5 a/ s% ~
% Description:
- C7 [+ b) |) {: J, j) ]
% ------------
6 |& q) g7 _7 X2 G, R
% dg - This function runs the differential grouping
: j" q. ^& F, e P% I
% procedure to identify the non-separable groups
; L/ v( w0 w% L' U- P* F! ~% M
% in cec'2010 benchmark problems.o
% k% n4 Y+ T: N" F& G
%
4 F& q+ A) h8 ~3 W; w Y5 g
% -------
0 ^5 T Z( }/ d4 f) i- ~1 g
% Inputs:
$ c8 ]- H3 Q& z6 F% X2 H& E% N, O# z7 i
% -------
8 T0 L6 x( J! e6 R( ?! w% X
% fun : the function suite for which the interaction structure
6 M6 w% I( g2 j0 i, ?1 G0 M$ K
% is going to be identified in this case benchmark_func
7 l& T$ F( O$ G
% of cec'2010.
0 @9 _% D$ [; `7 e$ [9 w
%
_6 @- N* f6 |5 P2 a
% fun_number : the function number.
4 ]3 q3 @0 {# P$ z/ D
%
. |% [- ^; f1 H0 h: c5 R
% options : this variable contains the options such as problem
5 W! |& @0 y( }6 S
% dimensionality, upper and lower bounds and the parameter
8 [+ ], \( I' ^6 r0 }
% epsilon used by differential grouping.
/ O; w1 f: Z9 J( H7 H8 R9 ~
% input3 - Description
* O& R; H% M7 k& C! H
%
. u/ n2 Y' k% t$ g! a! l8 S
% --------
4 |6 e: Y4 G4 O% w, w8 c9 J- h7 k- t
% Outputs:
$ Y6 Z' y- V8 f- D R
% --------
9 Q2 ~9 C8 n! R; K5 L
% sep : a vector of all separable variables.
. p3 t& N; G; B, f" {
% allgroups: a cell array containing all non-separable groups.
8 b9 o6 T% n* d/ n2 {% H
% FEs : the total number of fitness evaluations used.
+ k9 [. n) T( `% e5 Q: T/ N
%
# ~: }! x& e8 Z: l. \% d% C$ Y
% --------
" I7 f- `( D$ a( L6 a, j) ^4 q
% License:
) U- V) \& ]$ \3 A: K% X$ M' l5 t
% --------
' Y' l# g0 s" d- n8 T4 l+ Q/ C
% This program is to be used under the terms of the GNU General Public License
, G; A, _, B4 w5 @: r: c
% (http://www.gnu.org/copyleft/gpl.html).
3 B; x, T9 q8 J
% Author: Mohammad Nabi Omidvar
* v I0 Q! F! f7 i
% e-mail: mn.omidvar AT gmail.com
0 X: M) O/ b4 R3 T* _! m, v
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar
% a" g) @" M. J0 ?1 c' Q Z& ]1 C; T
$ @1 R" \' j: f2 @4 p% B
u5 K/ o2 W4 Q# W+ `2 R7 `
function [seps, allgroups, FEs] = dg(fun, fun_number, options);
) n6 J8 g' ]. c6 M0 M
ub = options.ubound;
* l# q1 e5 P! h. z. s3 u
lb = options.lbound;
: d8 z; c9 k1 o$ d( R! S0 N+ g' _8 F
dim = options.dim;
0 s ]) S$ @" I( |! @, A
epsilon = options.epsilon;
) }8 s& t; w! \. U, B( `3 h
r = ub - lb;
: l( s* Q' X2 L9 y. W7 r6 p1 J* A
dims = [1:1:dim];
! N5 v; Q2 z! N1 I
seps = [];
! @) j$ e% }: J: P8 j3 E2 M
allgroups = {};
! j# }& {# i; \5 `0 C
FEs = 0;
# m7 y: v P" a7 O1 @1 J) [6 y
9 c' U9 G1 T: r0 R( P; P' q5 Z9 n
while (length(dims) >= 1)
; k8 F* f4 q, y" g, R
allgroups;
0 m0 C. `% F7 _( D! J/ }
n = length(dims)
# n8 |$ \5 f7 ? {/ y5 k- J2 }2 Z2 k
group = [dims(1)];
0 V" l6 T1 ^" g+ K; H" ?/ K" {& k8 m
group_ind = [1];
! }7 E9 ^6 R+ g/ f* d
G7 f0 W% I7 `! s+ U; G
p1 = lb * ones(1,dim);
* T( D! ?( V; f2 }6 b
p2 = p1;
+ }; ]. x" L6 O# V
p2(dims(1)) = ub;
, O2 K! ^) i9 B1 K& r
8 Q! \: n% C4 Z N" Q# b
delta1 = feval(fun, p1, fun_number) - feval(fun, p2, fun_number);
: A3 P& A& j2 o) f1 i6 ^
8 }. m7 p& E, J1 z$ G: s% @
FEs = FEs + 2;
& x8 F$ r( D n* Y# S
/ h% p$ x) ` i% \6 s
for i=2:n
$ |! Z* v! L1 n% ]' d+ @
p3 = p1;
. O8 k8 l$ ]9 L7 x2 K
p4 = p2;
+ e6 M7 q9 r7 e+ g. J/ R' }/ ]
% [, W2 k! `' T8 v. {2 B
temp = 0;
4 Z' o9 D, b& _- m `
p3(dims(i)) = temp;
4 C& y W X2 \2 H) X/ I2 ^5 R
p4(dims(i)) = temp;
% F( e, u1 Q e R2 X5 H
3 B& h0 q* k: r7 v; K# `
delta2 = feval(fun, p3, fun_number) - feval(fun, p4, fun_number);
% n, o8 ]/ G& R7 g: p' t
( T u, Y' K+ ~& ^3 n) V/ t
FEs = FEs + 2;
# V: z: f1 [2 x$ W
: C+ e8 y% h" ~/ @/ `8 r# E8 P% y
if(abs(delta1-delta2) > epsilon)
* j3 ]4 ?. q) N5 b
group = [group ; dims(i)];
. ?; u( g) a7 p
group_ind = [group_ind ; i];
- ]* @' Z# ~ N# |' o/ U5 I7 ?
end
: Z& ]/ l# ^: E2 S/ x
end
( x" c2 G1 D" C2 e; F3 Y
! D+ S" r8 V& k( _3 ~) ?' @, _
if(length(group) == 1)
3 t' w& p; r9 d8 F; j3 e$ v2 ?
seps = [seps ; group];
! x. M% Z4 N* t$ b( K' P, F
else
6 O( |& [$ g% U5 h/ p
allgroups = {allgroups{1:end}, group};
$ ~" J5 |3 A4 U2 N2 N
end
1 f+ A8 k3 R. A1 h- r
+ o7 G; O' S1 q
if(length(dims) > 0)
, W! @2 }: H! e+ X- {2 K$ }& d/ y
dims(group_ind) = [];
1 I7 a) s# D* T: B, v, z7 i8 @1 s9 j
end
0 W2 y0 e/ ]8 L" t# q
end
/ s' t j! o) t7 D
end
& i; s0 u$ V$ a1 i
+ p+ C, p8 g) T" a! T
% i/ v1 i! k, f0 f" m
analyze.m
a; L( V2 F$ Q$ q" J% [3 @* K
, X* e) O3 S( W3 ^
% Author: Mohammad Nabi Omidvar
6 K! c4 @: J' Q
% email address: mn.omidvar AT gmail.com
: s8 g* n; b" B1 S. S
%
! m" c% o7 j. U. _" y# |
% ------------
) l7 r1 I2 c& k, `
% Description:
- j1 ~9 }2 r. f. \
% ------------
! V9 F$ Q6 K0 c" I# z$ z7 F
% This file is used to analyze the performance of the differential
+ ~% \9 x8 n3 O- M+ J2 v
% grouping algorithm on CEC'2010 benchmark problems.
, ~, K' d% ]7 g
% This program reads the data files generated by differential
' G8 W) Q8 ^9 D* d" V4 r
% grouping and shows how many variables from each formed group
: t0 Z* q' ?- o$ z( {& {
% are correctly identified and to which permutation group they
Z; f2 e# P" l$ e
% belong.
3 K2 y _" ^, r3 E
%
' q7 _, \) e* s# f( I
%--------
0 C8 I5 u( L8 E6 E; Q5 Q' G
% Inputs:
5 C6 ]$ L% w: A! `4 B2 H
%--------
$ M0 G- q3 }- k% u a
% funs: a vector containing the functions ids the functions that you
/ s k& f8 X* g$ ?& `
% want to analyze.
2 @% q, H \8 t0 S* D
%
- Z9 F; k" S6 ]) D
% -----------
+ ` f0 ^3 J0 B0 p$ U6 k
% References:
. Q; \: l/ |7 m" g" `. m
% -----------
$ _# o) P. Y1 m$ y( ?1 \
% Omidvar, M.N.; Li, X.; Mei, Y.; Yao, X., "Cooperative Co-evolution with
6 u7 l, g8 I# D+ V# B
% Differential Grouping for Large Scale Optimization," Evolutionary Computation,
* i) B2 \/ v% J# q& _( h
% IEEE Transactions on, vol.PP, no.99, pp.1,1, 0
) z ?* w8 J1 H* ^. j% l3 B
% http://dx.doi.org/10.1109/TEVC.2013.2281543
, L9 ?/ {6 w1 i; J& C' B( q
%
4 E& E6 V8 q! M- n0 V
% --------
) s4 @' \; ?- D5 }" ~' ?/ {! D4 L
% License:
) D- D/ J- m% s% ]/ ~8 G) ?: \) O
% --------
. @; r2 y, \: w) h
% This program is to be used under the terms of the GNU General Public License
9 ^+ R6 x5 Z5 m5 ^5 b' M% i ^
% (http://www.gnu.org/copyleft/gpl.html).
) ~7 T. O9 D! ~% j
% Author: Mohammad Nabi Omidvar
8 g, D/ s, p; z5 W
% e-mail: mn.omidvar AT gmail.com
9 N$ T4 V: m$ q
% Copyright notice: (c) 2013 Mohammad Nabi Omidvar
4 ~% \* d. M9 o/ V2 \* I' D
6 U& G0 G; L1 U7 Q
9 Z) o3 f9 ~* t- b/ d4 b8 @% L9 ^
function analyze(funcs)
/ |+ X. K' Q7 V, Z* a
more off;
+ v. X' r- O* h7 ?( F8 a' L
. S5 ~: x; ^: T) g+ \ }
% Number of non-separable groups for each function in CEC'210 benchmark suite.
4 h" H* S5 p. C+ W
numNonSep = [0 0 0 1 1 1 1 1 10 10 10 10 10 20 20 20 20 20 20 20];
( S& ]8 S* Y9 {
! z0 G7 G4 Y$ P1 j
for f=funcs
" }8 G% v% S" d5 j
filename = sprintf('./results/F%02d.mat', f);
2 ^- O) H; F6 o1 m0 S
p = 1:1:1000;
& A( Z1 z. o, ^5 B q$ @
load(filename);
: G5 M) n* u6 |, q
) u9 }& H3 P* d, K
mat = zeros(length(nonseps), 20);
% d# _- K; X. ^ }
drawline('=');
9 r! b1 o- E$ S$ b! _1 e
fprintf('Function F: %02d\n', f);
+ F% T$ F" q8 y; u; ?
fprintf('FEs used: %d\n', FEs);
+ O* i& U+ M- o: W0 ?5 \
fprintf('Number of separables variables: %d\n', length (seps));
' n0 @/ t: i! L6 c6 O
fprintf('Number of non-separables groups: %d\n', length (nonseps));
& d5 T7 P+ u. ~0 y% K! Q
4 [) |- q) Q" Y& u
filename1 = sprintf('./cec2010/datafiles/f%02d_op.mat', f);
6 x/ k" C9 V* m0 l- y' U7 r# ^
filename2 = sprintf('./cec2010/datafiles/f%02d_opm.mat', f);
- H- m# z7 U \
flag = false;
p) F2 {/ T/ f8 G+ Q
if(exist(filename1))
6 R. T a: Z- x/ k) F; h, w
load(filename1);
7 Y% w# |- @6 C
flag = true;
. B' W$ {( G( g, M7 d+ v% C( ?- B% z
elseif(exist(filename2))
d$ ^/ z9 t0 q7 |
load(filename2);
, c! v) g( E+ X5 e( K! Q) e% @1 h
flag = true;
Z# _" Q! m% ]+ ?; X4 @! h4 R
end
/ g! D6 w1 T) g7 _4 B
; T1 _6 }9 N1 P: A2 ^
printheader();
( Z9 w% Q4 e5 \- k, u( }2 A y7 i' N
& f5 J7 [, S* K5 s* X# I0 z
for i=[1:1:length(nonseps)]
" X9 q6 O" j* D$ T
fprintf('Size of G%02d: %3d | ', i, length (nonseps{i}));
/ \( o9 P1 X4 ~. w8 b4 [; g5 K! i
m = 50;
# c5 z. D4 d4 k4 }) o) }
if(flag)
7 ?7 ^6 l `3 n9 ~9 I2 I: g8 w! F
for g=[1:1:20]
1 v+ z7 W' W* U: _ e1 v
captured = length(intersect(p((g-1)*m+1:g*m), nonseps{i}));
" C- H2 K8 h& n
fprintf(' %4d', captured);
C8 g) n4 v9 C+ ~0 w: [8 ?) y0 X
mat(i, g) = captured;
) @" I3 K8 }" l' g
end
/ R2 U2 X0 @; Z9 l
end
" L7 O( Y7 f* ~- P3 E' V! r
fprintf('\n');
/ h" Q" p$ w( h3 _3 }; K
end
. W" [" |! k0 |$ E
4 f7 t2 `% D/ ?6 t {
mat2 = mat;
6 L) U! z# Z2 e) P9 L
[temp I] = max(mat, [], 1);
2 w7 @' ~$ E _ R2 N4 g4 R& k
[sorted II] = sort(temp, 'descend');
% M L% Q( O/ g3 z& R) C
masks = zeros(size(mat));
6 Z$ Q: e% h# T: A- b4 D
for k = 1:min(size(mat))
) ~* y, o" t! t5 ?# \* P* n
mask = zeros(1, length(sorted));
5 t, F" A& b& t4 t* B1 v
mask(II(k)) = 1;
) [$ d8 Q4 r! T2 T: u% I" Z: V
masks(I(II(k)), :) = mask;
3 d! O0 V1 ?, _6 R* d
%point = [I(k) II(k)];
4 D5 M q$ u6 i% s: G H
mat(I(II(k)), :) = mat(I(II(k)), :) .* mask;
3 \. D. w/ L$ F
[temp I] = max(mat, [], 1);
8 [6 Z; F! B$ Z/ X% a
[sorted II] = sort(temp, 'descend');
7 ~' @0 e7 v3 y- w2 R
end
8 P% u, `) i+ \' e$ G7 h. r7 M
mat = mat2 .* masks;
$ r5 ?$ ~1 I8 ^8 i4 q% ^
[temp I] = max(mat, [], 1);
: O6 Q- W+ {: h* b. _4 h0 p
if(ismember(f, [19 20]))
$ ~7 Z- b' B6 f( a$ w
gsizes = cellfun('length', nonseps);
; U# M: } X$ y! w
fprintf('Number of non-separable variables correctly grouped: %d\n', max(gsizes));
6 i- M1 W' _' w3 A) X
else
7 ?3 K* z" q" D+ F% n6 e; F
fprintf('Number of non-separable variables correctly grouped: %d\n', sum(temp(1:numNonSep(f))));
3 U( d" ?4 i: G: c) h# A
end
5 Y6 q. O+ x2 d% W3 G9 K
drawline('=');
* l5 }* V! p0 ?* h) u- v9 M
pause;
/ g, ?2 l6 O4 N3 S: l. Y& F/ I
end
( w2 A+ a F+ y
) S- |3 ^4 u1 @) q$ V {, F* n
end
4 r5 j' j G+ Q* |/ M# Q
% Helper Functions ----------------------------------------------------------
0 x1 x( H m0 a3 k3 b
function drawline(c)
' d9 |9 J1 ]+ T! E* o
for i=1:121
. a5 m/ j( r7 O7 v, u# m
fprintf(1,c);
/ h8 @) R1 j# K' ^9 ^
end
8 h6 Y+ N. J1 u% O% N( u0 C
fprintf('\n')
2 }# [1 _' }, B6 B6 |
end
' R, j0 E& m( k/ u& g6 i# ?7 q
4 Q; J, @! c* @( F9 H; I/ Z6 x) r
function printheader()
, J) e8 U2 ^ h' f! g! X$ g
fprintf('Permutation Groups| ');
, G/ R5 s7 }# _1 n7 e$ V
for i=1:20
$ I) W/ t; r# U C2 b/ o9 N, l
fprintf(' %4s', sprintf('P%d', i));
. Q. y+ m2 | U
end
- |) i @- X$ F7 B; u( n! J4 y
fprintf('\n')
5 r3 m1 u! ]. e
drawline('-');
. z" L+ k' w) E0 V5 m0 V
end
( Z) ~6 o) k; t4 Y& ~
% End Helper Functions ------------------------------------------------------
' P# `, _ A' l6 U( r/ W
6 w/ c$ K1 Q* Z2 q9 c8 M
6 K# u9 ?& S2 N
作者:
yin123
时间:
2020-5-25 12:21
差分分组合作协同进化MATLAB代码
欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/)
Powered by Discuz! X3.2