0% found this document useful (0 votes)
4 views

Lab 4

The document discusses the components and solutions of constraint satisfaction problems (CSPs), including variables, domains, and constraints. It provides examples such as the map-coloring problem and a hotel room assignment scenario, detailing the number of solutions based on different conditions. Additionally, it outlines the formulation of CSPs for placing knights on a chessboard and demonstrates the use of the AC-3 algorithm for detecting inconsistencies in assignments.

Uploaded by

zainab.fetoh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lab 4

The document discusses the components and solutions of constraint satisfaction problems (CSPs), including variables, domains, and constraints. It provides examples such as the map-coloring problem and a hotel room assignment scenario, detailing the number of solutions based on different conditions. Additionally, it outlines the formulation of CSPs for placing knights on a chessboard and demonstrates the use of the AC-3 algorithm for detecting inconsistencies in assignments.

Uploaded by

zainab.fetoh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

INTELLIGENT

SYSTEM
LAB 4 “CSP”
Q1: What are the three
components of a constraint
satisfaction problem?
ANSWER:
 Variables: {X1, . . . , Xn}
 Domains (one for each variable): {D1, . . . ,
Dn}.
Each domain Di consists of a set of values:
{….}.
 Constraints that specify allowable
combinations of values
Q2:What is a answer to a
constraint satisfaction problem?
ANSWER:
 A complete, consistent assignment of
values to variables.
 Complete: every variable is assigned a
value.
 Consistent: no constraints are violated
by the assigned values
Q3: How many solutions are there for the map-
coloring problem in the following Figure ? How
many solutions if four colors are allowed? Two
colors?
Answer:
 There are 18 solutions for coloring
Australia with three colors. Start with
SA, which can have any of three colors.
Then moving clockwise, WA can have
either of the other two colors, and
everything else is strictly determined;
that makes 6 possibilities for the
mainland, times 3 for Tasmania yields
18. (3*2*1*1*1*1*3=18)
 With four colors, there are 768 solutions
(4*3*2*2*2*2*4).

 With two colors, there are no solutions.


Q4:Suppose you are running a hotel with
seven rooms on one floor : Three
families want to book all seven rooms.
However people in the same family don’t
get along, so they cannot be in adjacent
rooms.
(a) Formulate this problem as a
constraint satisfaction problem.
ANSWER:
 Variables: {X101, . . . , X107}
corresponding to the rooms
 Domains: {f1, f2, f3} corresponding to
the families, for all variables
 Constraints: people in the same family
cannot be in adjacent rooms
For example: X102 != X103, and so on
(b) How many solutions are
there to this CSP?
 Start with room 103, which can have any
of the three families.
 Then, moving clockwise, room 102 can
have either of the other two families,
 and then everything else is strictly
determined. That makes 6 possibilities
for rooms 102–107, times the three
possibilities for room 101. Total: 18
(3*2*1*1*1*1*3).
(c) How many solutions are there
if there are four families?
ANSWER:
Four choices for Room 103, 3 for Room
102, then two each for rooms 104, 105,
106, and 107, times 4 for room 101 =
(4×3×2×2×2×2×4 =768)
(d) How many solutions are there
if there are only two families?
ANSWER:
No solutions with just two families.
Q5: color each region either red, green,
or blue in such a way that no
neighboring regions have the same color
 Variables: WA , NT, Q,NSW, V, SA,T.

 Domains: {red, green, blue}

 Constraints: adjacent regions must have


different colors .
Implicit: WA != NT
Explicit: (WA, NT) E {(red, green),(red,
blue),….}
Can Have more than solution
Q6:Consider the problem of placing k knights
on an n×n chessboard such that no two knights
are attacking each other where k is given
and k≤n^2

(a)Choose a CSP formulation. In your


formulation, what are the variables?
Answer :
 Each variable represents a square on
the chessboard.
 The domain of each variable is {0, 1},
where 0 indicates that no knight is
placed on the square, and 1 indicates
that a knight is placed on the square.
(b) What are the possible values of each variable?
Answer :
 The possible values for each variable are {0, 1}

(c) What sets of variables are constrained, and how?


Answer :
 The sets of variables that are constrained are:
No two knights should be able to attack each other.
This constraint can be defined as follows:
 For each pair of variables representing two squares, if both
variables have a value of 1 (i.e., knights are placed on
those squares), then the squares should not be attacking
each other according to the knight's movement rules. This
means that the two squares should not be two squares
horizontally and one square vertically or one square
horizontally and two squares vertically away from each
other.
Q6: Use the AC-3 algorithm to show that arc
consistency can detect the inconsistency of the
partial assignment {W A =green, V =red }for the
Australia map coloring
problem.
Solution

You might also like