applications of totally monotone matriceshaimk/adv-alg-2012/lws.pdf · column minima form a stairs...
TRANSCRIPT
Applications of totally monotone matrices
Totally Monotone Matrix k l
i
j
<
<
Mik < Mil Mjk < Mjl
If i<j, k<l,
Totally Monotone Matrix
< <
Totally Monotone Monotone
(Inverse) Monge Matrices k l
i
j
If for every i<j, k<l, Mik + Mjl ≥ Mil + Mjk
Inverse Monge Totally Monotone
k l
i
j
<
<
Mik < Mil Mjk < Mjl Mik + Mjl ≥ Mil + Mjk
Inverse Monge Totally Monotone of the transpose
k l
i
j
<
<
Mik < Mjk Mil < Mjl Mik + Mjl ≥ Mil + Mjk
Row maxima in totally monotone matrices
Given a totally monotone matrix compute the maximum in each row.
Classical results on totally monotone matrices
• SMAWK (Shor, Moran, Aggarwal, Wilber, Klawe): Row maxima/minima in O(n) time
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
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
Motivation: Paragraph packing
From my ibook:
The w matrix is Monge 1 2 3 n
0 1
2
n-1
i0
i1
j0 j1
w
Add f(i) to row i 1 2 3 n
+ f(0)
+ f(1)
+ f(i0)
j0 j1
=G
+ f(i1)
+ f(n-1)
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
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 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
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
A Linear Algorithm
p = c + (c-r) + 1
r
c
c p
A Linear Algorithm
p = c + (c-r) + 1
r
c
c p
SMAWK
A Linear Algorithm
For (c+1) ≤ j ≤ p Set F(j) = min {G(i,j) | r ≤ i ≤ c}
r
c
c p
SMAWK
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
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
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
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
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
A Linear Algorithm
j0, set c := p
p-1
r
c
c p
SMAWK
SMAWK
c+1 c+2 j0
A Linear Algorithm
j0, set c := p
c
r
c
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
A Linear Algorithm
j0, set F(j0) = H(j0), r := c+1, c := j0
c
r
c=j0
Analysis
Work per iteration proportional to c-r+1
p-1
r
c
c p
SMAWK
SMAWK
c+1 c+2 j0
Potential function
Φ(i) = r+c Always increasing, and ≤ 2n
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
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