Computer Science CPSC 322
Lectur ture e 8
In Intr tro to to CSP SP CSP as as Sear earch ch
1
Lectur ture e 8 In Intr tro to to CSP SP CSP as as Sear - - PowerPoint PPT Presentation
Computer Science CPSC 322 Lectur ture e 8 In Intr tro to to CSP SP CSP as as Sear earch ch 1 Announ nouncem emen ents Assignment 1 due today @ 11:59pm solution posted 2 days after, to accommodate for late days
1
Both midterm and final will have questions very similar, or even verbatim, from this set ( about 40-60% of overall mark) You can answer these questions by studying the slides and textbook – Cover questions as we proceed through the material, come to see us if you have doubts on how to answer – BUT DO STUDY THE REVELANT MATERIAL FIRST! Do not wait until just before the midterm to review the questions, if you start now it will be much easier to cover all the relevant ones before the exam
finding the answers to these questions
But if you come to office hours with ideas, we will be happy to discuss them with you
Sel elec ection Com
plete Op Opti timal Tim ime Spac pace
DFS LIFO N N O(bm) O(mb) BFS FIFO Y Y O(bm) O(bm) IDS LIFO Y Y O(bm) O(mb) LCFS min cost Y ** Y ** O(bm) O(bm) Best First min h N N O(bm) O(bm) A* min f Y** Y** O(bm) O(bm) B&B LIFO + pruning Y** Y** O(bm) O(mb) IDA* LIFO Y** Y** O(bm) O(mb) MBA* min f Y** Y** O(bm) O(bm)
5
Sel elec ection Com
plete Op Opti timal Tim ime Spac pace
DFS LIFO N N O(bm) O(mb) BFS FIFO Y Y O(bm) O(bm) IDS LIFO Y Y O(bm) O(mb) LCFS min cost Y ** Y ** O(bm) O(bm) Best First min h N N O(bm) O(bm) A* min f Y** Y** O(bm) O(bm) B&B LIFO + pruning Y** Y** O(bm) O(mb) IDA* LIFO Y Y O(bm) O(mb) MBA* min f Y** Y** O(bm) O(bm)
6
Representation Reasoning Technique
8
9
Representation Reasoning Technique
10
11
Representation Reasoning Technique
12
13
Source: Michael Littman
14
1. allowable combinations of values for subsets of variables (hard constraints) 2. preferences over values of variables (soft constraints)
15
Boolean: |dom(V)| = 2 Finite: |dom(V)| is finite Infinite but discrete: the domain is countably infinite Continuous: e.g., real numbers between 0 and 1
Soon, however, we will give a broader definition of state, so it is best to start distinguishing the two concepts .
17
18
combination is ok)
20
Crossword Puzzle 1:
length
21
22
23
24
25
We will mostly deal with binary constraints
26
V2 ≠ 2
We will mostly deal with binary constraints
participating in the constraint
– for constraint V1 > V2 and dom(V1) = {1,2,3} and dom(V2) = {1,2}:
for each variable satisfy the constraint else false: V = {V1,V2}
–
dom(V1) = {1,2,3};
–
dom(V2) = {1,2}
27 V1 V2
V1 V2 2 1 3 1 3 2
V2 ≠ 2
binary (k=2): V1 + V2 < 5 3-ary: V1 + V2 + V4 < 5 We will mostly deal with binary constraints
participating in the constraint
– for constraint V1 > V2 and dom(V1) = {1,2,3} and dom(V2) = {1,2}:
for each variable satisfy the constraint else false: V = {V1,V2}
–
dom(V1) = {1,2,3};
–
dom(V2) = {1,2}
28
filled in
letters at points where they intersect
Slide 29
v1[ ] h1[]
points where they intersect
Slide 30
v1[ ] h1[]
WA NT NT NT NT SA SA NT NT QU
WA NT NT Red Green Red Bue Green Red Green Blue Blue Red Blue Green NT NT SA SA Red Green Red Bue Green Red Green Blue Blue Red Blue Green NT NT QU Red Green Red Bue Green Red Green Blue Blue Red Blue Green
32
33
Slide 34
Slide 36
37
We will mostly deal with binary constraints
participating in the constraint
variable which satisfy the constraint
consistent with that constraint, i.e.
38
Definition: A model of a CSP is an assignment of values to all of its variables (i.e., a possible world) that satisfies all of its constraints.
– dom(V1) = {1,2,3,4}
– C1: V1 ≠ 2 – C2: V1 > 1
Definition: A constraint satisfaction problem (CSP) consists of:
39
Definition: A model of a CSP is an assignment of values to all of its variables (i.e., a possible world) that satisfies all of its constraints.
– dom(V1) = {1,2,3,4}
– C1: V1 ≠ 2 – C2: V1 > 1
V1 = 3 V1 = 4 Definition: A constraint satisfaction problem (CSP) consists of:
40
A None Another example:
B 1 C 2 D 3 E 4
41
V = {V1,V2}
– dom(V1) = {1,2,3} – dom(V2) = {1,2}
– C1: V2 ≠ 2 – C2: V1 + V2 < 5 – C3: V1 > V2
{V1=1, V2=1} {V1=1, V2=2} {V1=2, V2=1} {V1=2, V2=2} {V1=3, V2=1} {V1=3, V2=2}
{V1=2, V2=1} (a model) {V1=3, V2=1} (a model)
42
WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue, T = green
43
44
45
this is now an optimization problem
46
size of the search space
quickly, even though they may offer no theoretical guarantees
47
Fo For a in dom(A) Fo For b in dom(B) Fo For c in dom(C) if {A=a, B=b, C=c} satisfies all constraints return n {A=a, B=b, C=c} fail
49
50
Fo For a in dom(A) Fo For b in dom(B) Fo For c in dom(C) if {A=a, B=b, C=c} satisfies all constraints return n {A=a, B=b, C=c} fail
51
52
53
{V1 = v1,…,Vk = vk }
nodes {V1 = v1,…,Vk = vk, Vk+1 = x} for each x ∈ dom(Vk+1)
54
V1 = v1 V2 = v1 V1 = v1 V2 = v2 V1 = v1 V2 = vk
V1 = v1 V2 = v1 V3 = v2 V1 = v1 V2 = v1 V3 = v1 {} V1 = v1 V1 = vk
55
56
57
59
regardless of the value of the other variables ⇒ Fail! Prune!
60
V1 = v1 V2 = v1 V1 = v1 V2 = v2 V1 = v1 V2 = vk
V1 = v1 V2 = v1 V3 = v2 V1 = v1 V2 = v1 V3 = v1 {} V1 = v1 V1 = vk
Check unary constraints on V1 If not satisfied = PRUNE Check constraints on V1 and V2 If not satisfied = PRUNE
61
62
A=1 A=2 A=3 A=4 C=1 C=2 C=3 C=4 C=1 C=2 C=3 C=4 C=1 C=2 C=3 C=4 C=1 C=2 C=3 C=4
63
A=1 B=1 failure B=2 C=1 D=1 failure D=2 failure D=3 failure D=4 failure C=2 failure C=3 D=1 failure D=2 failure D=3 failure D=4 failure C=4 D=1 failure D=2 failure D=3 failure D=4 failure
64
EXAMPLE : DA = DB = DC = {1,2,3,4} (A ≠B) ∧ (B ≠C) ∧ (C < D) ∧ (A=D) ∧ (B ≠ D) ∧ (E < A) ∧ (E < B) ∧ (E < C) ∧ (E < D)
A=1 D=1 C= 1 failure C=2 failure C=3 failure C=4 failure D=2 failure D=3 failure D=4 failure
EXAMPLE : DA = DB = DC = {1,2,3,4} (A ≠B) ∧ (B ≠C) ∧ (C < D) ∧ (A=D) ∧ (B ≠ D) ∧ (E < A) ∧ (E < B) ∧ (E < C) ∧ (E < D)
A=1 B=1 failure B=2 C=1 D=1 failure D=2 failure D=3 failure D=4 failure C=2 failure C=3 D=1 failure D=2 failure D=3 failure D=4 failure C=4 D=1 failure D=2 failure D=3 failure D=4 failure
65
66
67
V1 = v1 V2 = v1 V1 = v1 V2 = v2 V1 = v1 V2 = vk V1 = v1 V2 = v1 V3 = v2 V1 = v1 V2 = v1 V3 = v1 {} V1 = v1 V1 = vk
68
V1 = v1 V2 = v1 V1 = v1 V2 = v2 V1 = v1 V2 = vk V1 = v1 V2 = v1 V3 = v2 V1 = v1 V2 = v1 V3 = v1 {} V1 = v1 V1 = vk
69
between:
whether it is a model, a solution)
disadvantages.
state).
70