Computation: Potentials and Limitations Edward Tsang.

Slides:



Advertisements
Similar presentations
Heuristic Search techniques
Advertisements

Problem solving with graph search
State Space Representation and Search
Traveling Salesperson Problem
Lecture 24 Coping with NPC and Unsolvable problems. When a problem is unsolvable, that's generally very bad news: it means there is no general algorithm.
Reducibility Class of problems A can be reduced to the class of problems B Take any instance of problem A Show how you can construct an instance of problem.
October 1, 2012Introduction to Artificial Intelligence Lecture 8: Search in State Spaces II 1 A General Backtracking Algorithm Let us say that we can formulate.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Lecture 12: Revision Lecture Dr John Levine Algorithms and Complexity March 27th 2006.
ICS-171:Notes 4: 1 Notes 4: Optimal Search ICS 171 Summer 1999.
Part2 AI as Representation and Search
Search Techniques MSc AI module. Search In order to build a system to solve a problem we need to: Define and analyse the problem Acquire the knowledge.
1 Greedy Algorithms. 2 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Using Search in Problem Solving
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Analysis of Algorithms CS 477/677
EAs for Combinatorial Optimization Problems BLG 602E.
Using Search in Problem Solving
Backtracking.
Ch. 11: Optimization and Search Stephen Marsland, Machine Learning: An Algorithmic Perspective. CRC 2009 some slides from Stephen Marsland, some images.
1.1 Chapter 1: Introduction What is the course all about? Problems, instances and algorithms Running time v.s. computational complexity General description.
Programming & Data Structures
Genetic Algorithms and Ant Colony Optimisation
How difficult is it to solve a problem?. Computability and Feasibility  Can a specific problem be solved by computation?  If so, can a suitably efficient.
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
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.
Analysis of Algorithms
Search Methods An Annotated Overview Edward Tsang.
15 July 2005Edward Tsang (Copyright)1 Constraint Satisfaction and Optimization Professor Edward Tsang University of Essex URL:
CSC 413/513: Intro to Algorithms NP Completeness.
1 Short Term Scheduling. 2  Planning horizon is short  Multiple unique jobs (tasks) with varying processing times and due dates  Multiple unique jobs.
Cliff Shaffer Computer Science Computational Complexity.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Lecture 3: Uninformed Search
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Introduction to Genetic Algorithms. Genetic Algorithms We’ve covered enough material that we can write programs that use genetic algorithms! –More advanced.
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
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.
Optimization Problems
Analysis of the Traveling Salesman Problem and current approaches for solving it. Rishi B. Jethwa and Mayank Agarwal. CSE Department. University of Texas.
Biologically Inspired Computation Ant Colony Optimisation.
Chapter VI What should I know about the sizes and speeds of computers?
Chapter 3.5 and 3.6 Heuristic Search Continued. Review:Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
Copyright © 2014 Curt Hill Algorithm Analysis How Do We Determine the Complexity of Algorithms.
1 Computability Tractable, Intractable and Non-computable functions.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
Lecture 3: Uninformed Search
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Artificial Intelligence Problem solving by searching CSC 361
Subject Name: Operation Research Subject Code: 10CS661 Prepared By:Mrs
Comparing Genetic Algorithm and Guided Local Search Methods
CS 2210 Discrete Structures Algorithms and Complexity
Study Guide for ES205 Yu-Chi Ho Jonathan T. Lee Nov. 7, 2000
CSCE350 Algorithms and Data Structure
Metaheuristic methods and their applications. Optimization Problems Strategies for Solving NP-hard Optimization Problems What is a Metaheuristic Method?
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Applied Combinatorics, 4th Ed. Alan Tucker
3. Brute Force Selection sort Brute-Force string matching
3. Brute Force Selection sort Brute-Force string matching
Backtracking and Branch-and-Bound
Combinatorial Explosion
The N-Queens Problem Search The N-Queens Problem Most slides from Milos Hauskrecht.
Major Design Strategies
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs
Major Design Strategies
3. Brute Force Selection sort Brute-Force string matching
CS 2210 Discrete Structures Algorithms and Complexity
Presentation transcript:

