A* Algorithm - Exercises: Artificial Intelligence

123
Exercises: Artificial Intelligence A*

Transcript of A* Algorithm - Exercises: Artificial Intelligence

Exercises: Artificial Intelligence

A*

A* ALGORITHM

A*

A* Algorithm

• Input:

– QUEUE: Path only containing root

• Algorithm:

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

• Remove first path from QUEUE

Create paths to all children• Create paths to all children

• Reject paths with loops

• Add paths and sort QUEUE (by f = cost + heuristic)

• IF QUEUE contains paths: P, QAND P ends in node Ni && Q contains node Ni AND cost_P ≥ cost_Q

THEN remove P

– IF goal reached THEN success ELSE failure

FIRST EXAMPLE ON A*

A*

A* algorithm by Example

S77

0

f = accumulated path cost + heuristic

QUEUE = path containing root

CS

A GB10

7 5

90

69

1 1

12

5

QUEUE: <S>

A* algorithm by Example

Sf = accumulated path cost + heuristic

A1011

1

B910

1

Remove first path, Create paths to all

children, Reject loops and Add paths.

Sort QUEUE by f

CS

A GB10

7 5

90

69

1 1

12

5

QUEUE: <SB,SA>

A10 B9

A* algorithm by Example

Sf = accumulated path cost + heuristic

A1011

1

B

Remove first path, Create paths to all

children, Reject loops and Add paths.

Sort QUEUE by f

CS

A GB10

7 5

90

69

1 1

12

5

QUEUE: <SA,SBC,SBG,SBA>

A10 B

C512

7

G013

13

A10

1020

A* algorithm by Example

Sf = accumulated path cost + heuristic

A1011

1

B

IF P terminating in I with cost_P &&

Q containing I with cost_Q AND

cost_P ≥ cost_Q THEN remove P

CS

A GB10

7 5

90

69

1 1

12

5

QUEUE: <SA,SBC,SBG,SBA>

A10 B

C512

7

G013

13

A10

1020

A* algorithm by Example

Sf = accumulated path cost + heuristic

A B

Remove first path, Create paths to all

children, Reject loops and Add paths.

Sort QUEUE by f

CS

A GB10

7 5

90

69

1 1

12

5

QUEUE: <SBC,SBG,SAB>

A B

C512

7

G013

13

B9

1019

A* algorithm by Example

Sf = accumulated path cost + heuristic

A B

IF P terminating in I with cost_P &&

Q containing I with cost_Q AND

cost_P ≥ cost_Q THEN remove P

CS

A GB10

7 5

90

69

1 1

12

5

QUEUE: <SBC,SBG,SAB>

A B

C512

7

G013

13

B9

1019

A* algorithm by Example

Sf = accumulated path cost + heuristic

B

Remove first path, Create paths to all

children, Reject loops and Add paths.

Sort QUEUE by f

CS

A GB10

7 5

90

69

1 1

12

5

QUEUE: <SBCG,SBG>

B

C G013

13

G012

12

A* algorithm by Example

Sf = accumulated path cost + heuristic

B

IF P terminating in I with cost_P &&

Q containing I with cost_Q AND

cost_P ≥ cost_Q THEN remove P

CS

A GB10

7 5

90

69

1 1

12

5

QUEUE: <SBCG,SBG>

B

C G013

13

G012

12

A* algorithm by Example

Sf = accumulated path cost + heuristic

B

SUCCESS

CS

A GB10

7 5

90

69

1 1

12

5

QUEUE: <SBCG>

B

C

G012

12

PROBLEM

A*

Problem

• Perform the A* Algorithm on the following

figure. Explicitly write down the queue at each

step.

A10

6

C

S

A

GB0

6

D

E

F1

4

2

13

4

17

10

5

6

6

6

7

4

6

3

A* SEARCH

A*

A* Search

S

QUEUE:

S

1717

0

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

S

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A1016

6

B1318

5

C414

10

QUEUE:

SCSC

SA

SB

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A1016

6

B1318

5

CQUEUE:

SA

D218

16

SA

SCD

SB

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A B1318

5

CQUEUE:

SAE

D218

16

E416

12

SAE

SCD

SB

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A B1318

5

CQUEUE:

SAEF

D218

16

E

F117

16

B1331

18

SAEF

SCD

SB

SAEB

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A B1318

5

CQUEUE:

