Problem Set 1 – Search

Problem Set 1 – Search
Introduction to Artificial Intelligence
The Hebrew University of Jerusalem
Due on: Nov. 19th , 14:00
Rothberg B first floor, AI course box #11
Submit hard copy of your work
Uninformed Search
Problem 1 [20 Points] Missionaries and Cannibals problem:
• Three missionaries and three cannibals must cross a river
• They have a small boat that can carry up to two people
• At any moment, if the missionaries are outnumbered by cannibals then they would be eaten
• Note that the boat cannot cross the river by itself
In order to devise a transportation plan we will formulate the problem as a search problem, with
state space S = {(c, m, b)} :
• c is the number of cannibals on the origin bank
• m is the number of missionaries on the origin bank
• b is the location of the boat
With this state formulation - I = {(3, 3, 0)}, G = {(0, 0, b)}
Given the following partial definition of transition function f :
• Moving two missionaries from the original bank to the target bank
(c, m, 0| (m ≥ 2) ∧ (m − 2 = c ∨ m = 2)) → (c, m − 2, 1)
• Moving one missionary and one cannibal from the target bank to the original bank
(c, m, 1| (c ≤ m) ∧ (c ≤ 2) ∧ (m ≤ 2)) → (c + 1, m + 1, 0)
1. Complete the formulation of the search problem.
2. Find an optimal solution (optimal in the sense of boat rides) by using some search (uninformed) algorithm.
3. Is there a danger of missionaries being eaten by cannibals during the search? Explain.
1
Problem 2 [10 Points] Prove (with a short but accurate argument) or give a counterexample:
For every search space with constant step cost, iterative deeping using GRAPH-SEARCH always
finds an optimal solution.
Problem 3 [5 Points] Describe a state space in which iterative deepening
search performs much
worst than depth-first search (for example, time complexity of O n2 vs. O (n)).
Informed Search
Problem 4 [15 Points] 3-puzzle problem:
• 2x2 board
• three tiles (1,2,3)
• actions – {up, down, left, right}
• goal and start states are given in the figure
to the left
Tiles out of Row and Column heuristic (hT RC ) counts the number of tiles out of row + number
of tiles out of column.
• Show that hT RC is admissible
• Show how the path to the goal can be found using A∗ search with the hT RC heuristic (i.e.
draw the search-graph, clearly stating g,h and f values for each node)
Problem 5 [5 Points] Consider the following heuristic for the Pac-Man Food Search Problem;
For a given state s, let f ood - all the uneaten dots in s, position - pac-man position in s, and
X = f ood ∪ {position}. Finally, let
X
h (s) =
min {dM AN (x, y) : y ∈ X, x 6= y}
x∈X
where dM AN is the Manhattan distance. Is h an admissible heuristic? Prove (with a short but
accurate argument) or give a counterexample.
Problem 6 [5 Points] We say that a heuristics h is ε-admissible if for every s ∈ S h (s) ≤ h∗ (s)+ε
for an admissible heuristic h∗ , and for every g ∈ G h (g) = 0. Show that if h is an ε-admissible
heuristic and A∗ with h (using TREE-SEARCH) will return a path with cost C, then C ≤ C ∗ + ε
where C ∗ is the cost of the optimal path.
Problem 7 [5 Points] Prove that if a heuristic is consistent it must be admissible.
Problem 8 [5 Points] Prove (with a short but accurate argument) or give a counterexample: If
heuristics h1 dominates heuristics h2 and h1 is consistent, then h2 is consistent.
Optimization (Meta-Heuristics)
Problem 9 [15 Points] The Knapsack Problem Suppose you are given a set of items I =
{1, . . . n} each with a value vi ≥ 0 and a weight wi ≥ 0. The maximum weight that we can carry
in the bag is W . You are asked to find a subset of items C ⊂ I, such that:
P
• The sum of the weights in is at most the knapsack’s capacity – i∈C wi ≤ W .
P
• The value of the items – i∈C vi is as high as possible.
2
1. Give a function which expresses these optimization criteria and explain how you
would perform gradient descent on this
function (i.e. specify the states and neighbors relation).
2. Who do you think will perform better - gradient ascent or simulated annealing? Why?
3. Describe how you would encode this problem for a genetic algorithm (i.e. specify the
fitness function, mutation and crossover
operators).
4. Would genetic algorithms work better than
iterative improvement on this problem or
not? Explain your answer.
CSP
Problem 10 [15 Points] You are in charge of creating the train schedule in Jerusalem. You
decide that for this mission you will use CSP. Before you implement a computer program you decide
to solve a toy problem on paper. In your toy problem there are:
• Three trains A (two spaces long), B & C
(one space long each)
LCV heuristics. Show the process in a clear
and organized fashion.
• When a train departs, it moves one space
(on its track) each time-step (one hour) until it arrives its destination.
• Departure times - 8:00, 9:00 or 10:00
• Trains must leave at different times
• Two trains cannot occupy a crossing section at the same time-step
• Start and Goal states are given in the figures to the left
1. Describe the toy problem as a CSP problem.
2. Draw the constraint graph.
3. Find a solution using a back-track search
with arc-consistency and the MRV and
3