CS 401 Max Flow Applications Xiaorui Sun 1 Survey Design Survey - - PowerPoint PPT Presentation

cs 401
SMART_READER_LITE
LIVE PREVIEW

CS 401 Max Flow Applications Xiaorui Sun 1 Survey Design Survey - - PowerPoint PPT Presentation

CS 401 Max Flow Applications Xiaorui Sun 1 Survey Design Survey Design Survey design. Design survey asking n 1 consumers about n 2 products. Can only survey consumer i about a product j if they own it. Ask consumer i between c i and c i '


slide-1
SLIDE 1

CS 401

Max Flow Applications

Xiaorui Sun

1

slide-2
SLIDE 2

Survey Design

slide-3
SLIDE 3

Survey Design

Survey design.

Design survey asking n1 consumers about n2 products. Can only survey consumer i about a product j if they own it. Ask consumer i between ci and ci' questions. Ask between pj and pj' consumers about product j.

  • Goal. Design a survey that meets these specs, if possible.

1 3 1' 3' 2 4 2' 4' [c1, c1’] = [2, 4] [2, 4] [2, 4] [2, 4] [p1, p1’] = [2, 4] [2, 4] [2, 4] [2, 4]

consumers products

slide-4
SLIDE 4

Survey Design

Survey design.

Design survey asking n1 consumers about n2 products. Can only survey consumer i about a product j if they own it. Ask consumer i between ci and ci' questions. Ask between pj and pj' consumers about product j.

  • Goal. Design a survey that meets these specs, if possible.

Bipartite perfect matching. Special case when ci = ci' = pi = pi' = 1.

slide-5
SLIDE 5

Survey Design

  • Algorithm. Formulate as a circulation problem with lower

bounds.

Include an edge (i, j) if customer own product i. Demands = 0 for all vertices Integer circulation Û feasible survey design.

s

1 3 5 1' 3' 5'

t

2 4 2' 4' [c1, c1'] [0, 1]

consumers

[p1, p1'] [0, ¥]

products

slide-6
SLIDE 6

Image Segmentation

slide-7
SLIDE 7

Image Segmentation

Given an image we want to separate foreground from background

  • Important problem in image processing.
  • Divide image into coherent regions.

7

slide-8
SLIDE 8

Foreground / background segmentation

Label each pixel as foreground/background. ! = set of pixels, " = pairs of neighboring pixels. #$ is the original image. #$ ≫ 0 means we prefer to label ' in foreground. ($,* ≥ 0 is separation penalty for labeling one of ' and j as foreground, and the other as background. Goals: Find partition (-, -) that minimizes: − 0

$∈2

#$ +

$,* ∈4 $∈2,*∈2

($,* where - is the foreground.

8

slide-9
SLIDE 9

Min cut Formulation

!′ = (%′, '′). Add s to correspond to foreground; Add t to correspond to background; Use two anti-parallel edges instead of undirected edge.

9

pij pij pij

s t

i j

pij *+ if *+ > 0

!′

−*+ if *+ < 0

slide-10
SLIDE 10

Min cut Formulation (cont’d)

Consider min cut (", ") in G’. (" = foreground.)

10

%&' ", " = )

*∈,

−&* 1/012 + )

*∈,

&* 1/042 + )

*,5 ∈6 *∈,,5∈,

'*,5 = − ∑*∈, &* + ∑*∈, &* 1/042 + ∑*∈, &* 1/042 + ∑⋯'*,5 = − ∑*∈, &* + ∑* &* + ∑⋯'*,5 = − ∑*∈, &* + ∑⋯'*,5 + constant Precisely, what we want to minimize.

s t

i j

pij

?′ "

&5 if &5 > 0 −&5 if &5 < 0

slide-11
SLIDE 11

Reality

The main difficulty is to come up with a good model. Segmentation may be real-valued instead of {0,1}. There are many more than 1 objects. May need labeling. Augmenting path is not great for GPU.

11

slide-12
SLIDE 12

Summary

Min s-t cut problem. Find an s-t cut of minimum capacity. Max flow problem. Find s-t flow of maximum value. Ford-Fulkerson Algorithm. Augment flow along augmenting path

  • O(nm) for unit capacity graph
  • O(m2 log C) for integer capacity graph

Max flow applications

  • Bipartite matching, disjoint paths, circulation, image segmentation
  • Techniques: add source/sink, reduce to circulation, turn negative

values to (positive) capacities

12

slide-13
SLIDE 13

Longest Common Subsequence

Sequence alignment Common subsequence length = # matches

13

a g c d e f

  • f

b c d e a

  • Common subsequence = af

2 matches, 8 gaps

a

  • g

c d e f f b c d e

  • a

Common subsequence = acde 4 matches, 2 gaps, 1 mismatch

slide-14
SLIDE 14

Longest Common Subsequence

14

LCS: alignment with largest number of matches Let !"#(%, ') be the number of matches for the best alignment

)*, … , ), and -*, … , -. Case 1: OPT matches ),, -.

  • !"#(% − 1, ' − 1)+1 if ), = -., otherwise !"#(% − 1, ' − 1)

Case 2: OPT leaves ), unmatched

  • !"# % − 1, '

Case 3: OPT leaves -. unmatched

  • !"#(%, ' − 1)