CONSTRAINT SATISFACTION PROBLEMS CHAPTER 5 Chapter 5 1
Constraint Satisfaction Problems Chapter 5 Chapter 5 1
Outline ◇CSP examples Backtracking search for CSPs Problem structure and problem decomposition ◇Local search for CSPs Chapter 5 2
Outline ♦ CSP examples ♦ Backtracking search for CSPs ♦ Problem structure and problem decomposition ♦ Local search for CSPs Chapter 5 2
Constraint satisfaction problems (CSPs) Standard search problem: state is a "black box"-any old data structure that supports goal test,eval,successor CSP: state is defined by variables Xi with values from domain Di goal test is a set of constraints specifying allowable combinations of values for subsets of variables Simple example of a formal representation language Allows useful general-purpose algorithms with more power than standard search algorithms Chapter 5 3
Constraint satisfaction problems (CSPs) Standard search problem: state is a “black box”—any old data structure that supports goal test, eval, successor CSP: state is defined by variables Xi with values from domain Di goal test is a set of constraints specifying allowable combinations of values for subsets of variables Simple example of a formal representation language Allows useful general-purpose algorithms with more power than standard search algorithms Chapter 5 3
Example:Map-Coloring Northern Territory Western Queensland Australia South Australia New South Wales Victoria Variables WA,NT,Q,NSW,V,SA,T Tasmania Domains Di={red,green,blue} Constraints:adjacent regions must have different colors e.g.,WA NT (if the language allows this),or (WA,NT){(red,green),(red,blue),(green,red),(green,blue),...} Chapter 5 4
Example: Map-Coloring Western Australia Northern Territory South Australia Queensland New South Wales Victoria Tasmania Variables WA, NT, Q, NSW, V , SA, T Domains Di = {red, green, blue} Constraints: adjacent regions must have different colors e.g., WA 6= NT (if the language allows this), or (WA, NT) ∈ {(red, green),(red, blue),(green, red),(green, blue), . . .} Chapter 5 4
Example:Map-Coloring contd. Northern Territory Western Queensland Australia South Australia New South Wales /ictoria Tas Solutions are assignments satisfying all constraints,e.g., {WA=red,NT=green,Q=red,NSW=green,V=red,SA=blue,T=green} Chapter 5 5
Example: Map-Coloring contd. Western Australia Northern Territory South Australia Queensland New South Wales Victoria Tasmania Solutions are assignments satisfying all constraints, e.g., {WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue, T = green} Chapter 5 5
Constraint graph Binary CSP:each constraint relates at most two variables Constraint graph:nodes are variables,arcs show constraints NT WA SA NSW General-purpose CSP algorithms use the graph structure to speed up search.E.g.,Tasmania is an independent subproblem! Chapter 5 6
Constraint graph Binary CSP: each constraint relates at most two variables Constraint graph: nodes are variables, arcs show constraints Victoria WA NT SA Q NSW V T General-purpose CSP algorithms use the graph structure to speed up search. E.g., Tasmania is an independent subproblem! Chapter 5 6
Varieties of CSPs Discrete variables finite domains;size d=O(d")complete assignments e.g.,Boolean CSPs,incl.Boolean satisfiability (NP-complete) infinite domains (integers,strings,etc.) e.g.,job scheduling,variables are start/end days for each job need a constraint language,e.g.,StartJob1+5<Start.Jobs linear constraints solvable,nonlinear undecidable Continuous variables e.g.,start/end times for Hubble Telescope observations linear constraints solvable in poly time by LP methods Chapter 5 7
Varieties of CSPs Discrete variables finite domains; size d ⇒ O(dn) complete assignments ♦ e.g., Boolean CSPs, incl. Boolean satisfiability (NP-complete) infinite domains (integers, strings, etc.) ♦ e.g., job scheduling, variables are start/end days for each job ♦ need a constraint language, e.g., StartJob1 + 5 ≤ StartJob3 ♦ linear constraints solvable, nonlinear undecidable Continuous variables ♦ e.g., start/end times for Hubble Telescope observations ♦ linear constraints solvable in poly time by LP methods Chapter 5 7
Varieties of constraints Unary constraints involve a single variable, e.g,SA卡green Binary constraints involve pairs of variables, e.g,SA≠WA Higher-order constraints involve 3 or more variables, e.g.,cryptarithmetic column constraints Preferences(soft constraints),e.g.,red is better than green often representable by a cost for each variable assignment constrained optimization problems Chapter 5 8
Varieties of constraints Unary constraints involve a single variable, e.g., SA 6= green Binary constraints involve pairs of variables, e.g., SA 6= WA Higher-order constraints involve 3 or more variables, e.g., cryptarithmetic column constraints Preferences (soft constraints), e.g., red is better than green often representable by a cost for each variable assignment → constrained optimization problems Chapter 5 8
Example:Cryptarithmetic T WO R +T WO FOUR 2 Variables:F TU W RO X1 X2 X3 Domains:{0,1,2,3,4,5,6,7,8,9} Constraints alldiff F,T,U,W,R,O) O+O=R+10·X1,etc. Chapter 59
Example: Cryptarithmetic F T U W R O + T W O T W O F O U R X3 X2 X1 Variables: F T U W R O X1 X2 X3 Domains: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} Constraints alldiff(F, T,U, W, R, O) O + O = R + 10 · X1, etc. Chapter 5 9
Real-world CSPs Assignment problems e.g.,who teaches what class Timetabling problems e.g.,which class is offered when and where? Hardware configuration Spreadsheets Transportation scheduling Factory scheduling Floorplanning Notice that many real-world problems involve real-valued variables Chapter 5 10
Real-world CSPs Assignment problems e.g., who teaches what class Timetabling problems e.g., which class is offered when and where? Hardware configuration Spreadsheets Transportation scheduling Factory scheduling Floorplanning Notice that many real-world problems involve real-valued variables Chapter 5 10