REPRESENTATION METHODS
Download
1 / 82

Lecture - PowerPoint PPT Presentation


  • 278 Views
  • Updated On :

REPRESENTATION METHODS. Represent the information:

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Lecture' - Angelica


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Slide1 l.jpg

REPRESENTATION METHODS

Represent the information:

Animals are generally divided into birds and mammals. Birds are further classified into large birds and small birds. Small birds include sparrows, and crows. The large birds are ostriches. The mammals include whales, monkeys, and elephants. Charlie is a elephant.

CS 331/531 Dr M M Awais


Slide2 l.jpg

Predicate

  • types(Animals, Birds,Mammals)

  • types(Birds, Largebirds, Smallbirds)

  • Etc…

  • Unify to answer the queries

  • IS THERE ANY OTHER WAY?

CS 331/531 Dr M M Awais


Slide3 l.jpg

Semantic Nets (Graphical Methods)

Animal

Super Class: Animal

IS-A

IS-A

IS-A

Mammal

Bird

Large

IS-A

IS-A

IS-A

small

Elephant

whales

instance

instance

Instance

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide4 l.jpg

Semantic Nets (Graphical Methods)

Animal

IS_A: Relation

Animal: Super

Bird: Class

Mammal: Class

IS-A

IS-A

IS-A

Mammal

Bird

Large

IS-A

IS-A

IS-A

small

Elephant

whales

instance

instance

Instance

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide5 l.jpg

Semantic Nets (Graphical Methods)

Animal

IS-A

IS-A

IS-A

Mammal

Bird

Large

IS-A

IS-A

IS-A

small

Elephant

whales

instance

instance

Instance

sparrow

crow

charlie

Instance: defines a specific instance of a class

CS 331/531 Dr M M Awais


Slide6 l.jpg

Semantic Nets (Graphical Methods)

Animal

IS-A

IS-A

IS-A

Mammal

Bird

Large

IS-A

IS-A

IS-A

small

Elephant

whales

instance

instance

Instance

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide7 l.jpg

Semantic Nets (Graphical Methods)

Animal

IS-A

IS-A

IS-A

Mammal

Bird

Large

IS-A

IS-A

IS-A

small

Elephant

whales

instance

instance

Instance

sparrow

crow

charlie

bananas

likes

Can have attribute link: likes for instance, class, superclass

CS 331/531 Dr M M Awais


Slide8 l.jpg

SEARCH METHODS

  • Formulate a problem as a search

  • Can answer queries such as:

  • Is CHARLIE an animal?

CS 331/531 Dr M M Awais


Slide9 l.jpg

Search Representation

Animal

Level 0: Root node

Mammal

Bird

Large

small

Elephant

whales

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide10 l.jpg

Search Representation

Animal

Level 0: Root node

Mammal

Level 1

Bird

Large

small

Elephant

whales

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide11 l.jpg

Search Representation

Animal

Level 0: Root node

Mammal

Level 1

Bird

Large

small

Elephant

whales

Level 2

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide12 l.jpg

Search Representation

Animal

Level 0: Root node

Mammal

Level 1

Bird

Large

small

Elephant

whales

Level 2

sparrow

crow

charlie

Level 3

CS 331/531 Dr M M Awais


Slide13 l.jpg

Answering Queries

Is charlie an animal?

Answer:

Traverse the tree

If charlie node

present then

answer is YES

otherwise NO

Animal

Level 0: Root node

Mammal

Level 1

Bird

Large

small

Elephant

whales

Level 2

sparrow

crow

charlie

Level 3

CS 331/531 Dr M M Awais


Slide14 l.jpg

Answering Queries

Is charlie an animal?

Answer:

Traverse the tree

If charlie node

present then

answer is YES

otherwise NO

Animal

Level 0: Root node

Mammal

Level 1

Bird

Large

small

Elephant

whales

Level 2

sparrow

crow

charlie

Level 3

The way one traverses the tree defines SEARCH TYPES

CS 331/531 Dr M M Awais


Slide15 l.jpg

