Announcements Homework 1 is out. Due Friday Oct 22 - - PowerPoint PPT Presentation

announcements
SMART_READER_LITE
LIVE PREVIEW

Announcements Homework 1 is out. Due Friday Oct 22 - - PowerPoint PPT Presentation

Introduc)on to Ar)ficial Intelligence Lecture 6 CSPs (cont.) CS/CNS/EE 154 Andreas Krause TexPoint fonts used in EMF. Announcements Homework 1


slide-1
SLIDE 1

Introduc)on ¡to ¡ ¡

Ar)ficial ¡Intelligence ¡

Lecture ¡6 ¡– ¡CSPs ¡(cont.) ¡

CS/CNS/EE ¡154 ¡ Andreas ¡Krause ¡ TexPoint ¡fonts ¡used ¡in ¡EMF. ¡ ¡

slide-2
SLIDE 2

Announcements ¡

Homework ¡1 ¡is ¡out. ¡Due ¡Friday ¡Oct ¡22 ¡ Room ¡for ¡recita)on ¡and ¡office ¡hours: ¡ ¡

Annenberg ¡107; ¡ ¡Tuesday ¡and ¡Thursday ¡4:30-­‑5:30pm ¡

Project ¡assignments ¡have ¡been ¡sent ¡out ¡ Will ¡post ¡details ¡on ¡evalua)on ¡soon ¡ “Science ¡of ¡Iron ¡Man” ¡tonight ¡8pm ¡(Beckman ¡Auditorium) ¡

2 ¡

slide-3
SLIDE 3

Constraint ¡sa)sfac)on ¡problems ¡

So ¡far: ¡“black ¡box ¡search” ¡

Environment ¡state ¡is ¡arbitrary ¡object ¡

CSPs: ¡

state ¡is ¡defined ¡by ¡variables ¡Xi ¡taking ¡values ¡in ¡domain ¡Di ¡ goal ¡test ¡is ¡a ¡set ¡of ¡constraints ¡ step ¡cost ¡is ¡0 ¡– ¡just ¡need ¡to ¡find ¡goal ¡ ¡

(or ¡prove ¡that ¡constraints ¡can’t ¡be ¡sa)sfied) ¡

Can ¡develop ¡general ¡purpose ¡algorithms ¡for ¡large ¡

class ¡of ¡problems ¡

3 ¡

slide-4
SLIDE 4

Example: ¡Map ¡coloring ¡

Variables? ¡Domains? ¡Constraints? ¡

4 ¡

slide-5
SLIDE 5

Types ¡of ¡CSPs ¡

Discrete ¡variables ¡

Finite ¡domains ¡ Infinite ¡domains ¡

Con)nuous ¡variables ¡

5 ¡

slide-6
SLIDE 6

Types ¡of ¡constraints ¡

Unary: ¡involve ¡single ¡variable ¡ Binary: ¡involve ¡pairs ¡of ¡variables ¡ Higher-­‑order: ¡involve ¡3 ¡or ¡more ¡variables ¡ Sog ¡constraints: ¡viola)on ¡incurs ¡cost ¡

Constraint ¡op)miza)on ¡instead ¡of ¡sa)sfac)on ¡

6 ¡

slide-7
SLIDE 7

Solving ¡CSP ¡with ¡search ¡

Naïve ¡approach ¡

State ¡= ¡Par)al ¡assignment ¡to ¡variables ¡ Successor ¡fn ¡= ¡Assign ¡feasible ¡value ¡to ¡some ¡unassigned ¡var ¡ Goal ¡test ¡= ¡check ¡constraints ¡

Problems? ¡

7 ¡

slide-8
SLIDE 8

Backtracking ¡search ¡

Variable ¡assignments ¡are ¡commuta)ve! ¡ Only ¡need ¡to ¡consider ¡assignments ¡to ¡single ¡variable ¡

at ¡each ¡node ¡

Depth-­‑first ¡search ¡with ¡single ¡var. ¡assignments ¡is ¡

called ¡backtracking ¡search ¡

Can ¡solve ¡25-­‑queens ¡

8 ¡

slide-9
SLIDE 9

9 ¡

Backtracking ¡example ¡

slide-10
SLIDE 10

10 ¡

Backtracking ¡example ¡

slide-11
SLIDE 11

11 ¡

Backtracking ¡example ¡

slide-12
SLIDE 12

12 ¡

Backtracking ¡example ¡

slide-13
SLIDE 13

Improving ¡backtracking ¡search ¡

General ¡purpose ¡methods ¡can ¡dras)cally ¡improve ¡speed ¡ 1.

Which ¡variable ¡should ¡be ¡assigned ¡next? ¡

2.

In ¡what ¡order ¡should ¡we ¡try ¡the ¡values? ¡

3.

Can ¡we ¡detect ¡inevitable ¡failure ¡early? ¡

4.

Can ¡we ¡take ¡into ¡account ¡problem ¡structure? ¡

13 ¡

slide-14
SLIDE 14

Constraint ¡graph ¡

Nodes: ¡variables ¡ Arcs: ¡(binary) ¡constraints ¡

14 ¡

slide-15
SLIDE 15

