Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and...

172
1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander Wolff Chair for Computer Science I Source: CG: A&A §4

Transcript of Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and...

Page 1: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

1

Lecture 3. 2D Linear Programming via sweep-lines andrandomization

Advanced AlgorithmsWinter term 2019/20

Steven Chaplick & Alexander Wolff Chair for Computer Science I

Source: CG: A&A §4

Page 2: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

2 - 1

Maximizing ProfitYou are the boss of a small company that produces twoproducts, P1 and P2. If you produce x1 units of P1 and x2units of P2, your profit in e is

G(x1, x2) = 300x1 + 500x2

Page 3: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

2 - 2

Maximizing ProfitYou are the boss of a small company that produces twoproducts, P1 and P2. If you produce x1 units of P1 and x2units of P2, your profit in e is

G(x1, x2) = 300x1 + 500x2

Your production runs on three machines MA, MB, and MCwith the following capacities:

MA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

Page 4: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

2 - 3

Maximizing ProfitYou are the boss of a small company that produces twoproducts, P1 and P2. If you produce x1 units of P1 and x2units of P2, your profit in e is

G(x1, x2) = 300x1 + 500x2

Your production runs on three machines MA, MB, and MCwith the following capacities:

Which choice of (x1, x2) maximizes your profit?

MA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

Page 5: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 1

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 1500

0

linear constraints:

Page 6: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 2

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 1500

0

linear constraints:

Page 7: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 3

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 1500

0

linear constraints:

Page 8: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 4

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 1500

0

linear constraints:

Page 9: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 5

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

00

linear constraints:

Page 10: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 6

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

00

linear constraints:

Page 11: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 7

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

00

linear constraints:

set offeasiblesolutions

Page 12: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 8

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2

00

linear constraints:

linear objective fct.:

set offeasiblesolutions

Page 13: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 9

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

linear constraints:

linear objective fct.:

set offeasiblesolutions

Page 14: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 10

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

linear constraints:

linear objective fct.:

set offeasiblesolutions

Page 15: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 11

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

30,000e

linear constraints:

linear objective fct.:

set offeasiblesolutions

Page 16: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 12

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

linear constraints:

linear objective fct.:

set offeasiblesolutions

Page 17: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 13

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

linear constraints:

linear objective fct.:

set offeasiblesolutions

Page 18: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 14

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

linear constraints:

linear objective fct.:

set offeasiblesolutions

Page 19: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 15

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

linear constraints:

linear objective fct.:

∂MA ∩ ∂MB =set offeasiblesolutions

Page 20: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 16

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

linear constraints:

linear objective fct.:

∂MA ∩ ∂MB ={(110

40 )}

set offeasiblesolutions

Page 21: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 17

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

G(110, 40) =

linear constraints:

linear objective fct.:

set offeasiblesolutions

Page 22: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 18

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

G(110, 40) =

linear constraints:

linear objective fct.:

53,000set offeasiblesolutions

Page 23: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 19

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

53,000e

G(110, 40) =

linear constraints:

linear objective fct.:

53,000set offeasiblesolutions

Page 24: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 20

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

53,000e

G(110, 40) =

linear constraints:

linear objective fct.:

53,000set offeasiblesolutions

Page 25: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 21

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

53,000e

G(110, 40) =

linear constraints:

linear objective fct.:

53,000

Ax ≤ b

set offeasiblesolutions

Page 26: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 22

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

53,000e

G(110, 40) =

linear constraints:

linear objective fct.:

53,000

Ax ≤ b

x ≥ 0

set offeasiblesolutions

Page 27: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 23

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

53,000e

G(110, 40) =

linear constraints:

linear objective fct.:

53,000

Ax ≤ b

x ≥ 0

set offeasiblesolutions

Page 28: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 24

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

53,000e

G(110, 40) =

linear constraints:

linear objective fct.:

53,000

Ax ≤ b

maximize cTx

x ≥ 0

