# Heuristic Search

# Reading

You may want to focus on Question 1-2 below when you k

- Watch the Videoes
- Read the text book
- R&N Chapter 3.5: The
*A\(^*\) Algorithm* - R&N Chapter 3.6: Design of heuristic function
- plus the summary of Chapter 3

- R&N Chapter 3.5: The

Note that these two sections of the chapter really only gives you *one* (1) algorithm, the *A\(*\)* Algorithm. Howeever, it exists in many different variants, and it depends on the heuristic function which also has to be designed and varied.

# Briefing

## Evaluation as Reference Group

(postponed from last session)

- Generic Questions
- Are you comfortable with the goals of the module?
- Do you make progress when you do exercises?
- Are you able to complete exercises?
- Do you gain skills that you feel that you can use in the future?

- Alter-Begin-Continue (Yellow Stickers Exercise)

## Review Discussion

We discuss the following questions in class:

- What is a heuristic function? (page 102)
- What is an
*admissible*heuristic function? (page 103)

- What is an
- How can you use A\(^*\) to solve one problem?

Consider either the travel to Bucharest from the textbook, or a problem you have already studied. - How can you vary A\(^*\) to solve other problems?
- How can you vary the heuristic function \(h(x)\) for different problems?
- How can we measure run time or time complexity for tree searches?

# Discussion Exercise (AIMA Exercise 3.5)

*Taken from the exercises at github.*

Suppose two friends live in different cities on a map, such as the Romania map shown in the textbook. On every turn, we can simultaneously move each friend to a neighboring city on the map. The amount of time needed to move from city i to neighbor j is equal to the road distance d(i,j) between the cities, but on each turn the friend that arrives first must wait until the other one arrives (and calls the first on his/her cell phone) before the next turn can begin. We want the two friends to meet as quickly as possible.

- Write a detailed formulation for this search problem. (You will find it helpful to define some formal notation here.)
- Let \(D(i,j)\) be the straight-line distance between cities \(i\) and \(j\). Which of the following heuristic functions are admissible?
- \(D(i,j)\);
- \(2\cdot D(i,j)\);
- \(D(i,j)/2\).

- Are there completely connected maps for which no solution exists?
- Are there maps in which all solutions require one friend to visit the same city twice?

# Programming Exercises

- Blunder Episode 2
- see Search last week

- Train Passenger is a shortest path problem
- A\(^*\) Exercise
- Implement A\(^*\). The heuristic function is given.

- The 11-Puzzle
- It may be a good idea to test two different heuristics.
- What is the search depth in the test cases?
- How many nodes are created in the test cases?
- 11-puzzle at CodingGame
- pai-exercises provides a framework to solve \(N\)-Puzzle for arbitrary \(N\), with sample

solutions.

- If you want a challenge, there are two more puzzles tagged with A\(^*\).

# Debrief

Early debrief at 2.15 today. Discuss one programming exercises.