SCD

D218

16

E

F

G019

19

D224

22

SCD

SB

SAEFG

SAEFD

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A B1318

5

CQUEUE:

SB

DE

F

G019

19

F123

22

B1336

23

SB

SAEFG

SCDF

SCDB

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A BQUEUE:

SBD

E

F

G019

19

E415

11

D214

12

SBD

SBE

SAEFG

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A BQUEUE:

SBE

E

F

G019

19

E415

11

D

F119

18

C422

18

SBE

SBDF

SAEFG

SBDC

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A BQUEUE:

SBEF

E

F

G019

19

ED

F119

18

C422

18

F116

15

A1027

17

SBEF

SAEFG

SBDF

SBDC

SBEA

A* Search

S

C

S

A

GB0

6

D

EF

1

4

2

13

10

4

17

10

5

6

6

6

7

4

6

3

A BQUEUE:

SBEFG

E

F

G019

19

ED

C422

18

FA1027

17

G018

18

D 232

21

SBEFG

SAEFG

SBDC

SBEFD

SBEA

Exercises: Artificial Intelligence

Iterated Deepening A*

IDA* ALGORITHM

Iterated Deepening A*

IDA* Algorithm

• f-bound ôôôô f(S)

• Algorithm:

– WHILE (goal is not reached) DO

• f-bound ôôôô f-limitted_search(f-bound)• f-bound ôôôô f-limitted_search(f-bound)

– Perform f-limited search with f-bound

(See next slide)

f-limitted Search Algorithm

• Input:

– QUEUE ô Path only containing root

– f-bound ô Natural number

– f-new ô¶

• Algorithm:• Algorithm:

– WHILE (QUEUE not empty && goal not reached) DO• Remove first path from QUEUE

• Create paths to children

• Reject paths with loops

• Add paths with f(path) ≤ f-bound to front of QUEUE (depth-first)

• f-new ô minimum( {f-new} » {f(P) | P is rejected path} )

– IF goal reached THEN success ELSE report f-new

PROBLEM

Iterated Deepening A*

Problem

• Perform the IDA* Algorithm on the following

figure.

C S A109

G B D

5 1

4

8

5

S A B C D G

heuristic 0 0 4 3 0 0

IDA* SEARCH

Iterated Deepening A*

IDA* Search

S00

0

C S A

G B D

5

109

1

4

8

5

f-bound = 0

f-new = ¶¶¶¶

0 0

040

3

f-new = ¶¶¶¶

IDA* Search

S

A010

10B4

128

C312

9

C S A

G B D

5

109

1

4

8

5

0 0

040

3

f-bound = 0

f-new = 10A0 B4 C3

f-new = 10

Children are explored

depth-first!

IDA* Search

S00

0

C S A

G B D

5

109

1

4

8

5

0 0

040

3

f-bound = 10

f-new = ¶¶¶¶f-new = ¶¶¶¶

IDA* Search

S

A010

10B4

128

C312

9

C S A

G B D

5

109

1

4

8

5

0 0

040

3

f-bound = 10

f-new = 12A0 B4 C3

f-new = 12

IDA* Search

S

A B412

8C3

129

C S A

G B D

5

109

1

4

8

5

0 0

040

3

f-bound = 10

f-new = 11A B4 C3

D011

11

f-new = 11

IDA* Search

S00

0

C S A

G B D

5

109

1

4

8

5

0 0

040

3

f-bound = 11

f-new = ¶¶¶¶f-new = ¶¶¶¶

IDA* Search

S

A010

10B4

128

C312

9

C S A

G B D

5

109

1

4

8

5

0 0

040

3

f-bound = 11

f-new = 12A0 B4 C3

f-new = 12

IDA* Search

S

A B412

8C3

129

C S A

G B D

5

109

1

4

8

5

0 0

040

3

f-bound = 11

f-new = 12A B4 C3

D011

11

f-new = 12

IDA* Search

S

A B412

8C3

129

C S A

G B D

5

109

1

4

8

5

0 0

040

3

f-bound = 11

f-new = 12A B4 C3

D

B419

15

f-new = 12

IDA* Search

S00

0

C S A

G B D

5

109

1

4

8

5

0 0

040

3

f-bound = 12

f-new = ¶¶¶¶f-new = ¶¶¶¶

IDA* Search

S

A010

10B4

128

C312

9

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 12