set offeasiblesolutions

Page 29: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 25

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

53,000e

G(110, 40) =

linear constraints:

linear objective fct.:

53,000

Ax ≤ b

maximize cTx

x ≥ 0

maximum value of objec-tive fct. given constraints

=set offeasiblesolutions

Page 30: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

3 - 26

The AnswerMA : 4x1 + 11x2 ≤ 880MB : x1 + x2 ≤ 150MC : x2 ≤ 60

50

100

150

200

x2

x150 100 150

x1 ≥ 0x2 ≥ 0

G(x1, x2) = 300x1 + 500x2= (300, 500)(x1

x2)

00

”iso-profit line“ (orthogonal to (300500))

15,000e

45,000e30,000e

53,000e

G(110, 40) =

linear constraints:

linear objective fct.:

53,000

Ax ≤ b

maximize cTx

x ≥ 0

maximum value of objec-tive fct. given constraints

=

max{cTx | Ax ≤ b, x ≥ 0}=

set offeasiblesolutions

Page 31: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 1

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

Page 32: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 2

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).Many algorithms known, e.g.:

Page 33: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 3

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).Many algorithms known, e.g.:– Simplex [Dantzig ’47]

Page 34: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 4

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

Page 35: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 5

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Page 36: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 6

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

Page 37: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 7

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

Page 38: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 8

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

[“Book” application: casting]

Page 39: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 9

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

[“Book” application: casting]

Page 40: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 10

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

⋂H = ∅

[“Book” application: casting]

Page 41: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 11

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

⋂H = ∅

c

[“Book” application: casting]

Page 42: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 12

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

⋂H = ∅

⋂H unbnd. in dir. c

c

[“Book” application: casting]

Page 43: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 13

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

⋂H = ∅

⋂H unbnd. in dir. c

cc

[“Book” application: casting]

Page 44: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 14

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

⋂H = ∅

⋂H unbnd. in dir. c

cc

[“Book” application: casting]

Page 45: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 15

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

⋂H = ∅

⋂H unbnd. in dir. c

cc

⋂H bounded.[“Book” application: casting]

Page 46: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 16

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

⋂H = ∅

⋂H unbnd. in dir. c

cc

⋂H bounded.

set of optima: segment vs. point

[“Book” application: casting]

Page 47: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

4 - 17

Definition and Known Algorithms

Given a set H of n halfspaces in Rd and a direction c, finda point x ∈ ⋂

H such that cx is maximum (or minimum).

We consider d = 2.VERY important problem, e.g., in Operations Research.

Many algorithms known, e.g.:– Simplex [Dantzig ’47]– Ellipsoid method [Khatchiyan ’79]

– Inner-point method [Karmakar’ 84]

Good for instances where n and d are large.

⋂H = ∅

⋂H unbnd. in dir. c

cc c

⋂H bounded.

set of optima: segment vs. point

[“Book” application: casting]

Page 48: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 1

First Approach

• compute⋂

H iteratively

Page 49: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 2

First Approach

• compute⋂

H iteratively

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Page 50: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 3

First Approach

• compute⋂

H iteratively

IntersectHalfplanes(H)

Let H = (h1, . . . , hn)C ← h1foreach i from 2 to n do

C ← C ∩ hi

return C

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Page 51: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 4

First Approach

• compute⋂

H iteratively

IntersectHalfplanes(H)

Let H = (h1, . . . , hn)C ← h1foreach i from 2 to n do

C ← C ∩ hi

return C

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Running time:

Page 52: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 5

First Approach

• compute⋂

H iteratively

IntersectHalfplanes(H)

Let H = (h1, . . . , hn)C ← h1foreach i from 2 to n do

C ← C ∩ hi

return C

TIH(n) = n·

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Running time:

Page 53: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 6

First Approach

• compute⋂

H iteratively

IntersectHalfplanes(H)

Let H = (h1, . . . , hn)C ← h1foreach i from 2 to n do

