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

cs314 software engineering sprint 4 worldwide trips
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

11/1/18 1

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

slide-2
SLIDE 2

11/1/18 2

Internship Plan

Sprint Processes Tools Technology TripCo Epics

1

  • Clean Code
  • Configuration Management
  • Project Management
  • Scrum, Planning Poker
  • GitHub, ZenHub
  • CodePen
  • Unix, IntelliJ
  • Checkin
  • ReactStrap
  • HTML, JavaScript
  • REST API/HTTP
  • Calculate geographic

distances

2

  • Continuous Integration
  • Test Driven Development
  • Black Box Testing
  • Maven, Webpack,
  • Node.js
  • JUnit, Jest
  • ReactJS
  • Java Spark
  • JSON, SVG
  • Load destination file
  • Show map, itinerary

3

  • Code Coverage
  • White Box Testing
  • Travis-CI
  • Code Climate
  • Jacoco
  • Nearest neighbor
  • SQL, MariaDB
  • Plan short trips
  • Modify destinations
  • Show information

4

  • Continuous Delivery
  • User Experience
  • Peer Reviews
  • 2-opt
  • SQL join
  • KML
  • Plan shorter trips
  • Worldwide
  • Interactive map

5

  • 3-opt
  • Concurrency
  • Plan shortest trips
  • Plan trips faster
  • Finalize your resume

Sprint 4 Epics

  • Display optional information
  • Optimization (2-opt)
  • Worldwide (larger/multiple tables, filtered searches)
  • Interactive maps
  • Concurrency
  • Optimization (3-opt)
slide-3
SLIDE 3

11/1/18 3

Worldwide

  • 50,000 airports worldwide
  • additional information about region, country, continent
  • new SVG background map, equirectangular projection

+90

  • 180

+180

  • 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

slide-4
SLIDE 4

11/1/18 4

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;

slide-5
SLIDE 5

11/1/18 5

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
slide-6
SLIDE 6

11/1/18 6

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":[ … ]

slide-7
SLIDE 7

11/1/18 7

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;

slide-8
SLIDE 8

11/1/18 8

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

slide-9
SLIDE 9

11/1/18 9

"ill-advised data structure use" "ill-advised data structure use", part 2

slide-10
SLIDE 10

11/1/18 10

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

slide-11
SLIDE 11

11/1/18 11

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

slide-12
SLIDE 12

11/1/18 12

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 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

slide-13
SLIDE 13

11/1/18 13

2-opt cases 264,376 km with 3-opt

slide-14
SLIDE 14

11/1/18 14

route 23 15 3 9 7 … 21 11 5 4 23 index 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 inversions and swaps 3-opt cases (including 2 opt)

slide-15
SLIDE 15

11/1/18 15

  • riginal

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)

3-opt inversions, swaps, first/best

for start in 1..n for i in 1..n for j in 1..n for k in 1..n create distance[][] lookup distance[][] create route[] lookup route[] copy route[] create visited[] lookup visited[] reset visited[]

slide-16
SLIDE 16

11/1/18 16

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