Computation: Potentials and Limitations Edward Tsang

Computation: Potentials and Limits  Computers are fast  How fast can we solve a problem?  It depends on your algorithm  How to measure the speed of algorithms?  What problem-algorithms are “intractable”  What can we do about it? –Approximations –Heuristics 31 January 2016All Rights Reserved, Edward Tsang

Dealing with data  Suppose you believe the following: –Whenever the short-term moving average crosses with the long-term moving average from below, it signals a chance to buy –How to turn that into a concrete trading rule? 31 January 2016All Rights Reserved, Edward Tsang

FTSE January 2016All Rights Reserved, Edward Tsang

Moving Average Rules to Find  Let –m-MA be the m-days moving average –n-MA be the n-days moving average –m < n  Possible rules to find:  If the m-MA ≤ n-MA, on day d, but m-MA > n-MA on day d+1, then buy  If the m-MA ≥ n-MA, on day d, but m-MA < n-MA on day d+1, then sell 31/01/2016All Rights Reserved, Edward Tsang

Learning Moving Average Rules  To find Moving Averages (MAs) –You need to compare m-days and n-days MA –Where m < n  Not all m and n work with each other  To find a good rule, you have to try different m and n values, one at a time  You can examine how good a particular (m, n) is by testing it with past data 31/01/2016All Rights Reserved, Edward Tsang

Computation consideration  Suppose you decide that m is in [1, 20] and n is in [21, 70]  You have 20 × 50 = 1,000 combinations to evaluate  Suppose each combination takes 1 second to evaluate  So evaluation takes 1,000 seconds –or 17 minutes, which is acceptable 31/01/2016All Rights Reserved, Edward Tsang

Finding more robust rules  Suppose you want to find separate m and n for buying and selling  Now you need 1,000 seconds to find a buying rule, and another 1,000 seconds for selling –You need 1,000,000 seconds to find combinations –That is 115 days  You could speed it up with multiple computers –115 computers will take 1 day approximately 31/01/2016All Rights Reserved, Edward Tsang

Realistic rules are more complex  Simple rules would have been found by others  Prices will be changed to reflect rules found  Can you beat the market?  Yes, by finding more complex rules  For example, rules that relate stocks with index 31/01/2016All Rights Reserved, Edward Tsang

Example: relating stock with index  Let  k-MA s be the k-days moving average for stock s  k-MA I be the k-days moving average for index I  Buy if crossing is found in both the stock and the index graph within D days:  m-MA s ≤ n-MA s on day d, but m-MA s > n-MA s on day d+1  m-MA I ≤ n-MA I on day d’, but m-MA I > n-MA I on day d’+1  | d – d’ | ≤ D 31/01/2016All Rights Reserved, Edward Tsang

Time needed to find the complex rule  Let D be a value between 0 to 9  To find buying rules, 1,000 pairs of m and n’s  Total evaluations required 10,000  Same number to find selling rules  This time, it may take 2 seconds per evaluation  Time required: 2 × 10 8 seconds to complete –That is 63 years! 31/01/2016All Rights Reserved, Edward Tsang

A Closer Look at Complexity

Sudoku Puzzles  The task is to put one digit into one square  Each digit should appear once in a row, column or sub-square  Solvable by constraint solvers within 2 seconds 31 January 2016All Rights Reserved, Edward Tsang

Finding the Shortest Path  Given: –Junctions –Connections –Distance per connection (could be miles/minutes)  Find the shortest path from A to B 31 January 2016All Rights Reserved, Edward Tsang

Path-finding, Graph Representation  A graph is: (Nodes, Arcs)  Each Arc is a pair of nodes  Add a distance on each arc  Assume, for simplicity: –No multiple-paths between two nodes –All nodes are reachable 31 January 2016All Rights Reserved, Edward Tsang A B C D E F G

