

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















Chris BrooksDepartment of Computer ScienceUniversity of San Francisco
Department of Computer Science — University of San Francisco – p. 1/
best^ solution.
-^ In many cases, you just need to find a solution that satisfiessome criteria. •^ These criteria are called constraints. •^ A problem in which we want to find any solution that satisfiesour constraints is a
constraint satisfaction problem
-^ Constraints provide us with additional knowledge about theproblem that we can exploit.^ ◦^ We can also consider optimizing constrained problems.
Department of Computer Science — University of San Francisco – p. 2/
{x, x, ..., x^12
}n
-^ Each variable as a domain of possible values
n
-^ We also have a set of constraints
◦^ Unary constraints:
x <^10 , ymod
2 == 0, etc
◦^ Binary constraints:
x < y, x^ +^ y <^50 ,
no two adjacent
squares can be the same color, etc ◦ N-ary constraints:
x+^ x+^1
...^ +^ x= 75n^
, weight of chassis
plus engine plus body must be less than 3000 lbs, etc. • An assignment of values to variables that satisfies allconstraints is called a
consistent
solution.
-^ We might might also have an objective function
y^ =^ f^ (x^1
, ..., x)n
that lets us compare solutions.
Department of Computer Science — University of San Francisco – p. 4/
linear
programming
to solve the problem. ◦^ Express the problem as a system of equations • In other cases, we can use
dynamic programming
-^ Dynamic programming is a form of search. •^ In the most general case, we can express a CSP as a searchproblem.
Department of Computer Science — University of San Francisco – p. 5/
constraint graph
-^ Nodes represent variables, edges represent binary constraints.^ ◦^ For n-ary constraints, we must add nodes that representcombinations of values.
Department of Computer Science — University of San Francisco – p. 7/
-^ Can we color this map usingonly^ four
colors^ (R,Y,B,G), so that no adjacent countieshave the same color?^ Department of Computer Science — University of San Francisco – p. 8/
Department of Computer Science — University of San Francisco – p. 10/
Department of Computer Science — University of San Francisco – p. 11/
Department of Computer Science — University of San Francisco – p. 13/
Department of Computer Science — University of San Francisco – p. 14/
-^ Problem: place each queenon the board so that noqueen is attacking another. •^ We can reduce this to: Whatrow should each queen bein?
Department of Computer Science — University of San Francisco – p. 16/
chronological backtracking
.^ Department of Computer Science — University of San Francisco – p. 17/
Department of Computer Science — University of San Francisco – p. 19/
NorthernTerritoryQueenslandSouthAustralia
NewSouthWalesVictoriaTasmania
-^ Let’s say our searchalgorithm did the followingcoloring:^ ◦^ Q: Red, NSW: Green, V:Blue, T: Red •^ There is no consistent colorfor SA. •^ Backtracking will try allother colors for T, whichcannot possibly help. •^ The conlict set for SA is{Q,NSW,V}. •^ We backjump and undo V.Once V: Red, we can colorSA.
Department of Computer Science — University of San Francisco – p. 20/