Repository navigation
Expand file tree
/
Copy pathdarwinTest.m
More file actions
48 lines (43 loc) · 1.57 KB
/
Copy pathdarwinTest.m
File metadata and controls
48 lines (43 loc) · 1.57 KB
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
numberOfTrusses = 500; % must be even
numberOfRuns = 720;
gcp
pctRunOnAll warning off
trussArray = prepTrussArray(numberOfTrusses, [0, 0], [0.450, 0]);
trussArray = testTrussArray(trussArray, 0.8, 280000);
maxArray = zeros(1, numberOfRuns);
meanArray = zeros(1, numberOfRuns);
Video = VideoWriter("DP3 20", "MPEG-4");
Video.FrameRate = 6;
open(Video)
for i = 1:numberOfRuns
maxArray(i) = max([trussArray.capasity]);
meanArray(i) = mean([trussArray.capasity]);
% Video and Output Stuff
subplot(2,1,1);
plot(1:i, maxArray(1:i), 1:i, meanArray(1:i))
legend({['Highest Truss Capacity: ', num2str(maxArray(i))],['Mean Truss Capacity: ', num2str(meanArray(i))]},...
'Location','southeast')
set(gca,'XAxisLocation','top','YAxisLocation','left');
xlabel('Number of Generations')
ylabel('Truss Capacity')
subplot(2,1,2);
hold on
t = trussArray(1);
endNodes = t.endNodes;
nodes = [[t.nodesArray.x];[t.nodesArray.y]]';
graph = generateTrussGraph2(nodes, endNodes);
h = plotImageGraph(graph);
highlight(h,t.weightNode,'NodeColor','r')
title('Current Best Truss Design')
dim = [.15 .2 .2 .2];
str = {['Cost: ', num2str(t.cost)], ['Capacity: ', num2str(t.capasity)]};
cur_plot = gca;
cur_plot.YDir = 'normal';
hold off
frame = getframe(gcf); %get frame
writeVideo(Video, frame);
trussArray = sortTrussArray(trussArray);
trussArray = thanosArray(trussArray);
trussArray(numberOfTrusses/2 + 1:end) = testTrussArray(trussArray(numberOfTrusses/2 + 1:end), 0.8, 280000);
end
close(Video)