f-new = ¶¶¶¶A0 B4 C3

f-new = ¶¶¶¶

IDA* Search

S

A B412

8C3

129

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 12

f-new = ¶¶¶¶A B4 C3

D011

11

f-new = ¶¶¶¶

IDA* Search

S

A B412

8C3

129

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 12

f-new = 19A B4 C3

D

B419

15

f-new = 19

IDA* Search

S

A B C312

9

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 12

f-new = 13A B C3

D

B419

15

D G012

12

013

13

f-new = 13

IDA* Search

S

A B C312

9

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 12

f-new = 13A B C3

D

B419

15

D G012

12

013

13

A013

13

f-new = 13

IDA* Search

S

A B C312

9

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 12

f-new = 13A B C3

D

B419

15

D G012

12

013

13

A013

13

G014

14

f-new = 13

IDA* Search

S00

0

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 13

f-new = ¶¶¶¶f-new = ¶¶¶¶

IDA* Search

S

A010

10B4

128

C312

9

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 13

f-new = ¶¶¶¶A0 B4 C3

f-new = ¶¶¶¶

IDA* Search

S

A B412

8C3

129

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 13

f-new = ¶¶¶¶A B4 C3

D011

11

f-new = ¶¶¶¶

IDA* Search

S

A B412

8C3

129

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 13

f-new = 19A B4 C3

D

B419

15

f-new = 19

IDA* Search

S

A B C312

9

C S A

G B D

109

1

4

8

5

0 0

040

3

f-bound = 13

f-new = 19A B C3

D

B419

15

D G012

12

013

13

f-new = 19

Exercises: Artificial Intelligence

Simplified Memory-bounded A*

SMA* ALGORITHM

Simplified Memory-bounded A*

SMA* Algorithm

• Optimizes A* to work within reduced memory

• Key Idea:

– IF memory full for extra node (C)

– Remove highest f-value leaf (A)– Remove highest f-value leaf (A)

– Remember best-forgotten child in

each parent node (15 in S)

S

A 15 B 13

C 18

13

(15)

E.g. Memory of 3 nodes only

SMA* Algorithm

• Generate Children 1 by 1

– Expanding: add 1 child at the time to QUEUE

– Avoids memory overflow

– Allows monitoring if nodes need deletion– Allows monitoring if nodes need deletion

S

A 15 B 13

13

First add A later B

SMA* Algorithm

• Too long paths: Give up

– Extending path cannot fit in memory

• give up (C)

– Set f-value node (C) to ¶¶¶¶

S 13

• Remembers: path cannot be found here B 13

C ¶¶¶¶

D

18

E.g. Memory of 3 nodes only

SMA* Algorithm

• Adjust f-values

– IF all children Mi of node N have been explored

– AND "i: f(S…Mi) > f(S…N)

– THEN reset (through N ï through children)– THEN reset (through N ï through children)

• f(S…N) = min{f(S…Mi)|Mi child of N}

Better estimate for f(S)

S

A 15 B 24

1513

SMA* BY EXAMPLE

Simplified Memory-bounded A*

SMA* by Example

• Perform SMA* (memory: 3 nodes) on the

following figure.A

24

C

S GB3

15

S A B C G

heuristic 3 0 2 1 0

2

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3 3

0

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3 3

0

A0 4

4

Generate children(One by one)

A0 4

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3 3

0

A0 4

4B2 5

3A0 4 B2 5

Generate children(One by one)

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3 3

0

A0 4

4B2 5

3C1 6

5

(5)

A0 4 B2 5 C1 6

Generate children(One by one)

Memory full

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3

0

A0 4

4C1 6

5

(5)

43

A0 4 C1 6

All children are

explored

Adjust f-values

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3

0

A0 4

4C1 6

5

(5)

4

A0 4 C1 6

G0 6

6

Generate children(One by one)

Memory full

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3

0

A0 4

4

(5)

4

6A0 4

G0 6

6

6

All children are

explored

Adjust f-values

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3

0

A0 6

4

(5)

54

A0 6

G0 6

6

All children are

explored (update)

Adjust f-values

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3

0

A0

4

6

5

B2 5

3(6)A0

G0 6

6

6 B2 5

Generate children(One by one)

Memory full

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3

0

A0

4

(6)

6

5

B2 5

3(6)C1 6

5A0 6 B2 5 C1 6

