An Investigation into Maintaining Arc Consistency in a ...

5 downloads 0 Views 34KB Size Report
an arc consistency(AC) algorithm. The key AC algorithm was developed by Mackworth[1] called. AC-3 over twenty years ago and remains one of the easiest to ...
An Investigation into Maintaining Arc Consistency in a Dynamic Environment Malek Mouhoub and Jonathan Yip Department of Math & Computer Science, University of Lethbridge 4401 University Drive, Lethbridge, AB, Canada, T1K 3M4 phone : (+1 403) 329 2557 fax : (+1 403) 329 2519 yipj9,mouhoub @cs.uleth.ca



1

Abstract Constraint Satisfaction problems (CSPs) are a fundamental concept used in many Artificial Intelligence problems. The existence of a solution in a CSP is a NP-complete task and therefore, many filtering techniques have been developed to reduce the size of the problem before propagation towards the possibility of a solution. The most used and easiest to implement filtering techniques are node and arc consistency. Since node consistency is trivial, the majority of the attention is focused on arc-consistency. As was previously mentioned, a CSP may or may not have a solution and this is true during the application of an arc-consistency algorithm. If during the filtering, a node becomes empty, then clearly there will be no solution when the propagation towards a solution occurs after this filtering step. Therefore it is interesting to study arc-consistency or algorithms that recognizes when it is not necessary to continue any further into the filtering until further instruction is given (such as relaxing a constraint). One particular and interesting case is when the arc-consistency is performed in a dynamic environment (case where the constraints are added and/or removed during the processing). We talk then about dynamic arc-consistency algorithms. Our interest in this paper is to compare the known dynamic arc-consistency algorithms and provide an improvement on one of the algorithms.

Keywords: Consistency.

Constraint Satisfaction, Dynamic Arc

Introduction

Constraint Satisfaction problems (CSPs) are a major part in Artificial Intelligence. In particular, problems are usually in the form of a binary CSP, which involves a list of variables with a finite domain and a list of binary relations between these variables. One of the fundamental strategies used to reduce the size of the problem is by applying an arc consistency (AC) algorithm. The key AC algorithm was developed by Mackworth[1] called AC-3 over twenty years ago and remains one of the easiest to implement and understand today. There have been many attempts to best its worst case time complexity of O ed 3 and though in theory these other algorithms (namely AC-4[2], AC-6[3] and AC-7[4]) have better worst case time complexities, they are harder to implement. In fact, the AC4 algorithm fares worse on average time complexity than the AC-3 algorithm[5]. It was not only until recently when Zhang and Yap[6] proposed an improvement directly derived from the AC-3 algorithm into their algorithm AC-3.1. This new algorithm indeed improves the worst case time complexity to become comparable with the other algorithms at O ed 2 . The space complexity of the new algorithm is O ed , which is the same as AC-6 but because of its simplicity to implement, it becomes more attractive than AC-6. As we mentioned before, there has been a lot of work trying to improve AC algorithms but these algorithms pertain only to static problems. Research has been done concerning adapting these algorithms to work in a dynamic environment but has

 

   

been a minor research topic for the past five years when Debruyne last proposed DnAC6[7]. A dynamic arc consistency (DAC) algorithm is one that allows the removal of a constraint during the propagation of restrictions between nodes. This can either occur in the middle of restrictions or it may occur when it is known that a solution does not exist. In the latter, relaxations are made until all the nodes have at least one element in it. This of course does not guarantee a solution but it does reduce the chances of an inconsistent problem. In this paper, the aim of our work is to compare the different known DAC algorithms to determine their strengths and weaknesses. With this knowledge, we propose an improvement on one of the algorithms based on the new AC-3.1 algorithm to determine if we can improve on the inefficiencies of the other algorithms. The rest of this paper is organized as follows: in the next section, we will briefly describe what a dynamic constraint satisfaction problem (DCSP) is followed by an example of how a DAC algorithm would work. In section 3, the three known DAC algorithms are briefly presented followed by the proposed improvement to one of them. Following this, section 4 is dedicated to the experimental comparison of the four different DAC algorithms. Concluding remarks and a look at possible future work are presented in the final section.

2.1

Example

  

Consider the following problem (see figure 1): There are five nodes A B C D and E. Their domains are respectively :



 1 2 3 , Dom  2  3 , Dom  3  4 , Dom  2  4  6 , and Dom  2 

DomA



B



C



D

E

Consider the following sequence of instructions:

  B (see figure 1), 2. Add  B  C  , 3. Add  C D  , 4. and Add  A E 