SEARCH METHODS

  • Blind Search

    • Breadth First

    • Depth First

    • Iterative Deepening

  • Heuristic search

    • Hill Climbing

    • Best First

    • A* Search

CS 331/531 Dr M M Awais


Slide16 l.jpg

Standard Terms

Animal

Root node

Mammal

Bird

Large

small

Elephant

whales

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide17 l.jpg

Standard Terms

Animal

Childof Animal node

Mammal

Bird

Large

small

Elephant

whales

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide18 l.jpg

Standard Terms

Animal

Mammal

Bird

Bird and Mammal are Siblings

Large

small

Elephant

whales

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide19 l.jpg

Standard Terms

Animal

Root node

Mammal

Bird

Large

small

Elephant

whales

sparrow

crow

charlie

GOAL node

Path to a node is the list of nodes from the root to the goal node.

CS 331/531 Dr M M Awais


Slide20 l.jpg

Standard Terms

Animal

Root node

Mammal

Bird

Large

small

Elephant

whales

sparrow

crow

charlie

GOAL node

Path to a node is the list of nodes to the goal node (bold lines).

CS 331/531 Dr M M Awais


Slide21 l.jpg

How to Traverse the Tree to find PATH?

Animal

Mammal

Bird

Large

small

Elephant

whales

sparrow

crow

charlie

CS 331/531 Dr M M Awais


Slide22 l.jpg

ANALYSIS OF SEARCH STRATEGIES

Completeness: is the strategy guaranteed to find a solution where there is one?

Time Complexity: How long does it take to find a solution?

Space Complexity: How much memory does it need to perform the search?

Optimality: Does the strategy find the highest quality solution when there are several different solutions?

CS 331/531 Dr M M Awais


Slide23 l.jpg

  • Exhaustive Search

  • One can systematically check every state that is reachable from initial state to end out if it is a goal state.

  • Search Space

  • The set of all states is the search space

  • For simple/small search space exhaustive search is applicable [BRUTE FORCE or BLIND SEARCH]

  • For complex search space HEURISTIC SEARCH is used

CS 331/531 Dr M M Awais


Slide24 l.jpg

GRAPHS AND TREES

  • Graphs:-

  • Consist of a set of nodes with links between them

  • links can be directed / undirected

  • Path is the sequence of nodes connected nodes via links.

  • Acyclic graphs = (Paths linking a node

  • with itself are absent)

  • Trees???

CS 331/531 Dr M M Awais


Slide25 l.jpg

  • Tree:-

  • A tree is a special kind of graph with only one path to each node, usually represented with a special root node at the top

  • Relationship between nodes

  • Parent

  • Children

  • Sibling

  • Ancestor Node, Descendant Node, Leaf Node

CS 331/531 Dr M M Awais


Graphs vs trees l.jpg

d

a

c

a

b

c

d

g

f

e

b

Graphs VS Trees

  • Compare the searches in the two (which is efficient)

CS 331/531 Dr M M Awais


Relating state and graph nodes l.jpg
Relating State and Graph Nodes

  • Every physical state of a problem can be represented as a node in a graph/tree

  • The link between the nodes represent action required to change the states

  • For a navigation problem:

    • Link: driving action

    • Node: cities

  • For the Wumpus world problem:

    • Link: movement of the agent

    • Node: present position of the agent

CS 331/531 Dr M M Awais


8 puzzle problem states vs nodes l.jpg
8 Puzzle Problem: states vs. nodes

  • A state is a (representation of) a physical configuration

  • A node is a data structure constituting part of a search tree includes state, parent node, action, path costg(x), depth

CS 331/531 Dr M M Awais


8 puzzle problem states vs nodes29 l.jpg
8 Puzzle Problem: states vs. nodes

  • A state is a (representation of) a physical configuration

  • A node is a data structure constituting part of a search tree includes state, parent node, action, path costg(x), depth

CS 331/531 Dr M M Awais


Tree search algorithms l.jpg
Tree search algorithms

  • Basic idea:

    • offline, simulated exploration of state space by generating successors of already-explored states (a.k.a.~expanding states)

