A few m3 tips. Speed Tuning 1.Algorithm 2.Data structures 3.Low level code string streetName1, streetName2; if (streetName1 != streetName2) {... int streetId1,

Slides:



Advertisements
Similar presentations
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Advertisements

AMDM UNIT 7: Networks and Graphs
Graphs. Overview What is a graph? Some terminology Types of graph Implementing graphs (briefly) Some graph algorithms Graphs 2/18.
Computational problems, algorithms, runtime, hardness
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
Computability and Complexity 32-1 Computability and Complexity Andrei Bulatov Boolean Circuits.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Analysis of Algorithms CS 477/677
Circuits CSE 373 Data Structures Lecture 22. 3/12/03Circuits - Lecture 222 Readings Reading ›Sections and 9.7.
CS10 The Beauty and Joy of Computing Lecture #23 : Limits of Computing Thanks to the success of the Kinect, researchers all over the world believe.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Euler and Hamilton Paths
Euler Paths and Circuits. The original problem A resident of Konigsberg wrote to Leonard Euler saying that a popular pastime for couples was to try.
Chocolate Bar! luqili. Milestone 3 Speed 11% of final mark 7%: path quality and speed –Some cleverness required for full marks –Implement some A* techniques.
EECS 203: It’s the end of the class and I feel fine. Graphs.
Scott Perryman Jordan Williams.  NP-completeness is a class of unsolved decision problems in Computer Science.  A decision problem is a YES or NO answer.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
FACULTY OF ENGINEERING & INFORMATION TECHNOLOGIES P, NP, and Complexity Six fundamental facts One rule of thumb Three fundamental notions One fundamental.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CS440 Computer Science Seminar Introduction to Evolutionary Computing.
Euler and Hamilton Paths
A Genetic Solution to the Travelling Salesman Problem Ryan Honig.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
More Computational Complexity Shirley Moore CS4390/5390 Fall August 29,
Instructor: Shengyu Zhang 1. Tractable While we have introduced many problems with polynomial-time algorithms… …not all problems enjoy fast computation.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Cliff Shaffer Computer Science Computational Complexity.
Compsci 100, Fall What is Computing? Informatics? l What is computer science, what is its potential?  What can we do with computers in our lives?
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
Introduction to Genetic Algorithms. Genetic Algorithms We’ve covered enough material that we can write programs that use genetic algorithms! –More advanced.
1 The Euclidean Travelling Salesman Problem Peter Eades Professor of Software Technology University of Sydney.
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
CPS What is Computer Science? What is it that distinguishes it from the separate subjects with which it is related? What is the linking thread.
CS10: The Beauty and Joy of Computing Lecture #22 Limits of Computing Warning sign posted at Stern Hall. Also, Apple releases new operating.
Optimization Problems
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
Associated Matrices of Vertex Edge Graphs Euler Paths and Circuits Block Days April 30, May 1 and May
2101INT – Principles of Intelligence Systems Lecture 3.
Euler Paths and Circuits. The original problem A resident of Konigsberg wrote to Leonard Euler saying that a popular pastime for couples was to try.
Week 13 - Monday.  What did we talk about last time?  B-trees  Hamiltonian tour  Traveling Salesman Problem.
CPS Computational problems, algorithms, runtime, hardness (a ridiculously brief introduction to theoretical computer science) Vincent Conitzer.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
The Beauty and Joy of Computing Lecture #23 Limits of Computing Researchers at Facebook and the University of Milan found that the avg # of “friends” separating.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Computer Science: An Overview Eleventh Edition by J. Glenn Brookshear Chapter.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 30, 2014.
Solving the Logic Satisfiability problem Solving the Logic Satisfiability problem Jesus De Loera.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
David Luebke 1 2/18/2016 CS 332: Algorithms NP Completeness Continued: Reductions.
CSC 413/513: Intro to Algorithms
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
Introduction to NP-Completeness Tahir Azim. The Downside of Computers Many problems can be solved in linear time or polynomial time But there are also.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 30, 2014.
Graphs. Graph Definitions A graph G is denoted by G = (V, E) where  V is the set of vertices or nodes of the graph  E is the set of edges or arcs connecting.
Lecture 20 CSE 331 July 30, Longest path problem Given G, does there exist a simple path of length n-1 ?
A few m3 tips. Street Segment Length / Travel Time Need to compute in double precision –Otherwise too much round off See piazza.
Measuring Where CPU Time Goes
Breadth-First Search: Complexity
Routing Through Networks - 1
Unsolvable Problems December 4, 2017.
Intro to NP Completeness
Approximation Algorithms
M4 and Parallel Programming
Milestone 4: Courier Company
Not guaranteed to find best answer, but run in a reasonable time
Min Heap Update E.g. remove smallest item 1. Pop off top (smallest) 3
Efficiently Estimating Travel Time
Presentation transcript:

A few m3 tips

Speed Tuning 1.Algorithm 2.Data structures 3.Low level code string streetName1, streetName2; if (streetName1 != streetName2) {... int streetId1, streetId2; if (streetId1 != streetId2) {... Any speed difference?

Debugging Algorithms Start with a very simple test case –Adjacent intersections! –Step / breakpoint code in debugger –Make sure it does what you expect!

Debugging Algorithms Try a slightly harder case –Two intersections apart –Step / breakpoint code in debugger again! –Make sure code behaving exactly as you expect

Bigger Cases: Graphics Helps Hard to see large amounts of data in debugger Use graphics to animate / visualize #define VISUALIZE while (wavefront.size() != 0) { waveElem = wavefront.front(); #ifdef VISUALIZE draw_street_seg (waveElem.edgeID); flushinput(); // Draw right away #endif... Can’t leave this in when I submit (will fail unit tests). How do I turn this off when speed testing & before submitting code?

Milestone 4: Courier Company

Problem Definition Return: low travel time path Starting and ending at some depot And reaching all N delivery intersections Given M courier truck depots and Given N delivery locations M = 3 here, all intersections N = 8 here, all intersections

vector of street segment ids Possible Solution

How? Idea: re-use our m3 path-finding algorithm! // Go from first depot to first delivery wholePath = find_path (depot[0], delivery[0]); // Complete other deliveries, in order they were given for (i = 0; i < N; i++) { path = find_path (delivery[i], delivery[i+1]); wholePath += path; } // Go back to the first depot to drop off the truck path = find_path (delivery[N-1], depot[0]); wholePath += path;

Lots of wasted travel! Possible Solution

Need to optimize delivery order Recall: More Logical Solution

Exhaustive Algorithm? Try all possible delivery orders Pick the one with lowest travel time How many combinations? –M truck depots, N delivery locations –Pick one of M starting locations –Then can pick one of N deliveries to do first –Then one of N-1 for the second –… (repeat until last delivery) –Then M places to drop off truck –M * N * (N-1) * (N-2) * … * 1 * M = M 2 N!

Exhaustive Algorithm? Say M = 6, N = * 40! = 2.9 x Invoke find_path () N+1 times to get path between each intersection Say find_path takes 0.1 s (very good!) 2.9 x * 41 * 0.1 s = 1.2 x s  3.77 x years! Lifetime of universe: ~14 x 10 9 years!

Traveling Salesman Problem We are solving a variation of the traveling salesman problem Computationally hard problem –For N deliveries, no guaranteed optimal (lowest travel time solution) in polynomial time i.e. > O(N k ), for any k Means at least O(2 N ) –Need to use heuristics to solve Most research problems are computationally hard –Integrated circuit design, drug design, transportation network design, …

Pioneer of Complexity Theory Stephen Cook, U of T professor in Computer Science Created the main theory of computationally hard problems NP-complete problems –No polynomial time solution known on conventional computers –Showed that if a method to solve any of these problems in polynomial time was found, then all these problems could be solved in polynomial time –P vs. NP: most famous open problem in computer science 1970: denied tenure at UC Berkeley 1971: published most famous paper 1982: won Turing award