Presentation is loading. Please wait.

Presentation is loading. Please wait.

G51IAI Introduction to Artificial Intelligence

Similar presentations


Presentation on theme: "G51IAI Introduction to Artificial Intelligence"— Presentation transcript:

1 G51IAI Introduction to Artificial Intelligence
Dr Rong Qu Constraint Satisfaction Problems

2 An Example Constraint satisfaction problems are everywhere in our everyday life Map coloring A region in a map has several sub-regions Given a set of colors Assign each sub-region a color so that no adjacent sub-regions have the same color everywhere in our life start from a very simple example. probably the mostly used example in introducing CSPs. problem is very simple, but will lead to some important concepts. G51IAI – Introduction to AI

3 An Example Map coloring
Can we use 3 colors to color the map below (Australia)? rather simple problem - can easily find out a solution in seconds. a map of 100 regions - won’t be that easy to find a coloring satisfying the constraint. G51IAI – Introduction to AI

4 An Example Map coloring The above map can be modelled as a graph
WA Q SA NSW V T NT Node: sub-region Edge: constraint (adjacency) Problem modelled as graph coloring: adjacent nodes have different colors to solve bigger and more complex map coloring problem - need to firstly model the problem. G51IAI – Introduction to AI Relationship between problem elements  constraints

5 CSP – Definition A constraint satisfaction problem (CSP) consists of
a set of variables {x1, x2, … xi}; a finite set of domain D (possible values) associated with each variable; a set of constraints C restricting the values that the variables can simultaneously take CSP is to assign values to variables so that all constraints are satisfied standard definition of CSP - all the examples we introduce later can be defined using this standard form. G51IAI – Introduction to AI

6 CSP - Domain The domain of a variable is a set of possible values that can be assigned to the variable {1 … 500} – finite, integer {red, green, blue} – symbols {yes, no} – Boolean Temperatures – infinite; continuous G51IAI – Introduction to AI

7 CSP - Constraints Examples of constraints
The demand will be more than five thousands units in August John prefer to work at only weekends Schedule these employees to cover all shifts Optimise the benefit of products G51IAI – Introduction to AI

8 CSP - Constraints Constraint is a set of relations upon domains of variables Restriction on the values the variables can simultaneously take What values are (dis-)allowed among the variables Functions Matrices Inequalities x1 ≠ x2 or x1 < x2 3x + 6y = 0, y + x < 7 G51IAI – Introduction to AI

9 CSP - Constraints Formal definition
A constraint Ci,j,k… is a subset of possible relations between values of variables xi, xj, xk, ...; Ci,j,k…is a subset of Di × Dj × Dk × … G51IAI – Introduction to AI

10 CSP - Constraints Types of constraints Binary CSP
Unary: affect only one variable x >= 1, WA = green Binary: affect two variables x >= y, WA ≠ NT High-order: affect more than two variables alldifferent(WA, NT, Q) x = y = z Binary CSP With only unary and binary constraints G51IAI – Introduction to AI

11 CSP - Constraints Simplification of constraints
Replace a constraint by an equivalent constraint which has a simpler form Problem is easier to understand Information of original form is more apparent G51IAI – Introduction to AI

12 CSP - Solutions A solution to a CSP is an assignment of each variable with a value (within its domain), such that all constraints C are satisfied if a CSP has a feasible solution find one (any) solution all solutions G51IAI – Introduction to AI

13 CSP - Solutions Often we not only want a CSP solution but also the best one (optimal solution) Optimisation problems Objective function: to measure how good a solution is Constraint Optimisation Problems (COP) G51IAI – Introduction to AI

14 CSP – Other Definitions
Label a variable-value pair representing assigning the value to the variable Compound label the finite set of labels representing simultaneous assignments G51IAI – Introduction to AI

15 CSP – Other Definitions
Satisfiable a CSP (V,D,C) is satisfiable iff there is a compound label assigning values to all variables V that satisfy all constraints C A solution can then be defined as A compound label for all variables which satisfy all the constraints G51IAI – Introduction to AI

16 CSP – Example Variables Domains Constraints {WA, NT, Q, SA, NSW, V, T}
{red, green, blue} Constraints {not_same(WA,NT), not_same(WA, SA), not_same(NT,SA), …} G51IAI – Introduction to AI

17 CSP – Example WA Q SA NSW V T NT The above formulate the map coloring problem into a constraint satisfaction problem Solution {WA=red, NT=green, SA=blue, Q=red, NSW=green, V=red, T=red} G51IAI – Introduction to AI

18 CSP – Example WA = red is a label The problem is satisfiable.
G51IAI – Introduction to AI

19 CSP – Example The above solution using 3 colors
Is actually an optimal solution (using the least colors) There are more than one solution For example, given 7 colors, we’ll have 7! solutions for the problem (at least) G51IAI – Introduction to AI

20 CSP – Example Graph coloring is NP-Hard (Karp, 1972)
Optimal solutions of least colors cannot be obtained for 90-vertice graph (Johnson, 1991) Constraint based techniques are the mostly studied early approaches G51IAI – Introduction to AI

21 CSP So why is graph coloring important? CSP has many uses
A typical constraint satisfaction problem Can be used to model many real problems CSP has many uses Scheduling Timetabling Other optimisation problems in industrial G51IAI – Introduction to AI

22 CSP – Search Tree Depth first search ? G51IAI – Introduction to AI

23 CSP – Search Tree Backtracking ? G51IAI – Introduction to AI

24 CSP Techniques Constraint propagation Search strategies
Consistency enforcing Arc consistency, path consistency Search strategies Back and forward checking Variable and Value ordering Branch & bound (B&B) Constraint optimisation techniques G51IAI – Introduction to AI

25 CSP – Example II Scene labeling problem The first CSP studied
In vision, scene are captured as images, and processed as lines to represent images Lines need to be interpreted into types G51IAI – Introduction to AI

26 CSP – Example II Scene labeling problem Types of lines Convex edges +
The edge is moving away from the viewer Concave edges – The edge moves towards the viewer Occluding edges  Face at right can be seen by the viewer + - Convex: moving away from the viewer Concave: moving towards the viewer area on the right: face of the object which can be seen as the viewer G51IAI – Introduction to AI

27 CSP – Example II Scene labeling problem defined as CSP Variables
Domains G H I B C A D F E Convex: moving away from the viewer Concave: moving towards the viewer area on the right: face of the object which can be seen as the viewer + -   G51IAI – Introduction to AI

28 CSP – Example II Scene labeling problem defined as CSP Constraints
G51IAI – Introduction to AI

29 CSP – Example III Sudoku Variables Domain Constraints 6 5 2 3 9 7 1 4
8 G51IAI – Introduction to AI

30 CSP – Example IV N-Queen problem Variables Domain Constraints
G51IAI – Introduction to AI


Download ppt "G51IAI Introduction to Artificial Intelligence"

Similar presentations


Ads by Google