CS 331/531 Dr M M Awais


Example romania l.jpg
Example: Romania

CS 331/531 Dr M M Awais


Example romania32 l.jpg
Example: Romania

  • On holiday in Romania; currently in Arad.

  • Flight leaves tomorrow from Bucharest

  • Formulate goal:

    • be in Bucharest

  • Formulate problem:

    • states: various cities

    • actions: drive between cities

  • Find solution:

    • sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest

CS 331/531 Dr M M Awais


Tree search example l.jpg
Tree search example

CS 331/531 Dr M M Awais


Tree search example34 l.jpg
Tree search example

CS 331/531 Dr M M Awais


Tree search example35 l.jpg
Tree search example

Keep on expanding unless you reach the goal

CS 331/531 Dr M M Awais


Search strategies l.jpg
Search strategies

  • A search strategy is defined by picking the order of node expansion

  • Strategies are evaluated along the following dimensions:

    • completeness: does it always find a solution if one exists?

    • time complexity: number of nodes generated

    • space complexity: maximum number of nodes in memory

    • optimality: does it always find a least-cost solution?

  • Time and space complexity are measured in terms of

    • b: maximum branching factor of the search tree

    • d: depth of the least-cost solution

    • m: maximum depth of the state space (may be ∞)

CS 331/531 Dr M M Awais


Blind search strategies l.jpg
Blind Search: Strategies

  • Breadth First (Breadth wise expansion)

  • Depth First (Depth wise expansion)

  • Iterative Deepening (combination)

CS 331/531 Dr M M Awais


Breadth first search l.jpg
Breadth-first search

  • Expand shallowest unexpanded node

  • Implementation:

    • FIFO queue, i.e., new successors go at end

CS 331/531 Dr M M Awais


Breadth first search39 l.jpg
Breadth-first search

CS 331/531 Dr M M Awais


Breadth first search40 l.jpg
Breadth-first search

CS 331/531 Dr M M Awais


Breadth first search41 l.jpg
Breadth-first search

CS 331/531 Dr M M Awais


Properties of breadth first search l.jpg
Properties of breadth-first search

  • Complete?Yes (if b is finite)

  • Time?1+b+b2+b3+… +bd + b(bd-1) = O(bd+1)

  • Space?O(bd+1) (keeps every node in memory)

  • Optimal? Yes (if cost = 1 per step)

  • Space is the bigger problem (more than time)

CS 331/531 Dr M M Awais


Breath first algorithm l.jpg
Breath First: Algorithm

  • 1. Start with queue = [initial - state] and found = FALSE

  • While queue not empty and not found do:

  • (a) Remove the first node n from queue

  • (b) if N is a goal state then found = TRUE

  • (c ) Find all the successor nodes of X, and put them on the end of the queue

CS 331/531 Dr M M Awais


Slide44 l.jpg

Goal: D

  • Open = [A]; closed = []

    • Evaluate A not goal

CS 331/531 Dr M M Awais


Slide45 l.jpg

Goal: D

  • Open = [A]; closed = []

    • Evaluate A not goal

  • Open = [B,C];closed =[A]

    • Evaluate B not goal

CS 331/531 Dr M M Awais


Slide46 l.jpg

Goal: D

  • Open = [A]; closed = []

    • Evaluate A not goal

  • Open = [B,C];closed =[A]

    • Evaluate B not goal

  • Open = [C,D,E];closed = [B,A]

    • Evaluate C not goal

CS 331/531 Dr M M Awais


Slide47 l.jpg

Goal: D

  • Open = [A]; closed = []

    • Evaluate A not goal

  • Open = [B,C];closed =[A]

    • Evaluate B not goal

  • Open = [C,D,E];closed = [B,A]

    • Evaluate C not goal

  • Open = [D,E,G,F];closed = [C,B,A]

    • Evaluate D is goal: STOP

Path: A B D

Path Cost: The cost in reaching D from A

Path cost = 2

A to B=1, B to D=1

