forked from fieldsend/ieee_cec_2014_nmmso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multinational_ea.m
104 lines (95 loc) · 3.93 KB
/
multinational_ea.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
function [P_real_before, P_eval_before, P_binary_before, ...
nation_mask_before, evals_before, P_real_after, P_eval_after, ...
P_binary_after, nation_mask_after, evals_after] = ...
multinational_ea(pop_size, max_evaluations, problem_func,...
problem_func_params, param_num, mn, mx, select_type, ...
gov_size, p_mut, p_cross)
% Implementation of the "Multinational Evolutionary Algorithm"
% described by Rasmus K. Ursem (1999) in the paper by the same name in
% Proceedings of the Congress on Evolutionary Computation, pages 1633-1640
%
% Implementation provided corresponds to that used in:
%"Running Up Those Hills: Multi-Modal Search with the Niching Migratory
% Multi-Swarm Optimiser"
% by Jonathan E. Fieldsend
% published in Proceedings of the IEEE Congress on Evolutionary Computation,
% pages 2593-2600, 2014
%
% Please reference both papers if you undertake work utilising this code.
% Implementation (c) by Jonathan Fieldsend, University of Exeter, 2014
%
% Assumes function maximisation
%
% REQUIRED ARGUMENTS
%
% pop_size = population size
% max_evaluations = maximum number of evaluations to be taken through the
% problem function
% problem_func = string containing function to be optimised
% problem_func_params = meta-parameters needed by test function (distinct
% from optimisation (design) parameters
% param_num = number of design parameters
% mn = minimum design parameter values (a vector with param_num elements)
% mx = maximum design parameter values (a vector with param_num elements)
% select_type = slection_type used. 1 for weighted, otherwise national
% selection is used
%
% OPTIONAL ARGUMENTS
%
% The user may set the following optional arguments, if they are
% not provided, the default used in the original CEC paper will be used.
%
% gov_size = (max) size of goverment, default 8
% p_mut = probability of bit mutation, default 0.025
% p_cross = probability of crossover, default 0.9
%
% OUTPUTS
%
% Due to the algorithm design (dynamic populations) the final generation
% may exceed the alloted maximum number of evaluations. As such the final
% population state and the penultimate population state are returned (with
% the corresponding evaluation number tracked)
%
% P_real = matrix of real values of world population, pop_size by param_num
% P_eval = vector of function evalutions of world population, pop_size by 1
% P_binary = matrix of binary representation of world population, pop_size
% by (param_num*20)
% nation_mask = vector of nation meberships, pop_size by 1
% evals = how many problem function evaluations have been used so far
% P_real = matrix of real values of world population, pop_size by param_num
%
% P_eval = vector of function evalutions of world population, pop_size by 1
% P_binary = matrix of binary representation of world population, pop_size
% by (param_num*20)
% nation_mask = vector of nation meberships, pop_size by 1
% evals = how many problem function evaluations have been used so far
if (max_evaluations<=0)
error('max_evaluations argument must be positive');
end
% use default parameters used in original 1999 paper if not specified
if exist('gov_size','var')==0
gov_size = 8;
end
if exist('p_mut','var')==0
p_mut = 0.025;
end
if exist('p_cross','var')==0
p_cross = 0.9;
end
% at start no evaluations used, and multinational EA state is empty
P_real_after=[];
P_eval_after=[];
P_binary_after=[];
nation_mask_after=[];
evals_after=0;
while (evals_after < max_evaluations)
P_real_before = P_real_after;
P_eval_before = P_eval_after;
P_binary_before = P_binary_after;
nation_mask_before=nation_mask_after;
evals_before = evals_after;
[P_real_after, P_eval_after, P_binary_after, nation_mask_after, evals_after] = ...
multinational_ea_iterative(pop_size, max_evaluations, problem_func, ...
problem_func_params, param_num, mn, mx, select_type, evals_after, ...
P_real_after, P_eval_after, P_binary_after, nation_mask_after, gov_size, p_mut,p_cross);
end