• Non ci sono risultati.

Fundamentals of Artificial Intelligence

N/A
N/A
Protected

Academic year: 2021

Condividi "Fundamentals of Artificial Intelligence"

Copied!
30
0
0

Testo completo

(1)

Fundamentals of Artificial Intelligence

Laboratory

Dr. Mauro Dragoni

Department of Information Engineering and Computer Science

Academic Year 2020/2021

(2)

Exercise 3.10

page 02

Apply both the iterative deepening depth-first search and the bidirectional

search for reaching the goal (N-17) from the start (N-0)

(3)

Exercise 3.10 - Solution

page 03

 In order to avoid misunderstanding and to do not create confusion, we apply the algorithm as it is explained in the book without considering possible variants.

Iterative deepening d0 = {0}

d1 = {0,1,2,4,7,14}

d2 = {0,1,2,4,7,14,5,8,11}

d3 = {0,1,2,4,7,14,5,8,11,6,9,15}

d4 = {0,1,2,4,7,14,5,8,11,6,9,15,13,17}

(4)

Exercise 3.10 - Solution

page 04

 In order to avoid misunderstanding and to do not create confusion, we apply the algorithm as it is explained in the book without considering possible variants.

Bidirectional search (by applying breadth-first) Step0 = {0} {17}

Step1 = {0,1,2,4,7,14} {17,3,10,13,15,16}

Step2 = {0,1,2,4,7,14,5,8,11} {17, 3,10,13,15,16,9,12,11}

Bidirectional search (by applying breadth-first) Step0 = {0} {17}

Step1 = {0,1} {17,3}

Step2 = {0,1,5} {17,3,10}

Step3 = {0,1,5,6} {17,3,10,13}

Step4 = {0,1,5,6,9} {17,3,10,13,9}

(5)

Exercise 3.11

page 05

Apply the greedy best-first search strategy for finding the route from Lugoj to

Bucharest.

(6)

Exercise 3.11 - Solution

page 06

Apply the greedy best-first search strategy for finding the route from Lugoj to Bucharest.

 Initial state: Lugoj(244)

Step1, expanding Lugoj: Mehadia(241), Timisoara(329) Step2, expanding Mehadia: Lugoj(244), Drobeta(242)

Step3, expanding Drobeta: Mehadia(241), Craiova(160)

Step4, expanding Craiova: Drobeta(242), Rimnicu Vilcea(193), Pitesti(100)

Step4, expanding Pitesti: Craiova(160), Rimnicu Vilcea(193), Bucharest(0)

(7)

Exercise 3.12

page 07

 A* algorithm ---

WHILE (QUEUE not empty && first path not reach goal) DO Remove first path from QUEUE

Create paths to all children Reject paths with loops

Add paths and sort QUEUE (by f = cost + heuristic) IF QUEUE contains paths: P, Q

AND P ends in node Ni && Q contains node Ni AND cost(P) ≥ cost(Q)

THEN remove P

IF goal reached THEN success ELSE failure

---

(8)

Exercise 3.12

page 08

f = accumulated path cost + heuristic QUEUE = path containing root

QUEUE = <S>

(9)

Exercise 3.12

page 09

f = accumulated path cost + heuristic

Remove first path, Create paths to all children,

Reject loops and Add paths. SORT QUEUE by f

QUEUE = <SB,SA>

(10)

Exercise 3.12

page 010

f = accumulated path cost + heuristic

Remove first path, Create paths to all children,

Reject loops and Add paths. SORT QUEUE by f

QUEUE = <SA,SBC,SBG,SBA>

(11)

Exercise 3.12

page 011

f = accumulated path cost + heuristic

IF QUEUE contains paths: P, Q

AND P ends in node Ni && Q contains node Ni AND cost(P) ≥ cost(Q)

THEN remove P

QUEUE = <SA,SBC,SBG,SBA>

(12)

Exercise 3.12

page 012

f = accumulated path cost + heuristic

Remove first path, Create paths to all children,

Reject loops and Add paths. SORT QUEUE by f

QUEUE = <SBC,SBG,SAB>

(13)

Exercise 3.12

page 013

f = accumulated path cost + heuristic

IF QUEUE contains paths: P, Q

AND P ends in node Ni && Q contains node Ni AND cost(P) ≥ cost(Q)

THEN remove P

QUEUE = < SBC,SBG,SAB>

(14)

Exercise 3.12

page 014

f = accumulated path cost + heuristic

Remove first path, Create paths to all children,

Reject loops and Add paths. SORT QUEUE by f

QUEUE = <SBCG,SBG>

(15)

Exercise 3.12

page 015

f = accumulated path cost + heuristic

IF QUEUE contains paths: P, Q

AND P ends in node Ni && Q contains node Ni AND cost(P) ≥ cost(Q)

THEN remove P

QUEUE = < SBCG,SBG>

(16)

Exercise 3.12

page 016

f = accumulated path cost + heuristic

SUCCESS

QUEUE = < SBCG>

(17)

Exercise 3.13

page 017

 Perform the A* Algorithm on the following figure. Explicitly write down the queue

at each step.

(18)

Exercise 3.13

page 018

 Step 1

(19)

Exercise 3.13

page 019

 Step 2

(20)

Exercise 3.13

page 020

 Step 3

(21)

Exercise 3.13

page 021

 Step 4

(22)

Exercise 3.13

page 022

 Step 5

(23)

Exercise 3.13

page 023

 Step 6

(24)

Exercise 3.13

page 024

 Step 7

(25)

Exercise 3.13

page 025

 Step 8

(26)

Exercise 3.13

page 026

 Step 9

(27)

Exercise 3.13

page 027

 Step 10

(28)

Exercise 3.13

page 028

 Step 11

(29)

Exercise 3.14

page 029

 Design a genetic algorithm for solving a Sudoku puzzle.

• Provide the data structure needed and define the parameters.

• Define the fitness function.

• Define the selection operator.

• Define the crossover operator.

• Define the mutation operator.

(30)

Exercise 3.14

page 030

 Design a genetic algorithm for solving a Sudoku puzzle.

Riferimenti

Documenti correlati

Questo elemento rappresenta che la scelta di Djokovic come global ambassador per Uniqlo è stata fortemente studiata perché ha una ripercussione positiva sul marchio,

The first part of this paper investigates the elements of choral characterisation that are subtly but persistently woven into the chorus ’ self-presentation in the early phases of

The information sources we rely upon are the tags by which users annotated resources, that are available through the ArsMeteo platform, and the ontology OntoEmotion, that was

Several debates revolve around the role of religions in the strictly political sphere, focusing on religious actors playing a political role, on the role of

state ← UPDATE-STATE (state, action, percept, model) if GOAL-ACHIEVED (state, goal) then return a null action if plan is empty then.. plan ← PLAN (state, goal, model) action ←

 Starting from the green node at the top, which algorithm will visit the least number of nodes before visiting the yellow goal node?... Neither BFS nor DFS will ever encounter

Arcs are labeled with the cost of traversing them and the estimated cost to a goal (i.e., the h function) is reported inside nodes (so lower scores are better). Apply

Department of Information Engineering and Computer Science Academic Year 2020/2021...