1. Add A

where Add is a restriction. The results of these are:

            2. Dom   3 , Dom  3 , Dom  3 , Dom  2  4  6 and Dom  2 ; 3. Dom   3 , Dom  3 , Dom  3 , Dom  4  6 and Dom  2 ;

1. DomA 2 3 , DomB 2 3 , DomC 3 4 , DomD 2 4 6 and DomE 2 ; B

A

C

D

2 Dynamic Constraint Satisfaction Problems A dynamic constraint satisfaction is simply a sequence of static CSPs, each subsequent one resulting from a change in the preceding one imposed by an outside factor. This change can either be a restriction (adding a new constraint) to make the problem more constrained or a relaxation˙(removing a constraint because it is no longer required or because the current CSP has an empty node meaning no solution) in order to make the CSP less constrained.

A

E

B

C

D

E

4. all nodes become empty. As one can see, after the fourth restriction, the problem becomes inconsistent and therefore at this stage a relaxation should be proposed. Of course, it does not have to be the constraint that caused the inconsistency as can be seen by doing the following relaxation : Relax A B resulting in 1. DomA 3 , DomB 3 , DomC 3 , DomD 46 and DomE 2 .



   

  



  

{1,2,3}

{2}

{1,2,3}

{2}

A

E

A

E

=

Add(A=B)

B

D {2,4}

B {2,3}

D {2,4}

{2,3}

C

C

{3,4}

{3,4}

Figure 1: Dynamic Constraint Satisfaction Problem

3 dynamic Arc-Consistency Algorithms 3.1

DnAC4

