MJ-Addic

Plotting script for THPC final project

May 28th, 2018
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 11.89 KB | None | 0 0
  1. %% Plot function for TSP genetic algorithm.
  2.  
  3.  
  4. % Usage put
  5. % the wanted random city map as a filename to the RandomCiteis load function
  6. % Similarly put the wanted initial vectors filename to the initial vectors load function
  7. % and childVector filename to the load function of ChildVector
  8. %%
  9. %filename='D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_100\BestChildVec.dat'
  10. %%
  11. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_100\RandomCityMap.dat');
  12. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_100\BestChildVec.dat');
  13. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_100\InitialVectors.dat');
  14.  
  15. %close all;
  16. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  17. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  18.  
  19. figure;
  20. hold on
  21. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  22. plot(plotVector1,plotVector2,'-r');
  23. title('Initial situation, Serial n=100')
  24. xticks([])
  25. yticks([])
  26. hold off
  27.  
  28. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  29. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  30.  
  31. figure;
  32. hold on
  33. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  34. plot(plotVector1,plotVector2,'-r');
  35. xticks([])
  36. yticks([])
  37. title('After GA, Serial n=100')
  38. hold off
  39.  
  40. %%
  41.  
  42. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_200\RandomCityMap.dat');
  43. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_200\BestChildVec.dat');
  44. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_200\InitialVectors.dat');
  45.  
  46. %close all;
  47. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  48. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  49.  
  50. figure;
  51. hold on
  52. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  53. plot(plotVector1,plotVector2,'-r');
  54. title('Initial situation, Serial n=200')
  55. xticks([])
  56. yticks([])
  57. hold off
  58.  
  59. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  60. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  61.  
  62. figure;
  63. hold on
  64. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  65. plot(plotVector1,plotVector2,'-r');
  66. xticks([])
  67. yticks([])
  68. title('After GA, Serial n=200')
  69. hold off
  70.  
  71. %%
  72. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_300\RandomCityMap.dat');
  73. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_300\BestChildVec.dat');
  74. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_300\InitialVectors.dat');
  75.  
  76. %close all;
  77. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  78. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  79.  
  80. figure;
  81. hold on
  82. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  83. plot(plotVector1,plotVector2,'-r');
  84. title('Initial situation, Serial n=300')
  85. xticks([])
  86. yticks([])
  87. hold off
  88.  
  89. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  90. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  91.  
  92. figure;
  93. hold on
  94. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  95. plot(plotVector1,plotVector2,'-r');
  96. xticks([])
  97. yticks([])
  98. title('After GA, Serial n=300')
  99. hold off
  100.  
  101. %%
  102. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_400\RandomCityMap.dat');
  103. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_400\BestChildVec.dat');
  104. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_400\InitialVectors.dat');
  105.  
  106. %close all;
  107. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  108. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  109.  
  110. figure;
  111. hold on
  112. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  113. plot(plotVector1,plotVector2,'-r');
  114. title('Initial situation, Serial n=400')
  115. xticks([])
  116. yticks([])
  117. hold off
  118.  
  119. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  120. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  121.  
  122. figure;
  123. hold on
  124. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  125. plot(plotVector1,plotVector2,'-r');
  126. xticks([])
  127. yticks([])
  128. title('After GA, Serial n=400')
  129. hold off
  130. %%
  131. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_500\RandomCityMap.dat');
  132. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_500\BestChildVec.dat');
  133. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\Serial_500\InitialVectors.dat');
  134.  
  135. %close all;
  136. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  137. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  138.  
  139. figure;
  140. hold on
  141. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  142. plot(plotVector1,plotVector2,'-r');
  143. title('Initial situation, Serial n=500')
  144. xticks([])
  145. yticks([])
  146. hold off
  147.  
  148. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  149. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  150.  
  151. figure;
  152. hold on
  153. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  154. plot(plotVector1,plotVector2,'-r');
  155. xticks([])
  156. yticks([])
  157. title('After GA, Serial n=500')
  158. hold off
  159.  
  160. %%
  161. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r100\RandomCityMap.dat');
  162. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r100\BestChildVec.dat');
  163. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r100\InitialVectors.dat');
  164. %close all;
  165. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  166. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  167. figure;
  168. hold on
  169. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  170. plot(plotVector1,plotVector2,'-r');
  171. title('Initial situation, 16 cores n = 100')
  172. xticks([])
  173. yticks([])
  174. hold off
  175. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  176. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  177. figure;
  178. hold on
  179. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  180. plot(plotVector1,plotVector2,'-r');
  181. xticks([])
  182. yticks([])
  183. title('After GA, 16 cores n = 100')
  184. hold off
  185. %%
  186. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r200\RandomCityMap.dat');
  187. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r200\BestChildVec.dat');
  188. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r200\InitialVectors.dat');
  189. %close all;
  190. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  191. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  192. figure;
  193. hold on
  194. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  195. plot(plotVector1,plotVector2,'-r');
  196. title('Initial situation, 16 cores n = 200')
  197. xticks([])
  198. yticks([])
  199. hold off
  200. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  201. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  202. figure;
  203. hold on
  204. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  205. plot(plotVector1,plotVector2,'-r');
  206. xticks([])
  207. yticks([])
  208. title('After GA, 16 cores n = 200')
  209. hold off
  210. %%
  211. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r300\RandomCityMap.dat');
  212. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r300\BestChildVec.dat');
  213. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r300\InitialVectors.dat');
  214. %close all;
  215. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  216. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  217. figure;
  218. hold on
  219. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  220. plot(plotVector1,plotVector2,'-r');
  221. title('Initial situation, 16 cores n = 300')
  222. xticks([])
  223. yticks([])
  224. hold off
  225. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  226. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  227. figure;
  228. hold on
  229. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  230. plot(plotVector1,plotVector2,'-r');
  231. xticks([])
  232. yticks([])
  233. title('After GA, 16 cores n = 300')
  234. hold off
  235. %%
  236. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r400\RandomCityMap.dat');
  237. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r400\BestChildVec.dat');
  238. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r400\InitialVectors.dat');
  239. %close all;
  240. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  241. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  242. figure;
  243. hold on
  244. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  245. plot(plotVector1,plotVector2,'-r');
  246. title('Initial situation, 16 cores n = 400')
  247. xticks([])
  248. yticks([])
  249. hold off
  250. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  251. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  252. figure;
  253. hold on
  254. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  255. plot(plotVector1,plotVector2,'-r');
  256. xticks([])
  257. yticks([])
  258. title('After GA, 16 cores n = 400')
  259. hold off
  260. %%
  261. RandomCiteis = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r500\RandomCityMap.dat');
  262. ChildVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r500\BestChildVec.dat');
  263. InitialVector = load('D:\GoogleDrive\School Things (Current)\Tools of High Performance Computing\Datas\16Cores\r500\InitialVectors.dat');
  264. %close all;
  265. plotVector1 = [RandomCiteis(InitialVector(1,:)'+1,1);flip(RandomCiteis(InitialVector(1,1)'+1,1))];
  266. plotVector2 = [RandomCiteis(InitialVector(1,:)'+1,2);flip(RandomCiteis(InitialVector(1,1)'+1,2))];
  267. figure;
  268. hold on
  269. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  270. plot(plotVector1,plotVector2,'-r');
  271. title('Initial situation, 16 cores n = 500')
  272. xticks([])
  273. yticks([])
  274. hold off
  275. plotVector1 = [RandomCiteis(ChildVector(1,:)'+1,1);flip(RandomCiteis(ChildVector(1,1)'+1,1))];
  276. plotVector2 = [RandomCiteis(ChildVector(1,:)'+1,2);flip(RandomCiteis(ChildVector(1,1)'+1,2))];
  277. figure;
  278. hold on
  279. plot(RandomCiteis(:,1),RandomCiteis(:,2),'O');
  280. plot(plotVector1,plotVector2,'-r');
  281. xticks([])
  282. yticks([])
  283. title('After GA, 16 cores n = 500')
  284. hold off
Advertisement