Tutorial week 12

1 / 27
About This Presentation
Title:

Tutorial week 12

Description:

... two dog foods, Frisky Pup and Husky Hound, that are made from a blend of cereal and meat. ... of meat, and sells for $7. A package of Husky Hound uses ... – PowerPoint PPT presentation

Number of Views:99
Avg rating:3.0/5.0
Slides: 28
Provided by: cseCu

less

Transcript and Presenter's Notes

Title: Tutorial week 12


1
Tutorial week 12
  • Li Yongkun

2
outline
  • FFT example
  • hw6 answer
  • hw7 answer

3
FFT --one example
  • Compute the FFT of (1,0,1,0,).
  • FFT (2,0,2,0)

4
Hw6 problem1 --description
  • 3-Coloring is a yes/no question, but we can
    phrase it as an optimization problem as follows.
  • Suppose we are given a graph G (V, E), and we
    want to color each
  • node with one of three colors, even if we arent
    necessarily able to give different
  • colors to every pair of adjacent nodes. Rather,
    we say that an edge (u, v) is
  • satisfied if the colors assigned to u and v are
    different. Consider a 3-coloring that
  • maximizes the number of satisfied edges, and let
    c denote this number. Give a
  • polynomial-time algorithm that produces a
    3-coloring that satisfies at least 2/3c
  • edges. If you want, your algorithm can be
    randomized in this case, the expected
  • number of edges it satisfies should be at least
    2/3c.

5
Hw6 problem1 --algorithm
  • Algorithm
  • Initialize for each vertex v ? V color v
    lt- 0
  • //use 0, 1, 2 represent three colors
  • For each vertex v ? V
  • Randomly pick one color c
  • Coloring v color v lt- c

6
Hw6 problem1 --efficiency
  • We want the expected number of edges it
    satisfies should be at least 2/3c.
  • For each node, there are 3 choices. So, for each
    edge, there are 339 color state. Only when two
    nodes have the same color, the color state is not
    satisfied. So there are 3 states are not
    satisfied for each edge. For each edge, the
    probability that it satisfies the condition is
    2/3.
  • For each edge e, define r.v. X(e), 1 e is
    satisfied, 0 e is not satisfied
  • P(X(e)1)2/3.
  • Define r.v. X number of edge that is satisfied,
    X

7
Hw6 problem2 --description
  • Let G (V, E) be an undirected graph with n
    nodes and m edges. For a
  • subset X ? V, we use GX to denote the sub-graph
    induced on Xthat is, the
  • graph whose node set is X and whose edge set
    consists of all edges of G for
  • which both ends lie in X. We are given a natural
    number k n and are interested in
  • finding a set of k nodes that induces a dense
    sub-graph of G well phrase this
  • concretely as follows. Give a polynomial-time
    algorithm that produces, for a given
  • natural number k n, a set X ? V of k nodes with
    the property that the induced
  • sub-graph GX has at least mk(k-1)/n(n-1)
    edges. You may give either
  • a deterministic algorithm, or
  • a randomized algorithm that has an expected
    running time that is polynomial, and that only
    outputs correct answers.

8
Hw6 problem2 --algorithm
  • Algorithm
  • Initialize X is empty
  • While( GX is not satisfied) // less than
    mk(k-1)/n(n-1) edges
  • Randomly pick k nodes
  • Add these nodes into X

9
Hw6 problem2 --analysis
  • Step1 Prove For each GX generated by randomly
    picking k nodes. The expectation of number of
    edges is mk(k-1)/(n(n-1)).
  • For each edge e, define r. v. Y(e) e is chosen
    or not. 1 yes, 0 no
  • e is chosen iff both ends of e lie
    in X.
  • Define r. v. Y number of edges of GX

10
Hw6 problem2 --analysis
  • Step2 Prove For each randomly constructed GX,
    Pr EX mk(k-1)/(n(n-1)) 1/(mn(n-1)).
  • Define p(i) GX has i edges
  • Define
  • So

11
Hw6 problem2 --analysis
  • Step3 After polynomial times loop, you can get
    the GX which has at least mk(k-1)/(n(n-1))
    edges
  • Pr EX mk(k-1)/(n(n-1)) 1/(mn(n-1)).
  • O(mn(n-1))
  • If the condition becomes GX has at least
    edges
  • O (m) is enough

12
Hw6 problem3 --description
  • Suppose youre designing strategies for selling
    items on a popular auction Web site. Unlike other
    auction sites, this one uses a one-pass auction,
    in which each bid must be immediately (and
    irrevocably) accepted or refused. Specifically,
    the site works as follows.
  • First a seller puts up an item for sale.
  • Then buyers appear in sequence.
  • When buyer i appears, he or she makes a bid bi gt
    0.
  • The seller must decide immediately whether to
    accept the bid or not.
  • If the seller accepts the bid, the item is sold
    and all future buyers are turned away. If the
    seller rejects the bid, buyer i departs and the
    bid is withdrawn and only then does the seller
    see any future buyers. Suppose an item is offered
    for sale, and there are n buyers, each with a
    distinct bid. Suppose further that the buyers
    appear in a random order, and that the seller
    knows the number n of buyers. Wed like to design
    a strategy whereby the seller has a reasonable
    chance of accepting the highest of the n bids. By
    a strategy, we mean a rule by which the seller
    decides whether to accept each presented bid,
    based only on the value of n and the sequence of
    bids seen so far.

