instructor neelima gupta [email protected]. table of contents five representative problems

22
Instructor Neelima Gupta [email protected]

Upload: quentin-jennings

Post on 19-Jan-2016

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Instructor

Neelima Gupta

[email protected]

Page 2: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Table of Contents

Five representative problems

Page 3: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Five Representative ProblemsInterval Scheduling : can be solved by a greedy approach.Weighted Interval Scheduling : Natural greedy doesn’t

work, no other greedy is known, more sophisticated technique DP solves the problem.

Maximum Bipartite MatchingIndependent SetCompetitive Facility Location

Page 4: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Thanks to Neha (16)

Interval Scheduling Problem

Time0

P(1)=10

P(3)=4

P(4)=20

P(2)=3

1 2 3 4 5 6 7 8 9

P(5)=2

Page 5: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Examples Jobs submitted to an operating system,

Resource: CPU.

An HR of a company needs to schedule meetings of some committees in a meeting room, resource is meeting room

Scheduling classes in a room, resource is class-room

Page 6: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Greedy Approach :Increasing Finishing Times

Thanks to Neha (16)

Time0

P(1)=10

P(4)=20

P(2)=3

1 2 3 4 5 6 7 8 9

P(5)=2

.

back

Page 7: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Weighted Interval Scheduling

Time0

P(1)=10

P(3)=4

P(4)=20

P(2)=3

1 2 3 4 5 6 7 8 9

P(5)=2

Thanks to Neha (16)

Page 8: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Examples Jobs submitted to an operating system,

Resource: CPU.Weights: profit by executing the job

Page 9: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Greedy Approach

Time0

P(1)=10

P(4)=20

P(2)=3

1 2 3 4 5 6 7 8 9

P(5)=2

.

Thanks to Neha (16)

Page 10: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Greedy does not work

Time0

P(1)=10

P(4)=20

P(2)=3

1 2 3 4 5 6 7 8 9

P(5)=2

Optimal schedule

Schedule chosen by greedy app

Greedy approach takes job 2, 3 and 5 as best schedule and makes profit of 7. While optimal schedule is job 1 and job4 making profit of 30 (10+20). Hence greedy will not work

Thanks to Neha (16)

Page 11: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

u1

u2

u3

u4

v1

v2

v3

Figure 1

Example of a Bipartite graph :

u1

u2

Edge like this is not acceptable in Bipartite GraphV1

V2

(Thanks to Aditya(04),Abhishek(03)-Msc 2014)

Page 12: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

ExamplesThere is a set T of teachers with a set C of courses.

A teacher can teach only some set of courses represented by the edges in the bipartite graph.

Thus, bipartite graphs are used to represent relationships between two distinct sets of objects…teachers and courses here.

Jobs/Employers and Applicants: An employer receives several applications but only few of them qualify for the interview. Similarly an applicant applies for many jobs but qualify only for few for them for interview. An edge (a, e) in the bipartite graph represents that the applicant ‘a’ qualifies for the interview for job ‘e’.

Page 13: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Maximum Matching is a matching of maximum Cardinality.

u1

u2

u3

u4

v1

v2

v3

V

1

V2

By Applying the definition of matching, If we choose the edge (u1,v1) first

And then (u2, v2)

So no more edge can be included, hence matching in this case is :

(u1,v1) , (u2, v2)

(Thanks to Aditya(04),Abhishek(03)-Msc 2014)

Page 14: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

But instead of picking (u2,v2) , if we pick

• (u2 ,v3) after (u1 , v1) then

•( u4 ,v2) .

u1

u2

u3

u4

v1

v2

v3

V

1

V2

So, the problem is to find the Matching with MAXIMUM CARDINALITY in a given Bipartite graph.

Hence the Maximum Matching is :

(u1,v1) , (u2, v3 ) , (u4 , v2)

(Thanks to Aditya(04),Abhishek(03)-Msc 2014)

Page 15: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

ExamplesThere is a set T of teachers with a set C of courses.

A teacher can teach only some set of courses represented by the edges in the bipartite graph.A teacher needs to be assigned at most one course

and one course must be taught by only one teacher.

Suppose a number of committee meetings are to be scheduled in various meeting rooms during the time 3pm - 4pm. A committee meeting can be held only in few rooms (may be because other rooms are smaller in size than the committee size etc). An edge (c, r) represents that committee ‘c’ can be scheduled in room ‘r’.A committee needs to be assigned one room and one

room must be assigned to only one committee.

Page 16: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Maximum Bipartite Matching from Abhishek Aditya

Page 17: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Maximum Bipartite Matching from Abhishek Aditya

Page 18: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Maximum Bipartite Matching from Abhishek Aditya

Page 19: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Independent Set Given a graph G = (V, E), a subset S of V

is said to be independent if no two nodes in S are joined by an edge in G.

Page 20: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Thanks to: Sonia Verma (25, MCS '09)

Maximal Independent set of size 2

Page 21: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

Thanks to: Sonia Verma (25, MCS '09)

Maximal Independent set of size 3 …also Maximum

Page 22: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Five representative problems

More on Independent Set and Comp. FLP from Anurag