1 / 24

Heuristic Search

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

gloria
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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Heuristic Search Intro to Prolog

  2. Heuristic Algorithm • Two Parts • Heuristic Measure • Algorithm that uses it to search the state space

  3. Tic Tac Toe • Exhaustive Search • Total Number of States • 9x8x7x6… • =9!

  4. How to Decrease Search Space? • Configuration Equivalent under symmetric operation • Reduced to 12x7! • Still Exponential

  5. 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

  6. 8 Puzzle • Four Heuristics • 283 283 283 • 164 1 4 164 • 75 765 75

  7. 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

  8. 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)

  9. 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

  10. 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)

  11. Algorithm • 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

  12. 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

  13. 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).

  14. Queries • ?- man(kasim). • Yes • ?-Playguitar(kasim). • No • ?-man(amir). • No. • Drivestaxi(amir). • No.

  15. KB2 • Listenstomusic(asim). • Happy(bashir). • Playsguitar(asim) :- listenstomusic(asim). • Playsguitar(bashir) :- listenstomusic(bashir). • Listenstomusic(bashir) :- happy(bashir). • 2 facts and 3 rules

  16. :- • 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)

  17. 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

  18. KB3 • 5 clauses • Happy(asim). • Listentomusic(khurram). • Playsguitar(asim):-listenstomusic(asim),happy(asim). • Playsguitar(khurram):-happy(khurram). • Playsguitar(khurram):-Listentomusic(khurram).

  19. Logical Conjunction • Playsguitar(asim):-listenstomusic(asim),happy(asim). • Note that the rule has two item in its body (two goals) • , AND • ?- Playsguitar(asim)?

  20. Logical Disjunction • Playsguitar(khurram):-happy(khurram). • Playsguitar(khurram):-Listentomusic(khurram). • It is a way of saying either --- or --- • ?-Playsguitar(khurram).

  21. 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).

  22. 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

  23. 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 :-

  24. Numbers • 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))))

More Related