0% found this document useful (0 votes)
14 views18 pages

CSE 3207 Artificial Intelligence: Mohiuddin Ahmed Assistant Professor Department of CSE Ruet

The document discusses Constraint Satisfaction Problems (CSPs), defining them as problems characterized by variables with specific domains and constraints that dictate allowable value combinations. It provides examples such as map-coloring and cryptarithmetic puzzles, illustrating the nature of variables, domains, and constraints involved. Additionally, it highlights the use of backtracking search as a method for solving CSPs, particularly in scenarios like the n-queens problem.

Uploaded by

sajeebmahmud3962
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views18 pages

CSE 3207 Artificial Intelligence: Mohiuddin Ahmed Assistant Professor Department of CSE Ruet

The document discusses Constraint Satisfaction Problems (CSPs), defining them as problems characterized by variables with specific domains and constraints that dictate allowable value combinations. It provides examples such as map-coloring and cryptarithmetic puzzles, illustrating the nature of variables, domains, and constraints involved. Additionally, it highlights the use of backtracking search as a method for solving CSPs, particularly in scenarios like the n-queens problem.

Uploaded by

sajeebmahmud3962
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

CSE 3207

Artificial Intelligence

Mohiuddin Ahmed
Assistant Professor
Department of CSE
RUET
Constraint Satisfaction Problems
Constraint satisfaction problems (CSPs)

• Standard search problem:


– state is a "black box“ – any data structure that supports successor
function and goal test

• 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
Example: Map-Coloring

• Variables WA, NT, Q, NSW, V, SA, T


• Domains Di = {red,green,blue}
• Constraints: adjacent regions must have different colors
• e.g., WA ≠ NT, or (WA,NT) in {(red,green),(red,blue),
(green,red), (green,blue),(blue,red),(blue,green)}
Example: Map-Coloring
• Complete Assignment:
 A solution assigns a value
to every variable in the
problem domain. There
should be no unassigned
variables left in the final
solution.
• Solutions are complete and consistent • Consistent Assignment:
assignments
• e.g., WA = red, NT = green, Q = red,
 The assigned values must
NSW = green,V = red,SA = blue,T = green satisfy all constraints
imposed on the variables.
Constraint graph
• Binary CSP: each constraint relates two variables
• Constraint graph: nodes are variables, arcs are constraints
Varieties of CSPs
• Discrete variables
– finite domains:
• n variables, domain 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

• Continuous variables
– e.g., start/end times for Hubble Space Telescope observations
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
Example: Cryptarithmetic
• Cryptarithmetic (also called alphametics or verbal arithmetic) is
a type of mathematical puzzle in which digits are substituted by
letters or symbols. Each letter represents a unique digit (0-9), and the
goal is to find the correct assignment of digits to satisfy the given
arithmetic equation.
Example: Cryptarithmetic

• 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
– X1 + W + W = U + 10 · X2
– X2 + T + T = O + 10 · X3
– X3 = F, T ≠ 0, F ≠ 0
Real-world CSPs
• Assignment problems
– e.g., who teaches what class

• Timetabling problems
– e.g., which class is offered when and where?

• Transportation scheduling

• Factory scheduling

• Notice that many real-world problems involve real-valued variables


Backtracking search
• Variable assignments are commutative, i.e.,
[ WA = red then NT = green ] same as [ NT = green then WA = red ]

• => Only need to consider assignments to a single variable at each node

• Depth-first search for CSPs with single-variable assignments is called backtracking


search

• Can solve n-queens for n ≈ 25


Backtracking search
Backtracking Example
Backtracking example
Backtracking example
Backtracking example
Example: 4-Queens
• States: 4 queens in 4 columns (44 = 256 states)

• Actions: move queen in column

• Goal test: no attacks

You might also like