Search for Constraint Satisfaction Problems

4.5 Search for Constraint Satisfaction Problems

Search methods can be used for solving Constraint Satisfaction Problems, CSPs. 26 CSPs are characterized by a set of requirements, treated as constraints, which should

be fulfilled. However, it is very difficult to fulfill them at the same time, because they are in conflict. Drawing up a timetable in a school is a good example of a CSP. We should fulfill at the same time such constraints as the availability of classrooms (of various sizes and equipment), the availability of classes (a class of pupils cannot have two lessons at the same time), the availability of teachers, etc. There are a lot of important application areas of search methods for CSPs, e.g., shop floor control, project management, logistics, VLSI design, and molecular biology.

Constraint satisfaction problems can be described by the following elements: • a finite set of variables: x 1 , x 2 ,..., x n ,

• for each variable x i the set of its possible values D x i , called a domain, • a finite set of constraints that are combinations of values of variables.

For example, let us consider the following problem. Let there be seven kingdoms K1, K2, …, K7 (they are the variables in our CSP) on a hypothetical island shown in Fig. 4.8 a. One should color in the map with three colors: blond (B), silver (S), and charcoal (C), so that no two adjacent kingdoms have the same color. Formally, the set {B, S, C} is the domain for each variable, and a set of constraints is defined in

Backtracking search is the simplest method. It consists of assigning consecutive variables (e.g., in the order B, S, C) to subsequent variables by generating a DFS tree. If an assignment conflicts with the set of constraints, then we backtrack from our

24 In case we analyze a tree having more plies. 25 It is of great importance in complex games, e.g., chess. The Deep Blue computer, playing against

G. Kasparov, expanded some paths to 40 plies. 26 Constraint satisfaction problems are of great importance in computer science. Therefore, there is

a variety of mathematical models, mainly based on graph theory, operational research, and linear algebra, that are used for their solution. In the monograph we introduce only basic ideas of AI heuristic search methods which are used for solving these problems. We refer the reader interested in CSPs to the well-known monograph of Edward Tsang [305]. For constraint programming, the monograph by Krzysztof R. Apt [8] is recommended.

4.5 Search for Constraint Satisfaction Problems 45

(a)

(b)

(c)

(d)

(e)

(f)

Fig. 4.8 Succeeding steps of search tree generation for a constraint satisfaction problem current path. Let us look at Fig. 4.8 b. Firstly, we generate the tree root corresponding

to the variable K1 and we assign the value B to it. (We color in the kingdom K1 with blond.) 27 In the next step (cf. Fig. 4.8 c), we assign B to K2 at first. However,

27 Each subsequent level in the tree corresponds to a subsequent variable.

46 4 Search Methods assigning a value to K2 that is incompatible with a previous assignment to K1 is

denoted by !K1.) So, we backtrack and we try to assign S to K2 (cf. Fig. 4.8 d). Now, all the constraints are fulfilled. In Fig. 4.8 e one can see that after assigning B to K3

an assignment to K1 is denoted !K1 again.) In Fig. 4.8 f one can see the situation after assigning S to K3 and B to K4.

A solution of the problem, which consists of assigning one of the values B, S,

C to all the variables K1, K2, …, K7 and fulfilling all the constraints is shown in Fig. 4.9 a. An interpretation of this solution with the help of the colored map is shown in Fig. 4.9 b. Let us notice that a value assigned to a variable in the solution of the

Fig. 4.9 An example of a constraint satisfaction problem: a a search tree generated at the moment of finding a solution—all the variables have values ascribed and all the constraints are satisfied,

b the map colored according to a solution found

4.5 Search for Constraint Satisfaction Problems 47 problem is represented by the last assignment to this variable in the search tree. For

example, in the left subtree starting from the assignment of B to K4, we have tried to ascribe all the possible values to K7 for all combinations of colors for K6. However, we have had to backtrack from the whole subtree. This has resulted from an incorrect assignment of B to K4. (After this assignment there is no solution to the problem.) Only when we have changed this assignment to K4 = S (the right subtree) do we find a solution, completed when the variable K7 has received the value B. Thus, a solution in a backtracking search method is represented by the outermost right path in the tree. Everything that is to the left of this path represents backtracking. Let us notice that for quite a simple problem we have to generate quite a big search tree to find the solution. This means that the method is not efficient. In fact, backtracking search is a basis for defining more efficient methods. Let us introduce two of them.

We begin with the following observation. Let us look at Fig. 4.9 a once more. After assigning B to K4 and C to K5 there is no “good” assignment for K7. This is illustrated by the repeated trial of assigning all the possible values to K7 after an assignment of all the possible values to K6. (The subtree below the node K5 =

C is “complete”.) If we had knew about this at the moment of assigning C to K5, we would not have had to generate a subtree below the node K5 = C. Checking whether assignments performed till now eliminate all the possible values for one of the remaining variables is the basic idea of forward checking search.

