Question
The following problem is based of the travelling salesperson problem. It focuses on loading a files information into distinct arrays. function loadTSP - this p5.js
The following problem is based of the travelling salesperson problem. It focuses on loading a files information into distinct arrays.
function loadTSP - this p5.js function will read a TSP problem from a .tsp file (a280.tsp). This problem should only consider Euclidean distance problems. The information loaded in the problem includes the problem name, total number of cites, the ids of each city, and the co-ordinates of those cites. You should store the city information as 3 parallel arrays (ids, xcords, ycoords) or an array of objects with an id, x and y value.
The file a280.tsp is as follows:
NAME : a280
COMMENT : drilling problem (Ludwig)
TYPE : TSP
DIMENSION: 280
EDGE_WEIGHT_TYPE : EUC_2D
NODE_COORD_SECTION
1 288 149
2 288 129
3 270 133
4 256 141
5 256 157
6 246 157
7 236 169
8 228 169
9 228 161
10 220 169
11 212 169
12 204 169
13 196 169
14 188 169
15 196 161
16 188 145
17 172 145
18 164 145
19 156 145
20 148 145
21 140 145
22 148 169
23 164 169
24 172 169
25 156 169
26 140 169
27 132 169
28 124 169
29 116 161
30 104 153
31 104 161
32 104 169
3390 165
3480 157
3564 157
3664 165
3756 169
3856 161
3956 153
4056 145
4156 137
4256 129
4356 121
4440 121
4540 129
4640 137
4740 145
4840 153
4940 161
5040 169
5132 169
5232 161
5332 153
5432 145
5532 137
5632 129
5732 121
5832 113
5940 113
6056 113
6156 105
624899
634099
643297
653289
662489
671697
6816 109
698 109
70897
71889
72881
73873
74865
75857
761657
77849
78841
792445
803241
813249
823257
833265
843273
853281
864083
874073
884063
894051
904443
914435
924427
933225
942425
951625
961617
972417
983217
994411
100569
1015617
1025625
1035633
1045641
1056441
1067241
1077249
1085649
1094851
1105657
1115665
1124863
1134873
1145673
1155681
1164883
1175689
1185697
119 10497
120 104 105
121 104 113
122 104 121
123 104 129
124 104 137
125 104 145
126 116 145
127 124 145
128 132 145
129 132 137
130 140 137
131 148 137
132 156 137
133 164 137
134 172 125
135 172 117
136 172 109
137 172 101
138 17293
139 17285
140 18085
141 18077
142 18069
143 18061
144 18053
145 17253
146 17261
147 17269
148 17277
149 16481
150 14885
151 12485
152 12493
153 124 109
154 124 125
155 124 117
156 124 101
157 10489
158 10481
159 10473
160 10465
161 10449
162 10441
163 10433
164 10425
165 10417
166929
167809
168729
1696421
1707225
1718025
1728025
1738041
1748849
175 10457
176 12469
177 12477
178 13281
179 14065
180 13261
181 12461
182 12453
183 12445
184 12437
185 12429
186 13221
187 12421
188 1209
189 1289
190 1369
191 1489
192 1629
193 15625
194 17221
195 18021
196 18029
197 17229
198 17237
199 17245
200 18045
201 18037
202 18841
203 19649
204 20457
205 21265
206 22073
207 22869
208 22877
209 23677
210 23669
211 23661
212 22861
213 22853
214 23653
215 23645
216 22845
217 22837
218 23637
219 23629
220 22829
221 22821
222 23621
223 25221
224 26029
225 26037
226 26045
227 26053
228 26061
229 26069
230 26077
231 27677
232 27669
233 27661
234 27653
235 28453
236 28461
237 28469
238 28477
239 28485
240 28493
241 284 101
242 288 109
243 280 109
244 276 101
245 27693
246 27685
247 26897
248 260 109
249 252 101
250 26093
251 26085
252 23685
253 22885
254 22893
255 23693
256 236 101
257 228 101
258 228 109
259 228 117
260 228 125
261 220 125
262 212 117
263 204 109
264 196 101
265 18893
266 18093
267 180 101
268 180 109
269 180 117
270 180 125
271 196 145
272 204 145
273 212 145
274 220 145
275 228 145
276 236 145
277 246 141
278 252 125
279 260 129
280 280 133
EOF
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started