Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

BS CS / BS SE CS-415 GIFT University Gujranwala

Course: Artificial Intelligence [A] 26-August-2022 (Spring 2022)


Resource Person: Muhammad Shakeel QUIZ – 5 (CSPs - II)

Total Points: 10

SOLUTION
Suppose that you are given the following 4-queens assignment:

Use the iterative improvement algorithm with minimum conflicts heuristic to find a solution for this CSP.
What would be an appropriate evaluation function for this problem?

An appropriate evaluation function would be:

c(n) = number of attacks between the queens

Page 1 of 2
BS CS / BS SE CS-415 GIFT University Gujranwala

1. Random number generator: Q-2, 3. Random number generator: Q-1,


c(n) = 3 c(n) = 1
Red numbers represent c(n) values. 1 2 3 4
1 2 3 4
Q 1
0 3
1 1
Q
1 Q
Q 0 2
2 1
2 3
Q
3
Q
3
Q
4
Q
4
Min-conflicts heuristic moves Q-1 to
Min-conflicts heuristic moves Q-2 to cell # 2. The result would be:
cell # 4. The result would be: 1 2 3 4
1 2 3 4
Q
1
Q
1 Q
Q 2
2
Q
3
Q
3
Q
4
Q
4
Here, c(n) = 0 (no attacks). So, one
2. Random number generator: Q-4, possible solution has been reached.
c(n) = 2
1 2 3 4

Q END OF QUIZ SOLUTION


1
Q
2
Q
3
Q 2
2 0
4 2

Min-conflicts heuristic moves Q-4 to


cell # 3. The result would be:
1 2 3 4

Q
1
Q
2
Q
3
Q
4
Page 2 of 2

You might also like