Friday, July 13, 2012

AI


A Constraint Satisfaction Problem(or CSP) is defined by a set of variables ,X1,X2,….Xn,and a set of constraints C1,C2,…,Cm. Each variable Xi has a nonempty domain D,of possible values. Each constraint Ci involves some subset of variables and specifies the allowable combinations of values for that subset.
A State of the problem is defined by an assignment of values to some or all of the variables,{Xi = vi,Xj = vj,…}. An assignment that does not violate any constraints is called a consistent or legal assignment. A complete assignment is one in which every variable is mentioned,and a solution to a CSP is a complete assignment that satisfies all the constraints.
Some CSPs also require a solution that maximizes an objective function.
Example for Constraint Satisfaction Problem :
Figure 2.15 shows the map of Australia showing each of its states and territories. We are given the task of coloring each region either red,green,or blue in such a way that the neighboring regions have the same color. To formulate this as CSP ,we define the variable to be the regions :WA,NT,Q,NSW,V,SA, and T. The domain of each variable is the set {red,green,blue}.The constraints require neighboring regions to have distinct colors;for example,the allowable combinations for WA and NT are the pairs
{(red,green),(red,blue),(green,red),(green,blue),(blue,red),(blue,green)}.
The constraint can also be represented more succinctly as the inequality WA not = NT,provided the constraint satisfaction algorithm has some way to evaluate such expressions.) There are many possible solutions such as
{ WA = red, NT = green,Q = red, NSW = green, V = red ,SA = blue,T = red}.
It is helpful to visualize a CSP as a constraint graph,as shown in Figure 2.15(b). The nodes of the graph corresponds to variables of the problem and the arcs correspond to constraints.
clip_image002
  Figure 2.15 (a) Principle states and territories of Australia. Coloring this map can be viewed as aconstraint satisfaction problem. The goal is to assign colors to each region so that no neighboring regions have the same color.

Figure 2.15 (b) The map coloring problem represented as a constraint graph.

CSP can be viewed as a standard search problem as follows :
Ø  Initial state : the empty assignment {},in which all variables are unassigned.
Ø  Successor function : a value can be assigned to any unassigned variable,provided that it does not conflict with previously assigned variables.
Ø  Goal test : the current assignment is complete.
Ø  Path cost : a constant cost(E.g.,1) for every step.
Every solution must be a complete assignment and therefore appears at depth n if there are n variables. Depth first search algorithms are popular for CSPs

Varieties of CSPs
(i) Discrete variables

Finite domains
   The simplest kind of CSP involves variables that are discrete and have finite domains. Map coloring problems are of this kind. The 8-queens problem can also be viewed as finite-domain CSP,where the variables Q1,Q2,…..Q8 are the positions each queen in columns 1,….8 and each variable has the domain {1,2,3,4,5,6,7,8}. If the maximum domain size of any variable in a CSP is d,then the number of possible complete assignments is O(dn) – that is,exponential in the number of variables. Finite domain CSPs include Boolean CSPs,whose variables can be either true or false.

Infinite domains
Discrete variables can also have infinite domains – for example,the set of integers or the set of strings. With infinite domains,it is no longer possible to describe constraints by enumerating all allowed combination of values. Instead a constraint language of algebric inequalities such as
Startjob1 + 5 <= Startjob3.

(ii) CSPs with continuous domains
CSPs with continuous domains are very common in real world. For example ,in operation research field,the scheduling of experiments on the Hubble Telescope requires very precise timing of observations; the start and finish of each observation and maneuver are continuous-valued variables that must obey  a variety of astronomical,precedence and power constraints. The best known category of continuous-domain CSPs is that of linear programming problems,where the constraints must be linear inequalities forming a convex region. Linear programming problems can be solved in time polynomial in the number of variables.
Varieties of constraints :
(i) unary constraints involve a single variable.
     Example : SA # green
(ii) Binary constraints involve paris of variables.
Example : SA # WA
(iii) Higher order constraints involve 3 or more variables.
Example : cryptarithmetic puzzles.

Figure 2.16 (a) Cryptarithmetic problem. Each letter stands for a distinct digit;the aim is to find a substitution of digits for letters such that the resulting sum is arithmetically correct,with the added restriction that no leading zeros are allowed. (b) The constraint hypergraph for the cryptarithmetic problem,showint the Alldiff constraint as  well as the column addition constraints. Each constraint is a square box connected to the variables it contains.

 

2.2.2 Backtracking Search for CSPs

 

The term backtracking search is used for depth-first search that chooses values for one variable at a time and backtracks when a variable has no legal values left to assign. The algorithm is shown in figure 2.17.

 

Figure 2.17 A simple backtracking algorithm for constraint satisfaction problem. The algorithm is modeled on the recursive depth-first search

 

 

Figure 2.17(b) Part of search tree generated by simple backtracking for the map coloring problem.

 

Propagating information through constraints
So far our search algorithm considers the constraints on a variable only at the time that the variable is chosen by SELECT-UNASSIGNED-VARIABLE. But by looking at some of the constraints earlier in the search, or even before the search has started, we can drastically reduce the search space.
Forward checking
One way to make better use of constraints during search is called forward checking. Whenever a variable X is assigned, the forward checking process looks at each unassigned variable Y that is connected to X by a constraint and deletes from Y ’s domain any value that is inconsistent with the value chosen for X. Figure 5.6 shows the progress of a map-coloring search with forward checking.

Constraint propagation
Although forward checking detects many inconsistencies, it does not detect all of them.
Constraint propagation is the general term for propagating the implications of a constraint on one variable onto other variables.
Arc Consistency
k-Consistency




Local Search for CSPs
2.2.3 The Structure of Problems
Problem Structure

Independent Subproblems
Tree-Structured CSPs

No comments:

Post a Comment