1 / 16

MÉTODOS DE BÚSQUEDA EN UN ESPACIO DE ESTADOS

MÉTODOS DE BÚSQUEDA EN UN ESPACIO DE ESTADOS. Estrategias de búsqueda no informada (Ciega). No existe información sobre la cantidad de estados intermedios o el costo de ruta para pasar del estado actual a la meta. Sólo se sabe distinguir si estamos en el estado meta o no.

dimaia
Télécharger la présentation

MÉTODOS DE BÚSQUEDA EN UN ESPACIO DE ESTADOS

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. MÉTODOS DE BÚSQUEDA EN UN ESPACIO DE ESTADOS

  2. Estrategias de búsqueda no informada (Ciega) • No existe información sobre la cantidad de estados intermedios o el costo de ruta para pasar del estado actual a la meta. • Sólo se sabe distinguir si estamos en el estado meta o no. • A esta búsqueda se le conoce también como búsqueda ciega.

  3. Métodos de búsqueda no informada • Existen varios métodos: • Búsqueda preferente por amplitud • Búsqueda preferente por profundidad • Búsqueda de costo uniforme • Búsqueda limitada por profundidad • Búsqueda por profundización iterativa • Búsqueda bidireccional

  4. BÚSQUEDA EN AMPLITUD • La búsqueda en amplitud, consiste en recorrer el árbol por niveles; es decir, primero se recorre el padre, luego los hijos de este(de izquierda a derecha), luego los nietos… y así sucesivamente hasta encontrar el elemento buscado. • Para nuestro algoritmo hemos definido las funciones padre, hd y hi que devuelven(si es que existen) respectivamente el nodo-padre, el hijo izquierdo y el hijo derecho. Estas funciones han sido usadas dentro nuestro algoritmo principal bpa que es iterativo, y consiste en comparar los elementos hasta que la lista ingresada este vacía. Primero verifica si el padre es elemento buscado y hace lo mismo con los hijos de este, luego envía como la lista a evaluar todo el hijo izquierdo y todo el hijo derecho para hacer lo mismo.

  5. BÚSQUEDA EN AMPLITUD

  6. BÚSQUEDA EN AMPLITUD

  7. BÚSQUEDA EN AMPLITUD

  8. BÚSQUEDA EN AMPLITUD

  9. BÚSQUEDA EN AMPLITUD

  10. BÚSQUEDA EN AMPLITUD ALGORITMO CL-USER 1> (defun bpa(elm lst) (cond ((null lst) nil)((equal nil(padre lst))nil) (t(if(equal elm(padre lst))t (if (equal elm (hi lst)) t (if (equal elm (hd lst)) t (or (bpa elm (second lst)) (bpa elm(third lst))))))))) BPA CL-USER 2> (defun padre(lst)) (if (atom lst) nil (first lst))) PADRE CL-USER 3> (defun hd(lst) (if (equal nil (third lst)) nil (if (atom (third lst)) (third lst) (first (third lst))))) HD

  11. BÚSQUEDA EN AMPLITUD ALGORITMO CL-USER 4> (defun hi(lst) (if (equalnil (secondlst)) nil (if (atom (secondlst)) (secondlst) (first (secondlst))))) HI CL-USER 5> bpa ‘e’(a(b c d)(e f)) T CL-USER 6> bpa ‘d’(a(b c d)(e f)) T

  12. BÚSQUEDA EN PROFUNDIDAD • La búsqueda por profundidad, consiste en recorrer los nodos de un árbol de la siguiente manera: Padre- Hijo Izquierdo-Hijo Derecho, es decir primero observa si el «padre» es el elemento buscado, luego observa a su «hijo izquierdo» y luego su «hijo derecho»; recursivamente a cado uno de sus hijos, en otras palabras recorre todos los hijos izquierdos y luego los hijos derechos hasta encontrar el elemento buscado. • En nuestro algoritmo; cuando un árbol se expresa en lista, todos los nodos se ingresan en pre-orden (Padre- H Izq- H Der), entonces sólo tendremos que recorrer de elemento en elemento de la «lista» (árbol) ingresada hasta encontrar nuestro elemento. • Se define una función principal «Buscar»; que recibe 2 parámetros, el primero el elemento a buscar y el segundo el árbol donde se buscara dicho elemento. Luego pasa a la función «Busq_Prof»; que recibe 3 parámetros, el primero el elemento a buscar, el segundo el primero (átomo o lista) del árbol y por último el resto del árbol, y así buscara el elemento recursivamente.

  13. BÚSQUEDA EN PROFUNDIDAD

  14. BÚSQUEDA EN PROFUNDIDAD

  15. BÚSQUEDA EN PROFUNDIDAD

  16. BÚSQUEDA EN PROFUNDIDAD ALGORITMO CL-USER 1> (defun Busq_Porf(n P R) (if (atom P) (if (null P) (if (null R) 100 (Busq_Prof n (first R)(rest R))) (if (equal n P) 1 (if (null R) 100 (+ 1 (Busq_Prof n (first R)(rest R)))))) (Busq_Prof n (first P)(if (null(rest P)) R (cons (rest P) R))))) BUSQ_PROF CL-USER 2> (defun Buscar(x A) (setq Canti_Nod (Busq_Prof x (first A)(rest A))) (if (> Canti_Nod 100)(format t «No se encontro el elemento ~d» x) (format t «Se recorrio ~d nodos para habllar el elemento ~d» Canti_Nod x))) BUSCAR CL-USER 3> Buscar ‘4’(1(2 4 5)(3 6)) Se recorrió 3 nodos para hallar el elemento 4 CL-USER 4> Buscar ‘10’(1(2 4 5)(3 6)) No se encontró el elemento 10

More Related