Artificial Intelligence Fall 200120104634748

Document Sample
Artificial Intelligence Fall 200120104634748 Powered By Docstoc
					                                                           Computer
                                                            Science

               CPSC 433 - Artificial Intelligence

                  Search Paradigms:
                  Set Based Search
                              Adapted from
                              slides by Jörg
Rob Kremer                      Denzinger
ICT 748
kremer@cpsc.ucalgary.ca
http://pages.cpsc.ucalgary.ca/~kremer/
  08/04/2010            CPSC 433 Artificial Intelligence    1
                            Search Paradigms
                                                     TOC
•   Introduction
•   Formal Definitions
•   Less Formally
•   Conceptual Example
•   Designing a set-based search model
•   Example: Resolution
•   Example: Blocks world arch
•   Remarks

08/04/2010        CPSC 433 Artificial Intelligence    2
                      Search Paradigms
                                           Set-based Search
Basic Idea:
We have a collection of pieces of information (facts)
  that is (mostly) growing during the performance of
  a search; a relation between the different pieces is
  either not known, not of interest or describing only
  consequences of facts.
 Represent collection as a set, go from one set to
  successor by adding/deleting facts according to
  rules taking into account other facts already in the
  collection.
08/04/2010        CPSC 433 Artificial Intelligence       3
                      Search Paradigms
                                          Formal Definitions
Set-based Search Model Aset = (Sset,Tset):
• F: set of facts
• Ext  {AB | A,B  F}: set of extension rules
• Sset  2F          Power
                    set of F


• Tset = {(s,s')|  AB  Ext  A  s  s'=(s-A)B}

                                       Remove some
                                       facts and add
                                         some facts




08/04/2010        CPSC 433 Artificial Intelligence       4
                      Search Paradigms
                                             Formal Definitions
   Set-based Search Process Pset = (Aset,Env,Kset):
       Kset(s,e) = (s-A)B
   Where
   • AB  Ext
                                     Evaluate the
                                   “goodness” of a
   • A s                              change


   •  A'B'  Ext | A’ s  fWert(A,B,e)  fWert(A',B',e)
   • AB = fselect({A'B' |  A"B"  Ext | A" s 
Break a
  tie
                             fWert(A',B',e) 
       fWert(A",B",e)},e)

 For two functions fWert: 2F2FEnvNat and
   fselect: 22F2FEnv 2F2F
  08/04/2010         CPSC 433 Artificial Intelligence       5
                         Search Paradigms
                                              Formal Definitions
Set-based Search Instance Insset = (s0,Gset):

• s0, sgoal  2F
                         success


• Gset(s)  sgoal  s 
            there is no extension rule applicable in s

                           Failure (there’s
                           nowhere to go)




08/04/2010         CPSC 433 Artificial Intelligence          6
                       Search Paradigms
                                                     Less formally
• F can consist of solution pieces, solution
  candidates, parts of a world description, etc.
• With Ext we try to get more solution pieces,
  better candidates, more explicit parts of the
  description
• Or we eliminate wrong pieces, less good
  solutions, unnecessary explicit parts
• We construct the new parts using parts we
  already have
We make implicit knowledge explicit
08/04/2010        CPSC 433 Artificial Intelligence             7
                      Search Paradigms
                                                        Less formally
• The control selects the extension to apply by
     – Evaluating each applicable extension into a number
       (done by fWert)
     – Considering only extensions with minimal evaluation
     – Use fselect as tiebreaker
• Obviously, there usually are many different fWert
  and fselect functions
• Sometimes fWert can also produce integers or
  real numbers

08/04/2010           CPSC 433 Artificial Intelligence             8
                         Search Paradigms
                                                          Less formally
• We start with the given solution pieces, some
  random solutions, or the given parts of the
  description (or …)
• We stop, if
     – a complete solution sgoal is part of the actual state or
     – a good enough candidate that is really a solution is
        found or
     – the description is good enough or
     – a time limit is reached
     i.e. if enough knowledge (sgoal) is made explicit
08/04/2010             CPSC 433 Artificial Intelligence             9
                           Search Paradigms
Conceptual Example (I):Set-based Search

             + =                                 + =


                                                      3
                   9
                                        11




                    + =

08/04/2010         CPSC 433 Artificial Intelligence       10
                       Search Paradigms
Conceptual Example (I): Set-based Search

    Next state:




08/04/2010        CPSC 433 Artificial Intelligence   11
                      Search Paradigms
             Designing set-based search models
1. Identify set of facts F
2. Identify how you create new facts out of known
   facts (make sure that what you create are really
   facts!)
    Ext
3. You have your sets F and Ext that, with our
   definition earlier, are sufficient to define a set-
   based search model


08/04/2010          CPSC 433 Artificial Intelligence   12
                        Search Paradigms
         Designing set-based search processes
1. Identify possible functions that measure a fact

2. Decide if it is not too computationally expensive to compute
   the right side of applicable rules
   a) If it is not too expensive, define fWert by measuring A and B using 1.
   b) If it is too expensive, define fWert by measuring only A using 1.
   c) If you want to rely on random decisions, set fWert constant

