-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_ga.m
35 lines (30 loc) · 948 Bytes
/
run_ga.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
function [costs] = run_ga(CostData)
costs = zeros(5, 2);
NumIterations = 200;
PopulationSize = 20;
CrossoverProbability = 0.75;
MutationProbability = 0.65;
NumReceivers = 5;
NumPoints = 51;
params = [MutationProbability CrossoverProbability];
change = [0.05 0.04];
NumOfRuns = 2;
for i = 1:2
for k = 1:5
total = 0;
cost = 0;
for j = 1:NumOfRuns
[~, cost] = ...
ga(CostData, NumIterations, PopulationSize, ...
CrossoverProbability, MutationProbability, ...
NumPoints, NumReceivers);
total = total + cost;
end
costs(k, i) = total/NumOfRuns;
params(i) = params(i) + change(i);
end
[~, idx] = min(costs(:, i));
params(i) = params(i) - (6-idx)*change(i);
end
disp(params);
end