13
Hw6 problem3 --description
  • For example, the seller could always accept the
    first bid
  • presented. This results in the seller accepting
    the highest of the n bids with
  • Probability only 1/n, since it requires the
    highest bid to be the first one presented.
  • Give a strategy under which the seller accepts
    the highest of the n bids with
  • probability at least 1/4, regardless of the value
    of n. (For simplicity, you may
  • assume that n is an even number.) Prove that
    your strategy achieves this
  • probabilistic guarantee.

14
Hw6 problem3 --algorithm
  • Algorithm
  • Auction (n)
  • if n 5
  • Skip first 2 bids
  • i from 3 to 4
  • if bid (i) is larger than all first 2 bids,
    accept i-th bid
  • else accept the 5th bid
  • else
  • Skip first bids
  • i from 1 to n-1
  • If bid (i) is larger than all first
    bids
  • Accept i-th bid
  • If still not accept any bid, accept n-th bid

15
Hw6 problem3 --analysis
  • Step1 compute the probability that the accepted
    bid is highest
  • when adopt the strategy of
    skipping first k bids.
  • Define r. v. X the order of the highest bid
    (possible outcome1, 2, 3, , n)
  • Define event A the accepted bid is the largest
    one.
  • We want probability that A
    occurs when skip first k bids is adopted.

16
Hw6 problem3 --analysis
  • So,
  • Define g (x)xln(1/x) . g (x)ln(1/x)-1.
  • So when x1/e, g (x)0 gtk n/e.
  • That means (k/n)ln(n/k) obtains the largest
    value when kn/e.
  • k must be integer, let k
  • Verify.
  • When n is large enough, right.
  • n 5, consider separately

17
Hw6 problem3 --analysis
  • Verify
  • We have proved
  • ngt5
  • ngt8
  • 5ltn8
  • n5
  • 1 n 4 obviously right

18
Hw7 problem1 --description
  • Consider the following linear program.
  • maximize 5x 3y
  • 5x - 2y 0
  • x y 7
  • x 5
  • x 0
  • y 0
  • Plot the feasible region and identify the optimal
    solution.

19
Hw7 problem1 --answer
  • Draw the figure and parallel
  • move the objective function
  • The optimal solution is (5,2)

20
Hw7 problem2
  • The Canine Products company offers two dog foods,
    Frisky Pup and Husky Hound, that are made from a
    blend of cereal and meat. A package of Frisky Pup
    requires 1 pound of cereal and 1.5 pounds of
    meat, and sells for 7. A package of Husky Hound
    uses 2 pounds of cereal and 1 pound of meat, and
    sells for 6. Raw cereal costs 1 per pound and
    raw meat costs 2 per pound. It also costs 1.40
    to package the Frisky Pup and 0.60 to package
    the Husky Hound. A total of 240,000 pounds of
    cereal and 180,000 pounds of meat are available
    each month. The only production bottleneck is
    that the factory can only package 110,000 bags of
    Frisky Pup per month. Needless to say, management
    would like to maximize pro?t.
  • (a) Formulate the problem as a linear program in
    two variables.
  • (b) Graph the feasible region, give the
    coordinates of every vertex, and circle the
    vertex maximizing pro?t. What is the maximum
    pro?t?

21
Hw7 problem2 --answer
  • Formulate the problem as a linear program in two
    variables
  • Define x packages of Frisk Pup. y packages of
    Husky Hound
  • LP max 1.6x1.4y
  • s. t.
  • x2y240,000
  • 1.5xy180,000
  • x110,000
  • x0 and y0

22
Hw7 problem2 --answer
  • The optimal solution is
  • (60,000, 90,000)
  • Maximum profit 222,000

23
Hw7 problem2
  • set cover The set cover problem is as follows
    Given a set U and a collection of subsets S
    S1, , Sk, and a cost function c which gives
    each set Si a positive integer c(Si), find a
    minimum cost subcollection of S that covers all
    elements of U. That is, each element of U is
    contained in at least one subset Si that you
    picked.
  • The frequency f(u) of an element u in U is the
    number of sets Si it is in. The frequency f max
    f(u).
  • Write down an integer programming for this task,
    relax it to a LP, and then find a rounding
    method, and prove that it gives a polynomial
    time algorithm with approximation ratio f. That
    is, the algorithm outputs a value c s. t. c ? c
    ? f c, where c is the optimal solution of the
    set cover problem.

24
Hw7 problem2 --answer
  • Define r. v. X(i) ?0,1 with each S(i). X(i)1
    iff S(i) is in a (fixed) min set cover.
  • The objective
  • min ?S(i)?S X(i)C(S(i)).
  • Constraints
  • ?u?S(i) X(i)1 ?u?U
  • X(i) ?0,1 ?i

25
Hw7 problem2 --answer
  • IP
  • min ?S(i)?S X(i)C(S(i)).
  • s. t.
  • ?u?S(i) X(i)1 ?u?U
  • X(i) ?0,1 ?i
  • Relax to LP
  • min ?S(i)?S X(i)C(S(i)).
  • s. t.
  • ?u?S(i) X(i)1 ?u?U
  • 0 X(i) 1 ?i

26
Hw7 problem2 --answer
  • rounding procedure if X(i) 1/f, then pick it.
  • Prove denote
  • S an optimal set cover
  • X an solution of the LP
  • R(X) the rounding solution from X
  • Step1 S R(X)
  • For any element u since ?u?S(i) X(i) 1, at
    least one of X(i) (u ? S(i)) is 1\f, which
    will be picked to join the set.
  • Step2R(x) fS
  • ?iX(i) ?iX(i)1/f X(i) // we throw some
    part away
  • ?iX(i)1/f 1/f //
    X(i) 1/f
  • (1/f)R(x)

27
  • Thanks!
Write a Comment
User Comments (0)