Generate children(One by one)

Memory full

SMA* by Example

C

S

A

GB3

2

1

4

5

2

0

03 2

1

S3

0 (6)

5

B2 5

3C1 6

5B2 5 C1 6

G0 5

5

Generate children(One by one)

Memory full

PROBLEM

Simplified Memory-bounded A*

Problem

• Perform SMA* (memory: 4 nodes) on the

following figure.C

32A E

10 10 9 2

D

S FG

18

S A B C D E F H G

heuristic 12 5 5 5 2 2 1 1 0

B H

8 16 3 1

Problem

S12 12

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1

Problem

S12 12

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1A5 15

Problem

S12 12

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 13

8A5 15 B5 13

Problem

S12 12

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 13

8

13

A5 15 B5 13

Problem

S12 13

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 13

8A5 15 B5 13

D2 18

16

Problem

S12 13

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 13

8 (18)A5 15 B5 13

D2 18

16G0 24

24

Problem

S12 13

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 13

8 (18)

18A5 15 B5 13

G0 24

24

18

Problem

S12 13

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 18

8 (18)

15

A5 15 B5 18

G0 24

24

Problem

S12 15

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 18

8 (18)A5 15 B5 18

G0 24

24C5 17

12

Problem

S12 15

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 18

8 (18)

(18)

A5 15 B5 18

G0 20

20C5 17

12

Problem

S12 15

0

A5 15

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1

(18)

17A5 15

G0 20

20C5 17

12

17

Problem

S12 15

0

A5 17

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1

(18)

17

A5 17

G0 20

20C5 17

12

Problem

S12 17

0

A5 17

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1

(18)

(20)A5 17

G0 20

20C5 17

12

E2 17

15

Problem

S12 17

0

A5 17

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1

(18)

(20)A5 17

C5 17

12

E2 17

15

¶¶¶¶

Problem

S12 17

0

A5 17

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1

(18)

(20)A5 17

C5 17

12

E2

15

¶¶¶¶ G0 21

21

(¶¶¶¶)

Problem

S12 17

0

A5 17

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1

(18)

(20)A5 17

C5 17

12

G0 21

21

(¶¶¶¶)

21

Problem

S12 17

0

A5 17

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1

(18)

(20)

20A5 17

C5 21

12

G0 21

21

(¶¶¶¶)

20

Problem

S12 17

0

A5 20

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1

(18)

(20)

18

A5 20

C5 21

12

G0 21

21

(¶¶¶¶)

Problem

S12 18

0

A5 20

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1(20)B5 13

8A5 20

C5 21

12

G0 21

21

(21)

B5 13

Problem

S12 18

0

A5 20

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1(20)B5 13

8A5 20

C5 21

12D2 18

16(21)

B5 13

Problem

S12 18

0

A5 20

10D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1(20)B5 13

8

(20)

A5 20

D2 18

16

B5 13

G0 24

24

Problem

S12 18

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 13

8

(20)

18

D2 18

16

B5 13

G0 24

24

18

Problem

S12 18

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 18

8

(20)

(24)

D2 18

16

B5 18

G0 24

24

G0 19

19

Problem

S12 18

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 18

8

(20)

(24)

D2 18

16

B5 18

H1 18

17G0 19

19

(19)

Problem

S12 18

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 18

8

(20)

(24)

D2 18

16

B5 18

H1 18

17

(19)

¶¶¶¶

Problem

S12 18

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 18

8

(20)

(24)

D2 18

16

B5 18

H1

17

(19)

¶¶¶¶

19

Problem

S12 18

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 18

8

(20)

(24)

19

D2 19

16

B5 18

H1

17

(19)

¶¶¶¶

19

Problem

S12 18

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 19

8

(20)

(24)

19

D2 19

16

B5 19

H1

17

(19)

¶¶¶¶

Problem

S12 19

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 19

8

(20)

(24)

D2 19

16

B5 19

H1

17

¶¶¶¶ G0

19

19

Problem

S12 19

0

D

S

C

FG

3

1

2

8B

A E

H

10

8

10 9 2

16 3 1

12

5 5 2

0 1

25 1B5 19

8

(20)

(24)

D2 19

16

B5 19

G0

19

19

Exercises: Artificial Intelligence

Monotonicity 1

PROBLEM

Monotonicity 1

Problem

• Prove that:

– IF a heuristic function h satisfies the monotonicity

restriction

• h(x) ≤ cost(x…y) + h(y)• h(x) ≤ cost(x…y) + h(y)

– THEN f is monotonously non-decreasing

• f(s…x) ≤ f(s…x…y)

Monotonicity 1

• Given:

– h satisfies the monotonicity restriction

• Proof:

f(S…A) = cost(S…A) + h(A)f(S…A) = cost(S…A) + h(A)

Monotonicity 1

• Given:

– h satisfies the monotonicity restriction

• Proof:

f(S…A) = cost(S…A) + h(A)f(S…A) = cost(S…A) + h(A)

≤ cost(S…A) + cost(A…B) + h(B)

Monotonicity 1

• Given:

– h satisfies the monotonicity restriction

• Proof:

f(S…A) = cost(S…A) + h(A)f(S…A) = cost(S…A) + h(A)

≤ cost(S…A) + cost(A…B) + h(B)

≤ cost(S…A…B) + h(B)

Monotonicity 1

• Given:

– h satisfies the monotonicity restriction

• Proof:

f(S…A) = cost(S…A) + h(A)f(S…A) = cost(S…A) + h(A)

≤ cost(S…A) + cost(A…B) + h(B)

≤ cost(S…A…B) + h(B)

≤ f(S…A…B)

Exercises: Artificial Intelligence

Monotonicity 2

PROBLEM

Monotonicity 2

Problem

• Prove or refute:

– IF f is monotonously non-decreasing

• f(s…x) ≤ f(s…xy)

– THEN h is an admissable heuristic– THEN h is an admissable heuristic

• h is an underestimate of the remaining path to the goal

with the smallest cost

• Can an extra constraint on h change this?

Monotonicity 2

• Given:

– f is mononously non-decreasing

• Proof (Counter-example):

S7 7

0D6 8

2B6 7

1G5

3

8

f is monotonously non-decreasing,

yet h is not an admissable heuristic.

Monotonicity 2

• Given:

– f is mononously non-decreasing

– Extra constraint: h(G) = 0

• Proof:• Proof:

f(S…A) ≤ f(S…AB) ≤ … ≤ f(S…AB…G)

Monotonicity 2

• Given:

– f is mononously non-decreasing

– Extra constraint: h(G) = 0

• Proof:• Proof:

f(S…A) ≤ f(S…AB) ≤ … ≤ f(S…AB…G) ñ

f(S…A) ≤ f(S…G)

Monotonicity 2

• Given:

– f is mononously non-decreasing

– Extra constraint: h(G) = 0

• Proof:• Proof:

f(S…A) ≤ f(S…AB) ≤ … ≤ f(S…AB…G) ñ

f(S…A) ≤ f(S…G) ñ

cost(S…A) + h(A) ≤ cost(S…G) + h(G)

Monotonicity 2

• Given:

– f is mononously non-decreasing

– Extra constraint: h(G) = 0

• Proof:• Proof:

f(S…A) ≤ f(S…AB) ≤ … ≤ f(S…AB…G) ñ

f(S…A) ≤ f(S…G) ñ

cost(S…A) + h(A) ≤ cost(S…G) + h(G) ñ

cost(S…A) + h(A) ≤ cost(S…A) + cost(A…G) + h(G)

Monotonicity 2

• Given:

– f is mononously non-decreasing

– Extra constraint: h(G) = 0

• Proof:• Proof:

f(S…A) ≤ f(S…AB) ≤ … ≤ f(S…AB…G) ñ

f(S…A) ≤ f(S…G) ñ

cost(S…A) + h(A) ≤ cost(S…G) + h(G) ñ

cost(S…A) + h(A) ≤ cost(S…A) + cost(A…G) + h(G) ñ

h(A) ≤ cost(A…G) + h(G)

Monotonicity 2

• Given:

– f is mononously non-decreasing

– Extra constraint: h(G) = 0

• Proof:• Proof:f(S…A) ≤ f(S…AB) ≤ … ≤ f(S…AB…G) ñ

f(S…A) ≤ f(S…G) ñ

cost(S…A) + h(A) ≤ cost(S…G) + h(G) ñ

cost(S…A) + h(A) ≤ cost(S…A) + cost(A…G) + h(G) ñ

h(A) ≤ cost(A…G) + h(G) ñ

h(A) ≤ cost(A…G)