The first dynamic algorithm was proposed by Bessi`ere called DnAC4[8]. This algorithm uses the idea of the AC-4 algorithm to determine if a value in a node has any support or not by keeping track of a list of counters of the number of support each element in each node has with each element in every other node. In addition, DnAC4 stores the justification of each value deleted in order to be able to retract a constraint incrementally. To keep track of all this support and justification requires a worst case space complexity of O ed 2 nd . The worst case time complexity of this algorithm is O ed 2 .

  

 



3.2 AC DC As an attempt to overcome this worst case space complexity, Neveu and Berlandier proposed AC DC[9]. This algorithm has its basis on AC3 and does not store any justification table. During relaxation, in order to make this an incremental algorithm, it relies on looking at only possible values to put back into nodes. Although this algorithm improves the worst case space complexity to O e nd , it also has a poorer worst case time complexity of O ed 3 compared to O ed 2 of DnAC4.



  

 

 

3.3

DnAC6

Seeing that both these algorithms lacked in one area, Debruyne proposed the DnAC6 algorithm[7]. The idea is similar to that of DnAC4 where a justification table is kept. The key difference is that instead of looking at all elements in a node, DnAC6 realizes that only the first element with support has to be found. This algorithm improves on the other two with a worst case time complexity of O ed 2 and a worst case space complexity of O ed nd .

    



3.4

AC DC using AC-3.1

After the proposal of DnAC6, there has been little work done on improving dynamic AC algorithms. With the introduction of the new AC-3.1 algorithm, perhaps the idea can be adapted into solving incremental arc consistency problems. The basic idea that we took was to integrate the AC-3.1 into the AC DC algorithm since that algorithm was based on AC-3. The problem with the AC DC algorithm was that it relied solely on the AC-3 algorithm and did not keep support lists like DnAC4 or DnAC6 causing the relaxation of a constraint to be fairly time consuming. This is also the reason for its worst case time complexity of O ed 3 . If AC-3.1 was integrated into the AC DC algorithm, then by theory the worst case time complexity should be O ed 2 . In addition to this, the worst case space complexity remains the same as the original AC DC algorithm of O e nd . During preliminary tests performed on randomly generated CSPs, we concluded that this new





 



 



  



adaptation of AC DC using the AC-3.1 algorithm improves the time complexity when concerning restrictions as can be concluded by the results shown by Zhang and Yap. The more interesting question is whether this algorithm’s time complexity can remain the same during retractions. One major concern is that during the restrictions, the AC-3.1 algorithm keeps a Resume table of the last place to start checking for consistency from. Unfortunately, during retractions, this Resume table may prove useless as values in the domain of nodes are restored. Our attempt was to follow an idea observed from the DnAC6 algorithm. Instead of replacing values in the node in the order they were deleted, the algorithm should place these values to be restored at the end of the list of values for that node, thereby keeping the Resume table intact. Briefly, the algorithm is as follows. Using the same idea as AC DC, in the propose(i, j, var propagable) procedure, instead of looking for the possible propagable values from the start of node j, to start where the last ”Resume” point was for the deleted element in node i. In other words, do not look from the start of node j, start looking at the last support of the element in node i. Similarly this can be done in the propagate k m varpropagable varrestorable procedure but most of the work is done in the last step of the original AC DC algorithm where it has to filter out the inconsistent restorations. This is where the new algorithm can save the most amount of time by being able to use the Resume table.



 







4 Experimental tests In order to compare the performance of the four DAC algorithms seen in the previous section, we have performed tests on randomly generated DCSPs each having 50 variables. The criterion used to compare the algorithms is the running time needed by each algorithm to achieve arc-consistency. The experiments were performed on a Sun Sparc 10 and all procedures are coded in C/C++. Each variable has 50 elements in it and restrictions were done until a complete graph (number of

    

1225) was obtained. constraints=N N 1 2 Afterwards, relaxations were done until the graph was 50constrained. These tests were performed on various degree of tightness to determine if one type of problem, (over-constrained, middleconstrained or under-constrained) favored any of the algorithms. Figure 2 shows the results of the tests in the case of restrictions. As we can easily see, the results provided by the new AC DC algorithm fares better than that of the original AC DC in all cases. Also the new AC DC algorithm is comparable if not better than DnAC6 (that has the best restriction time of the three dynamic AC algorithms) as can be seen in figure 2. Although, the new implementation has yet to reach the time used by the DnAC4 or DnAC6 algorithms, it has been a vast improvement over the previous AC DC algorithm. Also, considering that this new algorithm has a better space complexity than DnAC4 and DnAC6, it is worthwhile to further study this algorithm. This is especially interesting in the case of problems having large domain sizes.









5

Conclusion and future work

In this paper we have presented an experimental comparison of dynamic arc-consistent algorithms. The results demonstrate that the the new algorithm, an adaptation of the the new AC-3 algorithm for dynamic constraints can beat DnAC6 during restrictions it terms of time it reaches arc-consistency. Along with this fact is that the new algorithm requires less memory space than that of DnAC4 and DnAC6. Further work would be to look at how to improve this new adaptation of AC DC to improve its efficiency during retractions. It has shown promising results by significantly performing better than the original AC DC algorithm. Other work would be to look into integrating the dynamic arc consistency algorithms during the backtrack search phase in order to handle the addition and relaxation of constraints. For instance, if an element from a node is deleted during the backtrack, would it be





AC|DC DnAC4 7.000

Time(sec)

6.000

DnAC6 New AC|DC

5.000 4.000 3.000 2.000 1.000 0.000 0.94 0.83 0.71 0.55 0.40 0.36 0.35 0.34 0.34 0.33 0.26 0.20 0.14 0.08 0.01

Tightness Figure 2: Comparative restriction time of the dynamic arc-consistency algorithms worthwhile to use a DAC algorithm to determine its effect or would it be more costly than just continuing on with the backtrack search.

References [1] A. K. Mackworth. Consistency in networks of relations. Artificial Intelligence, 8:99–118, 1977. [2] R. Mohr and T. Henderson. Arc and path consistency revisited. Artificial Intelligence, 28:225–233, 1986. [3] C. Bessi`ere. Arc-consistency and arcconsistency again. Artificial Intelligence, 65:179–190, 1994. [4] C. Bessi`ere, E. Freuder, and J.C. Regin. Using inference to reduce arc consistency computation. In IJCAI’95, pages 592–598, Montr´eal, Canada, 1995. [5] R. J. Wallace. Why AC-3 is almost always better than AC-4 for establishing arc consistency in CSPs. In IJCAI’93, pages 239–245, Chambery, France, 1993. [6] Yuanlin Zhang and Roland H. C. Yap. Making ac-3 an optimal algorithm. In Seventeenth

International Joint Conference on Artificial Intelligence (IJCAI’01), pages 316–321, Seattle, WA, 2001. [7] R. Debruyne. Arc consistency in dynamic csps is no more prohibitive. In 8th International Conference on Tools with Artificial Intelligence (ICTAI’96), Toulouse, pages pages 299–306, 1996. [8] C. Bessi`ere. Arc-consistency in dynamic constraint satisfaction problems. In AAAI’91, pages 221–226, Anaheim, CA, 1991. [9] B. Neuveu and P. Berlandier. Arc-consistency for dynamic constraint satisfaction problems : An rms free approach. In ECAI-94, Workshop on Constraint Satisfaction Issues Raised by Practical Applications, Amsterdam, 1994.