Merging two upper hulls

Post on 05-Feb-2016

52 views 0 download

Tags:

description

Merging two upper hulls. Suppose, UH ( S 2 ) has s points given in an array according to their order on UH ( S 2 ) . We allocate processors and divide the points on UH ( S 2 ) into intervals and do a parallel search. We can identify the point in time. - PowerPoint PPT Presentation

transcript

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 1

Merging two upper hulls

• Suppose, UH(S2) has s points given in an array according to their order on UH(S2).

• We allocate processors and divide the points on UH(S2) into intervals and do a parallel search.

• We can identify the point in time.

s

irq log

( ) (1)log

sO O

s

s

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 2

Merging two upper hulls

• Suppose, the common tangent to UH(S1) and UH(S2) is the line .

• u is on UH(S1) and v is on UH(S2) .

• If we know the line , we can say in O(1) time whether u is above or below the line .

uv

ii rrq

ii rrq

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 3

Merging two upper hulls

• Suppose, there are t points on UH(S1), given in an array according to their order on UH(S1).

• We divide these t points in intervals, each interval contains points.

• We now do a parallel search in the following ways.

tt

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 4

Merging two upper hulls

• We allocate processors for the parallel search.

• Suppose ri is the boundary vertex of one of the intervals.

• For each such ri, we can find the tangent to UH(S2) in O(1) time using processors.

t s

sii rrq

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 5

Merging two upper hulls

u is to the left of (along the polygonal chain of UH(S ))

if and only if is above

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 6

Merging two upper hulls

• Hence, we can identify two boundary vertices rj and rk such that u is above rj and below rk.

• Hence, u must be one of the vertices in between rj and rk.

• This computation takes O(1) time and processors.

t

( )s t O n

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 7

Merging two upper hulls

• We can do a similar computation to find a group of vertices on UH(S2) in which v is a member.

• This computation again takes O(1) time and processors.

s

( )s t O n

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 8

Merging two upper hulls

• Now, we have vertices on UH(S2) and vertices on UH(S1) .

• There are possible lines if we join one point from UH(S1) and one point from UH(S2) .

• For each of these O(n) lines, we can check in O(1) time whether the line is a common tangent to UH(S1) and UH(S2) .

s t

( )s t O n

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 9

Merging two upper hulls

• Suppose, is one such line.

• ul and ur are the two neighboring vertices of u. Also, vl and vr are the two neighboring vertices of v.

• is the common tangent to both UH(S1) and UH(S2) if all the point ul, ur, vl, vr are below .

uv

uvuv

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 10

Merging two upper hulls

• For each of the O(n) lines, we can check this condition in O(1) time.

• Hence, we can find a common tangent to UH(S1) and UH(S2) in O(1) time and O(n) work.

• We can form another array of vertices containing the vertices in UH(S1) UH(S2) by deleting some parts of the arrays of UH(S1) and UH(S2) and merging the remaining parts.

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 11

The convex hull algorithm

• We solve the problem through a divide and conquer strategy.

• The depth of the recursion is O(log n) and we can do the merging of the convex hulls at every level of the recursion in O(1) time and O(n) work.

• Hence, the overall time required is O(log n) and the overall work done is O(n log n) which is optimal.

• We need the CREW PRAM model due to the concurrent reading in the parallel search algorithm.

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 12

Intersection of half planes

• Consider a line L defined by the equation y = ax + b.

• L divides the entire plane into two half planes, H+

(L) and H-(L).• H+(L) consists of all the points (, ) such that

a + b.• Similarly, H-(L) consists of all the points a + b.• Intuitively, H+(L) is the set of points on or above the

line L,• And, H-(L) is the set of points on or below the line L.

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 13

Intersection of half planes

• For a set of lines, the intersection of the positive half planes defined by these lines is a convex region.

• However, the intersection may or may not be bounded.

• Our aim is to compute the boundary of the intersection.

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 14

Dual transform

• Let T be a transformation that maps a point p = (a, b) into the line T(p) defined by y = ax + b.

• The reverse transformation maps the line L : y = ax + b into the point T(L) = (-a, b).

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 15

A property

Property: A point p is below a line L if and only if T(p) is below the point T(L).– Consider a set of lines L1, L2,…,Ln, and the region C

defined by 1 i n H+(Li) – The region C consists of all the points above all the

lines Li,1 i n

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 16

Intersection of half planes

• In the transformed domain, T(C+) = { T(p) | pC+ } consists of all the lines above all the points T(Li), for 1 i n.

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 17

Intersection of half planes

• The extreme points of the intersection of half planes are now the line segments between two consecutive vertices of the convex hull in the dual space.

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 18

Intersection of half planes

• To compute the intersection of the half planes, we first convert the lines into their dual points.

• Then we compute the convex hull of these dual points.

• Finally, we get the extreme points of the intersection of half planes by converting the line segments between two consecutive extreme points of the convex hull into points.

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 19

Intersection of half planes

• The transformations take O(1) time each if we allocate one processor for each line.

• The convex hull construction takes O(log n) time and O(n log n) work on the CREW PRAM.

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 20

Two variable linear program

• The two-variable linear program problem is defined as:Minimize cx + dy (Objective function)Subject to: aix + biy + ci 0, 1 i n.

(Constraints)

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 21

Two variable linear programming

• Each constraint is a half plane. The feasible region is a set of points satisfying all the constraints.

• The solution of the linear program is a point in the feasible region that minimizes the objective function.

• The objective function is minimized at one of the extreme points of the feasible region.

Advanced Topics in Algorithms and Data Structures

Lecture 7.2, page 22

Two variable linear programming

• Hence, we can find all the O(n) extreme points of the feasible region by the half plane intersection algorithm.

• Then we can find the extreme point which minimizes the objective function.

• The algorithm takes O(log n) time and O(n log n) work on the CREW PRAM.