applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · column minima form a stairs...

33
Applications of totally monotone matrices

Upload: others

Post on 10-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Applications of totally monotone matrices

Page 2: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Totally Monotone Matrix k l

i

j

<

<

Mik < Mil Mjk < Mjl

If i<j, k<l,

Page 3: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Totally Monotone Matrix

< <

Totally Monotone Monotone

Page 4: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

(Inverse) Monge Matrices k l

i

j

If for every i<j, k<l, Mik + Mjl ≥ Mil + Mjk

Page 5: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Inverse Monge Totally Monotone

k l

i

j

<

<

Mik < Mil Mjk < Mjl Mik + Mjl ≥ Mil + Mjk

Page 6: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Inverse Monge Totally Monotone of the transpose

k l

i

j

<

<

Mik < Mjk Mil < Mjl Mik + Mjl ≥ Mil + Mjk

Page 7: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Row maxima in totally monotone matrices

Given a totally monotone matrix compute the maximum in each row.

Page 8: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Classical results on totally monotone matrices

• SMAWK (Shor, Moran, Aggarwal, Wilber, Klawe): Row maxima/minima in O(n) time

Page 9: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

The concave least weight subsequence problem

• Input: w(i,j) defined for the integers 0≤i<j≤n

• w(i0,j0)+w(i1,j1) ≤ w(i0,j1)+w(i1,j0) for 0 ≤ i0 < i1 < j0 < j1 ≤n

• Problem: Find an integer k and a sequence 0=ℓ0< ℓ1<……< ℓk=n that minimizes:

1

1

0

( , )k

i i

i

w

Page 10: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

The concave least weight subsequence problem

w(i0,j0)+w(i1,j1) ≤ w(i0,j1)+w(i1,j0) for

0 ≤ i0 < i1 < j0 < j1 ≤n

i0 i1 j0 j1

Page 11: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Motivation: Paragraph packing

From my ibook:

Page 12: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

The w matrix is Monge 1 2 3 n

0 1

2

n-1

i0

i1

j0 j1

w

Page 13: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Add f(i) to row i 1 2 3 n

+ f(0)

+ f(1)

+ f(i0)

j0 j1

=G

+ f(i1)

+ f(n-1)

Page 14: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

The matrix G: g(i,j) = f(i) + w(i,j) 1 2 3 n

0 1

2

n-1

g(i,j)

G

G Monge, f(i) is the minimum of column i

f(i)

i

Page 15: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Column minima form a stairs shape 1 2 3 n

0 1

2

n-1

G

G Monge, f(i) is the minimum of column i

f(i)

i

Page 16: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Can We Use SMAWK ?

• Min Max, monge inverse Monge by negating

• Column row by transpose

BUT

• We do not have constant access to an entry of G

Page 17: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm (invariants)

r

c

c

• F(j) = f(j) for j ≤ c • All minima in columns ≥ (c+1) are in rows ≥ r

r ≤ c

Page 18: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

p = c + (c-r) + 1

r

c

c p

Page 19: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

p = c + (c-r) + 1

r

c

c p

SMAWK

Page 20: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

For (c+1) ≤ j ≤ p Set F(j) = min {G(i,j) | r ≤ i ≤ c}

r

c

c p

SMAWK

Page 21: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

For (c+1) ≤ j ≤ p Set F(j) = min {G(i,j) | r ≤ i ≤ c}

p-1

r

c

c p

SMAWK

SMAWK

Page 22: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

For (c+2) ≤ j ≤ p Set H(j) = min {G(i,j) | c+1 ≤ i ≤ p-1}

p-1

r

c

c p

SMAWK

SMAWK

Page 23: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

If F(c+2) ≤ H(c+2) then f(c+2) = F(c+2) and H(c+3) is correct

p-1

r

c

c p

SMAWK

SMAWK

c+1 c+2

Page 24: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

If F(c+3) ≤ H(c+3) then f(c+3) = F(c+3) and H(c+4) is correct

p-1

r

c

c p

SMAWK

SMAWK

c+1 c+2

Page 25: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

j0, c+2 ≤ j0 ≤ p such that H(j0) < F(j0) ?

p-1

r

c

c p

SMAWK

SMAWK

c+1 c+2 j0

Page 26: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

j0, set c := p

p-1

r

c

c p

SMAWK

SMAWK

c+1 c+2 j0

Page 27: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

j0, set c := p

c

r

c

Page 28: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

j0, set F(j0) = H(j0), c := j0, r := c+1

p-1

r

c

c p

SMAWK

SMAWK

c+1 c+2 j0

Page 29: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

A Linear Algorithm

j0, set F(j0) = H(j0), r := c+1, c := j0

c

r

c=j0

Page 30: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Analysis

Work per iteration proportional to c-r+1

p-1

r

c

c p

SMAWK

SMAWK

c+1 c+2 j0

Page 31: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Potential function

Φ(i) = r+c Always increasing, and ≤ 2n

Page 32: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Potential increase

j0, r := c+1, c := j0 : r’ = r + (c-r+1), c’ ≥ c+2 Φ’ ≥ Φ + c-r+3

p-1

r

c

c p

SMAWK

SMAWK

c+1 c+2 j0

Page 33: Applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · Column minima form a stairs shape 1 2 3 n 0 1 2 n-1 G G Monge, f(i) is the minimum of column i f(i) i . Can

Potential increase

j0, set c := p : c’ = c + c-r+1 Φ’ ≥ Φ + c-r+1 (unless p=n but then it’s the last iteration)

p-1

r

c

c p

SMAWK

SMAWK

c+1 c+2 j0