cs314 software engineering sprint 4 worldwide trips
play

CS314 Software Engineering Sprint 4 - Worldwide Trips! Dave - PDF document

11/1/18 CS314 Software Engineering Sprint 4 - Worldwide Trips! Dave Matthews Sprint 4 Summary Use software engineering processes/tools Continuous Delivery Learn some additional technologies SQL (MariaDB) KML (Google


  1. 11/1/18 CS314 Software Engineering Sprint 4 - Worldwide Trips! Dave Matthews Sprint 4 Summary • Use software engineering processes/tools – Continuous Delivery • Learn some additional technologies – SQL (MariaDB) – KML (Google Maps, Google Earth) – Traveling Salesman Problem (2-opt, 3-opt) • Add features – Worldwide – Produce shortest trips 1

  2. 11/1/18 Internship Plan Sprint Processes Tools Technology TripCo Epics • Clean Code • GitHub, ZenHub • ReactStrap • Configuration Management • CodePen • Calculate geographic 1 • HTML, JavaScript distances • Project Management • Unix, IntelliJ • REST API/HTTP • Scrum, Planning Poker • Checkin • Continuous Integration • Maven, Webpack, • ReactJS • Load destination file 2 • Test Driven Development • Node.js • Java Spark • Show map, itinerary • Black Box Testing • JUnit, Jest • JSON, SVG • Travis-CI • Plan short trips • Code Coverage • Nearest neighbor 3 • Code Climate • Modify destinations • White Box Testing • SQL, MariaDB • Jacoco • Show information • 2 -opt • Continuous Delivery • Plan shorter trips 4 • User Experience • SQL join • Worldwide • Peer Reviews • KML • Interactive map • Plan shortest trips • 3-opt 5 • Plan trips faster • Concurrency • Finalize your resume Sprint 4 Epics • Display optional information • Optimization (2-opt) • Worldwide (larger/multiple tables, filtered searches) • Interactive maps • Concurrency • Optimization (3-opt) 2

  3. 11/1/18 +90 Worldwide -180 +180 • 50,000 airports worldwide • additional information about region, country, continent • new SVG background map, equirectangular projection -90 SQL worldwide tables # connect to the database from a shell mysql -D cs314 -h faure --user=cs314-db --password=eiK5liet1uej # once in SQL… # see a list of tables show tables; # see the columns in a table (world replaces airports) show columns from world_airports; show columns from region; show columns from country; show columns from continents; # notice the column similarities between tables 3

  4. 11/1/18 SQL worldwide query SET @phrase="%denver%"; SET @phrase="%london%"; SET @phrase="%alf%"; # search query, more columns for plan query SELECT world_airports.name, world_airports.municipality, region.name, country.name, continents.name FROM continents INNER JOIN country ON continents.id = country.continent INNER JOIN region ON country.id = region.iso_country INNER JOIN world_airports ON region.id = world_airports.iso_region WHERE country.name LIKE @phrase OR region.name LIKE @phrase OR world_airports.name LIKE @phrase OR world_airports.municipality LIKE @phrase ORDER BY continents.name, country.name, region.name, world_airports.municipality, world_airports.name ASC LIMIT 100; 4

  5. 11/1/18 TFFI • supported map format • search results found • search filters TFFI map format • config reponse – "maps":["svg","kml"] • trip request (in options) – "map":"svg" – "map":"kml" • config only return supported formats • the map attribute is optional, svg is assumed and required 5

  6. 11/1/18 TFFI search results found • search response includes – "found":# – total number of occurrences in the database (no limit) TFFI search filters • config response – return a list of names and values that can be filtered – "filters":[ … ] • query request – specify a list of names and values to filter – "filters":[ … ] 6

  7. 11/1/18 TFFI filter object { "name" : "type", "values" : [ "heliport", "balloonport", …] } § config object specifies all possible values for each name § search object specifies matching values for each name, multiple are allowed. § A null or [] for the values implies there is no filter, which is equivalent to matching all values. SQL worldwide query with a filter SET @country="United States"; SET @phrase="%alf%"; # search query, more columns for plan query SELECT world_airports.name, world_airports.municipality, region.name, country.name, continents.name FROM continents INNER JOIN country ON continents.id = country.continent INNER JOIN region ON country.id = region.iso_country INNER JOIN world_airports ON region.id = world_airports.iso_region WHERE (country.name LIKE @phrase OR region.name LIKE @phrase OR world_airports.name LIKE @phrase OR world_airports.municipality LIKE @phrase) AND country.name IN (@country) LIMIT 100; 7

  8. 11/1/18 Traveling Salesman Problem • Find the shortest hamiltonian cycle in a graph. – O(n!) – heuristic algorithms gain speed at cost of tour quality – construction + improvement • Construction – Nearest Neighbor, cheapest link, … • Improvement – 2-opt, 3-opt, k-opt, LK, tabu, SA, GA, … https://web.tuke.sk/fei-cit/butka/hop/htsp.pdf 8

  9. 11/1/18 "ill-advised data structure use" "ill-advised data structure use", part 2 9

  10. 11/1/18 Tour Construction • Nearest Neighbor, cheapest link, others – O(n^2) for a single starting city • Does the answer change if I select a other starting cities? – O(n^3) to try all starting cities nearestNeighbor(cities) { for each starting city find the nearest unvisited city, go there revisit previous step if any unvisited cities left return to starting city keep best tour } https://web.tuke.sk/fei-cit/butka/hop/htsp.pdf 306,617 km with nearest neighbor 10

  11. 11/1/18 Tour Improvement • Applied to each constructed tour. • 2-opt and 3-opt – O(n^3) and O(n^4) nearestNeighborWithOptimization(cities) { for each starting city find the nearest unvisited city, go there revisit previous step if any unvisited cities left return to starting city improve the tour with optimization keep the best tour } https://web.tuke.sk/fei-cit/butka/hop/htsp.pdf 271,618 km with 2-opt 11

  12. 11/1/18 2-opt 2optReverse(route, i1, k) { // reverse in place while(i1 < k) { temp = route[i1] route[i1] = route[k] route[k] = temp i1++; k-- } } improvement = true while improvement { improvement = false for (i = 0; i <= n-3; i++) { // assert n>4 for (k = i + 2; k <= n-1; k++) { delta = -dis(route,i,i+1)-dis(route,k,k+1)+dis(route,i,k)+dis(route,i+1,k+1) if (delta < 0) { //improvement? 2optReverse(route, i+1, k) improvement = true } } } } 2-opt inversions route 23 15 3 9 7 … 21 11 5 4 23 index 0 1 2 3 … n-3 n-2 n-1 n i i+1 k k+1 i i+1 k k+1 i i+1 - … - k k+1 i i+1 - - - … - - - k k+1 0 <= i < i+1 < k < k+1 <=n 12

  13. 11/1/18 2-opt cases 264,376 km with 3-opt 13

  14. 11/1/18 3-opt inversions and swaps route 23 15 3 9 7 … 21 11 5 4 23 index 0 1 2 3 4 … n-4 n-3 n-2 n-1 n i i+1 j j+1 k k+1 i i+1 j j+1 k k+1 i i+1 … j j+1 … k k+1 0 <= i < i+1 <= j < j+1 <= k < k+1 <=n 3-opt cases (including 2 opt) 14

  15. 11/1/18 3-opt inversions, swaps, first/best original i i+1 --> j j+1 --> k k+1 2-opt i j <-- i+1 j+1 --> k k+1 2-opt i i+1 --> j k <-- j+1 k+1 2-opt i k <-- j+1 j <-- i+1 k+1 3-opt i j <-- i+1 k <-- j+1 k+1 3-opt i k <-- j+1 i+1 --> j k+1 3-opt i j+1 --> k j <-- i+1 k+1 3-opt i j+1 --> k i+1 --> j k+1 distances (i, ?) (?, ?) (?, k+1) create distance[][] for start in 1..n lookup distance[][] for i in 1..n create route[] lookup route[] copy route[] for j in 1..n create visited[] lookup visited[] for k in 1..n reset visited[] 15

  16. 11/1/18 compute GCD create distance[][] for start in 1..n lookup distance[][] create route[] for i in 1..n // add a city create route[] create visited[] lookup route[] set route[] copy route[] set route[] for j in 1..n // closest lookup visited[] compute GCD create visited[] set visited[] lookup visited[] set visited[] 16

Recommend


More recommend