For the second exercise, we will deal with a
pair of informed search algorithms: greedy and A*. For that
purpose, we will use a fourth domain, the 8-puzzle. We have a 3x3
grid that contains 8 tiles and a hole. In each situation we can
slid towards the hole some of its adjacent tiles. As an example,
we will use the following intial and goal states:
|
|
|
Initial
state 1
|
|
Goal
state
|
We will use four possible actions
u,
d,
l,
r (meaning up, down, left,
right, respectively) depending on which of the adjacent tiles we
move towards the hole.
As before, we will have to encode the problem defining the
predicates
initial,
goal and
transition.
Informed search: greedy and A*
Predicate search allows two algorithms for informed search:
greedy and
a_star. These predicates
maintain the fringe as a priority queue ordered by the heuristic
function
h in the case of the
greedy
algorithm, and by function f = cost+
h in the case of
a_star (algorithm A*).
In both cases, we have to specify a new predicate
h(N,X), that will define the
heuristic function:
h(N,X)
|
Specifies the heuristic value X
for any node search N, where
N has the structure n(State,ParentNodeNum,Action,Cost,Deth)
|
As an example, the file romania.pl already contains an heuristic
function that uses the straight distance from any city to
Bucharest
h(n(S,_,_,_,_),D) :- straight(S,D).
|
Compare the search results using the uninformed search algorithms
seen before (
breadth,
depth,
uniform)
with respect to:
?-
search('romania.pl',greedy).
...
?- search('romania.pl',a_star).
...
|
Los ejercicios serán realizados preferentemente
en grupos de 2 alumnos. Para la entrega, hay que empaquetar todos
los archivos necesarios para los ejercicios 1 y 2 (salvo
search.pl) en un único zip y subirlo a la plataforma Moodle. La
calificación máxima es de 1.5 puntos = 15% de la asignatura.
La fecha límite de entrega es el viernes
22 de abril de 2016. Todas las prácticas deberán
superar una defensa presencial que puede realizarse antes de
la entrega, durante las horas de laboratorio, o después,
reservando turno en horario de tutorías (se hará público un
horario de reserva de turno). La copia de prácticas se puntúa
automáticamente con un 0 en este apartado.