Let us analyze this method for our example with the help of Fig. 4.10 a. We will track the variable K7. As we can see, after assigning S to K2, the set of values that can

is adjacent to K7). Then, after assigning B to K4, the set of values that are possible the set of values that are possible for K7 is the empty set, because of the constraint subtree there is no sense in expanding the path after assigning B to K6. One can

easily notice the better efficiency of a forward checking search than a backtracking search, comparing the search trees shown in Figs. 4.9 a and 4.10 a. In order to improve the efficiency of the methods presented till now a lot of modifications have been proposed, including search with variable ordering, search with value ordering, etc. However, one of the most efficient approaches to CSP search is based on the constraint propagation technique. We analyze this technique for our

example with the help of Fig. 4.10 b. After assigning B to K1, the set of possible assignment K2 = S causes the following sequence of subsequent restrictions for

variables K5, K3, and K7: (a) the set of possible assignments for K5 is reduced to {C}, because of the constraint

(b) the set of possible assignments for K3 is reduced to {S}, because of (a) and the (c) the set of possible assignments for K7 is reduced to {B}, because of (a), (b), and

48 4 Search Methods

(a)

K1 = B K7 = {B,S,C}

K2 =

! K1 B S

K7 = {B,C}

K3 =

! K1 B

K7 = {B,C}

(b)

K1 =

B K5 = {S,C}

K2 =

x K7 = {B}

Fig. 4.10 Search tree for the constraint satisfaction problem: a for the forward checking search method, b for the constraint propagation method

As we can see in Fig. 4.10 b, in the constraint propagation method, just after assigning S to K2 (i.e., as early as on the second level of the tree) we are able to determine admissible assignments for three variables that reduce the search tree considerably.

4.5 Search for Constraint Satisfaction Problems 49 Summing up, after fixing the set of admissible values for a variable, we propagate

consequences of the restrictions imposed on this set to the remaining variables (hence, the name of the method). A lot of efficient algorithms, such as AC-3, AC-4, PC-2, and PC-4, have been developed based on the constraint propagation approach.

Local search is the third approach which is used for solving CSP problems. It is similar to hill climbing, introduced in Sect. 4.3 . We assign values to all the variables and we successively improve this assignment until it violates the constraints. Min- conflicts search is one of the most popular methods. First of all, we randomly generate initial assignments. Then, after choosing a variable with a value which conflicts with some constraints, we change the value in order to minimize the number of conflicts with other variables. This method gives good results, although it is strongly depen- dant on the initial assignment. Due to its iterative nature, the method is especially recommended in case constraints change over time.

Dokumen yang terkait

Hubungan pH dan Viskositas Saliva terhadap Indeks DMF-T pada Siswa-siswi Sekolah Dasar Baletbaru I dan Baletbaru II Sukowono Jember (Relationship between Salivary pH and Viscosity to DMF-T Index of Pupils in Baletbaru I and Baletbaru II Elementary School)

0 46 5

Institutional Change and its Effect to Performance of Water Usage Assocition in Irrigation Water Managements

0 21 7

The Effectiveness of Computer-Assisted Language Learning in Teaching Past Tense to the Tenth Grade Students of SMAN 5 Tangerang Selatan

4 116 138

the Effectiveness of songs to increase students' vocabuloary at second grade students' of SMP Al Huda JAkarta

3 29 100

The effectiveness of classroom debate to improve students' speaking skilll (a quasi-experimental study at the elevent year student of SMAN 3 south Tangerang)

1 33 122

Kerjasama ASEAN-China melalui ASEAN-China cooperative response to dangerous drugs (ACCORD) dalam menanggulangi perdagangan di Segitiga Emas

2 36 164

The Effect of 95% Ethanol Extract of Javanese Long Pepper (Piper retrofractum Vahl.) to Total Cholesterol and Triglyceride Levels in Male Sprague Dawley Rats (Rattus novergicus) Administrated by High Fat Diet

2 21 50

Factors Related to Somatosensory Amplification of Patients with Epigas- tric Pain

0 0 15

The Concept and Value of the Teaching of Karma Yoga According to the Bhagavadgita Book

0 0 9

Pemanfaatan Permainan Tradisional sebagai Media Pembelajaran Anak Usia Dini untuk Mengembangkan Aspek Moral dan Bahasa Anak Utilization of Traditional Games as Media Learning Early Childhood to Develop Aspects of Moral and Language Children Irfan Haris

0 0 11