15 ¡

Most ¡constrained ¡variable ¡

Most ¡constrained ¡variable: ¡

choose ¡the ¡variable ¡with ¡the ¡fewest ¡legal ¡values, ¡a.k.a. ¡

minimum ¡remaining ¡values ¡(MRV) ¡heuris)c ¡

slide-16
SLIDE 16

16 ¡

Most ¡constraining ¡variable ¡

Tie-­‑breaker ¡among ¡most ¡constrained ¡variables ¡ Most ¡constraining ¡variable: ¡

choose ¡the ¡variable ¡with ¡the ¡most ¡constraints ¡on ¡remaining ¡

variables ¡

slide-17
SLIDE 17

17 ¡

Least ¡constraining ¡value ¡

Given ¡a ¡variable, ¡choose ¡the ¡least ¡constraining ¡value ¡

(the ¡one ¡that ¡rules ¡out ¡the ¡fewest ¡values ¡in ¡the ¡ remaining ¡variables) ¡

Combining ¡these ¡heuris)cs ¡makes ¡1000 ¡queens ¡feasible ¡

slide-18
SLIDE 18

Improving ¡backtracking ¡search ¡

General ¡purpose ¡methods ¡can ¡dras)cally ¡improve ¡speed ¡

Which ¡variable ¡should ¡be ¡assigned ¡next? ¡

¡ ¡ ¡Most ¡constrained ¡ ¡Most ¡constraining ¡

In ¡what ¡order ¡should ¡we ¡try ¡the ¡values? ¡

¡ ¡ ¡Least ¡constraining ¡

Can ¡we ¡detect ¡inevitable ¡failure ¡early? ¡ Can ¡we ¡take ¡into ¡account ¡problem ¡structure? ¡

18 ¡

slide-19
SLIDE 19

19 ¡

Forward ¡checking ¡

Idea: ¡ ¡

Keep ¡track ¡of ¡remaining ¡legal ¡values ¡for ¡unassigned ¡variables ¡ Terminate ¡search ¡when ¡any ¡variable ¡has ¡no ¡legal ¡values ¡

slide-20
SLIDE 20

20 ¡

Forward ¡checking ¡

Idea: ¡ ¡

Keep ¡track ¡of ¡remaining ¡legal ¡values ¡for ¡unassigned ¡variables ¡ Terminate ¡search ¡when ¡any ¡variable ¡has ¡no ¡legal ¡values ¡

slide-21
SLIDE 21

21 ¡

Forward ¡checking ¡

Idea: ¡ ¡

Keep ¡track ¡of ¡remaining ¡legal ¡values ¡for ¡unassigned ¡variables ¡ Terminate ¡search ¡when ¡any ¡variable ¡has ¡no ¡legal ¡values ¡

slide-22
SLIDE 22

22 ¡

Forward ¡checking ¡

Idea: ¡ ¡

Keep ¡track ¡of ¡remaining ¡legal ¡values ¡for ¡unassigned ¡variables ¡ Terminate ¡search ¡when ¡any ¡variable ¡has ¡no ¡legal ¡values ¡

slide-23
SLIDE 23

23 ¡

Constraint ¡propaga)on ¡

Forward ¡checking ¡propagates ¡informa)on ¡from ¡assigned ¡to ¡

unassigned ¡variables, ¡but ¡doesn't ¡provide ¡early ¡detec)on ¡for ¡ all ¡failures: ¡

NT ¡and ¡SA ¡cannot ¡both ¡be ¡blue! ¡ Can ¡use ¡constraint ¡propaga)on ¡to ¡detect ¡viola)ons ¡early ¡

slide-24
SLIDE 24

24 ¡

Arc ¡consistency ¡

Simplest ¡form ¡of ¡propaga)on ¡makes ¡each ¡arc ¡consistent ¡ X ¡Y ¡is ¡consistent ¡iff ¡

for ¡every ¡value ¡x ¡of ¡X ¡there ¡is ¡some ¡allowed ¡y ¡

slide-25
SLIDE 25

25 ¡

Arc ¡consistency ¡

Simplest ¡form ¡of ¡propaga)on ¡makes ¡each ¡arc ¡consistent ¡ X ¡Y ¡is ¡consistent ¡iff ¡

for ¡every ¡value ¡x ¡of ¡X ¡there ¡is ¡some ¡allowed ¡y ¡ If ¡X ¡loses ¡a ¡value, ¡neighbors ¡of ¡X ¡need ¡to ¡be ¡rechecked ¡

slide-26
SLIDE 26

26 ¡

Arc ¡consistency ¡

Simplest ¡form ¡of ¡propaga)on ¡makes ¡each ¡arc ¡consistent ¡ X ¡Y ¡is ¡consistent ¡iff ¡

for ¡every ¡value ¡x ¡of ¡X ¡there ¡is ¡some ¡allowed ¡y ¡

¡If ¡X ¡loses ¡a ¡value, ¡neighbors ¡of ¡X ¡need ¡to ¡be ¡rechecked ¡

slide-27
SLIDE 27

27 ¡

Arc ¡consistency ¡