3. Identify rules that have the same fWert-value and design fselect
   as tiebreaker (random decisions are best expressed using
   fselect)

  08/04/2010                CPSC 433 Artificial Intelligence              13
                                Search Paradigms
                Concrete Example (2): Resolution
• We describe our world by a collection of special logical
  formulas, so-called clauses:
         L1(t11,…,t1,n1)  …  Lm(tm1,…,tm,nm)
  where Li is a predicate symbol or its negation,
  tij terms out of function symbols and variables (x,y…)
  variables in different clauses are disjunct
• Examples: pq, P(a,b,x)R(x,y,c), Q(f(a,b),g(x,y)),
         Q(a,b)
• A consequence we want to prove is negated, transformed into
  clauses and these clauses are added to the world.
• The consequence is proven, if the empty clause () can be
  deduced.
   08/04/2010         CPSC 433 Artificial Intelligence    14
                          Search Paradigms
             Concrete Example (2): Resolution
• We derive new clauses by either Resolution or
  Factorization
Resolution:                    Most General
                                 Unifier
  C  P , D  P’
     (C  D)     if  = mgu(P,P’)
Factorization:
  C  P  P'
  (C  P)     if  = mgu(P,P’)
Note: clauses commute: pq  qp, pqr same
  as rpq
08/04/2010        CPSC 433 Artificial Intelligence   15
                      Search Paradigms
             Concrete Example (2): Resolution
Needed: Unification to compute mgu
Yet another set-based search problem:
States: set of term equations u  v, with  indicating
  failure
Extension rules:
Delete:      Decompose:                      Orient:
E  {t  t} E  {f(t1,…,tn)  f(s1,…,sn)}    E  {t  x}
     E           E  {t1  s1,…,tn  sn}     E  {x  t}
                                            if t no var.
08/04/2010        CPSC 433 Artificial Intelligence   16
                      Search Paradigms
              Concrete Example (2): Resolution
Substitute:                          if x not in t, with s[xt] the
      E  {x  t, t'  s'}           term generated out of s by
E  {x  t, t'[xt]  s'[xt]}       exchanging all occurences of
                                     x by t
Occurcheck:
E  {x  t}                          if x in t
   
Clash:
E  {f(t1,…,tn)  g(s1,…,sn)}
                                     if f  g
                
Goal condition: all equations in the state have form
  x  t and Occurcheck and Substitute are not applicable
 08/04/2010            CPSC 433 Artificial Intelligence      17
                           Search Paradigms
             Concrete Example (2): Resolution
x,y,z variables
Examples for Unification:
(1)f(g(x,y),c)  f(g(f(d,x),z),c)
(2)h(c,d,g(x,y))  h(c,d,g(g(a,y),z))
Examples for Resolution:
(1)p  q, p  q, p  q, p  q
(2)P(x)  R(x), R(f(a,b)), P(g(a,b))
(3)P(x)  R(y), R(f(a,b)), P(g(a,b))

08/04/2010        CPSC 433 Artificial Intelligence   18
                      Search Paradigms
             Concrete Example (2): Resolution
Tasks:
• Describe Resolution as set-based search model
• Given the following control idea, describe
  formally a search control for your model, so that
  we have a search process:
  Perform factorization whenever possible; choose
  the smallest possible clauses for resolution; if
  several clause pairs are smallest, use an
  ordering <Lit on the predicates and terms

08/04/2010        CPSC 433 Artificial Intelligence   19
                      Search Paradigms
             Concrete Example (2): Resolution
