You are on page 1of 7

ARTIFICIAL INTELLIGENCE UNIT-1

Constraint Satisfaction Problem


Constraint Satisfaction
Problem
A constraint satisfaction problem (CSP) is a problem that
requires its solution within some limitations/conditions also
known as constraints. It consists of the following:

• A finite set of variables which stores the solution. (V = {V1, V2,


V3,....., Vn} )
• A set of discrete values known as domain from which the
solution is picked. (D = {D1, D2, D3,.....,Dn} )
• A finite set of constraints. (C = {C1, C2, C3,......, Cn} )
• Please note that the elements in the domain can be both
continuous and discrete but in AI, we generally only deal with
discrete values.
Popular Problems of CSP
The following problems are some of the popular problems that can
be solved using CSP:

• CryptoArithmetic (Coding alphabets to numbers.)


• n-Queen (In an n-queen problem, n queens should be placed in a
nXn matrix such that no queen shares the same row, column or
diagonal.)
• Map Coloring (Coloring different regions of map ensuring no
adjacent regions have the same color.)
• Crossword (Everyday puzzles appearing in newspapers. In
crossword problem, the constraint is that there should be the
correct formation of the words, and it should be meaningful.)
• Sudoku (A number grid. The gameplay where the constraint is
that no number from 0-9 can be repeated in the same row or
column.)
• Latin Square Problem
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

• Solutions are complete and consistent


assignments
• e.g., WA = red, NT = green, Q = red, NSW
= green,V = red,SA = blue,T = green
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

Another Example
https://www.youtube.com/watch?v=HC6Y49iTg1k
Thank you

You might also like