Simplest ¡form ¡of ¡propaga)on ¡makes ¡each ¡arc ¡consistent ¡ X ¡Y ¡is ¡consistent ¡iff ¡

for ¡every ¡value ¡x ¡of ¡X ¡there ¡is ¡some ¡allowed ¡y ¡

If ¡X ¡loses ¡a ¡value, ¡neighbors ¡of ¡X ¡need ¡to ¡be ¡rechecked ¡ Arc ¡consistency ¡detects ¡failure ¡earlier ¡than ¡forward ¡checking ¡ Can ¡be ¡run ¡as ¡a ¡preprocessor ¡or ¡ager ¡each ¡assignment ¡

slide-28
SLIDE 28

28 ¡

Arc ¡consistency ¡algorithm ¡AC-­‑3 ¡

Time ¡complexity: ¡O(n2d3) ¡

slide-29
SLIDE 29

Improving ¡backtracking ¡search ¡

General ¡purpose ¡methods ¡can ¡dras)cally ¡improve ¡speed ¡

Which ¡variable ¡should ¡be ¡assigned ¡next? ¡

¡ ¡ ¡Most ¡constrained ¡ ¡Most ¡constraining ¡

In ¡what ¡order ¡should ¡we ¡try ¡the ¡values? ¡

¡ ¡ ¡Least ¡constraining ¡

Can ¡we ¡detect ¡inevitable ¡failure ¡early? ¡

¡ ¡ ¡Forward ¡checking, ¡constraint ¡propaga)on ¡

Can ¡we ¡take ¡into ¡account ¡problem ¡structure? ¡

29 ¡

slide-30
SLIDE 30

Problem ¡structure ¡

Constraint ¡graph ¡ Suppose ¡we ¡have ¡

n ¡variables, ¡ grouped ¡into ¡indep. ¡ Subproblems ¡with ¡at ¡ ¡ most ¡c ¡variables ¡

30 ¡

slide-31
SLIDE 31

Tree ¡structured ¡CSPs ¡

¡Theorem: ¡If ¡CSP ¡has ¡tree ¡structure, ¡can ¡solve ¡it ¡in ¡)me ¡ ¡ ¡ ¡O(n ¡d2) ¡ ¡Will ¡see ¡this ¡again ¡for ¡probabilis)c ¡reasoning! ¡

31 ¡

slide-32
SLIDE 32

Solving ¡tree ¡structured ¡CSPs ¡

Choose ¡root; ¡orient ¡edges ¡away ¡from ¡root ¡ Pick ¡topological ¡ordering ¡ For ¡j ¡from ¡n ¡down ¡to ¡1: ¡remove ¡all ¡parent ¡values ¡for ¡

which ¡there ¡is ¡no ¡consistent ¡child ¡value ¡

For ¡j ¡from ¡1 ¡to ¡n: ¡assign ¡values ¡consistently ¡with ¡parent ¡ Special ¡case ¡of ¡constraint ¡propaga)on ¡

32 ¡

slide-33
SLIDE 33

Nearly ¡tree-­‑structured ¡CSPs ¡

33 ¡

slide-34
SLIDE 34

Cutset ¡condi)oning ¡

Pick ¡subset ¡(“cutset”) ¡of ¡variables ¡such ¡that ¡remaining ¡

variables ¡form ¡a ¡tree ¡

Search ¡through ¡each ¡possible ¡instan)a)on ¡of ¡cutset, ¡

and ¡try ¡to ¡solve ¡remaining ¡tree-­‑structured ¡CSP ¡

34 ¡

slide-35
SLIDE 35

Junc)on ¡trees ¡(more ¡later) ¡

35 ¡

slide-36
SLIDE 36

Improving ¡backtracking ¡search ¡

General ¡purpose ¡methods ¡can ¡dras)cally ¡improve ¡speed ¡

Which ¡variable ¡should ¡be ¡assigned ¡next? ¡

¡ ¡ ¡Most ¡constrained ¡ ¡Most ¡constraining ¡

In ¡what ¡order ¡should ¡we ¡try ¡the ¡values? ¡

¡ ¡ ¡Least ¡constraining ¡

Can ¡we ¡detect ¡inevitable ¡failure ¡early? ¡

¡ ¡ ¡Forward ¡checking, ¡constraint ¡propaga)on ¡

Can ¡we ¡take ¡into ¡account ¡problem ¡structure? ¡

¡ ¡ ¡Independent ¡subproblems; ¡trees; ¡tree-­‑like ¡graphs ¡

36 ¡

slide-37
SLIDE 37

Summary ¡

CSPs ¡are ¡special ¡search ¡problem ¡

Environment ¡state ¡described ¡using ¡variables ¡ Goal ¡test ¡given ¡by ¡constraints ¡

Backtracking ¡= ¡DFS ¡with ¡fixed ¡var. ¡assigned ¡per ¡node ¡ Can ¡be ¡sped ¡up ¡using ¡

Variable ¡and ¡value ¡selec)on ¡heuris)cs ¡ Forward ¡checking ¡ Constraint ¡propaga)on ¡/ ¡inference ¡ Exploit ¡dependency ¡structure ¡among ¡variables ¡

37 ¡