120 likes | 258 Views
4-Queens Example. (slides adapted from Prof. Kauchak). X1 { 1 ,2,3,4}. X2 {1,2,3,4}. 1. 2. 3. 4. 1. 2. 3. 4. X3 {1,2,3,4}. X4 {1,2,3,4}. 4-Queens Problem. What can we remove with forward checking?. X1 { 1 ,2,3,4}. X2 { 1 , 2 ,3,4}. 1. 2. 3. 4. 1. 2. 3. 4. X3
E N D
4-Queens Example (slides adapted from Prof. Kauchak)
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem What can we remove with forward checking?
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem Anything else with arc consistency? Can’t have X2 = 3! (Conflicts with all possible values of X3) forward propagation
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem Anything else? Can’t have X3 = 4! (Conflicts with X2=4)
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3, } X4 {1,2,3,4} 4-Queens Problem Anything else? Can’t have X3 = 2! (Conflicts with all possible values of X4)
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem Did not have to search over values. Just looked at constraints.
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem Try X1=2 Forward checking removes values
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem ? Can’t have X3 = 3 (Conflicts with X2=4)
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem ? Can’t have X4 = 1 or X4 = 4
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem
X1 {1,2,3,4} X2 {1,2,3,4} 1 2 3 4 1 2 3 4 X3 {1,2,3,4} X4 {1,2,3,4} 4-Queens Problem Searched just 2 variables (X1, X2)!