(assuming a unit cost between nodes)

CS 331/531 Dr M M Awais


Uniform cost search l.jpg
Uniform-cost search

  • Expand least-cost unexpanded node

  • Implementation:

    • queue ordered by path cost

  • Equivalent to breadth-first if step costs all equal

CS 331/531 Dr M M Awais


Depth first search l.jpg
Depth-first search

  • Expand deepest unexpanded node

  • Implementation:

    • LIFO queue, i.e., put successors at front

CS 331/531 Dr M M Awais


Depth first search50 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search51 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search52 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search53 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search54 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search55 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search56 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search57 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search58 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search59 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Depth first search60 l.jpg
Depth-first search

CS 331/531 Dr M M Awais


Properties of depth first search l.jpg
Properties of depth-first search

  • Complete? No: fails in infinite-depth spaces, spaces with loops

    • Modify to avoid repeated states along path

       complete in finite spaces

  • Time?O(bm): terrible if m is much larger than d

    • but if solutions are dense, may be much faster than breadth-first

  • Space?O(bm), i.e., linear space!

  • Optimal? No

CS 331/531 Dr M M Awais


Depth first l.jpg
Depth First

1. Start with agenda = [initial - state] and found = FALSE

2. While agenda not empty and not found do:

(a) Remove the first node N from agenda

(b) if N is not in visited then

(I) Add N to visited

(II) if N is a goal state then found = TRUE

(III) Put N’s successors on the front of the stack

CS 331/531 Dr M M Awais


Slide63 l.jpg

Goal: C

  • Open=[A],closed=[]

    • Evaluate A not a goal

CS 331/531 Dr M M Awais


Slide64 l.jpg

Goal: C

  • Open=[A],closed=[]

    • Evaluate A not a goal

  • Open=[B,C];closed=[A]

    • Evaluate B not a goal

CS 331/531 Dr M M Awais


Slide65 l.jpg

Goal: C

  • Open=[A],closed=[]

    • Evaluate A not a goal

  • Open=[B,C];closed=[A]

    • Evaluate B not a goal

  • Open=[D,E,C];closed=[B,A]

    • Evaluate D not a goal

CS 331/531 Dr M M Awais


Slide66 l.jpg

Goal: C

  • Open=[A],closed=[]

    • Evaluate A not a goal

  • Open=[B,C];closed=[A]

    • Evaluate B not a goal

  • Open=[D,E,C];closed=[B,A]

    • Evaluate D not a goal

  • Open=[H,I,E,C];closed=[D,B,A]

    • Evaluate H not a goal

CS 331/531 Dr M M Awais


Slide67 l.jpg

Goal: C

  • Open=[A],closed=[]

    • Evaluate A not a goal

  • Open=[B,C];closed=[A]

    • Evaluate B not a goal

  • Open=[D,E,C];closed=[B,A]

    • Evaluate D not a goal

  • Open=[H,I,E,C];closed=[D,B,A]

    • Evaluate H not a goal

  • Open=[I,E,C];closed=[H,D,B,A]

    • Evaluate I not a goal

CS 331/531 Dr M M Awais


Slide68 l.jpg

Goal: C

  • Open=[A],closed=[]

    • Evaluate A not a goal

  • Open=[B,C];closed=[A]

    • Evaluate B not a goal

  • Open=[D,E,C];closed=[B,A]

    • Evaluate D not a goal

  • Open=[H,I,E,C];closed=[D,B,A]

    • Evaluate H not a goal

  • Open=[I,E,C];closed=[H,D,B,A]

    • Evaluate I not a goal

  • Open=[E,C];closed=[I,H,D,B,A]

    • Evaluate E not a goal

CS 331/531 Dr M M Awais


Slide69 l.jpg

Goal: C

  • Open=[A],closed=[]

    • Evaluate A not a goal

  • Open=[B,C];closed=[A]

    • Evaluate B not a goal

  • Open=[D,E,C];closed=[B,A]

    • Evaluate D not a goal

  • Open=[H,I,E,C];closed=[D,B,A]

    • Evaluate H not a goal

  • Open=[I,E,C];closed=[H,D,B,A]

    • Evaluate I not a goal

  • Open=[E,C];closed=[I,H,D,B,A]

    • Evaluate E not a goal

  • Open=[J,K,C];closed=[E,I,H,D,B,A]

    • Evaluate J not a goal