Path-finding – Dijkstra’s Algorithm  Find shortest paths from A to every other node  For each node –Remember the current shortest distance from A –Current parent that is links to A  Starting from A, compute one node at a time –Pick the remaining node x that is closest to A –Update distance/parent of every neighbours of x if needed  Complexity: O(n 2 ) 31 January 2016All Rights Reserved, Edward Tsang

Dijkstra’s Algorithm Pseudo Code For each node v in graph parent[v]  undefined; dist[v]  ∞ Dist[source]  0 Q  {all nodes in graph} While Q is not empty Do Remove x from Q s.t. dist[x] is minimum For each of x’s neighbour y alt  dist[x] + distance[x,y] If alt < dist[y] dist[y]  alt; parent[y]  x 31 January 2016All Rights Reserved, Edward Tsang

Sunday, 31 January 2016Edward Tsang (Copyright)18 Travelling Salesman Problem (TSP)  Goal: to find shortest route through all cities  Optimization involved: minimization A (4,10) B (0,5) D (6,6) E (10,6) C (6,3)

Sunday, 31 January 2016Edward Tsang (Copyright)19 Distance Table for an example TSP ABCDE A B C D E Heuristic:

Sunday, 31 January 2016Edward Tsang (Copyright)20 Branch & Bound (1) A c=0 h=20 AB c=6 h=14 ABC c=12 h=11 ABCD c=15 h=8 ABCDEA c=26 h=0 ABCEDA c=25 h=0 ABCE c=17 h=7 ABD c=12 h=11 ABDC c=15 h=8ABDE c=16 h=7 ABDCEA c=27 h=0 ABDECA c=28 h=0 ABE c=16 h=10 AC, AD, AE to be searched Pruned c=cost h=lower bound

Sunday, 31 January 2016Edward Tsang (Copyright)21 Branch & Bound (2) A c=0 h=20 AD c=4 h=17 ADC c=7 h=10 ADCE c=12 h=10 ADCEBA c=28 h=0 ADCBEA c=30 h=0 ADCB c=13 h=8 ADE c=8 h=13 ADEC c=13 h=10ADEB c=18 h=7 ADCBEA c=30 h=0 ADCBEA c=30 h=0 ADB c=10 h=11 AB, AC, AE to be searched …. c=cost h=lower bound

Sunday, 31 January 2016Edward Tsang (Copyright)22 HC Example: 2-opting for TSP  Candidate tour: a round trip route  Neighbour: exchange two edges, change directions accordingly A B C E D A B C E D

Sunday, 31 January 2016Edward Tsang (Copyright) 23 List reversing  2-Opting  List representation: –A list could represent cities in sequence  2-Opting can be seen as sub-list reversing –Easy to implement Breaking points

Sunday, 31 January 2016Edward Tsang (Copyright)24 Combinatorial Explosion ABCD EFG H  Put 1 penny in square 1  2 pennies in square 2  4 pennies in square 3, etc.  Even the world’s richest man can’t afford it –10 19 p = £100,000 trillion –World GDP 2008 was US$60 trillion (  £37 trillion)

Sunday, 31 January 2016Edward Tsang (Copyright)25 Car Sequencing Problem Options ABS CD …   Total: 120 Production: ABS area:  3/5 CD area:  2/3

Sunday, 31 January 2016Edward Tsang (Copyright)26 Combinatorial Explosion in Car Sequencing  Schedule 30 cars: –Search space: 30 factorial  leaf nodes  Generously allow: –Explore one in every leaf nodes! –Examine nodes per second!  Problem takes over 32 thousand years to solve!!! –10 32 ÷ ÷ ÷ 60 ÷ 60 ÷ 24 ÷ 365  31,710  How to contain combinatorial explosion?

Computational complexity basics  Let n measures the size of a problem  Can we express how fast an algorithm is in term of n? –On average and at worst? –Expressed as O(n 2 ), O(log n), O(10 n )  Also applied to amount of memory required  A problem that cannot be solved fast enough to be useful is called intractable 31 January 2016All Rights Reserved, Edward Tsang

