Docsity

Logic Programming and Artificial Intelligence: Problem Sheet 8 Solutions, Study notes of Computer Numerical Control

Toggle sidebar
bg1
Logic Programming and Artificial Intelligence
25 May 2010
Solutions to Problem Sheet 8
1. Consider the board positions to be numbered left to right from zero to six. The heuristic function
is defined as follows:
h(n) = SUM of the position numbers of the white tiles + SUM of (6 - position number) for all black
tiles.
As an example, the start state has a heuristic value of 27:
BBBWWWE
0123456
white sum = 3+4+5 = 12
+ black sum = 6+5+4 = 15
----------------------
h(start) = 27
This heuristic function, his not an admissible heuristic since it sometimes overestimates the true
cost to a goal. For example, in the search space below h(goal) = 8, while the true cost is defined to
be zero. Since his not a lower bound on the true cost to a goal, this search does not guarantee an
optimal solution (though a solution of cost 14 may be the best we can do).
Nodes are represented in the form: (g(position), position, h(position)). The numbers to the right
of the nodes indicate the order in which they are removed from the list and expanded.
The Search Space:
(0 BBBWWWE 27)1
|
----------------------------------------------------
| | |
(1 BBBWEWW 29) (2 BBBEWWW 30) (1 BBBWWEW 28)2
|
---------------------------------------------------|
| | |
(2 BBBWEWW 29) (2 BBBEWWW 30) (3 BBEWWBW 25)3
|
----------------------------------------------------
| | | |
(4 BBWWEBW 23) (4 BBWEWBW 24) (4 BEBWWBW 24) (4 EBBWWBW 23)4
|
---------------
| |
(5 BEBWWBW 24) (6 WBBEWBW 20)5
|
-----------------------------------------------------------------
| | | | |
(8 WBBWWBE 17)6 (7 WBEBWBW 19) (7 WEBBWBW 18) (7 WBBBWEW 22) (7 WBBWEBW 19)
|
---------------------------------
| |
(9 WBBWEBW 19) (9 WBBWWEB 16)7
|
-----------------------------------
|||
(10 WBBWEWB 17) (11 WBEWWBB 13)8 (10 WBBEWWB 18)
|
---------------------------------------------------
| | | |
(12 WEBWWBB 12) (12 EBWWWBB 15) (12 WBWWEBB 11)9 (12 WBWEWBB 12)
|
---------------------------------------------------
| | | |
(13 WBWEWBB 12) (13 WBWWBEB 12) | (13 WBWWBBE 13)
|
[14 WEWWBBB 8]10
Goal!
1
pf2

Partial preview of the text

Download Logic Programming and Artificial Intelligence: Problem Sheet 8 Solutions and more Study notes Computer Numerical Control in PDF only on Docsity!

Logic Programming and Artificial Intelligence 25 May 2010 Solutions to Problem Sheet 8

  1. Consider the board positions to be numbered left to right from zero to six. The heuristic function is defined as follows: h(n) = SUM of the position numbers of the white tiles + SUM of (6 - position number) for all black tiles. As an example, the start state has a heuristic value of 27:

BBBWWWE 0123456 white sum = 3+4+5 = 12

  • black sum = 6+5+4 = 15

h(start) = 27

This heuristic function, h is not an admissible heuristic since it sometimes overestimates the true cost to a goal. For example, in the search space below h(goal) = 8, while the true cost is defined to be zero. Since h is not a lower bound on the true cost to a goal, this search does not guarantee an optimal solution (though a solution of cost 14 may be the best we can do). Nodes are represented in the form: (g(position), position, h(position)). The numbers to the right of the nodes indicate the order in which they are removed from the list and expanded. The Search Space: (0 BBBWWWE 27)

|

| | | (1 BBBWEWW 29) (2 BBBEWWW 30) (1 BBBWWEW 28)

(2 BBBWEWW 29) (2 BBBEWWW 30) (3 BBEWWBW 25)

|

| | | | (4 BBWWEBW 23) (4 BBWEWBW 24) (4 BEBWWBW 24) (4 EBBWWBW 23)

|

| | (5 BEBWWBW 24) (6 WBBEWBW 20)

|

| | | | | (8 WBBWWBE 17)6 (7 WBEBWBW 19) (7 WEBBWBW 18) (7 WBBBWEW 22) (7 WBBWEBW 19)

|

| | (9 WBBWEBW 19) (9 WBBWWEB 16)

|

| | | (10 WBBWEWB 17) (11 WBEWWBB 13)8 (10 WBBEWWB 18)

|

| | | | (12 WEBWWBB 12) (12 EBWWWBB 15) (12 WBWWEBB 11)9 (12 WBWEWBB 12)

|

| | | | (13 WBWEWBB 12) (13 WBWWBEB 12) | (13 WBWWBBE 13) | [14 WEWWBBB 8] Goal!

Note that some of the ties in the search tree shown above could have been broken differently, resulting in a different solution. This heuristic function does lead us much more quickly to the solution than many admissible heuristics might (as some of you found out the hard way).

  1. (a) (i) Uniform-cost search: A C B D F E J H (There are three other possibilities, which are obtained by swapping B and C, swapping D and F, or making both swaps.) (ii) Greedy best-first search: A C E D G (iii) Aāˆ—^ search: A C E B F H or A C E B F D J H (b) There are no such nodes.
  2. (a) C is arc-consistent if for each value in the domain of each variable there are values in the domains of the other variables that satisfy the constraints. (b) Both b and c should be pruned from the domain of X.
  3. (a) A set of constraints is arc consistent if and only if each constraint in the set is arc consistent.

(b) X : { 1 , 2 , 3 } Y : { 1 , 2 , 3 } Z : { 1 , 2 , 3 } W : { 1 , 3 }

(c) X : { 2 } Y : { 1 } Z : { 2 , 3 } W : { 1 }

  1. (a) Introduce carry variables, making the sum

S E N D

M O R E

c 3 c 2 c 1 c 0 M O + 10c 3 N + 10c 2 E + 10c 1 Y + 10c 0

Thus, in our problem formulation we have the following variables and domains: i. D, E, M, N, O, R, S, Y ∈ { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ii. c 0 , c 1 , c 2 , c 3 ∈ { 0 , 1 } and the constraints: (a) {S, E, N, D, M, O, R, Y } are all different. (b) D + E = 10c 0 + Y (c) N + R + c 0 = 10c 1 + E (d) E + O + c 1 = 10c 2 + N (e) S + M + c 2 = 10c 3 + 0 (f) c 3 = M (g) M 6 = 0 (h) S 6 = 0 (i) R = 8