CS 331/531 Dr M M Awais


Slide70 l.jpg

Goal: C

  • Open=[A],closed=[]

    • Evaluate A not a goal

  • Open=[B,C];closed=[A]

    • Evaluate B not a goal

  • Open=[D,E,C];closed=[B,A]

    • Evaluate D not a goal

  • Open=[H,I,E,C];closed=[D,B,A]

    • Evaluate H not a goal

  • Open=[I,E,C];closed=[H,D,B,A]

    • Evaluate I not a goal

  • Open=[E,C];closed=[I,H,D,B,A]

    • Evaluate E not a goal

  • Open=[J,K,C];closed=[E,I,H,D,B,A]

    • Evaluate J not a goal

  • Open=[K,C];closed=[K, E,I,H,D,B,A]

    • Evaluate K not a goal

CS 331/531 Dr M M Awais


Slide71 l.jpg

Goal: C

  • Open=[A],closed=[]

    • Evaluate A not a goal

  • Open=[B,C];closed=[A]

    • Evaluate B not a goal

  • Open=[D,E,C];closed=[B,A]

    • Evaluate D not a goal

  • Open=[H,I,E,C];closed=[D,B,A]

    • Evaluate H not a goal

  • Open=[I,E,C];closed=[H,D,B,A]

    • Evaluate I not a goal

  • Open=[E,C];closed=[I,H,D,B,A]

    • Evaluate E not a goal

  • Open=[J,K,C];closed=[E,I,H,D,B,A]

    • Evaluate J not a goal

  • Open=[K,C];closed=[J,E,I,H,D,B,A]

    • Evaluate K not a goal

  • Open=[C];closed=[K,E,I,H,D,B,A]

    • Evaluate C is goal: STOP

CS 331/531 Dr M M Awais


Depth limited search l.jpg
Depth-limited search

  • depth-first search with depth limit L

  • nodes at depth Lhave no successors

  • Do not apply depth first after a certain depth

CS 331/531 Dr M M Awais


Iterative deepening search l 0 l.jpg
Iterative deepening search L=0

For depth 0, evaluate the root node and stop

CS 331/531 Dr M M Awais


Iterative deepening search l 1 l.jpg
Iterative deepening search L=1

CS 331/531 Dr M M Awais


Iterative deepening search l 175 l.jpg
Iterative deepening search L=1

CS 331/531 Dr M M Awais


Iterative deepening search l 176 l.jpg
Iterative deepening search L=1

CS 331/531 Dr M M Awais


Iterative deepening search l 2 l.jpg
Iterative deepening search L=2

CS 331/531 Dr M M Awais


Iterative deepening search l 278 l.jpg
Iterative deepening search L=2

CS 331/531 Dr M M Awais


Iterative deepening search l 3 l.jpg
Iterative deepening search L=3

CS 331/531 Dr M M Awais


Iterative deepening search l.jpg
Iterative deepening search

  • Number of nodes generated in a depth-limited search to depth d with branching factor b:

    NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd

  • Number of nodes generated in an iterative deepening search to depth d with branching factor b:

    NIDS = (d+1)b0 + d b^1 + (d-1)b^2 + … + 3bd-2 +2bd-1 + 1bd

  • For b = 10, d = 5,

    • NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111

    • NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456

  • Overhead = (123,456 - 111,111)/111,111 = 11%

CS 331/531 Dr M M Awais


Properties of iterative deepening search l.jpg
Properties of iterative deepening search

  • Complete? Yes

  • Time?(d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)

  • Space?O(bd)

  • Optimal? Yes, if step cost = 1

CS 331/531 Dr M M Awais


Summary of algorithms l.jpg
Summary of algorithms

CS 331/531 Dr M M Awais


ad