June 11, Dynamic Programming( Weighted Interval Scheduling)

Similar documents
IEOR E4004: Introduction to OR: Deterministic Models

Lecture 10: The knapsack problem

CSE 417 Dynamic Programming (pt 2) Look at the Last Element

2. This algorithm does not solve the problem of finding a maximum cardinality set of non-overlapping intervals. Consider the following intervals:

CSE202: Algorithm Design and Analysis. Ragesh Jaiswal, CSE, UCSD

Homework #4. CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class

Advanced Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

On the Optimality of a Family of Binary Trees Techical Report TR

Optimization Methods. Lecture 16: Dynamic Programming

Essays on Some Combinatorial Optimization Problems with Interval Data

0/1 knapsack problem knapsack problem

UNIT 2. Greedy Method GENERAL METHOD

CS360 Homework 14 Solution

Dynamic Programming cont. We repeat: The Dynamic Programming Template has three parts.

Problem Set 2: Answers

Issues. Senate (Total = 100) Senate Group 1 Y Y N N Y 32 Senate Group 2 Y Y D N D 16 Senate Group 3 N N Y Y Y 30 Senate Group 4 D Y N D Y 22

What is Greedy Approach? Control abstraction for Greedy Method. Three important activities

Dynamic Programming: An overview. 1 Preliminaries: The basic principle underlying dynamic programming

For every job, the start time on machine j+1 is greater than or equal to the completion time on machine j.

CMPSCI 311: Introduction to Algorithms Second Midterm Practice Exam SOLUTIONS

A DNC function that computes no effectively bi-immune set

Programming for Engineers in Python

Best counterstrategy for C

1 Shapley-Shubik Model

Design and Analysis of Algorithms 演算法設計與分析. Lecture 8 November 16, 2016 洪國寶

Introduction to Dynamic Programming

Bidding Languages. Noam Nissan. October 18, Shahram Esmaeilsabzali. Presenter:

Slides credited from Hsu-Chun Hsiao

Deterministic Dynamic Programming

ECE 586GT: Problem Set 1: Problems and Solutions Analysis of static games

Chapter 15: Dynamic Programming

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Handout 4: Deterministic Systems and the Shortest Path Problem

Optimization Methods in Management Science

1) S = {s}; 2) for each u V {s} do 3) dist[u] = cost(s, u); 4) Insert u into a 2-3 tree Q with dist[u] as the key; 5) for i = 1 to n 1 do 6) Identify

Real Options and Game Theory in Incomplete Markets

Project Management Chapter 13

Maximum Contiguous Subsequences

Chapter 1. Introduction: Some Representative Problems. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Introduction to Real-Time Systems. Note: Slides are adopted from Lui Sha and Marco Caccamo

useful than solving these yourself, writing up your solution and then either comparing your

Tug of War Game. William Gasarch and Nick Sovich and Paul Zimand. October 6, Abstract

Game Theory Fall 2003

Option Models for Bonds and Interest Rate Claims

Subject : Computer Science. Paper: Machine Learning. Module: Decision Theory and Bayesian Decision Theory. Module No: CS/ML/10.

Monash University School of Information Management and Systems IMS3001 Business Intelligence Systems Semester 1, 2004.

MS-E2114 Investment Science Lecture 4: Applied interest rate analysis

Lecture l(x) 1. (1) x X

Problem Set 7. Problem 7-1.

PARELLIZATION OF DIJKSTRA S ALGORITHM: COMPARISON OF VARIOUS PRIORITY QUEUES

Markov Decision Processes: Making Decision in the Presence of Uncertainty. (some of) R&N R&N

The Complexity of Simple and Optimal Deterministic Mechanisms for an Additive Buyer. Xi Chen, George Matikas, Dimitris Paparas, Mihalis Yannakakis

CS224W: Social and Information Network Analysis Jure Leskovec, Stanford University

56:171 Operations Research Midterm Exam Solutions Fall 1994

The exam is closed book, closed calculator, and closed notes except your three crib sheets.

Lecture 17: More on Markov Decision Processes. Reinforcement learning

FUNCIONAMIENTO DEL ALGORITMO DEL PCR: EUPHEMIA

Bounding Optimal Expected Revenues for Assortment Optimization under Mixtures of Multinomial Logits

The Process of Modeling

Problem 1 Food Manufacturing. The final product sells for $150 per ton.

Chapter 2 Linear programming... 2 Chapter 3 Simplex... 4 Chapter 4 Sensitivity Analysis and duality... 5 Chapter 5 Network... 8 Chapter 6 Integer

Lecture 6. 1 Polynomial-time algorithms for the global min-cut problem

Introduction to Operations Research

Computational Aspects of Prediction Markets

An Algorithm for Distributing Coalitional Value Calculations among Cooperating Agents

56:171 Operations Research Midterm Exam Solutions October 19, 1994

Lecture outline W.B.Powell 1

Advanced Operations Research Prof. G. Srinivasan Dept of Management Studies Indian Institute of Technology, Madras

Chapter wise Question bank

SET 1C Binary Trees. 2. (i) Define the height of a binary tree or subtree and also define a height balanced (AVL) tree. (2)