C ← C ∩ hi

return C

TIH(n) = n·

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

C := chain of linesegments (s1, . . . , st)

Running time:

Page 54: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 7

First Approach

• compute⋂

H iteratively

IntersectHalfplanes(H)

Let H = (h1, . . . , hn)C ← h1foreach i from 2 to n do

C ← C ∩ hi

return C

TIH(n) = n·

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

C := chain of linesegments (s1, . . . , st)

Walk around C to findsj, sj′ ∈ C intersecting hi

Running time:

Page 55: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 8

First Approach

• compute⋂

H iteratively

IntersectHalfplanes(H)

Let H = (h1, . . . , hn)C ← h1foreach i from 2 to n do

C ← C ∩ hi

return C

TIH(n) = n·

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

C := chain of linesegments (s1, . . . , st)

Walk around C to findsj, sj′ ∈ C intersecting hi

Update C

Running time:

Page 56: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 9

First Approach

• compute⋂

H iteratively

IntersectHalfplanes(H)

Let H = (h1, . . . , hn)C ← h1foreach i from 2 to n do

C ← C ∩ hi

return C

TIH(n) = n·

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

C := chain of linesegments (s1, . . . , st)

Walk around C to findsj, sj′ ∈ C intersecting hi

Update C

O(n)Running time:

Page 57: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 10

First Approach

• compute⋂

H iteratively

IntersectHalfplanes(H)

Let H = (h1, . . . , hn)C ← h1foreach i from 2 to n do

C ← C ∩ hi

return C

TIH(n) = n·

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

C := chain of linesegments (s1, . . . , st)

Walk around C to findsj, sj′ ∈ C intersecting hi

Update C

