-
Notifications
You must be signed in to change notification settings - Fork 0
/
EDA.asv
60 lines (52 loc) · 1.68 KB
/
EDA.asv
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
function [Xoptima,FitnessOptimum] = EDA(dimensionSize,landscape,boundary,lambda,miu,simulationLimit)
%estimation of distribution algorithms
%lambda is the population size
if miu > lambda,
miu = lambda;
end
population = [];
parents = [];
offsprings = [];
fitnesspoul = [];
%initialize the population
for i = 1:lambda,
individual = [];
for j=1:dimensionSize,
individual = [individual,boundary(1)+(boundary(2) - boundary(1))*rand()];
end
population = [population;individual];
end
simulationCounts = 0;
while simulationCounts < simulationLimit,
simulationCounts = simulationCounts+1;
offsprings = [];
fitnesspoul = [];
%evaluate the population
for i = 1:lambda,
fitnesspoul = [fitnesspoul;landscape(population(i,:))];
end
%select about miu individuals in population as the parents
[tempSorted,tempindex] = sort(fitnesspoul(:),'descend');
topMiuInedices = tempindex(1:miu);
parents = population(topMiuInedices(:),:);
%generate the probability distribution
MeanOfParent = mean(parents);
VarOfParent = var(parents)*(miu-1)/miu;%the var normalize parents by miu-1
for i = 1:lambda,
tempIndividual = boundary(1)-1;
while min(tempIndividual)<boundary(1) | max(tempIndividual) > boundary(2),
tempIndividual = normrnd(MeanOfParent,VarOfParent);
end
offsprings = [offsprings;tempIndividual];
end
population = offsprings;
end
for i = 1:lambda,
fitnesspoul = [fitnesspoul;landscape(population(i,:))];
end
fprintf('The Results:\n');
bestIndex = find(fitnesspoul == max(fitnesspoul));
fprintf('fitness:\n')
disp(fitnesspoul(bestIndex(1)));
fprintf('individual:\n')
disp(population(bestIndex(1),:));