Tasks (cont.):
• Apply your process to the search instance to the
  following set of clauses:
  { P(x,y)  P(y,x),
    P(f(x),g(y))  R(y),
    P(g(x),f(x)),
    R(x)  Q(x,b),
    Q(a,x)}


08/04/2010        CPSC 433 Artificial Intelligence   20
                      Search Paradigms
                Concrete Example(3) Blocks World
  We want to build an arch in 6x4 coordinate world containing
   3 3x1 blocks.

                                                             c
                C
                B                                    a              b   
                A

S0 = {(A,h,2,1), (B,h,2,2), (C,h,2,3)}         G = {{,,} | a,b,c 
                                                   =(a,v,?,?) /\ =(b,v,?,?) /\ =(c,h,?,?)
                                                   /\ on (c,a) /\ on (c,b) /\ ~touch(a,b) }

  08/04/2010                     CPSC 433 Artificial Intelligence                        21
                                     Search Paradigms
                  Concrete Example(3) Blocks World
F: (name, orientation, x-coord, y-coord)


covers(a,x,y) = (a,v,x,y) \/ (a,v,x,y-1) \/ (a,v,x,y-2) //vertical case
             \/ (a,h,x,y) \/ (a,h,x-1,y) \/ (a,h,x-2,y) //horizontal case

overlaps(a,b) = x,y  covers(a,?,x,y,) /\ covers(b,?,x,y)

on(b,a) = (a,v,x,y) /\ covers(b,x,y+4) \/              //vertical
          (a,h,x,y) /\ (covers(b,x,y+1) \/ covers(b,x+1,y+1) \/ covers(b,x+2,y+1)) //horz

touch(a,b) = (a,h,x,y) /\ covers(b,x+4,y) \/             //horizontal
             (a,v,x,y) /\ (covers(b,x+1,y) \/ covers(b,x+1,y+1) \/ covers(b,x+1,y+2)) \/ //v
            on(a,b) \/ touch(b,a)                       //up/down and reverse case


    08/04/2010                     CPSC 433 Artificial Intelligence                    22
                                       Search Paradigms
                    Concrete Example(3) Blocks World
Env =  a,x,y  ((a,v,x,y) -> x<7 /\ y<3) /\ ((a,h,x,y) -> x<5 /\ y<5) //in the borders
       /\ (b | b≠a ~overlaps(a,b))                     //no overlap
       /\ ((b  on(a,b)) \/ (a,?,?,1))                  //gravity

S = {{(A,o,x,y),(B,o’,x’,y’),(C,o’’,x’’,y’’)} | Env}        //type of state is a set of A,B,C blocks

Ext = {ff’ | s:S | f  s  (s-ff’)  S}                    //can move a block anywhere legal

fwert = 10 + ((a,b  (a,v,?,?) /\ (b,v,?,?) /\ touch(a,b)) ? -5 : 0) + //vert’s shouldn’t touch
             ((a,b  (a,h,?,?) /\ (b,h,?,?) /\ on(a,b)) ? -2 : 0)      //don’t stack horizontals

fselect = <random>

Tset = {(s,s')|  AB  Ext  A  s  s'=(s-A)B}              //from the basic def. of Tset


     08/04/2010                       CPSC 433 Artificial Intelligence                         23
                                          Search Paradigms
                          Concrete Example(3) Blocks World

     move(C,v,1,1)                                  move(C,v,5,1)                       move(C,v,6,1)



move(C,v,5,1) move(B,v,5,1) move(B,v,6,1) move(B,v,1,1) move(B,v,6,1) move(C,v,5,1) move(B,v,1,1) move(B,v,5,1)
             8             10            10              10                 5       8         10                 5
     fwert                                                          fwert       fwert   fselect          fwert
   move(A,v,2,1)
             move(A,v,3,1) move(A,v,4,1)

             5             10            5
     fwert                       fwert

                 move(B,h,1,4)

                          10
                     G!
      08/04/2010                             CPSC 433 Artificial Intelligence                           24
                                                 Search Paradigms
                                                    Remarks
• Set-based search states can very quickly get
  very large.
• Usually a lot of extensions are possible
   control is very important
• Almost all evolutionary search approaches are
  set-based (see labs and later example)




08/04/2010       CPSC 433 Artificial Intelligence       25
                     Search Paradigms

				
DOCUMENT INFO