Total Time: O(n2) :(

O(n)Running time:

Page 58: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

5 - 11

First Approach

• compute⋂

H iteratively

IntersectHalfplanes(H)

Let H = (h1, . . . , hn)C ← h1foreach i from 2 to n do

C ← C ∩ hi

return C

TIH(n) = n·

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

C := chain of linesegments (s1, . . . , st)

Walk around C to findsj, sj′ ∈ C intersecting hi

Update C

Exercise: Compute C ∩ hi faster.

Total Time: O(n2) :(

O(n)Running time:

Page 59: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

6 - 1

Second Approach

• compute⋂

H via divide and conquer

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Page 60: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

6 - 2

Second Approach

• compute⋂

H via divide and conquer

IntersectHalfplanes(H)

if |H| = 1 thenC ← h, where {h} = H

elsesplit H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return C

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Page 61: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

6 - 3

Second Approach

• compute⋂

H via divide and conquer

IntersectHalfplanes(H)

if |H| = 1 thenC ← h, where {h} = H

elsesplit H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return C

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Page 62: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

6 - 4

Second Approach

• compute⋂

H via divide and conquer

IntersectHalfplanes(H)

if |H| = 1 thenC ← h, where {h} = H

elsesplit H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return C

Running time:

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Page 63: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

6 - 5

Second Approach

• compute⋂

H via divide and conquer

IntersectHalfplanes(H)

if |H| = 1 thenC ← h, where {h} = H

elsesplit H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return C

Running time: TIH(n) = 2TIH(n/2) + TICR(n)

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Page 64: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

6 - 6

Second Approach

• compute⋂

H via divide and conquer

IntersectHalfplanes(H)

if |H| = 1 thenC ← h, where {h} = H

elsesplit H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return C

Running time: TIH(n) = 2TIH(n/2) + TICR(n)

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

Page 65: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

6 - 7

Second Approach

• compute⋂

H via divide and conquer

IntersectHalfplanes(H)

if |H| = 1 thenC ← h, where {h} = H

elsesplit H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return C

Running time: TIH(n) = 2TIH(n/2) + TICR(n)

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

How complex canthe new region be?

Page 66: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

6 - 8

Second Approach

• compute⋂

H via divide and conquer

IntersectHalfplanes(H)

if |H| = 1 thenC ← h, where {h} = H

elsesplit H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return C

Running time: TIH(n) = 2TIH(n/2) + TICR(n)

How??

• walk ∂ (⋂

H), find vertex x w/ cx maximum, O(n) time

How complex canthe new region be?

Page 67: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 1

Intersecting Convex Regions

C1C2

Page 68: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 2

Intersecting Convex Regions

C1C2

`

Page 69: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 3

Intersecting Convex Regions

C1C2

`How many segments on `?

Page 70: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 4

Intersecting Convex Regions

C1C2

`How many segments on `?

Page 71: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 5

Intersecting Convex Regions

Lleft(C1)

C1C2

`

Lright(C1)

Lleft(C2)

Lright(C2)

How many segments on `?

Page 72: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 6

Intersecting Convex Regions

Lleft(C1)

C1C2

`

Lright(C1)

Lleft(C2)

leftEdgeC1

rightEdgeC1

leftEdgeC2

rightEdgeC2

Lright(C2)

How many segments on `?

Page 73: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 7

Intersecting Convex Regions

Lleft(C1)

C1C2

`

Lright(C1)

Lleft(C2)

leftEdgeC1

rightEdgeC1

leftEdgeC2

Is > 4 possible?

rightEdgeC2

Lright(C2)

How many segments on `?

Page 74: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 8

Intersecting Convex Regions

Lleft(C1)

C1C2

`

Lright(C1)

Lleft(C2)

leftEdgeC1

rightEdgeC1

leftEdgeC2

Is > 4 possible?No!

rightEdgeC2

Lright(C2)

How many segments on `?

Page 75: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 9

Intersecting Convex Regions

Lleft(C1)

C1C2

`

Lright(C1)

Lleft(C2)

leftEdgeC1

rightEdgeC1

leftEdgeC2

Is > 4 possible?No!

rightEdgeC2

Lright(C2)

How many segments on `?

How does this help us?

Page 76: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

7 - 10

Intersecting Convex Regions

Lleft(C1)

C1C2

`

Lright(C1)

Lleft(C2)

leftEdgeC1

rightEdgeC1

leftEdgeC2

Theorem. The intersection of two convex polygonalregions can be computed in linear time.

Is > 4 possible?No!

rightEdgeC2

Lright(C2)

How many segments on `?

How does this help us? sweep-line algorithm!

Page 77: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 1

Sweep-Line Algorithm

C1 C2

Page 78: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 2

Sweep-Line Algorithm

C1 C2

sweep line

events

Page 79: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 3

Sweep-Line Algorithm

C1 C2

events

Page 80: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 4

Sweep-Line Algorithm

C1 C2

events

Page 81: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 5

Sweep-Line Algorithm

C1 C2

events

Page 82: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 6

Sweep-Line Algorithm

C1 C2

events

Page 83: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 7

Sweep-Line Algorithm

C1 C2

events

next event?

Page 84: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 8

Sweep-Line Algorithm

C1 C2

events

next event?

Page 85: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 9

Sweep-Line Algorithm

C1 C2

events

Page 86: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 10

Sweep-Line Algorithm

C1 C2

events

Page 87: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 11

Sweep-Line Algorithm

C1 C2

events

Page 88: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 12

Sweep-Line Algorithm

C1 C2

events

Page 89: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 13

Sweep-Line Algorithm

C1 C2

events

Page 90: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 14

Sweep-Line Algorithm

C1 C2

events

Page 91: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 15

Sweep-Line Algorithm

C1 C2

events

next event?

Page 92: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 16

Sweep-Line Algorithm

C1 C2

events

next event?

Page 93: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 17

Sweep-Line Algorithm

C1 C2

events

Page 94: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

8 - 18

Sweep-Line Algorithm

C1 C2

events

Done, since we havefinished C!

Page 95: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 1

Data Structures1) event (-point) queue Q

2) (sweep-line) status T

Page 96: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 2

Data Structures1) event (-point) queue Q

p ≺ q ⇔def.

2) (sweep-line) status T

Page 97: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 3

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. yp > yq

2) (sweep-line) status T

Page 98: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 4

Data Structures1) event (-point) queue Q

p ≺ q ⇔def.

p q

yp > yq

2) (sweep-line) status T

Page 99: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 5

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

2) (sweep-line) status T

Page 100: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 6

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

2) (sweep-line) status T

`

Page 101: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 7

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

2) (sweep-line) status T

`

Page 102: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 8

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

Store event pts in sorted order acc. to ≺

2) (sweep-line) status T

`

Page 103: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 9

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

Store event pts in sorted order acc. to ≺

2) (sweep-line) status T

