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

Constraint Satisfaction Problems: Dr. Amar Singh Associate Professor, School of Computer Applications

Constraint Satisfaction Problems (CSPs) involve: 1) A set of variables that can take on a finite set of values from their domains. 2) A set of constraints restricting the values that variables can simultaneously take. 3) A solution that assigns values to all variables while satisfying all constraints. Common examples of CSPs include scheduling problems, graph coloring, puzzles like the 8-puzzle and missionaries-cannibals problem, and cryptarithmetic word problems. Solving a CSP requires finding a complete and consistent assignment of values to all variables.

Uploaded by

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

Constraint Satisfaction Problems: Dr. Amar Singh Associate Professor, School of Computer Applications

Constraint Satisfaction Problems (CSPs) involve: 1) A set of variables that can take on a finite set of values from their domains. 2) A set of constraints restricting the values that variables can simultaneously take. 3) A solution that assigns values to all variables while satisfying all constraints. Common examples of CSPs include scheduling problems, graph coloring, puzzles like the 8-puzzle and missionaries-cannibals problem, and cryptarithmetic word problems. Solving a CSP requires finding a complete and consistent assignment of values to all variables.

Uploaded by

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

Constraint Satisfaction Problems

Dr. Amar Singh


Associate Professor,
School of Computer Applications
8 Puzzle Problem
• An 8 puzzle is a simple game consisting of a 3
x 3 grid (containing 9 squares).
• One of the squares is empty.
• The object is to move to squares around into
different positions and having the numbers
displayed in the "goal state“.
Example: The 8-puzzle

• Initial state?
• Set of operators?
• Goal state?
• Path cost?
Example: The 8-puzzle

• Initial state? locations of tiles


• Set of operators? move blank left, right, up, down
• Goal state? = goal state (given)
• Path cost? 1 per move
Missionaries and Cannibals problem
• Three missionaries and three cannibals must
cross a river using a boat which can carry at
most two people, under the constraint that,
for both banks, that the missionaries present
on the bank cannot be outnumbered by
cannibals.
• The boat cannot cross the river by itself with
no people on board.
Bank 1 River Bank

3 M, 3 C Send 2 C 0 M, 2 C

3 M, 2 C 1 C came back 0 M, 1 C
3M, 0 C Send 2 C 0 M, 3 C
3M, 1 C 1 C came back 0 M, 2 C
1M, 1 C Send 2 M 2 M, 2C
2M, 2 C 1 M, 1C came back 1 M, 1 C

0 M, 2C send 2 M 3 M, 1 C
0M,3C 1 C came back 3 M, 0 C
0, 1 M Send 2 C 3 M, 2 C
0 M, 2 C Send 1 C back 3 M, 1 C
0 M, 0 C Send 2 C 3 M, 1 C
Introduction
• A Constraint Satisfaction Problem consists of:
– A set of variables, X
– For each variable xi in X, a domain Di.
• D is finite set of possible values.
– A set of constraints restricting tuples of values.
• If only pair of values, it’s a binary CSP.
– A solution is an assignment of value in Di to each
variable xi such that every constraint satisfied.
Examples
• Many problems in AI are types of CSP.
– Scheduling
– Time Table
– Graph Coloring
– Machine Vision
– Puzzles
Coloring in CSP
• Can we color all 4 regions with 3 colors so that
no two adjacent regions are of same color

V3

V1

V4

V2
Example: 8-Queens
Example: 8-Queens
• Variables: 64 squares, number of queens
V = {S1,1, S1,2, …, S8,8, Number_of_queens}
• Values: Queen or No-Queen
Si,j is an element of DS = {queen, empty}
Number_of_queens is an element of DN = [0, 64]
• Constraints: Attacks, queen count
{Number_of_queens = 8,
Si,j = queen  Si,j+n = empty,
Si,j = queen  Si+n,j = empty,
Si,j = queen  Si+n,j+n = empty}
Sudoku Game
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
Send
More
Money

S 9
E 5
N 6
D 7
M 1
O 0
R 8
Y 3
Example: Map-Coloring

Note: In
general, 4 colors
are necessary
• 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 (i.e., all variables are assigned


values) and consistent (i.e., does not violate any
constraints) assignments, e.g., WA = red, NT = green, Q
= red, NSW = green, V = red, SA = blue, T = green

You might also like