Docsity

Heuristics - Artificial Intelligence - Lecture Slides | CPSC 481, Study notes of Computer Science

Partial preview of the text

Download Heuristics - Artificial Intelligence - Lecture Slides | CPSC 481 and more Study notes Computer Science in PDF only on Docsity!

Artificial Intelligence

CPSC 481

AI

As Representation and Search:

Heuristic Search for Problem Solving

Lecture Overview

 Heuristics in AI and problem solving

 Heuristic search algorithms

 Hill-climbing, simulated annealing, best-first search, constraint

satisfaction

 Game playing strategies using mini-max and alpha-beta pruning

 Performance evaluation of heuristics

 Theoretical evaluation criteria

 Complexity and efficiency issues

First Three Levels of the Tic-Tac-Toe

State Space Reduced by Symmetry

*There are nine but really

three initial moves (corner, center, side).

***** Symmetry in this game decreases the search space.

Search space for Tic-Tac-Toe game: 9!

The “most wins” Heuristic Applied to

the First Children in Tic-Tac-Toe

Components of a Heuristic Function

 A heuristic function, f(n) = g(n) + h(n)

 g(n) : the distance (or other measure) from the start to current state, n,

 E.g., count 0 for the beginning state and is incremented by 1 for each level of the search.

 h(n) : a heuristic estimate of the distance from state n to a goal.

 h value guides search toward heuristically promising states

while g value prevents search from indefinitely fruitless path

 If two states are the same or nearly the same, it is generally preferable

to examine the state that is nearest to the root state of the graph (initial

state) since it will give a greater probability of being on the shortest path

to the goal.

 Good heuristic function returns

 Unique and non-conflicting score with accurate measure of better

Several Heuristics for the 8-puzzle Game

The start state, first moves, and goal state for 8-puzzle.

Possible heuristics :

(1) Counts the tiles out of place compared with the goal state in each state. (2) Sum all the distances by which the tiles are out of place. (3) Multiplies a small number, e.g., 2 times each direct tile reversal.

The Heuristic f Applied to States in the 8-puzzle

Simple Hill-climbing: a Heuristic Search

 Strategies

 Expand the current state of the search

 Evaluate its children states

 Select the first close (better) node for further expansion ( but keeps no history )

 Continue until it finds a solution or reach a no better state

 Comment on the approach

 One of the simplest approaches to implement a heuristic

 Problems

 May be stuck at local maxima

 If it reach a state that has a better evaluation than any of its children, the algorithm halts and may fail to find the best solution

 May get confused by the result of evaluation when the best is not clear

(see graph in next slide)

Variations of Hill-climbing

Steepest-ascent (or descent) hill-climbing (also called gradient search)

 To decide the next move, all successors are compared and the closest to
the solution is chosen while in a simple hill climbing. Used for optimization.
 Still fail if there is no closer node, which may happen if there are local
maxima in the search space which are not solutions.

Simulated annealing (SA)

 A generic probabilistic meta-heuristic for the global optimization problem.
 At each step, the SA heuristic considers some neighbor, s' of the current
state s, and probabilistically decides between moving the system to state s'
or staying in state s. The probabilities are chosen so that the system
ultimately tends to move to states of lower energy. This step is repeated until
the system reaches a state that is solution, good enough for the application,
or until a given computation budget has been exhausted.
 The name and inspiration come from annealing in metallurgy, a technique
involving heating and controlled cooling of a material to reduce their defects.

Best-First Search Algorithm

 Most algorithms (backtracking, hill-climbing, etc.)

 Can be effective as long as their evaluation functions are sufficiently

informative to avoid local maxima, dead ends, and related anomalies in

a search space

 Best-first search always selects the most promising state on

open for expansion (so it is often called Greedy best-first search)

 Using f(n) = h(n)

 Basic principle used

 The more informed the heuristic, the fewer states are processed.

 Algorithm sketch

 Maintain Open (to be visited) and Closed (already visited) states

 Maintain the information of ancestor states and the shortest path

 Duplicate states are not retained

 Open is maintained as a priority queue

 Like a search algorithm taking only good strategies from

 DFS, BFS, Backtracking, Simple hill-climbing, steepest-descent hill climbing 14

Best-First Search of a Hypothetical State

Space

Letters represent states

Numbers represent heuristic values as cost , e.g ., the smaller the better in this example.

Bold states indicate the states expanded by the heuristic algorithm

Assume P is the goal

A Trace of the Execution of Best-First

Search

* Maintain a priority queue

Heuristic f(n) Applied to States in the 8-puzzle

f(n) is a cost function: the smaller the better.

Successive Stages of Open and Closed with

Best-first Search