artificial intelligence as representation and search

14
Artificial Intelligence as Representation and Search

Upload: kirk-snider

Post on 02-Jan-2016

11 views

Category:

Documents


0 download

DESCRIPTION

Artificial Intelligence as Representation and Search. Representation. The purpose of representation is to abstract out the problem features which are non-essential to solving the problem and to capture those features which are essential. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Artificial Intelligence as Representation and Search

Artificial Intelligenceas

Representation and Search

Page 2: Artificial Intelligence as Representation and Search

Representation• The purpose of representation is to abstract out the

problem features which are non-essential to solving the problem and to capture those features which are essential.

• An example is “blocks worlds” where the problem is to construct a sequence of actions for a robot arm to transform the initial arrangement of blocks into a goal arrangement.– Essential Features

• Which blocks are on top of which blocks

• Which blocks are clear

• Which blocks are on table

Page 3: Artificial Intelligence as Representation and Search

Blocks World Representations

• Predicate Calculus

– Predicates : Clear(a), Ontable(a), On(b,a)

– Rules : X ¬Y on(Y,X) Clear(X)

• Arrays or Strings

– Stack : ABC

• State Space Graph– Graph with 3 blocks

– Start and Goal states

Page 4: Artificial Intelligence as Representation and Search

Natural Language UnderstandingSemantic Net Representation

vertebrate

bird

bluebirdsmall blue

feathers flies

isa

property

colorsize

coveringisa

Page 5: Artificial Intelligence as Representation and Search

Tic Tac Toe Representation

X

O

O

R1 O O

R2 O O

R3 X X

C1 X X

C2

C3 O O OO

D1 X O XO

D2

Page 6: Artificial Intelligence as Representation and Search

Blocks World SearchFind path from Start State to Goal State

Page 7: Artificial Intelligence as Representation and Search

Backtrack Search for BW3 solutionPrivate Function extend() As Boolean

Dim ex As Boolean = False

Dim children As New Stack(Of String)

If ns.Count = 0 Then

lbHistory.Items.Add("Goal unreachable ")

Return ex

Exit Function

ElseIf nextV = CInt(goal) Then

lbHistory.Items.Add("Path to goal: " & showS(s))

Return ex

Exit Function

End If

ex = True

children = NextChildren()

If children.Count = 0 Then

'backtrack

While s.Count > 0 And nextV = s.Peek

de.Push(nextV)

labels(CInt(nextV)) = "D"

s.Pop() 'remove first element of s

ns.Pop() 'remove first element of ns

nextV = ns.Peek

End While

s.Push(nextV)

labels(nextV) = "S"

Else

'next level

Dim nc As Stack(Of String) = NextChildren()

For Each state In nc

'save children on ns

ns.Push(state)

Next

nextV = ns.Pop

'get next child

s.Push(nextV)

labels(nextV) = "S"

End If

Return ex

End Function

Page 8: Artificial Intelligence as Representation and Search

Backtrack Search for BW3 solution

Page 9: Artificial Intelligence as Representation and Search

Semantic Net Searchfind attributes of specified object – CLIPS implementation

Page 10: Artificial Intelligence as Representation and Search

Semantic Net Searchfind attributes of specified object – CLIPS implementation

Page 11: Artificial Intelligence as Representation and Search

BFS Semantic Net• (deftemplate concept (slot cid) (slot name) (slot depth))• (deftemplate link (slot start) (slot end) (slot linkName))

• (deffacts snet• (concept (cid 1) (name bluebird) (depth -1))• (concept (cid 2) (name small) (depth -1))• (concept (cid 3) (name blue) (depth -1))• (concept (cid 4) (name feathers) (depth -1))• (concept (cid 5) (name bird) (depth -1))• (concept (cid 6) (name flies) (depth -1))• (concept (cid 7) (name vertebrate) (depth -1))• (link (start 1) (end 2) (linkName size))• (link (start 1) (end 3) (linkName color))• (link (start 1) (end 5) (linkName isa))• (link (start 5) (end 4) (linkName covering))• (link (start 5) (end 6) (linkName property))• (link (start 5) (end 7) (linkName isa))• )

• (defrule initsearch• (concept (cid 1) (name ?n) (depth -1))• =>• (assert (concept (cid 1) (name ?n) (depth 0)) )• )

• (defrule search• (concept (cid ?s) (name ?n) (depth ?d))• (test (> ?d -1))• (concept (cid ?e) (name ?m) (depth -1))• (link (start ?s) (end ?e) (linkName ?x))• =>• (bind ?dep (+ ?d 1))• (assert (concept (cid ?e) (name ?m) (depth ?dep)))• (printout t "Name : " ?m " , relation: " ?x " , depth : " ?dep crlf)• )

Page 12: Artificial Intelligence as Representation and Search

BFS Semantic Net• CLIPS (V6.20 03/31/02)• CLIPS> (load SemanticNet2.txt)• Defining deftemplate: concept• Defining deftemplate: link• Defining deffacts: snet• Defining defrule: initsearch +j• Defining defrule: search +j+j+j• TRUE• CLIPS> (reset)• CLIPS> (run)• Name : bird , relation: isa , depth : 1• Name : vertebrate , relation: isa , depth : 2• Name : flies , relation: property , depth : 2• Name : feathers , relation: covering , depth : 2• Name : blue , relation: color , depth : 1• Name : small , relation: size , depth : 1• CLIPS>

Page 13: Artificial Intelligence as Representation and Search

Tic Tac Toe Search

Page 14: Artificial Intelligence as Representation and Search

Tic Tac Toe SearchIf Start then

Mark Center

Else

Find Row, Column or Diagonal which is a win for Player and Mark

Else

Find Row, Column or Diagonal which is a win for opponent and Mark

Else

Construct a Fork if possible .. Etc.