`

... linear time?

Page 104: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 10

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

Store event pts in sorted order acc. to ≺nextEvent() : either, next point (by ≺), or the intersectionpt. of two active segments (below the sweep-line)

2) (sweep-line) status T

`

Page 105: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 11

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

Store event pts in sorted order acc. to ≺nextEvent() : either, next point (by ≺), or the intersectionpt. of two active segments (below the sweep-line)

2) (sweep-line) status T

`

... runtime?

Page 106: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 12

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

Store event pts in sorted order acc. to ≺nextEvent() : either, next point (by ≺), or the intersectionpt. of two active segments (below the sweep-line)

2) (sweep-line) status T

`

... runtime? O(1), since num. active segments ≤ 4 :)

Page 107: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 13

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

Store event pts in sorted order acc. to ≺nextEvent() : either, next point (by ≺), or the intersectionpt. of two active segments (below the sweep-line)

2) (sweep-line) status T

`

`

... runtime? O(1), since num. active segments ≤ 4 :)

Page 108: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 14

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

Store event pts in sorted order acc. to ≺nextEvent() : either, next point (by ≺), or the intersectionpt. of two active segments (below the sweep-line)

2) (sweep-line) status T

Store the segments intersected by ` in left-to-right order.

`

`

... runtime? O(1), since num. active segments ≤ 4 :)

Page 109: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

9 - 15

Data Structures1) event (-point) queue Q

p ≺ q ⇔def. or (yp = yq and xp < xq)

p q

yp > yq

Store event pts in sorted order acc. to ≺nextEvent() : either, next point (by ≺), or the intersectionpt. of two active segments (below the sweep-line)

2) (sweep-line) status T

Store the segments intersected by ` in left-to-right order.

`

`

Also, maintain the new convex hull.

... runtime? O(1), since num. active segments ≤ 4 :)

Page 110: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

10 - 1

Second Approach: Halfplane IntersectionTheorem. The intersection of two convex polygonal

regions can be computed in linear time.

Page 111: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

10 - 2

Second Approach: Halfplane IntersectionTheorem. The intersection of two convex polygonal

regions can be computed in linear time.

IntersectHalfplanes(H)

if |H| = 1 then C ← h, where {h} = Helse

split H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return CRunning time: TIH(n) = 2TIH(n/2) + TICR(n)

Page 112: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

10 - 3

Second Approach: Halfplane IntersectionTheorem. The intersection of two convex polygonal

regions can be computed in linear time.

Corollary. The intersection of n half planes can becomputed in O(n log n) time.

IntersectHalfplanes(H)

if |H| = 1 then C ← h, where {h} = Helse

split H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return CRunning time: TIH(n) = 2TIH(n/2) + TICR(n)

Page 113: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

10 - 4

Second Approach: Halfplane IntersectionTheorem. The intersection of two convex polygonal

regions can be computed in linear time.

Corollary. The intersection of n half planes can becomputed in O(n log n) time.

Can we do better?

IntersectHalfplanes(H)

if |H| = 1 then C ← h, where {h} = Helse

