Constraint Satisfaction Problems - Notes for Assignment | CS 580, Assignments of Computer Science

Material Type: Assignment; Class: Intro Artificial Intelligence; Subject: Computer Science; University: George Mason University; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 02/12/2009

koofers-user-dmr
koofers-user-dmr 🇺🇸

10 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Constraint Satisfaction Problems
Chapter 3, Section 7 and Chapter 4, Section 4.4
CS 580, Jana Kosecka, Chapter 3, Section 7 and Chapter 4, Section 4.4 1
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 V
i
with values from domain D
i
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
CS 580, Jana Kosecka, Chapter 3, Section 7 and Chapter 4, Section 4.4 2
pf3
pf4
pf5
pf8

Partial preview of the text

Download Constraint Satisfaction Problems - Notes for Assignment | CS 580 and more Assignments Computer Science in PDF only on Docsity!

Constraint Satisfaction Problems

Chapter 3, Section 7 and Chapter 4, Section 4.

CS 580, Jana Kosecka, Chapter 3, Section 7 and Chapter 4, Section 4.4 1

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 Vi 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

Example: 4-Queens as a CSP

Assume one queen in each column. Which row does each one go in?

Variables Q 1 , Q 2 , Q 3 , Q 4

Domains Di = { 1 , 2 , 3 , 4 }

Constraints Q (^) i 6 = Q (^) j (cannot be in same row) |Q (^) i − Q (^) j| 6 = |i − j| (or same diagonal) 1

Q = 1 Q 2 = 3

Translate each constraint into set of allowable values for its variables

E.g., values for (Q 1 , Q 2 ) are (1, 3) (1, 4) (2, 4) (3, 1) (4, 1) (4, 2)

CS 580, Jana Kosecka, Chapter 3, Section 7 and Chapter 4, Section 4.4 3

Constraint graph

Binary CSP: each constraint relates at most two variables

Constraint graph: nodes are variables, arcs show constraints

Q 1 Q 2

Q 3 Q 4

Applying standard search

Let’s start with the straightforward, dumb approach, then fix it

States are defined by the values assigned so far

Initial state: all variables unassigned

Operators: assign a value to an unassigned variable

Goal test: all variables assigned, no constraints violated

Notice that this is the same for all CSPs!

CS 580, Jana Kosecka, Chapter 3, Section 7 and Chapter 4, Section 4.4 7

Implementation

CSP state keeps track of which variables have values so far Each variable has a domain and a current value

datatype CSP-State components: Unassigned, a list of variables not yet assigned Assigned, a list of variables that have values datatype CSP-Var components: Name, for i/o purposes Domain, a list of possible values Value, current value (if any)

Constraints can be represented explicitly as sets of allowable values, or implicitly by a function that tests for satisfaction of the constraint

Standard search applied to map-coloring

UNASSIGNED ASSIGNED

C1 C2 C

UNASSIGNED ASSIGNED

C2 C C1 = RED

UNASSIGNED ASSIGNED

UNASSIGNED ASSIGNED

C1 C C2 = BLUE

C1 C C3 = GREEN

CS 580, Jana Kosecka, Chapter 3, Section 7 and Chapter 4, Section 4.4 9

Complexity of the dumb approach

Max. depth of space m = ?? n (number of variables)

Depth of solution state d = ?? n (all vars assigned)

Search algorithm to use?? depth-first

Branching factor b = ?? Σi|Di| (at top of tree)

This can be improved dramatically by noting the following:

  1. Order of assignment is irrelevant so many paths are equivalent
  2. Adding assignments cannot correct a violated constraint

Heuristics for CSPs

More intelligent decisions on which value to choose for each variable which variable to assign next

Given C 1 = Red, C 2 = Green, choose C 3 = ?? . Given C 1 = Red, C 2 = Green, what next?? .

C 1 C 2 C 3

C 5 C 6 C 4

Can solve n-queens for n ≈ 1000

CS 580, Jana Kosecka, Chapter 3, Section 7 and Chapter 4, Section 4.4 13

Heuristics for CSPs

More intelligent decisions on which value to choose for each variable which variable to assign next

Given C 1 = Red, C 2 = Green, choose C 3 = ?? C 3 = Green: least-constraining-value Given C 1 = Red, C 2 = Green, what next?? C 5 : most-constrained-variable

C 1 C 2 C 3

C 5 C 6 C 4

Can solve n-queens for n ≈ 1000

Iterative algorithms for CSPs

Hill-climbing, simulated annealing typically work with “complete” states, i.e., all variables assigned

To apply to CSPs: allow states with unsatisfied constraints operators reassign variable values

Variable selection: randomly select any conflicted variable

min-conflicts heuristic: choose value that violates the fewest constraints i.e., hillclimb with h(n) = total number of violated constraints

CS 580, Jana Kosecka, Chapter 3, Section 7 and Chapter 4, Section 4.4 15

Summary

CSPs are a special kind of problem: states defined by values of a fixed set of variables goal test defined by constraints on variable values

Backtracking = depth-first search with

  1. fixed variable order
  2. only legal successors

Forward checking prevents assignments that guarantee later failure

Variable ordering and value selection heuristics help significantly