SOLVING ROBUST SUPPLY CHAIN PROBLEMS

CS599: Algorithm Design in Strategic Settings Fall 2012 Lecture 6: Prior-Free Single-Parameter Mechanism Design (Continued)

DM559/DM545 Linear and integer programming

Project Planning. Jesper Larsen. Department of Management Engineering Technical University of Denmark

CPS 270: Artificial Intelligence Markov decision processes, POMDPs

Computing Unsatisfiable k-sat Instances with Few Occurrences per Variable

Martingales. by D. Cox December 2, 2009

Lecture 7: Bayesian approach to MAB - Gittins index

CS221 / Spring 2018 / Sadigh. Lecture 9: Games I

Game Theory Problem Set 4 Solutions

CS 188 Fall Introduction to Artificial Intelligence Midterm 1

Iteration. The Cake Eating Problem. Discount Factors

Lesson 16: Saving for a Rainy Day

Lecture 9: Games I. Course plan. A simple game. Roadmap. Machine learning. Example: game 1

Online Shopping Intermediaries: The Strategic Design of Search Environments

Sublinear Time Algorithms Oct 19, Lecture 1

Recharging Bandits. Joint work with Nicole Immorlica.

Confidence Intervals for the Difference Between Two Means with Tolerance Probability

Assortment Optimization Over Time

Notes on the symmetric group

Lecture 11: Bandits with Knapsacks

1 Online Problem Examples

Computing Unsatisfiable k-sat Instances with Few Occurrences per Variable

CE 191: Civil and Environmental Engineering Systems Analysis. LEC 15 : DP Examples

Submodular Minimisation using Graph Cuts

Day 3. Myerson: What s Optimal

Algorithmic Game Theory and Applications. Lecture 11: Games of Perfect Information

Chapter 8 Statistical Intervals for a Single Sample

Family Vacation. c 1 = c n = 0. w: maximum number of miles the family may drive each day.

Stochastic Dual Dynamic Programming

Transcription:

Dynamic Programming( Weighted Interval Scheduling) June 11, 2014

Problem Statement: 1 We have a resource and many people request to use the resource for periods of time (an interval of time) 2 Each interval (request) i has a start time s i and finish time f i 3 Each interval (request) i, has a value v i Conditions: the resource can be used by at most one person at a time. we can accept only compatible intervals (requests) (overlap-free). Goal: a set of compatible intervals (requests) with a maximum total value.

What if all the values are the same?

What if all the values are the same? We start with the one which has the smallest finish time and add it into our solution and remove the ones that have intersection with it and repeat!

1 v 1 = 2 2 3 4 5 6 v 2 = 4 v 3 = 4 v 4 = 7 v 5 = 2 v 6 = 1

1 v 1 = 2 2 3 4 5 6 v 2 = 4 v 3 = 4 v 4 = 7 v 5 = 2 v 6 = 1 1 v 1 = 2 2 3 4 5 6 v 2 = 4 v 3 = 4 v 4 = 7 v 5 = 5 v 6 = 1

We order the intervals (requests) based on their finishing time (non-increasing order of finishing time) : f 1 f 2 f n

We order the intervals (requests) based on their finishing time (non-increasing order of finishing time) : f 1 f 2 f n For every interval j let p(j) be the largest index i < j such that intervals i, j do not overlap. p(j) = 0 if there is no interval before j and disjoint from j.

We order the intervals (requests) based on their finishing time (non-increasing order of finishing time) : f 1 f 2 f n For every interval j let p(j) be the largest index i < j such that intervals i, j do not overlap. p(j) = 0 if there is no interval before j and disjoint from j. 1 v 1 = 2 p(1) = 0 2 3 4 5 6 v 2 = 4 v 3 = 4 v 4 = 7 v 5 = 2 v 6 = 1 p(2) = 0 p(3) = 0 p(4) = 0 p(5) = 3 p(6) = 4

Let OPT (j) be the value of the optimal solution considering only intervals from 1 to j (according to their order).

Let OPT (j) be the value of the optimal solution considering only intervals from 1 to j (according to their order). We can write a recursive formula to compute OPT (j), Either interval j is in the optimal solution or j is not in the solution.

Let OPT (j) be the value of the optimal solution considering only intervals from 1 to j (according to their order). We can write a recursive formula to compute OPT (j), Either interval j is in the optimal solution or j is not in the solution. Therefore : OPT (j) = max{opt (j 1), v j + OPT (p(j))}

Let OPT (j) be the value of the optimal solution considering only intervals from 1 to j (according to their order). We can write a recursive formula to compute OPT (j), Either interval j is in the optimal solution or j is not in the solution. Therefore : OPT (j) = max{opt (j 1), v j + OPT (p(j))} Try not to implement using recursive call because the running time would be exponential! Recursive function is easy to implement but time consuming!

Dynamic Programming Iterative-Compute-Opt() 1. M[0] := 0; 2. for j = 1 to n 3. M[j] = max{v j + M[p(j)], M[j 1]}

