Alignment, Part II Vasileios Hatzivassiloglou University of Texas at Dallas.

Slides:



Advertisements
Similar presentations
Dynamic Programming In this handout A shortest path example
Advertisements

Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
CSE 373: Data Structures and Algorithms Lecture 5: Math Review/Asymptotic Analysis III 1.
Recursion –a programming strategy for solving large problems –Think “divide and conquer” –Solve large problem by splitting into smaller problems of same.
Introduction to Algorithms
RAIK 283: Data Structures & Algorithms
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Dynamic Programming Technique. D.P.2 The term Dynamic Programming comes from Control Theory, not computer science. Programming refers to the use of tables.
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 2. Reminder: Recursive algorithm Reduce problem to one or more sub-problems of smaller sizes (linear or tree.
Unit 181 Recursion Definition Recursive Methods Example 1 How does Recursion work? Example 2 Problems with Recursion Infinite Recursion Exercises.
Analyzing algorithms & Asymptotic Notation BIO/CS 471 – Algorithms for Bioinformatics.
Dynamic Programming A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 8 ©2012 Pearson Education, Inc. Upper Saddle River,
Backtracking.
16.Greedy algorithms Hsu, Lih-Hsing. Computer Theory Lab. Chapter 16P An activity-selection problem Suppose we have a set S = {a 1, a 2,..., a.
Dynamic Programming Introduction to Algorithms Dynamic Programming CSE 680 Prof. Roger Crawfis.
Algorithm Cost Algorithm Complexity. Algorithm Cost.
LINEAR PROGRAMMING SIMPLEX METHOD.
Space-Efficient Sequence Alignment Space-Efficient Sequence Alignment Bioinformatics 202 University of California, San Diego Lecture Notes No. 7 Dr. Pavel.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 8 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Lecture 8. How to Form Recursive relations 1. Recap Asymptotic analysis helps to highlight the order of growth of functions to compare algorithms Common.
1 Chapter 24 Developing Efficient Algorithms. 2 Executing Time Suppose two algorithms perform the same task such as search (linear search vs. binary search)
Dynamic Programming. Well known algorithm design techniques:. –Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic programming.
ADA: 7. Dynamic Prog.1 Objective o introduce DP, its two hallmarks, and two major programming techniques o look at two examples: the fibonacci.
Types of IP Models All-integer linear programs Mixed integer linear programs (MILP) Binary integer linear programs, mixed or all integer: some or all of.
Chapter 12 Recursion, Complexity, and Searching and Sorting
Analysis of Algorithms
Recursion and Dynamic Programming. Recursive thinking… Recursion is a method where the solution to a problem depends on solutions to smaller instances.
CS 5243: Algorithms Dynamic Programming Dynamic Programming is applicable when sub-problems are dependent! In the case of Divide and Conquer they are.
1 Recurrences Algorithms Jay Urbain, PhD Credits: Discrete Mathematics and Its Applications, by Kenneth Rosen The Design and Analysis of.
Fundamentals of Algorithms MCS - 2 Lecture # 7
1 CSC 427: Data Structures and Algorithm Analysis Fall 2008 Dynamic programming  top-down vs. bottom-up  divide & conquer vs. dynamic programming  examples:
Dynamic Programming. What is dynamic programming? Break problem into subproblems Work backwards Can use ‘recursion’ ‘Programming’ - a mathematical term.
Analysis of Algorithms These slides are a modified version of the slides used by Prof. Eltabakh in his offering of CS2223 in D term 2013.
Analyzing algorithms & Asymptotic Notation BIO/CS 471 – Algorithms for Bioinformatics.
10/25/20151 CS 3343: Analysis of Algorithms Lecture 6&7: Master theorem and substitution method.
Algorithm Analysis (Algorithm Complexity). Correctness is Not Enough It isn’t sufficient that our algorithms perform the required tasks. We want them.
CSC 221: Recursion. Recursion: Definition Function that solves a problem by relying on itself to compute the correct solution for a smaller version of.
Recursion. Math Review Given the following sequence: a 1 = 1 a n = 2*a n-1 OR a n+1 = 2*a n What are the values of the following? a 2 = a 3 = a 4 =
Data Structures R e c u r s i o n. Recursive Thinking Recursion is a problem-solving approach that can be used to generate simple solutions to certain.
Algorithm Analysis CS 400/600 – Data Structures. Algorithm Analysis2 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely.
Introduction to Bioinformatics Algorithms Divide & Conquer Algorithms.
Introduction to Algorithms (2 nd edition) by Cormen, Leiserson, Rivest & Stein Chapter 2: Getting Started.
Chapter 7 Dynamic Programming 7.1 Introduction 7.2 The Longest Common Subsequence Problem 7.3 Matrix Chain Multiplication 7.4 The dynamic Programming Paradigm.
Algorithm Complexity L. Grewe 1. Algorithm Efficiency There are often many approaches (algorithms) to solve a problem. How do we choose between them?
Dynamic Programming (DP) By Denon. Outline Introduction Fibonacci Numbers (Review) Longest Common Subsequence (LCS) More formal view on DP Subset Sum.
Fundamental Data Structures and Algorithms Ananda Guna March 18, 2003 Dynamic Programming Part 1.
Dynamic Programming. What is Dynamic Programming  A method for solving complex problems by breaking them down into simpler sub problems. It is applicable.
Dynamic Programming Examples By Alexandra Stefan and Vassilis Athitsos.
Chapter 6 (Lafore’s Book) Recursion Hwajung Lee.  Definition: An algorithmic technique. To solve a problem on an instance of size n, the instance is:
CSE 3358 NOTE SET 2 Data Structures and Algorithms 1.
Permutations & Combinations: Selected Exercises. Copyright © Peter Cappello2 Preliminaries Denote the # of arrangements of some k elements of a set of.
Rod cutting Decide where to cut steel rods:
Modeling with Recurrence Relations
Analysis of Algorithms
Dynamic Programming Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Introduction to the Design and Analysis of Algorithms
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Algorithm design and Analysis
Data Structures and Algorithms
Sequence Alignment 11/24/2018.
CS 3343: Analysis of Algorithms
Dynamic Programming.
Solving Recurrence Relations
Dynamic Programming.
DYNAMIC PROGRAMMING.
Lecture 4 Dynamic Programming
At the end of this session, learner will be able to:
Presentation transcript:

Alignment, Part II Vasileios Hatzivassiloglou University of Texas at Dallas

Finding the optimal alignment Simple algorithm: Construct all possible alignments, score them, and pick the best How many alignments are there for two strings of length n and m?

or C(p, q): Number of combinations of q objects out of p, p≥q Arrange the p objects in line from 1 to p Pick the first (p choices), second (p-1 choices), up to q-th (p-q+1 choices) This will generate all permutations of each set of q objects, so divide by q! Combinatorics basics

Asymptotic analysis How large is C(n+m, n)? Asymptotic analysis: we look at how fast C(n+m, n) grows in comparison to functions like (n+m) 2 or 2 n+m Ultimately, constants have a small effect on the growth rate – they are dominated by terms involving the variables n and m

Example function growth n2n2 100n 2 2n2n n=5252,50032 n= ,0001,024 n=10010,0001,000, e30

Asymptotic analysis of C(p,q)

Upper bound for C(p,q) There are 2 p subsets of a set with p elements, some of which will have q elements Therefore, C(p, q) ≤ 2 p In particular, C(2n, n) ≤ 2 2n = 4 n

Alignments versus scoring We have explored the potential alignments of two strings The set of such alignments (and their number) remains constant and independent of the scoring function The scoring function may make it hard or easy to locate the optimal alignment(s)

Dynamic programming A general strategy for addressing computationally intractable problems by solving all smaller subproblems and remembering the results “Programming” in the mathematical sense Developed in the 1950’s and applied to many problems

Calculating the Fibonacci sequence f(n) = f(n-1)+f(n-2) if n>1; f(0)=0; f(1)=1 int fib(int n) { if (n==0) {return 0}; if (n==1) {return 1}; return fib(n-1)+fib(n-2); }

Recursive computation of Fibonacci

How long does the recursion take? Calculating fib(n) takes at least f(n) addition steps –because we ultimately add 0 or 1 each time How large is f(n)?

Dynamic programming for the Fibonacci sequence int MAX_N = 10,000; int known_fib[MAX_N]; known_fib[0]=0; known_fib[1]=1; known_n=1; int dynamic_fib(int n) { if (n==MAX_N) {printf(“N is too large!”); exit;} if (n<=known_n) {return known_fib[n];} new_fib = dynamic_fib(n-1) + dynamic_fib(n-2); known_n++; /* Necessarily, n==known_n */ known_fib[known_n] = new_fib; return new_fib; }

Complexity of alternative solution Linear in n This is not necessarily the best algorithm for calculating the Fibonacci sequence –Can be calculated iteratively in O(logn) time –Can be calculated directly

Dynamic programming for optimizing choices We have three departments in an organization, each of which comes up with a number of proposals Each proposal has a cost and an estimated revenue Each department can execute at most one proposal Find the optimal set of proposals (maximizing expected revenue) with a fixed total budget

Proposal data Total budget = 5 Dept ADept BDept C ProposalCostRevCostRevCostRev I II III IV

Recursive solution The optimal solution with n+1 departments must include a combination of proposals for n departments Is this included combination optimal for the n departments when the (n+1)th department is not considered? –Not necessarily!

Dynamic programming basics Choices correspond to stages Each stage has a number of states, each of which encodes relevant information about choices in previous stages The principle of optimality: We need to know only the state of a stage to make an optimal choice for that stage We only need to deal with viable states, that can be reached from a previous stage

Proposal example Three stages, one for each department State in each stage: Total money left before reaching that stage Principle of optimality: To choose the optimal project for department X we only need to know how much money is left for X

Solving the proposal problem Construct table with states as rows, stages as columns Each cell contains the best value we can obtain for the quantity we optimize Fill it in from left to right (by stages) Within a given stage, consider each viable prior state and all transitions that can happen from that state in the current stage Update the value for the resulting state from a transition; keep the best result

DP for the proposal problem Money leftDept ADept BDept C

DP for the proposal problem Money leftDept ADept BDept C

DP for the proposal problem Money leftDept ADept BDept C

DP for the proposal problem Money leftDept ADept BDept C

DP for the proposal problem Money leftDept ADept BDept C

DP for the proposal problem Money leftDept ADept BDept C

DP for the proposal problem Money leftDept ADept BDept C

DP for the proposal problem Money leftDept ADept BDept C

DP for the proposal problem Money leftDept ADept BDept C

DP for the proposal problem Money leftDept ADept BDept C

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Money leftDept ADept BDept C DP for the proposal problem

Complexity If we have n stages, m possible states, and k options at each stage –Time complexity O(nmk) –Space complexity O(nm) Straightforward recursion would take –O(k n ) time and space