A few m3 tips. Street Segment Length / Travel Time Need to compute in double precision –Otherwise too much round off See piazza.

Slides:



Advertisements
Similar presentations
Chapter 1 - VB 2008 by Schneider1 Chapter 1 - An Introduction to Computers and Problem Solving 1.1 An Introduction to Computers 1.2 Windows, Folders, and.
Advertisements

The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Chapter 1 - An Introduction to Computers and Problem Solving
Computational problems, algorithms, runtime, hardness
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
Lecture 40 CSE 331 Dec 8, Finals 3:35-6:05pm KNOX 104 Tue, Dec 14 Blog post on the finals up.
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
Chapter 11: Limitations of Algorithmic Power
2/9/2007EECS150 Lab Lecture #41 Debugging EECS150 Spring2007 – Lab Lecture #4 Laura Pelton Greg Gibeling.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling.
Package Transportation Scheduling Albert Lee Robert Z. Lee.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
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.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
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.
Program Development Life Cycle (PDLC)
Week 5 - Wednesday.  What did we talk about last time?  Exam 1!  And before that?  Review!  And before that?  if and switch statements.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CS440 Computer Science Seminar Introduction to Evolutionary Computing.
Representing and Using Graphs
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
CSC 413/513: Intro to Algorithms NP Completeness.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
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.
A few m3 tips. Speed Tuning 1.Algorithm 2.Data structures 3.Low level code string streetName1, streetName2; if (streetName1 != streetName2) {... int streetId1,
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.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
Umans Complexity Theory Lectures Lecture 1a: Problems and Languages.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
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.
SNU OOPSLA Lab. 1 Great Ideas of CS with Java Part 1 WWW & Computer programming in the language Java Ch 1: The World Wide Web Ch 2: Watch out: Here comes.
CS10: The Beauty and Joy of Computing Lecture #22 Limits of Computing Warning sign posted at Stern Hall. Also, Apple releases new operating.
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.
2101INT – Principles of Intelligence Systems Lecture 3.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Recursion.
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.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Computer Science: An Overview Eleventh Edition by J. Glenn Brookshear Chapter.
1 CSE 326: Data Structures: Graphs Lecture 24: Friday, March 7 th, 2003.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
David Luebke 1 2/18/2016 CS 332: Algorithms NP Completeness Continued: Reductions.
CSC 413/513: Intro to Algorithms
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 ?
By: Megan Funk. I will: 1. Explain the binary number system How to: -Generate binary from a number -Add binary 2. Explain the base-b number system 3.
Measuring Where CPU Time Goes
Breadth-First Search: Complexity
Unsolvable Problems December 4, 2017.
EECS150 Fall 2007 – Lab Lecture #4 Shah Bawany
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

Street Segment Length / Travel Time Need to compute in double precision –Otherwise too much round off See piazza

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 2N delivery intersections And always picking up a package before delivering it and Given M courier truck depots Given N deliveries (pick up, drop off) M = 3 here, all intersections N = 4 here, all intersections DD AA AA BB BB CC CC DD

No  dropping off packages before they’re picked up! Possible Solution? AA AA BB BB CC CC DD DD

BB CC Legal Solution AA AA BB CC DD DD Output: vector of street segment ids

How? Re-use m3 path-finder // Go from first depot to first package pick up path = find_path (depot[0], delivery[0].pickUp); // Complete deliveries, in order for (i = 0; i < N-1; i++) { path += find_path (delivery[i].pickUp, delivery[i].dropOff); path += find_path (delivery[i].dropOff, delivery[i+1].pickUp); } // Drop off last package path += find_path (delivery[N-1].pickUp, delivery[N-1].dropOff); // Go back to the first depot to drop off the truck path += find_path (delivery[N-1].dropOff, depot[0]);

Lots of wasted travel! Possible Solution AA AA BB BB CC CC DD DD

BB CC AA AA BB CC DD DD 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 deliveries  2N pick-up + drop-off intersections –Pick one of M starting locations –Then pick one of 2N pick-up/drop-off intersections –Then one of 2N-1 for the second intersection –… (repeat until last delivery) –Then M places to drop off truck –M * 2N * (2N-1) * (2N-2) * … * 1 * M = M 2 (2N)! Some of these are illegal orders  say algorithm checks legality after generating the solution

Exhaustive Algorithm? Say M = 10, N = * (2*30)! = 8.3 x Invoke find_path () 2N+1 times to get path between each intersection Say find_path takes 0.1 s (very good!) 8.3 x * 61 * 0.1 s = 5.1 x s  1.6 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 –Proved 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

Digression Top 10 Programming Languages (source: IEEE Spectrum,Oct2011 Issue)

Summary C++: 9% C: 16% (25% total) Java + C#: Another 28% –(Mostly) simplified C++ –Java: Android, web apps, IBM –C#: Microsoft’s answer to Java Objective C: Another 4% –Alternative syntax for adding objects to C –Apple (Mac, iPhone, …) Total: 57% C++ related

Grace Hopper Math professor & computer engineer Lead programmer on Harvard Mark I –1 st fully programmable comp Wrote first programming manual Created first compiler  A- Known as both a great engineer and great communicator –Pioneering work in programming computers & computer languages