Antologia IA

20
 Primavera 2014 Facultad de Ciencias de la Computación Búsqueda   Demos    Proyectos D r . F e r na nd o Za c a r í a s F lo r e s

description

Breve descripcion de IA

Transcript of Antologia IA

  • Primavera 2014

    Facultad de Ciencias de la Computacin

    Bsqueda Demos Proyectos

    Dr. Fernando Zacaras Flores

  • Bsqueda Heurstica I

    Pedro Meseguer IIIA-CSIC

    Bellaterra, [email protected]

    Bsqueda Heurstica 2

    Temario curso Introduccin

    Bsqueda sistemtica Bsqueda ciega Bsqueda informada: primero el mejor, A* Bsqueda en memoria acotada Bsqueda con adversario (juegos) Bsqueda en tiempo real

    Bsqueda local Vecindad Funcin de evaluacin Criterios de salto

  • Bsqueda Heurstica 3

    Parmetros

    Curso 22 horas

    Nivel: postgraduado es autocontenidose supone un ciertoconocimiento del tema

    Evaluacin: examen de conceptos generales no es muy duro, pero ... ... se suspende

    Transparencias:www.iiia.csic.es/~pedro/

    Clases : jueves de 15 a 17, IIIA

    Calendario: Octubre: 26 Noviembre: 2, 9, 16, 23, 30 Diciembre: 14, 21 Enero: 18 Febrero: 1, 8 (EXAMEN)

    a confirmar en Navidad

    Bsqueda Heurstica 4

    Qu es bsqueda?

    Bsqueda: mtodo computacional para resover problemas

    Qu problemas? single-agent path-finding: nico agente encuentra camino two-player games: juegos de dos jugadores constraint satisfaction: satisfaccin de restricciones

    Caractersticas: problemas difciles: NP-completos la solucin se calcula por enumeracin se supone que requieren inteligencia Inteligencia Artificial

  • Bsqueda Heurstica 5

    Ejemplos

    AJEDREZmovimientos que llevan a

    situacin ganadora

    two-player games

    PUZZLE de 8

    1 234

    5

    6 7 8

    1 2 38 47 6 5

    ?

    single-agent path-finding

    8 REINAS

    poner 8 reinas de ajedrez en un tablero 8x8

    y que no se ataquen

    constraint satisfaction

    Bsqueda Heurstica 6

    Conceptos bsicos

    Estado: una posible configuracin de un problema Espacio de estados: todas las configuraciones Operadores:

    acciones legales generan estados sucesores de un estado

    espacio del problema

    problemaconcreto

    Estados inicial y objetivo explcito puede ser implcito Solucin:

    secuencia operadores de inicial a objetivo: path-finding, games estado objetivo: constraint satisfaction

  • Bsqueda Heurstica 7

    Ejemplo: puzzle de 8 (I)1 2

    345

    6 7 8

    1 234 5

    6 7 8

    1 234

    5

    6 7 8

    1 2345

    6 7 8

    1 234

    5

    67

    8

    1 2 34567

    8estado objetivo

    sucesores

    Bsqueda Heurstica 8

    Ejemplo: puzzle de 8 (II) Espacio de estados: posibles configuraciones Operadores:

    arriba: ^ abajo: v derecha: > izquierda: v

    1 2 3

    45 6

    78

    1 2 3

    456

    78

    1 2345

    678

    1 2 3

    456

    78

    1 2 34

    56

    78

    1 2 345

    678

    1 2 345

    67

    81 2 3

    456

    78

    12

    3

    456

    78

    1 2 34567

    8

    estadoobjetivo

    Bsqueda Heurstica 10

    Grafo dirigido

    Espacio de estados: grafo dirigido

    De estado inicial a objetivo: bsqueda en grafo

    Por qu NO usar algoritmos de acceso en grafos?

    Porque el grafo no cabe en memoria: tamaos puzzle-8: 9! damas: 1020 ajedrez: 1040

    Hablamos de: Grafo implcito: espacio de estados no desarrollado Subgrafo explcito: subespacio desarrollado

  • Bsqueda Heurstica 11

    Sistemtica y no sistemtica Sistemtica: si existe una solucin la encuentra

    recorrido ordenado del espacio de estados si un estado no puede ser solucin --> poda

    No sistemtica: pueden no encontrar la solucin bsqueda local

    descenso por gradiente simulated annealing algoritmos genticos bsqueda tab

    pueden visitar varias veces el mismo estado

    Bsqueda Heurstica 12

    Bsqueda ciega

    Bsqueda en rbol:

    Tres formas de generar y recorrer el rbol:

    db

    ANCHURA:por niveles

    PROFUNDIDAD:por ramas

    PROF. ITERATIVA: porramas con nivel mximo

    - sol cercana raz?+ espacio lineal

    + sol ms cercana raz+ espacio lineal- repite trabajo

    + sol ms cercana raz- espacio exponencial

    sol

  • Bsqueda Heurstica 13

    Heurstica

    Origen: heuriskein (encontrar en griego) Significado:

    Procedimiento: criterio que puede resolver un problema pero que no hay garanta de que siempre lo resuelva.

    Funcin: estimacin del coste necesario para alcanzar una solucin desde el estado actual.

    EUREKA !!

    Arqumedes en su bao

    Bsqueda Heurstica 14

    Bsqueda Heurstica

    Bsqueda informada con funcin heurstica

    Heurstica: funcin que asigna a cada estado una estimacin del coste ptimo a la solucin

    Compromiso: dos efectos positivo: ahorra esfuerzo de bsqueda negativo: coste de clculo de la heurstica en cada nodo

    efecto neto positivo si:

    ahorro > coste

  • Bsqueda Heurstica 15

    Ejemplo: puzzle de 8

    Heursticas: # piezas fuera de sitio = 7

    distancia Manhattan = 3 + 1 + 1 + 3 + 1 + 1 + 2 = 12 (nmero pasos en cuadrcula)

    1 2 34567

    8estado objetivo

    1 234

    5

    6 7 8

    estadoactual

    Bsqueda Heurstica 16

    Bsqueda informada: primero el mejor

    Funcin f(n): coste del nodo n

    Lista OPEN: nodos generados pero no testeados

    Primero el mejor: siguiente n con min f(x) x OPEN

    OPEN

    Rendimiento: mucho mejor que la bsqueda ciega

  • Bsqueda Heurstica 17

    Algoritmo A*

    Heurstica: h(n) estima el coste de un camino ptimo de n a una solucin

    g(n): coste desde la raz hasta nOPEN

    n

    g(n)

    h(n)

    h(n) admisible: si no sobreestima el coste ptimo

    A*: primero el mejor con f(n) = g(n) + h(n), h admisible+ completo+ solucin ptima- espacio: a menudo degenera en exponencial

    Bsqueda Heurstica 18

    Bsqueda heurstica con memoria acotada

    Profundizacin iterativa A*:

    + h(n) admisible

    Branch and bound (DFBnB)

    UB = mejor f(x) en g(n) + h(n) = LB

    si UB

  • Bsqueda Heurstica 19

    Bsqueda con discrepancias

    rbol de bsqueda + heurstica: ordena los sucesores, izda. preferido a der.

    IDEA1: si la heurstica casi siempre acierta, la solucin estar en una rama con pocas discrepancias

    Discrepancia: ir en contra de la heurstica

    +

    Bsqueda Heurstica 20

    Bsqueda con discrepancias

    IDEA2: recorrer el rbol por orden creciente de discrepancias

    Dis: 0 1 1 2 1 2 2 3

    Vis: 1 2 3 5 4 6 7 8

  • Bsqueda Heurstica 21

    Juegos 2 jugadores, informacin perfecta

    Programas campeones del mundo: damas, othello

    Programa con muy buen rendimiento: ajedrez importante: desde 1956, ajedrez era un objetivo para IA Deep Blue gano a Kasparov en 1997 quantity had become quality

    Estrategia: bsqueda en un espacio de billones de nodos profundizacin selectiva

    Bsqueda Heurstica 22

    Bsqueda para juegos

    rbol de juegos:jugador A

    jugador B

    1 ply1 move

    Algoritmo minimax, asciende los valores de nodos terminales Mejora alfa-beta (ordenacin nodos) Funcin evaluacin, quiescencia, extensiones singulares

  • Bsqueda Heurstica 23

    Bsqueda en tiempo real

    Bsqueda clsica (off-line search):

    Bsqueda de una solucin completa Ejecucin de la solucin

    No sirve para tareas con tiempo o informacin limitada IDEA: alternar bsqueda con ejecucin (on-line search)

    Bsqueda Ejecucin Bsqueda Ejecucin Bsqueda Ejecucin

    Algoritmos: RTA*, LRTA*: primera ejecucin al repetir la misma tarea: mejorar rendimiento (ptimo rendimiento en el lmite)

    Bsqueda Heurstica 24

    Aplicaciones de bsqueda en tiempo real

    Warcraft IIIAge of Empires

    Agentes:tiempo e informacin limitada

    han de mejorar el rendimiento con la experiencia

  • Bsqueda Heurstica 25

    Resumen Bsqueda: mtodo computacional para resolver problemas Qu problemas? Resolucin por enumeracin Espacio de estados, operadores, inicial, objetivo Bsqueda ciega Heurstica: funcin que estima el coste al objetivo Bsqueda informada, A* Bsqueda en memoria acotada Bsqueda con discrepancias Bsqueda para juegos Bsqueda en tiempo real

    Bsqueda Heurstica 26

    Por qu estudiar bsqueda ...

    ...cuando hay otros temas ms de moda?

    Varias razones: muchos problemas no se pueden resolver de otra forma rea de investigacin viva:

    ver IJCAIs, AAAIs, ECAIs ideas nuevas: discrepancias, pattern databases, real time, ...

    proporciona un marco de referencia: muchos problemas de IA se pueden conceptualizar como bsqueda aunque se resuelvan en la prctica por otro mtodo

    explora ideas que se pueden exportar a otros campos

  • AIMA HomeAI on the WebCodeChaptersContentsCoursesErrataInstructors

    Search AIMA

    Online Demos (Applets) of Artificial IntelligenceThis page lists some demos of various artificial intelligence techniques that you can run in your browser. These can help explainhow AI algorithms work. Your next step after running these demos would be to download, run, and modify some source code,such as the AIMA online code repository.

    Demos by SiteHere are some of the best sites for demos; let [email protected] know of others.

    The OpenNERO 3D multiagent simulatorUBC: University of British Columbia's collection of applets that accompany the book Computational Intelligence. A bigcollection of high-quality applets, but they can be confusing, because they have so many options. However, they all share asimilar user interface, so learning one applet will help you understand the others.MIT: applets for MIT's online course. A good collection of simple applets: they have few controls, but they each do onething well.UTA: Univ. of Texas at Austin professor Diane Cook's collection. Somewhat of a work in progress, you need toexperiment to see which ones work and which don't.JARS: A Java Archive of all kinds of applets; this is a search for AI applets, applications, and frameworks.

    Demos by Topic (Chapter)In the following table, demos are organized by chapter in AIMA. For each chapter we list the demos that we know of. When thereare several, we make a rough attempt to have the best ones listed first, but this is subjective, and may depend on the particularbrowser you are using.

    Chap Topic Demos2 Vacuum Agent NTNU3-4 Search MIT / UBC3 Search trees RMIT3 A* Search 8/16-puzzle / 8-puzzle4 Genetic Algorithms TSP / Plant Eaters5 Minimax and Alpha-Beta MIT5 Checkers Chinook

    Use our professional PDF creation service at http://www.htm2pdf.co.uk!

  • 5 Othello Ajax / Cyrano / Chirico6 CSPs (Map coloring) MIT / UBC9 Definite Clause Deduction UBC11 Strips Planning UBC12 Continuous Planning Koenig14 Belief Networks UBC / JavaBayes17 Markov Decision Processes UBC18 Decision Trees Alberta / UBC20 Neural Networks UBC20 Support Vector (Kernel) Machines MIT21 Reinforcement Learning Blackjack25 Robotic Control UBC26 Art Aaron

    AI: A Modern Approach Modified: Mar 16, 2010

    Use our professional PDF creation service at http://www.htm2pdf.co.uk!

  • Contents:

    Home Rsum / CV AI Projects CG Projects Publications Contact

    Artificial IntelligenceThe question of whether computers can think is like the question of whether

    submarines can swim. --Edsger W. Dijkstra

    My Artificial Intelligence WorkHere y ou can see som e of the work I'v e done in AI, listed in rev erse chronological order. Feelfree to contact me if y ou hav e any questions or com m ents.See also my article on game trees.

    Alquerque (2007-2008)This was my entry for CodeCup 2008, anannual game AI competition held by theNetherlands. My program won several of thepractice rounds, and ranked 3rd place in thefinal competition.The task was to write a program that play ed thegam e Alquerque, a board gam e sim ilar to checkers.Program s com peted against each other intournam ent-sty le, and were ranked by total points.

    Som e of the features of m y entry , which could search to depths of 7 -1 0, or ev en higher:

    Alpha-Beta pruning with v arious alpha-beta tricks, m ov e sorting, quiescencesearching.Optim ized board representation, using bitboards for fast operations.Tim ed m ov es in order to search to the m axim um possible depth for each m ov e,

    Hom eRsum / CVAI Projects

    A lqu erqu e Rev ersiSolv in g Ch ess Ca ssa Rev ersi Geom et ricProofs

    CG ProjectsPublicationsContact

    Use our professional PDF creation service at http://www.htm2pdf.co.uk!

  • within the allotted tim e lim it for each m ov e.Material v alue calculated as a logarithm of a quotient rather than a difference, inorder to encourage piece captures when program is ahead.A com plete endgam e database used to perfectly solv e 1 v s. 1 positions.Heuristic strategies for position ev aluation, apart from m ov e searching, in order tolower probability of a draw gam e, and to finish gam es as quickly as possible."Fastest first" heuristic used to first search positions with high probability of a fastcut-off."Cache effect", sim ilar to a killer-m ov es heuristic, which increases speed by try ingrecently m ov ed pieces first.Hash-tables (though the nature of the gam e m ade it so that they were not v eryuseful, so I disabled them ).

    Reversi/Othello Solving (2006-2007)This program finds the perfect play forReversi (Othello) on a 6x6 board.It only takes a few hours to search through ov er 20billion positions in order to determ ine that if bothplay ers alway s m ake the best m ov e, the secondplay er wins by 4 (20-1 6).The program is highly optim ized, using 64-bitbitfields to represent the board, preprocessed tables

    for quickly finding and m aking legal m ov es, m idgam e searches for m ov e sorting, andv arious other optim izations to allow it to search through sev eral m illion nodes per secondon an AMD 64. (I wrote it with 64-bit processing in m ind.)

    Chess (2003)This is a program that plays chess. It followsall rules of modern chess, including enpassant captures and rules for drawn games.I wrote the AI engine back in 2002 when I was asenior in high school. It uses an alpha-beta searchfor searching the gam e space, along with a fewoptim izations and im prov em ents to allow it tosearch deeper. It isn't exceptionally strong, but itdoes look sev eral m ov es ahead, and will winagainst an opponent that m akes any m istakes. Itsm ain lacking features are an opening book, and

    Use our professional PDF creation service at http://www.htm2pdf.co.uk!

  • proper endgam e strategy , though it play s arelativ ely strong m iddlegam e.

    Later on, in 2003 , I wrote a v ery sim ple GUI for it, which is what y ou see here.Download:HamedChess - Windows Executable (1.03 MB) HamedChess - Windows Executable - Zipped (294 KB)

    Cassa (2002-2003)This was my entry for CodeCup 2003, anannual game AI competition held by theNetherlands, in which my program ranked4rd place in the final competition.The m ain feature of the program , aside from theusual alpha-beta searching techniques andoptim izations, was the way the v arious coefficientsthat controlled the gam e analy sis and thereforegam eplay were determ ined: by the use of angenetic algorithm that generated, com bined, andm utated different v ersions of the coefficient set.The coefficient sets were play ed against each otherin order to quantify fitness v alues.Hence the nam e, DarwinCaissa.

    Download:DarwinCaissa Source Code and Coefficient Set(28 KB)

    Reversi/Othello (2002)Before I wrote chess, I warmed up by writingstandard Reversi (Othello).Using m ov e sorting and alpha-beta pruning, theprogram searches to a depth of at least 7 -8 ply .Com bined with a v ery good analy sis function, theprogram is quite strong, and beats all but thestrongest of hum an play ers.Please forgiv e m e for the choice of colors. It seem edlike a good idea at the tim e! ;)

    Use our professional PDF creation service at http://www.htm2pdf.co.uk!

  • Download:HamedReversi - Windows Executable (380 KB) HamedReversi - Windows Executable - Zipped (184 KB)

    Geometry Solving System (2001-2002)Automated Geometric Theorem Prover

    In my junior and senior years of high school, Iworked on an automated theorem provingsystem for plane geometry.It takes as input, a series of facts as well as thehy pothesis to prov e, and uses its user-defineddatabase of base theorem s to attem pt to construct ageom etric proof of the hy pothesis. If it is successful,the com plete proof is written in an organized form ,as output.The program defines a language for description ofgeom etric objects within a plane (such as lines,points, angles, and triangles) as well as their

    relationships with each other (parallel lines, equal angles, etc.).The language is used to define the base theorem s, as well as the desired problem to solv e.Deduction is perform ed by using known facts, apply ing theorem s, and adding new facts,while storing the reasons behind ev ery fact, in order to be able to write the com pleteproof. In other words, it im plem ents a forward chaining algorithm on the im plicitunderly ing first-order logic defined by the sy stem .

    2 01 3 Ha m ed A h m a di | A ll Rig h ts Reser v ed | Desig n by A n dr ea s V iklu n d

    Use our professional PDF creation service at http://www.htm2pdf.co.uk!

    antologia.pdfbusqueda1-introduccion.pdfaima_cs_berkeley_edu-demos.pdfwww_hamedahmadi_com-ai_projects.pdf