Escolar Documentos
Profissional Documentos
Cultura Documentos
Focus on useful general-purpose algorithms with more power than standard search algorithms (BFS, DFS) and don't require user generated heuristics like A*.
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
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
Constraint graph
Binary CSP: each constraint relates two variables Constraint graph: nodes are variables, arcs are constraints
Varieties of CSPs
Discrete variables
finite domains:
n variables, domain size d O(dn) complete assignments e e.g., Boolean CSPs, incl. Boolean satisfiability (NP-complete)
infinite domains:
integers, strings, etc. e.g., job scheduling, variables are start/end days for each job need a constraint language, e.g., StartJob1 + 5 StartJob3
Continuous variables
e.g., start/end times for Hubble Space Telescope observations linear constraints solvable in polynomial time by LP
Varieties of constraints
Unary constraints involve a single variable,
e.g., SA green
Real-world CSPs
Assignment problems
e.g., who teaches what class
Timetabling problems
e.g., which class is offered when and where?
Transportation scheduling Factory scheduling Notice that many real-world problems involve real-valued variables Related techniques involving constraints? Why can't we use it for our homework problem?
Goal test: the current assignment is complete This is the same for all CSPs Every solution appears at depth n with n variables use depth-first search Path is irrelevant, so can also use complete-state formulation b = (n - l )d at depth l, hence n! dn leaves
Backtracking search
Variable assignments are commutative, i.e.,
[ WA = red then NT = green ] same as [ NT = green then WA = red ]
=> Only need to consider assignments to a single variable at each node Depth-first search for CSPs with single-variable assignments is called backtracking search Can solve n-queens for n 25
Backtracking search Baseline Comparative Algorithm. Can solve n-Queens for n=25
14
Backtracking example
Backtracking example
Backtracking example
Backtracking example
What are the possible improvements to basic BT search? What guiding principles/aims can we use to help answer this question?
What should we assign next, SA, QLD, NSW, VIC, TAS? Why?
Will the MRV Heuristic Help Us Choose the Root of the Tree?
If not, whats a reasonable method to choose and why?
Combining these heuristics makes 1000 queens feasible. How is this philosophically different to our heuristic search with A*
Forward checking
Idea:
Keep track of remaining legal values for unassigned variables Terminate search when any variable has no legal values
Forward checking
Idea:
Keep track of remaining legal values for unassigned variables Terminate search when any variable has no legal values
Forward checking
Idea:
Keep track of remaining legal values for unassigned variables Terminate search when any variable has no legal values
Forward checking
Idea:
Keep track of remaining legal values for unassigned variables Terminate search when any variable has no legal values
Using these heuristics in combination. What node ordering heuristic is a natural partner to forward checking?
Constraint propagation
Forward checking propagates information from assigned to unassigned variables, but doesn't provide early detection for all failures:
Forward checking would still continue searching. But why is there no point and why should we prune this part of the tree?
Constraint propagation
Forward checking propagates information from assigned to unassigned variables, but doesn't provide early detection for all failures:
NT and SA cannot both be blue! Constraint propagation repeatedly enforces constraints locally
Arc consistency
Simplest form of propagation makes each arc consistent X Y is consistent iff
for every value x of X there is some allowed y
Arc consistency
Simplest form of propagation makes each arc consistent X Y is consistent iff
for every value x of X there is some allowed y
Arc consistency
Simplest form of propagation makes each arc consistent X Y is consistent iff
for every value x of X there is some allowed y
Arc consistency
Simplest form of propagation makes each arc consistent X Y is consistent iff
for every value x of X there is some allowed y
If X loses a value, neighbors of X need to be rechecked Arc consistency detects failure earlier than forward checking Can be run as a preprocessor or after each assignment
So what if we find a nodes xi and xj are not arc consistent what should we do?
A Simple Example???
In your class groups use a CSP formulation to solve this problem. Given a set of n data points and a distance function d(xi, xj) between all pairs of points. Partition the data set into a two subsets so that the maximum diameter of the two subsets is minimized. Hint: Construct a simple example to verify your algorithm. Is the problem solvable in polynomial time with respect to the number of instances?
Given: Point set P = \{p_1, p_2, ..., p_n\}, the distance d(p_i, p_j) for each pair of points, a distance \alpha. Question: Is it possible to partition P into two sets P_1 and P_2 such that dia(P_1) <= \alpha and dia(P_2) <= \alpha? We can use 2SAT to solve BDP. For each point p_i we have a Boolean variable x_i. (The interpretation is that all points corresponding to variables set to True form one cluster and the remaining points form the other cluster.) The clauses of the 2SAT instance are constructed as follows. Examine each pair of points p_i and p_j (i \neq j). If d(p_i,p_j) > \alpha, add the clauses
Sudoku
http://www.websudoku.com/ Each Sudoku has a unique solution that can be reached logically without guessing. Enter digits from 1 to 9 into the blank spaces. Every row must contain one of each digit. So must every column, as must every 3x3 square.
Why does using these search techniques not make sense for this problem?
Points
Large search space commutativity what about using bfs or dfs?
fixed depth
Goal: Assign a value to every variable such that all constraints are satisfied
Name a sufficient condition when it will work Does this condition occur with the Sudoku formulation?
Symmetry breaking
Structured CSPs