Heuristic search
This presentation is the property of its rightful owner.
Sponsored Links
1 / 24

Heuristic Search PowerPoint PPT Presentation

  • Uploaded on
  • Presentation posted in: General

Heuristic Search. Intro to Prolog. Heuristic Algorithm. Two Parts Heuristic Measure Algorithm that uses it to search the state space. Tic Tac Toe. Exhaustive Search Total Number of States 9x8x7x6… =9!. How to Decrease Search Space?. Configuration Equivalent under symmetric operation

Download Presentation

Heuristic Search

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

Heuristic search

Heuristic Search

Intro to Prolog

Heuristic algorithm

Heuristic Algorithm

  • Two Parts

  • Heuristic Measure

  • Algorithm that uses it to search the state space

Tic tac toe

Tic Tac Toe

  • Exhaustive Search

  • Total Number of States

  • 9x8x7x6…

  • =9!

How to decrease search space

How to Decrease Search Space?

  • Configuration Equivalent under symmetric operation

  • Reduced to 12x7!

  • Still Exponential

Winning lines

Winning Lines

  • 4 2

    Move to the board in which X has the most winning lines

    2/3 of the space is pruned away with the first move

8 puzzle

8 Puzzle

  • Four Heuristics

  • 283 283 283

  • 164 1 4 164

  • 75 765 75

Good heuristics

Good Heuristics

  • The Design of a good Heuristic is an empirical problem, judgment and in tuition help, but the final measure of a heuristic must be its actual performance on problem instances

  • Fallible. It is possible that a search algorithm can be misled down some path that fails to lead to a goal-depth count of search may be used

Bias search in favor of states found shallower in the graph

Bias Search in favor of states found shallower in the graph

  • If two states have the same or nearly the same heuristic evaluations it is generally preferable to examine the state that is nearest to the root state of the graph

  • Evaluation function Sum of two components

  • F(n) = g(n) + h(n)

Best first search

Best-First Search

  • Best First Search, which is a way of combining the advantages of both depth-first and breadth-first search into a single method

  • In hill climbing, one move is selected and all others are rejected, never to be reconsidered.

  • In Best first, one move is selected but the others are kept around so they can be revisited later if the selected path becomes less promising

  • Hill climbing will stop if there are no successor states with better values than the current state

Two lists of nodes

Two Lists of Nodes

  • OPEN- Nodes that have been generated and have had the heuristic function applied to them but have not yet been examined(had their successors generated). Priority Queue in which highest priority nodes are those with the most promising heuristic value

  • CLOSED- Nodes that have already been examined. Check to see if node has been generated before(For Graphs)



  • Start with OPEN containing just the initial state

  • Until a goal is found or there are no nodes left on OPEN do

  • A) pick the best node on open

  • B) Generate its successors

  • C) For each successor do

    • if it has not been generated before, evaluate it, add it to open, and record its parent

    • If it has been generated before, change the parent if this new path is better than the previous one. In that case, update the cost of getting to this node and to any successors that this node may already have

Presentation on a

Presentation on A*

  • Explanation of Algorithm

    Ahmed Zia Tassadaq Shahid

    Hani Umar

  • Overestimation and Underestimation (Significance)

    Minhajuddin Asad Bilal

    Taimur Hashim Sajid

  • Advantages and Disadvantages

    Amin Ali Salman Fahad

    Sana Atif Ali Haseeb

  • Admissibility

    Talha Mubeen Shehryar

    Infraz Safdar

Facts rules and queries

Facts, Rules and Queries

  • A collection of facts and rules is called a knowledge base

  • How do we use a Prolog Program?

  • By Posing Queries.

  • KB1 (Collection of facts)

  • man(kasim).

  • man(khurram).

  • man(bhatti).

  • Playsguitar(bhatti).



  • ?- man(kasim).

  • Yes

  • ?-Playguitar(kasim).

  • No

  • ?-man(amir).

  • No.

  • Drivestaxi(amir).

  • No.

Heuristic search


  • Listenstomusic(asim).

  • Happy(bashir).

  • Playsguitar(asim) :- listenstomusic(asim).

  • Playsguitar(bashir) :- listenstomusic(bashir).

  • Listenstomusic(bashir) :- happy(bashir).

  • 2 facts and 3 rules

Heuristic search


  • Should be read as ‘if’ or ‘is implied by’

  • Rule head :- body

  • If Prolog knows that body follows from the information in the knowledge base Prolog can infer head

  • This fundamental deduction step is what logicians call modus ponens

  • ?- playsguitar(asim).

  • Yes (Although fact not explicitly stated)

Chain rule

Chain Rule

  • ?-playsguitar(bashir).

  • Yes (inferred knowledge)

  • The facts and rules contained in a knowledge base are called clauses

  • Thus KB2 contains 5 clauses and three predicates which are

  • listensToMusic

  • Happy

  • playsguitar

Heuristic search


  • 5 clauses

  • Happy(asim).

  • Listentomusic(khurram).

  • Playsguitar(asim):-listenstomusic(asim),happy(asim).

  • Playsguitar(khurram):-happy(khurram).

  • Playsguitar(khurram):-Listentomusic(khurram).

Logical conjunction

Logical Conjunction

  • Playsguitar(asim):-listenstomusic(asim),happy(asim).

  • Note that the rule has two item in its body (two goals)

  • , AND

  • ?- Playsguitar(asim)?

Logical disjunction

Logical Disjunction

  • Playsguitar(khurram):-happy(khurram).

  • Playsguitar(khurram):-Listentomusic(khurram).

  • It is a way of saying either --- or ---

  • ?-Playsguitar(khurram).

Another way to express or

Another way to express OR

  • Playsguitar(khurram):-happy(khurram);Listentomusic(khurram).

  • Woman(sara).

  • Woman(marium).

  • Woman(rubab).

  • Loves(khurram,sara).

  • Loves(asim,sara).

  • Loves(abc,xyz).

  • Loves(xyz,abc).

Queries with variables

Queries with Variables

  • ?-Woman(X).

  • Prolog works its way top to bottom trying to match or unify the expression woman(X)

  • Use ; to find start prolog searching on from the last point onwards

  • ?-Loves(asim,X), woman(X).

  • Write a Query for jealous

Prolog syntax

Prolog Syntax

  • Atoms

    A string of characters which may be upper or lower case, digits and the underscore character that begins with lowercase letter

    Arbitrary sequence of chars in single quotes ‘’

    String of special chars @= or ===> ; or :-



  • 23, 1001, 0, -365

  • Variables

  • Start with capital or underscore

  • Variable starting with underscore _ is called anonymous variable

  • Complex terms

  • Hide(X,father(father(father(asim))))

  • Login