Sorting of a list – Bubble Sort  Given: a list of numbers (7, 2, 6, 1, 4)  Task: sort them to ascending order (1, 2, 4, 6, 7)  This is what Bubble Sort does: –Compare adjacent numbers –Swop their position if not in order –Repeat until no more swops are needed (7, 2, 6, 1, 4)  (2, 7, 6, 1, 4)  (2, 6, 7, 1, 4)  (2, 6, 1, 7, 4)  (2, 1, 6, 7, 4)  (1, 2, 6, 7, 4)  (1, 2, 6, 4, 7)  (1, 2, 4, 6, 7) 31 January 2016All Rights Reserved, Edward Tsang

Bubble Sort in Pseudo code Procedure Bubble_Sort(A: list of n numbers) Repeat Swapped  False For i  0 to n do If A[i] > A[i+1] Then swap(A[i], A[i+1]), Swapped  True Until not(Swapped) 31 January 2016All Rights Reserved, Edward Tsang

Complexity of Bubble Sort  Length of the list is n = 5  The For loop takes n  1 comparisons  When exiting a For loop, one number is sorted  There are n numbers  Therefore, the For loop is Repeated n times  Bubble Sort takes O(n 2 ) time to complete –On average and at worst 31 January 2016All Rights Reserved, Edward Tsang

NP Completeness in laymen terms  A concept in computer science –It is about complexity in computation  A problem is NP-complete if finding solutions take exponential time  Example: try all combinations of a password –Assume 6 characters from a to z, A to Z, 0 to 9 –There are 62 6 (roughly ) combinations –Trying 2 passwords per second takes 2 milleniums! 31 January 2016All Rights Reserved, Edward Tsang

A little bit more technical on NP  NP is a concept in computational complexity –NP: non-polynomial time complete  Let n measures the size of a problem  A problem is NP-complete if: –Any solution can be verified in polynomial time E.g. n 2, where n measures the size of the problem –But it takes exponential time to find solutions E.g. 2 n 31 January 2016All Rights Reserved, Edward Tsang

Parallel processing for NP problems  Suppose we need to make n decisions –Each decision has m choices, where m is constant  There are m n combinations to explore  Suppose we use 10 processors –Assume linear speed-up, no overhead  Problem will be solved in 1/10 th of time –Getting an answer in 1 hour is better than 10 hours –But exploring m n combinations may take years 31 January 2016All Rights Reserved, Edward Tsang

P = NP?  P is the class of problems that can be solved in polynomial time  NP is the class of problems that takes exponential time to solve  P = NP? is an unsolved question in computer science –Studied under computational complexity  It is important to recognize the complexity class of your problem 31 January 2016All Rights Reserved, Edward Tsang

What to do with NP problems?  Just because a problem is NP-complete doesn’t mean that it is intractable –Sudoku: constraint propagation –Linear programming: exploiting problem features  However, most NP-complete problems are intractable in nature –Find approximations –Heuristics may help 31 January 2016All Rights Reserved, Edward Tsang

Searching Artificial Intelligence  Knowledge representation + Search Search Space = the set of all possible solutions under the given representation 31 January 2016All Rights Reserved, Edward Tsang Complete Search Systematically explore every candidate solution in the search space Incomplete Search Use heuristics to search in promising areas for solutions

Stochastic Search  Incomplete search –i.e. even if solutions exist, they may not be found  Evolutionary computation –To evolve solutions thru maintaining a population  Hill Climbing –To heuristically improve on the current solution  Many more –Tabu search, guided local search, neural network, … 31 January 2016All Rights Reserved, Edward Tsang

Conclusion  Computers are fast  Some problems can be solved very quickly  However, many problems are intractable  Computer scientists study complexity of algorithms  This helps us decide what technique to use –Great if optimal solutions can be found –Apply approximation methods otherwise 31 January 2016All Rights Reserved, Edward Tsang