Dynamic Programming Iterative-Compute-Opt() 1. M[0] := 0; 2. for j = 1 to n 3. M[j] = max{v j + M[p(j)], M[j 1]} Find-Solution(j) 1. if j = 0 then return 2. else 3. if (v j + M[p(j)] M[j 1]) 4. print j and print 5. Find-Solution(p(j)) 6. else 7. Find-Solution(j-1)

Exercise Problem: Given a weighted acyclic digraph D (weight are on the arcs), find a longest weighted path from source node s to sink node t. Source is the only node that has no incoming arc and sink is the only node that has no out-going arc.

1 v 1 = 2 p(1) = 0 2 3 4 5 v 2 = 4 v 3 = 4 v 4 = 7 v 5 = 2 p(2) = 0 p(3) = 0 p(4) = 0 p(5) = 3 6 v 6 = 1 p(6) = 4

Subset Sums and Knapsack Problem Subset Sums (Problem Statement): 1 We are given n items {1, 2,..., n} and each item i has weight w i 2 We are also given a bound W Goal: select a subset S of the items so that : 1 Σ i S w i W 2 Σ i S w i is maximized

A greedy approach won t work if it is based on picking the biggest value first. Suppose we have a set {W /2 + 1, W /2, W /2} of items. If we choose W /2 + 1 then we can not choose anything else. However the optimal is W /2 + W /2.

A greedy approach won t work if it is based on picking the biggest value first. Suppose we have a set {W /2 + 1, W /2, W /2} of items. If we choose W /2 + 1 then we can not choose anything else. However the optimal is W /2 + W /2. A greedy approach won t work if it is based on picking the smallest value first. Suppose we have a set {1, W /2, W /2} of items. If we choose 1 then we can only choose W /2 and nothing more. However the optimal is W /2 + W /2.

A greedy approach won t work if it is based on picking the biggest value first. Suppose we have a set {W /2 + 1, W /2, W /2} of items. If we choose W /2 + 1 then we can not choose anything else. However the optimal is W /2 + W /2. A greedy approach won t work if it is based on picking the smallest value first. Suppose we have a set {1, W /2, W /2} of items. If we choose 1 then we can only choose W /2 and nothing more. However the optimal is W /2 + W /2. Exhaustive search! Produce all the subset and check which one satisfies the constraint ( W ) and has maximum size. Running time O(2 n ).

Let OPT [i, w] be the optimal maximum value of a set S {1, 2,..., i} where the total value of the items in S is at most w.

Let OPT [i, w] be the optimal maximum value of a set S {1, 2,..., i} where the total value of the items in S is at most w. If w i > w then OPT [i, w] = OPT [i 1, w] otherwise

Let OPT [i, w] be the optimal maximum value of a set S {1, 2,..., i} where the total value of the items in S is at most w. If w i > w then OPT [i, w] = OPT [i 1, w] otherwise OPT [i, w] = max{opt [i 1, w], w i + OPT [i 1, w w i ]}

Subset-Sum(n,W) 1. Array M[0,.., n, 0,.., W ] 2. for ( i = 1 to W ) M[0, i] = 0 3. for ( i = 1 to n ) 4. for ( w = 1 to W ) 5. if (w < w i ) then M[i, w] = M[i 1, w] 6. else 7. if (w i + M[i 1, w w i ] > M[i 1, w]) 8. M[i, w] = w i + M[i 1, w w i ] 9. else M[i, w] = M[i 1, w]

Subset-Sum(n,W) 1. Array M[0,.., n, 0,.., W ] 2. for ( i = 1 to W ) M[0, i] = 0 3. for ( i = 1 to n ) 4. for ( w = 1 to W ) 5. if (w < w i ) then M[i, w] = M[i 1, w] 6. else 7. if (w i + M[i 1, w w i ] > M[i 1, w]) 8. M[i, w] = w i + M[i 1, w w i ] 9. else M[i, w] = M[i 1, w] Time complexity O(nW )

Exercise Suppose W = 6 and n = 3 and the items of sizes w 1 = w 2 = 2 and w 3 = 3. Fill out matrix M.

Problem : We are given n jobs {J 1, J 2,..., J n } where each J i has a processing time p i > 0 ( an integer). We have two identical machines M 1, M 2 and we want to execute all the jobs. Schedule the jobs so that the finish time is minimized.

Knapsack Problem Knapsack Problem : 1 We are given n items {1, 2,..., n} and each item i has weight w i 2 Each item has value v i 3 We are also given a bound W Goal: select a subset S of the items so that : 1 Σ i S w i W 2 Σ i S v i is maximized

Let OPT [i, w] be the optimal maximum value of a set S {1, 2,..., i} where the total value of the items in S is at most w.

Let OPT [i, w] be the optimal maximum value of a set S {1, 2,..., i} where the total value of the items in S is at most w. If w i > w then OPT [i, w] = OPT [i 1, w] otherwise

Let OPT [i, w] be the optimal maximum value of a set S {1, 2,..., i} where the total value of the items in S is at most w. If w i > w then OPT [i, w] = OPT [i 1, w] otherwise OPT [i, w] = max{opt [i 1, w], v i + OPT [i 1, w w i ]}