split H into sets H1 and H2 with |H1|, |H2| ≈ |H|/2C1 ← IntersectHalfplanes(H1)C2 ← IntersectHalfplanes(H2)C ← IntersectConvexRegions(C1, C2)

return CRunning time: TIH(n) = 2TIH(n/2) + TICR(n)

Page 114: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 1

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

c

Page 115: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 2

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

c

Page 116: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 3

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

m1 c

Page 117: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 4

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

m1

m2

c

Page 118: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 5

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

m1

m2

c

Page 119: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 6

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

m1 =

{x ≤ M if cx > 0,x ≥ M otherwise,

for some sufficiently large M

m1

m2

c

Page 120: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 7

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

m1 =

{x ≤ M if cx > 0,x ≥ M otherwise,

for some sufficiently large M

m1

m2

m2 =

{y ≤ M if cy > 0,y ≥ M otherwise.

c

Page 121: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 8

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

m1 =

{x ≤ M if cx > 0,x ≥ M otherwise,

for some sufficiently large M

m1

m2

m2 =

{y ≤ M if cy > 0,y ≥ M otherwise.

c

Idea: M based on obj.fct. c.see §4.5 of CG: A&A for moreon unbounded LPs.

Page 122: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 9

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

m1 =

{x ≤ M if cx > 0,x ≥ M otherwise,

for some sufficiently large M

m1

m2

m2 =

{y ≤ M if cy > 0,y ≥ M otherwise.

• Take the lexicographically largest solution.

c

Idea: M based on obj.fct. c.see §4.5 of CG: A&A for moreon unbounded LPs.

Page 123: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 10

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

m1 =

{x ≤ M if cx > 0,x ≥ M otherwise,

for some sufficiently large M

m1

m2

m2 =

{y ≤ M if cy > 0,y ≥ M otherwise.

• Take the lexicographically largest solution.

c

Idea: M based on obj.fct. c.see §4.5 of CG: A&A for moreon unbounded LPs.

Page 124: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

11 - 11

A Small Trick: Make Solution Unique⋂

H = ∅⋂

H unbnd. in dir. c

c c

⋂H bounded.

• Add two bounding halfplanes m1 and m2

m1 =

{x ≤ M if cx > 0,x ≥ M otherwise,

for some sufficiently large M

m1

m2

m2 =

{y ≤ M if cy > 0,y ≥ M otherwise.

• Take the lexicographically largest solution.

⇒ Set of solutions is either empty or a uniquely defined pt.

c

Idea: M based on obj.fct. c.see §4.5 of CG: A&A for moreon unbounded LPs.

Page 125: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 1

Incremental ApproachIdea: Don’t compute

⋂H, but just one (optimal) point!

Page 126: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 2

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

Page 127: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 3

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

Page 128: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 4

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

Page 129: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 5

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

Page 130: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 6

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

Page 131: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 7

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

Page 132: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 8

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

Page 133: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 9

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

Page 134: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 10

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

Page 135: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 11

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

Page 136: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 12

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

Page 137: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 13

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

Page 138: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 14

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

c

Page 139: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 15

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

c

π∂hi(c)

Page 140: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 16

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

w-c running time:

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

c

π∂hi(c)

Page 141: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 17

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

w-c running time:

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

c

π∂hi(c)

Page 142: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 18

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

w-c running time:

O(1)

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

c

π∂hi(c)

O(1)

Page 143: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 19

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

w-c running time:

O(1)

O(i)

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

c

π∂hi(c)

O(1)

Page 144: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 20

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

w-c running time:

O(1)

O(i)

T(n) = ∑ni=1 O(i) =

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

c

π∂hi(c)

O(1)

Page 145: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 21

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

w-c running time:

O(1)

O(i)

T(n) = ∑ni=1 O(i) =

= O(n2) :-(

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

c

π∂hi(c)

O(1)

Page 146: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 22

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

w-c running time:

O(1)

O(i)

T(n) = ∑ni=1 O(i) =

= O(n2) :-(

RandomizedIdea: Don’t compute

⋂H, but just one (optimal) point!

∂hi

c

π∂hi(c)

O(1)

Page 147: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

12 - 23

Incremental Approach

2DBoundedLP(H, c, m1, m2)

H0 = {m1, m2}v0 ← corner of m1 ∩m2for i← 1 to n do

if vi−1 ∈ hi thenvi ← vi−1

elsevi ← 1DBoundedLP(π∂hi

(Hi−1), π∂hi(c))

if vi = nil thenreturn nil

Hi = Hi−1 ∪ {hi}return vn

w-c running time:

O(1)

O(i)

T(n) = ∑ni=1 O(i) =

= O(n2) :-(

Randomized

compute random permutation of H

Idea: Don’t compute⋂

H, but just one (optimal) point!

∂hi

c

π∂hi(c)

O(1)

Page 148: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 1

Result

:-)Theorem. The 2D bounded LP problem can be solved in

O(n) expected time.

Page 149: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 2

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

Page 150: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 3

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

Then the expected running time is

E[T2d(n)] =

Page 151: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 4

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Page 152: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 5

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Page 153: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 6

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Page 154: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 7

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

We fix the i random halfplanes in Hi.

Page 155: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 8

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Pr[Xi =1] = probability that the optimal solutionchanges when hi is added to Hi−1.

We fix the i random halfplanes in Hi.

Page 156: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 9

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Pr[Xi =1] = probability that the optimal solutionchanges when hi is added to Hi−1.

We fix the i random halfplanes in Hi.

Page 157: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 10

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Pr[Xi =1] = probability that the optimal solutionchanges when hi is added to Hi−1.

= probability that the optimal solutionchanges when hi is removed from Hi.

We fix the i random halfplanes in Hi.

Page 158: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 11

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Pr[Xi =1] = probability that the optimal solutionchanges when hi is added to Hi−1.

= probability that the optimal solutionchanges when hi is removed from Hi.

We fix the i random halfplanes in Hi.

i.e., when vi ∈ ∂hiand vi ∈ ∂hj forexactly one j < i.

Page 159: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 12

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Pr[Xi =1] = probability that the optimal solutionchanges when hi is added to Hi−1.

= probability that the optimal solutionchanges when hi is removed from Hi.

We fix the i random halfplanes in Hi.

≤ 2/i.

i.e., when vi ∈ ∂hiand vi ∈ ∂hj forexactly one j < i.

Page 160: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 13

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Pr[Xi =1] = probability that the optimal solutionchanges when hi is added to Hi−1.

= probability that the optimal solutionchanges when hi is removed from Hi.

We fix the i random halfplanes in Hi.

≤ 2/i. This is independent of the choice of Hi.

i.e., when vi ∈ ∂hiand vi ∈ ∂hj forexactly one j < i.

Page 161: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 14

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Pr[Xi =1] = probability that the optimal solutionchanges when hi is added to Hi−1.

= probability that the optimal solutionchanges when hi is removed from Hi.

We fix the i random halfplanes in Hi.

≤ 2/i. This is independent of the choice of Hi.

Page 162: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 15

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Pr[Xi =1] = probability that the optimal solutionchanges when hi is added to Hi−1.

= probability that the optimal solutionchanges when hi is removed from Hi.

We fix the i random halfplanes in Hi.

≤ 2/i. This is independent of the choice of Hi.

= O(n).

Page 163: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

13 - 16

Result

:-)

Proof. Let Xi =

{1 if vi−1 6∈ hi,0 else.

}(indicator random variable).

Theorem. The 2D bounded LP problem can be solved inO(n) expected time.

= O(n) + ∑ E[Xi] ·O(i)

= O(n) + ∑ Pr[Xi = 1] ·O(i)

Then the expected running time is

E[T2d(n)] = E[∑ni=1(1− Xi) ·O(1) + Xi ·O(i)]

Pr[Xi =1] = probability that the optimal solutionchanges when hi is added to Hi−1.

= probability that the optimal solutionchanges when hi is removed from Hi.

We fix the i random halfplanes in Hi.

≤ 2/i. This is independent of the choice of Hi.

= O(n).

Proof technique:Backward analysis!

Page 164: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

14 - 1

Alt. for Intersecting Convex Regions

Use sweep-line alg. for map overlay (line-segment intersections) !

Running time TMO(n) =

CG: A & A §2

Page 165: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

14 - 2

Alt. for Intersecting Convex Regions

Use sweep-line alg. for map overlay (line-segment intersections) !

Running time TMO(n) = O((n + I) log n),where I = # intersection points.

CG: A & A §2

Page 166: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

14 - 3

Alt. for Intersecting Convex Regions

Use sweep-line alg. for map overlay (line-segment intersections) !

Running time TMO(n) = O((n + I) log n),where I = # intersection points.here: I ≤

CG: A & A §2

Page 167: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

14 - 4

Alt. for Intersecting Convex Regions

Use sweep-line alg. for map overlay (line-segment intersections) !

Running time TMO(n) = O((n + I) log n),where I = # intersection points.here: nI ≤

CG: A & A §2

O(n log n) for ICR

Page 168: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

14 - 5

Alt. for Intersecting Convex Regions

Use sweep-line alg. for map overlay (line-segment intersections) !

Running time TMO(n) = O((n + I) log n),where I = # intersection points.

Running time TIH(n) = 2TIH(n/2) + TICR(n)

here: nI ≤

CG: A & A §2

O(n log n) for ICR

Page 169: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

14 - 6

Alt. for Intersecting Convex Regions

Use sweep-line alg. for map overlay (line-segment intersections) !

Running time TMO(n) = O((n + I) log n),where I = # intersection points.

Running time TIH(n) = 2TIH(n/2) + TICR(n)

here: nI ≤

≤ 2TIH(n/2) + O(n log n)

CG: A & A §2

O(n log n) for ICR

Page 170: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

14 - 7

Alt. for Intersecting Convex Regions

Use sweep-line alg. for map overlay (line-segment intersections) !

Running time TMO(n) = O((n + I) log n),where I = # intersection points.

Running time TIH(n) = 2TIH(n/2) + TICR(n)

here: nI ≤

≤ 2TIH(n/2) + O(n log n)

∈ O(n log2 n)

CG: A & A §2

O(n log n) for ICR

Page 171: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

14 - 8

Alt. for Intersecting Convex Regions

Use sweep-line alg. for map overlay (line-segment intersections) !

Running time TMO(n) = O((n + I) log n),where I = # intersection points.

Running time TIH(n) = 2TIH(n/2) + TICR(n)

here: nI ≤

≤ 2TIH(n/2) + O(n log n)

∈ O(n log2 n)As this is more general, it is unsurprisingly worse ... ∗

CG: A & A §2

O(n log n) for ICR

∗ it can happen sometimes that general algorithms give optimal runtimes for special cases

Page 172: Advanced Algorithms - uni-wuerzburg.de · 1 Lecture 3. 2D Linear Programming via sweep-lines and randomization Advanced Algorithms Winter term 2019/20 Steven Chaplick & Alexander

14 - 9

Alt. for Intersecting Convex Regions

Use sweep-line alg. for map overlay (line-segment intersections) !

Running time TMO(n) = O((n + I) log n),where I = # intersection points.

Running time TIH(n) = 2TIH(n/2) + TICR(n)

here: nI ≤

≤ 2TIH(n/2) + O(n log n)

∈ O(n log2 n)As this is more general, it is unsurprisingly worse ... ∗

Better to use specialized algorithm for intersectingconvex regions/polygons

CG: A & A §2

O(n log n) for ICR

∗ it can happen sometimes that general algorithms give optimal runtimes for special cases