sp14 cs188 lecture 5 -- csps ii

Upload: imoptra143

Post on 05-Jul-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    1/38

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    2/38

    $oday

    +,cient Solution o CSPs

    -ocal Searc%

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    3/38

    .eminder: CSPs

    CSPs: /ariables Domains Constraints

    Im(licit 0(rovide code tocom(ute

    +2(licit 0(rovide a list o t%e legaltu(les

    Unary ) !inary ) 34ary

    5oals: 6ere: fnd any solution

    Also: fnd all fnd best etc'

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    4/38

    !ac"trac"ing Searc%

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    5/38

    Im(roving !ac"trac"ing

    5eneral4(ur(ose ideas give %uge gains in s(eed 7 but its all still 3P4%ard

    9iltering: Can &e detect inevitable ailure early

    ;rdering:

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    6/38

    Arc Consistency and !eyond

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    7/38

    Arc Consistency o an +ntire CSP

    A sim(le orm o (ro(agation ma"es sure all arcs are simuconsistent:

    Arc consistency detects ailure earlier t%an or&ard c%ec"i Im(ortant: I > loses a value neig%bors o > need to be rec =ust rerun ater eac% assignment?

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    8/38

    -imitations o Arc Consistency

    Ater enorcing arcconsistency: Can %ave one solution

    let

    Can %ave multi(le

    solutions let Can %ave no solutions let

    0and not "no& it

    Arc consistency still

    What wenwrong her

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    9/38

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    10/38

    K4Consistency

    Increasing degrees o consistency

    14Consistency 03ode Consistency: +ac% single nodesdomain %as a value &%ic% meets t%at nodes unaryconstraints

    4Consistency 0Arc Consistency: 9or eac% (air o nodesany consistent assignment to one can be e2tended tot%e ot%er

    K4Consistency: 9or eac% " nodes any consistentassignment to "41 can be e2tended to t%e "t% node'

    6ig%er " more e2(ensive to com(ute

    Bou need to "no& t%e " case: arc consistenc

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    11/38

    Strong K4Consistency

    Strong "4consistency: also "41 "4 7 1 consistent

    Claim: strong n4consistency means &e can solve &it%outbac"trac"ing?

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    12/38

    Structure

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    13/38

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    14/38

    $ree4Structured CSPs

     $%eorem: i t%e constraint gra(% %as no loo(s t%e CSP canin ;0n d time Com(are to general CSPs &%ere &orst4case time is ;0dn

     $%is (ro(erty also a((lies to (robabilistic reasoning 0latere2am(le o t%e relation bet&een syntactic restrictions and

    com(le2ity o reasoning

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    15/38

    $ree4Structured CSPs

    Algorit%m or tree4structured CSPs: ;rder: C%oose a root variable order variables so t%at (

    (recede c%ildren

    .emove bac"&ard: 9or i n : a((ly.emoveInconsistent0Parent0>i>i

    Assign or&ard: 9or i 1 : n assign >i consistently &it%

    .untime: ;0n d

    0&%y

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    16/38

    $ree4Structured CSPs

    Claim 1: Ater bac"&ard (ass all root4to4lea arcs are cons Proo: +ac% >→ B &as made consistent at one (oint and B

    could not %ave been reduced t%ereater 0because Bs c%ild(rocessed beore B

    Claim : I root4to4lea arcs are consistent or&ard assignmbac"trac"

    Proo: Induction on (osition

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    17/38

    Im(roving Structure

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    18/38

    3early $ree4Structured CSPs

    Conditioning: instantiate a variable (rune its neigdomains

    Cutset conditioning: instantiate 0in all &ays a setvariables suc% t%at t%e remaining constraint gra(

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    19/38

    Cutset Conditioning

    SA

    SA SA

    Instantiate t%ecutset 0all (ossible

    &ays

    Com(ute residualCSP or eac%assignment

    Solve t%e residualCSPs 0treestructured

    C%oose a cutset

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    20/38

    Cutset @uiH

    9ind t%e smallest cutset or t%e gra(% belo&

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    21/38

     $ree Decom(osition

    Idea: create a tree4structured gra(% o mega4variables

    +ac% mega4variable encodes (art o t%e original CSP

    Sub(roblems overla( to ensure consistent solutions

    M1 M2 M3 M4

      {(WA=r,SA=g,NT=b),

    (WA=b,SA=r,NT=g),

      …}

      {(NT=r,SA=g,Q=b),

      (NT=b,SA=g,Q=r),

      …}

     Agree: (M1,M2) ∈ 

    {((WA=g,SA=g,NT=g), (NT=g,SA=g,Q=g)), …}

    Agree

    on

    sharedvars

    NT

    SA

     

    WA

     

    Q

    SA

     

    NT

     

    Agree

    on

    sharedvars

    NS

    W

    SA

     

    Q

     

    Agree

    on

    sharedvars

    SA

     

    NS

    W

     

    i

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    22/38

    Iterative Im(rovement

    I i Al i % CSP

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    23/38

    Iterative Algorit%ms or CSPs

    -ocal searc% met%ods ty(ically &or" &it% Jcom(lete statevariables assigned

     $o a((ly to CSPs:  $a"e an assignment &it% unsatisfed constraints ;(erators reassign variable values 3o ringe? -ive on t%e edge'

    Algorit%m:

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    24/38

    +2am(le: F4@ueens

    States: F Mueens in F columns 0FF NO states

    ;(erators: move Mueen in column 5oal test: no attac"s +valuation: c0n number o attac"s

    #Demo: n4Mueens itim rovement 0-ND1

    /ideo o Demo Iterative Im(rovem

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    25/38

    /ideo o Demo Iterative Im(rovem@ueens

    /ideo o Demo Iterative Im(rove

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    26/38

    /ideo o Demo Iterative Im(roveColoring

    P =i C Li t

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    27/38

    Perormance o =in4ConLicts

    5iven random initial state can solve n4Mueens in almost ctime or arbitrary n &it% %ig% (robability 0e'g' n 1EEEE

     $%e same a((ears to be true or any randomly4generatedexcept  in a narro& range o t%e ratio

    S CSP

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    28/38

    Summary: CSPs

    CSPs are a s(ecial "ind o searc% (roblem: States are (artial assignments 5oal test defned by constraints

    !asic solution: bac"trac"ing searc%

    S(eed4u(s: ;rdering 9iltering Structure

    Iterative min4conLicts is oten eQective in

    (ractice

    -ocal Searc%

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    29/38

    -ocal Searc%

    -ocal Searc%

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    30/38

    -ocal Searc%

     $ree searc% "ee(s une2(lored alternatives on t%e ringe 0ecom(leteness

    -ocal searc%: im(rove a single o(tion until you cant ma"eringe?

    3e& successor unction: local c%anges

    5enerally muc% aster and more memory e,cient 0but inc

    6ill Climbing

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    31/38

    6ill Climbing

    Sim(le general idea:

    Start &%erever .e(eat: move to t%e best neig%boring state I no neig%bors better t%an current Muit

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    32/38

    6ill Climbing Diagram

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    33/38

    Simulated Annealing

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    34/38

    Simulated Annealing

    Idea: +sca(e local ma2ima by allo&ing do&n%illmoves

    !ut ma"e t%em rarer as time goes on

    3!

    Simulated Annealing

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    35/38

    Simulated Annealing

     $%eoretical guarantee: Stationary distribution:

    I $ decreased slo&ly enoug%

    &ill converge to o(timal state?

    Is t%is an interesting guarantee

    Sounds li"e magic but reality is reality:  $%e more do&n%ill ste(s you need to esca(e a

    local o(timum t%e less li"ely you are to everma"e t%em all in a ro&

    Peo(le t%in" %ard about ridge operators &%ic%let you um( around t%e s(ace in better &ays

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    36/38

    +2am(le: 34@ueens

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    37/38

    +2am(le: 34@ueens

  • 8/15/2019 Sp14 Cs188 Lecture 5 -- Csps II

    38/38

    3e2t $ime: Adversarial Searc