A u t o m a t e d Synthesis o f C o n s t r a i n e d Generators Wesley Braudaway* Department of Computer Science Rutgers University New Brunswick, NJ 08903 ARPAnet:
[email protected] Abstract Knowledge compilation is an emerging research area that focuses on "compiling" a problem solver's inefficient, explicit knowledge representation i n t o more efficient, implicit forms. This paper presents a technique that transforms a declarative problem description (specifying the problem but not how to solve it) into a reasonably efficient, generate-and-test problem solver. Our technique performs constraint incorporation, modifying the parameter generators so they only generate values that satisfy the problem constraints. Successful constraint incorporation depends upon choosing the right solution representation (i.e., the set of parameters). Having expressed a constraint in terms of a particular set of parameters, incorporation fails if the constraint is not factorable i n t o constraints on the individual parameter generators. R I C K , a Refinement-based constraint Incorporator for Compiling Knowledge, is a prototype program that compiles a problem specification into a problem solver using least commitment, topdown refinement to achieve constraint incorporation. R I C K refines an abstract solution representation to avoid premature commitment to representations that hinder constraint incorporation. R I C K is able to incorporate local constraints that constrain relatively small portions of the entire solution. We have tested these ideas by having R I C K automatically construct a house floor planning problem solver.
*The research reported here was supported in part by the Defense Advanced Research Projects Agency (DARPA) under Contract Number N00014-85-K-0116, in part by the National Science Foundation (NSF) under Grant Number DMC-8610507, and in part by the Center for Computer Aids to Industrial Productivity (CAIP), Rutgers University, with funds provided by the New Jersey Commission on Science and Technology and by CAIP's industrial members. The first author has also received support from I B M . The opinions expressed in this paper are those of the authors and do not reflect any policies, either expressed or implied, of any granting agency. * currently on leave at I B M Watson Research Center.
Chris Tong* Department of Computer Science Rutgers University New Brunswick, NJ 08903 ARPAnet:
[email protected] 1
Introduction
Many AI systems perform run time evaluation of explicitly represented domain knowledge to find a solution to a problem. Such systems make a particular tradeoff between the "explicitness of the representation and the efficiency of the computation" [Dietterich (ed.), 1986]. Explicitly represented knowledge is easier to gather, but more costly to evaluate. This observation has spawned a research area called knowledge compilation, which includes methods for "compiling" an inefficient, explicit knowledge representation into more efficient, implicit forms. The work described in this paper is being conducted w i t h i n the context of the K B S D E project [Tong, 1986]. The purpose of the project is to develop compilation techniques whose input is a declarative problem description that does not specify how to solve the problem. The problem description includes a set of problem constraints that must be satisfied by a solution. The compilation techniques we are developing produce a generateand-test problem solver. Such a problem solver must generate a solution that passes a set of tests, one for each problem constraint. We have attempted to develop a compilation method that places as few requirements as possible on the domain, so that the method is broadly applicable. Thus, we have made the very weak requirement that the problem be solvable using a generate-andtest algorithm. In addition to insisting that our compiler be general, we have also required that it produce reasonably efficient algorithms. Like computer language compilers, knowledge compilers can use optimization techniques to improve the performance of the resulting problem-solving system. One optimization technique for a generate-and-test architecture is test incorporation [Dietterich and Bennett, 1986]. Test incorporation involves test movement, constraint incorporation, or b o t h . Test movement regresses tests back into the generator process to achieve early pruning w i t h out affecting the correctness of the problem solver. Constraint incorporation [Tappel, 1980] modifies the generator so that it enumerates only those values which satisfy a particular problem constraint; we w i l l call such a generator a constrained generator. The test corresponding to the incorporated constraint can be removed from the generate-and-test problem solver. Constraint incorporation reduces the size of the problem solver's search space and results in a more efficient problem solver. Con-
Braudaway and Tong
583
s t r a i n t i n c o r p o r a t i o n m a k e s use o f e x p l i c i t l y r e p r e s e n t e d d o m a i n knowledge (e.g., specifications for system c o m ponents), thus distinguishing it from more conventional code o p t i m i z a t i o n a p p r o a c h e s w h i c h r e l y solely o n s y n tactic knowledge (e.g., d a t a dependencies a m o n g system components). T h i s p a p e r focuses o n c o n s t r u c t i n g c o n s t r a i n e d g e n e r a t o r s o f hierarchical s o l u t i o n s , i.e., s o l u t i o n s t h a t have p a r t s ( e . g . , a house w i t h r o o m s ) . H i e r a r c h i c a l s o l u t i o n s can b e g e n e r a t e d u s i n g c o r r e s p o n d i n g l y h i e r a r c h i c a l g e n e r a t o r s ( e . g . , F i g u r e 3 ) . T h a t i s , s o l u t i o n p a r t s are g e n erated by sub-generators, and p r i m i t i v e solution p a r a m eters are assigned values by p a r a m e t e r g e n e r a t o r s . A p a r t i c u l a r solution representation is d e f i n e d by a set of primitive parameters. To incorporate a constraint into a hierarchical generator requires t h a t it be localizable to a n d i n c o r p o r a t e d i n one o r m o r e o f t h e ( p r i m i t i v e ) p a rameter generators. Incorporating constraints is difficult w h e n the solution representation is " i n a p p r o p r i a t e " . A c o n s t r a i n t expressed i n t e r m s o f a p a r t i c u l a r s o l u t i o n r e p r e s e n t a t i o n c a n h a v e a s t r u c t u r e t h a t does n o t " m a t c h " t h a t o f the generator; t h a t is, the c o n s t r a i n t m a y not be factorable into constraints on the individual paramet e r g e n e r a t o r s . W e w i l l c a l l t h i s d i f f i c u l t y t h e structure mismatch problem. T h i s paper demonstrates a system which incorporates the constraints while avoiding this structure mismatch problem. R I C K , a Refinement-based c o n s t r a i n t I n c o r p o r a t o r for C o m p i l i n g K n o w l e d g e , i s a p r o t o t y p e p r o g r a m t h a t c o m p i l e s a p r o b l e m solver u s i n g least c o m m i t m e n t , top-down refinement to achieve c o n s t r a i n t i n c o r p o r a t i o n . T h e least c o m m i t m e n t a p p r o a c h helps t o a v o i d a p r e m a t u r e c o m m i t m e n t t o a r e p r e s e n t a tion t h a t may lead to the structure m i s m a t c h problem. S e c t i o n 2 of t h i s p a p e r defines t h e class of d o m a i n s for w h i c h o u r m e t h o d a p p l i e s a n d i l l u s t r a t e s a n e x a m p l e f r o m t h i s class: t h e house f l o o r p l a n n i n g d o m a i n . Section 3 illustrates the structure m i s m a t c h problem in the house f l o o r p l a n n i n g d o m a i n . T h e f o u r t h s e c t i o n discusses t h e c o n c e p t s b e h i n d o u r a p p r o a c h a n d i l l u s t r a t e s their i m p l e m e n t a t i o n in R I C K . We compare our work w i t h r e l a t e d research i n S e c t i o n 5 . F i n a l l y , S e c t i o n 6 s u m m a r i z e s t h e p a p e r a n d some o f t h e l i m i t a t i o n s o f o u r approach.
2
The problem domain
Parameter instantiation design problems. The K B S D E p r o j e c t has f o c u s e d o n design d o m a i n s w h e r e t h e p r o b l e m solver c o n s t r u c t s a n a r t i f a c t t h a t satisfies a set o f p r o b l e m c o n s t r a i n t s . M a n y design p r o b l e m s c a n b e v i e w e d as parameter instantiation p r o b l e m s . T h e hierarchical structure of t h e a r t i f a c t is u s u a l l y p r e - d e t e r m i n e d for a class o f p a r a m e t e r i n s t a n t i a t i o n p r o b l e m s ; for i n s t a n c e , a l l house f l o o r p l a n s consist o f r e c t a n g u l a r r o o m s , w h i c h , i n t u r n , c o n s i s t o f sides a n d c o r n e r s . T h e des i g n t a s k r e m a i n i n g f o r t h e p r o b l e m solver i s t o " f i l l i n " a n d " i n t e r c o n n e c t " t h e s t r u c t u r e b y a s s i g n i n g values t o the unspecified a r t i f a c t parameters in a way t h a t is consistent w i t h the p r o b l e m constraints. R I C K constructs a p r o b l e m solver f o r p a r a m e t e r i n s t a n t i a t i o n p r o b l e m s whose s o l u t i o n s are c o m p o s i t e o b j e c t s (e.g., house f l o o r plans). T h e p r o b l e m c o n s t r a i n t s are p r e s u m e d t o b e
584
Machine Learning
h a r d c o n s t r a i n t s t h a t define feasible s o l u t i o n s ( r a t h e r t h a n soft c o n s t r a i n t s t h a t define t h e r e l a t i v e o p t i m a l i t y o f feasible s o l u t i o n s ) . W e also p r e s u m e t h a t t h e design p r o b l e m i s n o t o v e r - c o n s t r a i n e d : a s o l u t i o n t h a t satisfies a l l t h e c o n s t r a i n t s can b e f o u n d . A h o u s e f l o o r p l a n n i n g d o m a i n . T o i l l u s t r a t e our ideas, w e w i l l use t h e p a r a m e t e r i n s t a n t i a t i o n p r o b l e m o f c o n s t r u c t i n g " h o u s e floor p l a n s " . A house floor p l a n is a t w o - d i m e n s i o n a l , r e c t a n g u l a r house p l a c e d a t t h e o r i g i n of an x-y grid and having rectangular rooms as parts; such a floor plan is abstractly depicted in Figure 1. A l l l e n g t h s a n d c o o r d i n a t e s are m u l t i p l e s o f 1 f o o t . T h e s o l u t i o n is a floor p l a n t h a t contains a problem-specific n u m b e r o f r o o m s , a n d satisfies a l l o f t h e p r o b l e m c o n s t r a i n t s s h o w n i n F i g u r e 2 . C o n s t r a i n t s S C I , SC2 a n d SC3 are " l o c a l " c o n s t r a i n t s since t h e y c o n s t r a i n each i n d i v i d u a l r o o m . C o n s t r a i n t s SC4 a n d SC5 are m o r e " g l o b a l , " c o n s t r a i n i n g pairs o f r o o m s , a n d all r o o m s , r e s p e c t i v e l y . O u r e x a m p l e s w i l l f o c u s o n t h e i n c o r p o r a t i o n o f t h e local constraints.
3
Constraint incorporation and representation shift
A s i m p l e b u t i n e f f i c i e n t g e n e r a t e - a n d - t e s t . A simp l e , h i e r a r c h i c a l , g e n e r a t e - a n d - t e s t p r o b l e m solver for the floor planning d o m a i n is shown in Figure 3. The g e n e r a t o r creates a c a n d i d a t e s o l u t i o n c o n t a i n i n g des c r i p t i o n s for each of t h e n r o o m s specified by a p a r ticular p r o b l e m . Each r o o m is generated by assigning values t o i t s p a r a m e t e r s u s i n g t h e i n i t i a l r e p r e s e n t a t i o n : (x,y) ( l o c a t i o n o f t h e S W r o o m c o r n e r ) , / ( l e n g t h i n t h e x d i r e c t i o n ) , a n d w ( w i d t h in the y d i r e c t i o n ) . The g e n e r a t o r s are i n v o k e d in a p a r t i c u l a r sequence (e.g., x _--> y --> / --> w A f t e r a l l t h e g e n e r a t o r s have been i n v o k e d , t h e testers e v a l u a t e t h e c a n d i d a t e s o l u t i o n for
satisfaction of the p r o b l e m constraints. A failure of any test results in chronological b a c k t r a c k i n g t h r o u g h the g e n e r a t o r sequence so a n e w c a n d i d a t e s o l u t i o n c a n be generated. For a 9 x 9 f o o t house w i t h 4 r o o m s , t h i s p r o b l e m solver ( F i g u r e 3) has a g e n e r a t i o n space c o n t a i n i n g 10 1 6 c a n d i d a t e s o l u t i o n s ( 4 r o o m s , each h a v i n g 4 p a r a m e t e r s t h a t each r a n g e over 10 v a l u e s ) . O n l y a s m a l l n u m b e r of these are a c c e p t a b l e s o l u t i o n s ( t h a t s a t i s f y c o n s t r a i n t s S C I S C 5 ) . I n a s o l u t i o n f o r t h i s p r o b l e m , each r o o m i s i n a house c o r n e r ; O n e r o o m has 4 possible sizes (/ — 4 | 5 a n d w = 4 | 5 ) ; i t s t w o a d j a c e n t r o o m s have o n l y t w o possible sizes (w = 4 | 5 f o r o n e , / — 4 | 5 for t h e o t h e r ) ; t h e f i n a l r o o m f i l l s t h e r e m a i n i n g area. Thus t h e r e are 1 6 = 4 x 2 x 2 x 1 d i f f e r e n t r o o m c o n f i g u r a t i o n s . T h e s e r o o m s c a n b e l a b e l l e d R 1 , . . . , R 4 i n 4 ! different ways. T h u s the t o t a l n u m b e r of acceptable solutions is 1 6 x 4 ! = 3 8 4 . A s s u m i n g a u n i f o r m d i s t r i b u t i o n of acceptable solut i o n s i n t h e space o f c a n d i d a t e s o l u t i o n s , t h e g e n e r a t e a n d - t e s t p r o b l e m solver w i l l g e n e r a t e r o u g h l y 1 0 1 6 / 384 = 2.6 * 1 0 1 4 c a n d i d a t e s b e f o r e f i n d i n g a s o l u t i o n . T h i s p r o b l e m solver i s v e r y i n e f f i c i e n t . T h e s t r u c t u r e m i s m a t c h p r o b l e m . W e use c o n s t r a i n t i n c o r p o r a t i o n t o i m p r o v e t h e efficiency o f t h e p r o b l e m s o l v e r . For e x a m p l e , c o n s t r a i n t S C I i s easily i n c o r p o r a t e d by changing the lower bounds of the l e n g t h a n d w i d t h generators f r o m 0 to 4. T h e candidate solut i o n s t h a t v i o l a t e S C I w i l l n o t b e g e n e r a t e d ; t h i s leaves a search space of r o u g h l y size 1.7 x 1 0 1 4 c a n d i d a t e s o l u t i o n s (4 r o o m s , e a c h h a v i n g 4 p a r a m e t e r s , 2 r a n g i n g over 10 v a l u e s , a n d 2 r a n g i n g over 6 v a l u e s ) . U n f o r t u n a t e l y , i n c o r p o r a t i n g a c o n s t r a i n t can b e d i f f i cult when the problem constraint on the entire solution cannot be p a r t i t i o n e d i n t o constraints on i n d i v i d u a l par a m e t e r g e n e r a t o r s , a s w e h a v e j u s t d o n e . T h i s case can occur when an i n a p p r o p r i a t e solution representation is c h o s e n . For e x a m p l e , r e p r e s e n t i n g r o o m s b y t h e f o u r p a -
This constraint implies that a room must either have its west side on the west side of the house, or its north side on the north side of the house, etc. Because this constraint refers to all the room parameters, and is a disjunction (when expressed using this room representation), there is no easy way to factor it into constraints on the individual room parameters. Because of the structure mismatch problem in this case, incorporation fails. Constraint i n c o r p o r a t i o n as representation s h i f t . Note, however, that the constraint refers to the containment (segmentof) of a room side w i t h i n a house side. A more appropriate solution representation would have represented a room rectangle by two perpendicular "side objects" (each "side object", in t u r n , having a location and a length). Given this representation, we could incorporate the "Side Adjacency" constraint by simply modifying the generator of one room side so as to place it along one of the four house sides. Our example suggests an obvious method for incorporating a constraint: shift the representation of either the constraint, the generator or b o t h , u n t i l incorporation succeeds. Unfortunately, the space of alternative representations is rather large. Also, the need to incorporate multiple constraints into a single generator means that the method must find a single representation that enables incorporation of all the constraints. Problem reformulation is a difficult research problem w i t h many unresolved issues [Korf, 1980]. In the next section, we present an alternative approach for knowledge compilation that reduces the combinatorial explosion when searching a space of representations.
4 4.1
Knowledge Compilation as Incremental Constraint Incorporation V i e w i n g Constraints as Generators of P a r t i a l Solutions
Construction of the inefficient, generate-and-test problem solver depicted in Figure 3 was based on viewing a problem constraint as a test on complete solutions. In contrast, our constraint incorporation approach (implemented in the R I C K program) is based on viewing a constraint as a constrained generator of partial solutions. For example, the "Side Adjacency" constraint (SC3):
The hl (the house l e n g t h value in the x direction) and hw (house w i d t h value in the y direction) are parameters whose values are problem-specific.
Braudaway and Tong
585
In contrast, a generator of complete rooms would construct complete 4-sided rooms. Generator Gp(SC3) is constrained since it only generates (partial) solutions t h a t satisfy the Side Adjacency constraint. Generator Gp(SC3) is expressed in terms of abstract objects such as r o o m sides and house sides, instead of p r i m i t i v e parameters such as x, y, 1, or w. This f o r m u lation of the generator is m o t i v a t e d by the constraint itself, which only specifies these abstract objects, and makes no c o m m i t m e n t to their p r i m i t i v e parameter representation. Several representation alternatives are usually possible; to unnecessarily commit to a particular one might make incorporation of other constraints difficult or impossible (due to the structure mismatch problem). In short, to facilitate a least c o m m i t m e n t approach, the constraint should be re-expressed as a " p a r t i a l solution generator" t h a t is: • partial. It only generates those parts of the (hierarchical) solution specified in the constraint. • abstract. The generated parts are expressed in terms of abstract objects. W h i c h constraints can be re-expressed in this way? Almost by definition, in order for a constraint to be reexpressible as a generator of partial solutions, it must be a " l o c a l " constraint; t h a t is, it must constrain only a part of the solution. T h i s paper summarizes how R I C K incorporates the three constraints SC1-SC3 (Figure 2) t h a t are local to i n d i v i d u a l rooms. 4.2
E x t e n d i n g this Idea into a Complete
Method
The following observations w i l l help motivate the extension of this idea i n t o a complete m e t h o d : • ( P A R T I A L ) By construction, the partial solution generator Gp(C) only generates solutions that satisfy the constraint C. • ( E X T E N D ) A n y consistent extension of Gp(C) i n t o a generator of complete solutions w i l l also only generate solutions t h a t satisfy C, thereby completely i n c o r p o r a t i n g the constraint. In a similar manner, if a constrained generator of p a r t i a l solutions is guaranteed to satisfy a set of constraints, then so w i l l any consistent extension. We w i l l call such extensions refinements of the partial solution generator. For instance, the "single room side" generator G P ( 5 C 3 ) generates room sides on the house boundary (thus creating p a r t i a l rooms t h a t satisfy SC3). 2
The notation Gp(C) specifies a partial solution generator whose generated values always satisfy the constraint C.
586
Machine Learning
G P ( 5 C 3 ) can be extended i n t o a complete room generator t h a t generates rooms w i t h (at least) one side adjacent to the house boundary. Thus the "Side Adjacency" constraint SC3 is s t i l l guaranteed to be satisfied. To represent the hierarchical structure of the artifact (e.g., a house w i t h rooms), R I C K uses an object hierarchy to organize the knowledge needed for constructing p a r t i a l solution generators and their refinements. The hierarchy contains two types of relations between objects: "subclass" ("isa") and " p a r t - o f " . The hierarchy economically (and m o d u l a r l y ) represents an entire set of alternative solution representations, at differing levels of abstraction. This hierarchy also contains the relevant structural constraints common to rectangular objects (e.g., the West r o o m side is perpendicular to the N o r t h room side.) We have described the first and t h i r d steps of a complete method for i n c o r p o r a t i n g constraints by refinement. The three steps are: S T E P 1 . Re-express each constraint C as a partial solution generator Gp(C) (see P A R T I A L ) . S T E P 2 . Merge each partial solution generator into a single solution generator G m ( { C i } ) which is guaranteed to satisfy the set of constraints
{Cii}
S T E P 3 . Refine generator Gm({Ci}) into a generator of complete solutions (expressed in terms of p r i m itive parameters) (see E X T E N D ) . For a more complete description of the method, refer to [Braudaway, 1988]. By representing p a r t i a l solution generators, we have fulfilled the major requirement of a least commitment approach for designing constrained generators. T h a t is, when R I C K incrementally constructs the generator, it only adds more detail when necessary. Since R I C K constructs a p a r t i a l solution generator from the problem constraint (achieving incorporation d u r i n g construct i o n ) , it avoids the structure mismatch problem described in Section 3. We have replaced the structure mismatch problem w i t h the new problem of merging several partial solution generators i n t o a single consistent solution generator. 4.3
Merging Partial Solution Generators
In our floor planning example, R I C K creates three part i a l solution generators, one for each of the local constraints SC1-SC3 (Figure 2). From constraints S C I and SC3, R I C K produces two " r o o m side" generators, and f r o m constraint SC2 it produces a generator pair for the diagonally opposed r o o m corners, SW and N E . Merging these partial solution generators is complicated by the interactions t h a t occur between t h e m . For example, each room must b o t h be inside the house (SC2) and have at least one side on the house boundary (SC3). When " s i m u l a t e d " , a p a r t i a l solution generator creates "values" t h a t are either abstract objects from the object hierarchy (e.g., corners SW and NE for a room R ) , computable functions on such abstract objects (e.g., corner SW £ Points(lcft house b o u n d a r y ) ) , or b o t h . To
S e l e c t a H o u s e S i d e HS, f r o m { W , N , E , S } G e n e r a t e a R o o m S i d e , RS, f r o m { W , N, E, S} u SidesCorrespondingTo(ffS)4 w i t h C o r n e r s E Points(HS)
say t h a t g e n e r a t o r s interact m e a n s t h a t a t least one c o m b i n a t i o n o f g e n e r a t a b l e v a l u e s i s inconsistent. T h i s suggests a s i m p l e a p p r o a c h f o r s o l v i n g t h e i n t e r action problem: • S y s t e m a t i c a l l y g e n e r a t e a l l c o m b i n a t i o n s o f values o f p a r t i a l s o l u t i o n g e n e r a t o r s , t e s t i n g each c o m b i n a tion (an a b s t r a c t , p a r t i a l solution) for consistency. • C o n s t r u c t t h e m e r g e d g e n e r a t o r b y c a c h i n g only t h e consistent solutions. Figure 4 illustrates R I C K ' s application of this m e t h o d to the floor p l a n n i n g d o m a i n . E a c h c o m b i n a t i o n o f values i s d e p i c t e d as a d i f f e r e n t p a t h in a s e a r c h t r e e . F o r e x a m p l e , t h e l e f t m o s t p a t h i n t h e tree i s c o n s t r u c t e d w h e n t h e p a r t i a l s o l u t i o n generators p r o d u c e values: [ H S = H o u s e West Side, RS=Room W e s t Side]; the next left most p a t h c o r r e s p o n d s t o [HS— H o u s e W e s t S i d e , RS— R o o m East Side]; etc. A f t e r g e n e r a t i n g a p a r t i c u l a r p a t h in the search tree ( a p a r t i c u l a r v a l u e c o m b i n a t i o n ) , a c o r r e s p o n d i n g set of c o n s t r a i n t s , i m p l i e d by the value c o m b i n a t i o n is coll e c t e d . For e x a m p l e , t h e v a l u e c o m b i n a t i o n [ H S = H o u s e W e s t S i d e , R S = R o o m E a s t Side] i m p l i e s t h a t t h e E a s t r o o m side m u s t b e p l a c e d o n t h e W e s t house side: Xcoord(SEcorner(RS)) = Xcoord(SWcorner(HS)). B e c a u s e a l l t h e c o n s t r a i n t s i n t h i s d o m a i n are l i n e a r , a l g e b r a i c c o n s t r a i n t s , R I C K uses a l i n e a r p r o g r a m ( t h e S i m p l e x m e t h o d ) to d e t e r m i n e their consistency (i.e., the e x i s t e n c e o f a f e a s i b l e s o l u t i o n t o these c o n s t r a i n t s ) . 3 T h e l i n e a r p r o g r a m discovers t h a t the above c o n straint is inconsistent w i t h (SC2), the "Inside House" constraint: Xcoord(SWcorner(HS)) < Xcoord(SWcorner(RS)), a n d a c o n s t r a i n t associated w i t h rectangles in general: Xcoord(SWcorner(RS)) < Xcoord(SEcorner(R5)). T h e i n c o n s i s t e n c y o f these c o n s t r a i n t s f o l l o w s b y t r a n s i t i v i t y . I n t u i t i v e l y , this indicates t h a t the abstract solut i o n has f o r c e d t h e S W r o o m c o r n e r o u t s i d e t h e h o u s e . I f a n a b s t r a c t s o l u t i o n i s c o n s i s t e n t , R I C K caches i t into a unified generator description. As illustrated in F i g u r e 4 , f o u r o u t o f e i g h t a b s t r a c t s o l u t i o n s are f o u n d t o b e c o n s i s t e n t ( t h e ones i n t h e f i g u r e t h a t h a v e n o t been crossed o u t ) , a n d are c a c h e d i n t o a s i n g l e , u n i f i e d generator description: 3
We realize in retrospect t h a t we should use an integer p r o g r a m m i n g m e t h o d to guarantee the soundness of the a n swer. We can also e x t e n d this a p p r o a c h by using routines t h a t check the consistency of other classes of (nonlinear) cons t r a i n t s . N o t e t h a t this floor planner cannot be i m p l e m e n t e d as a linear p r o g r a m , p r i m a r i l y because some of the constraints SC1-SC5 are expressed as d i s j u n c t i o n s .
The merge process has thus resolved the interaction between the "Side Adjacency" (SC3) and the "Inside House" (SC2) constraints. By using a " g o o d " abstraction hierarchy, only relatively abstract value combinations need to be tested. Furthermore, there are a relatively small number of these abstract solutions. The pruning of inconsistent abstract solution candidates removes entire equivalence classes of inconsistent solution candidates produced by a complete solution generator. 4.4
Refining into Primitive Representations
After merging the partial solution generators ( S T E P 2 ) , the resulting unified generator must be refined i n t o a complete generator, which consists of a set of p r i m i tive parameter generators. Constraint incorporation has been completed in the merging step. Thus all complete generators refined from the merged generator (STEP3) w i l l have the same generation space (even though it w i l l be represented differently). Since R I C K only distinguishes between alternative algorithms based on the size of their constrained generation spaces, it views all of the refinements as equally " g o o d " , and constructs all of t h e m . In the floor planning example, these alternative refinements correspond to the various alternatives for representing a rectangle in terms of p r i m i t i v e parameters (e.g., < x , y , l , w > ) . In actuality, the alternative problem solvers are not equally good; differences in data and program structures cause differences in space and time complexity. Ideally, selection should be based on criteria for data and program structure o p t i m i z a t i o n . In the current prototype system, the user selects the "best" alternative, which is then translated i n t o LISP. W h e n applied to the floor planning example, our method incorporates the three local floor planning constraints SC1-SC3 (Figure 2). The resulting problem solver (Figure 5) generates each room by picking a room location ( X , Y ) f r o m a point on a house side. The room specification is completed by generating length and w i d t h values (starting from the required minimums) that place the room inside the house w i t h respect to the room's location ( X , Y ) . T h i s problem solver generates roughly 6 x 10 10 candidate solutions for a 9x9 house w i t h 4 rooms (see Figure 5). For each of the 4 rooms, there are 4 ways to pick a house side, HS; for each of these cases, there are 21 ways to pick a room side that is a subsegment of that house side; also, there are 6 ways to pick the perpendicular magnitude. Thus the t o t a l number of candidate solutions is (21 x 6 x 4 ) 4 . This is a reduction in complexity of 6 orders of magnitude f r o m the inefficient, generate-and-test problem 4
A mapping that associates West room side with West house side, North room side with North house side, etc.
Braudaway and Tong
587
Tappel's approach takes a generate-and-test a l g o r i t h m a s i n p u t a n d i t e r a t i v e l y re-designs i t b y i n c o r p o r a t i n g constraints. T h e s t r a t e g y u s e d b y D I O G E N E S [ M o s t o w , 1988] i s s i m i l a r t o T a p p e P s b u t uses a t r a n s f o r m a t i o n a l a p proach to modify an initial generate-and-test algorithm ( f o r p o s s i b l y o v e r - c o n s t r a i n e d p r o b l e m s ) i n t o a m o r e efficient heuristic search a l g o r i t h m . T h i s a p p r o a c h uses d o m a i n k n o w l e d g e t h a t has b e e n p r o c e d u r a l l y e m b e d ded in some or all of the t r a n s f o r m a t i o n s . However, the d e s i g n k n o w l e d g e f o r c o n t r o l l i n g t h e c o m p i l a t i o n process i s s u p p l i e d b y t h e user o f t h e D I O G E N E S s y s t e m ( w h o selects a m o n g a p p l i c a b l e t r a n s f o r m a t i o n s ) . T h e m o d e l o f d e s i g n used b y b o t h o f these s t r a t e g i e s i s e s s e n t i a l l y h i l l c l i m b i n g t h a t i t e r a t i v e l y r e - d e s i g n s a p r o b l e m solver t o i m p r o v e i t s e f f i c i e n c y ( t h o u g h s o m e steps d o n o t d i r e c t l y i m p r o v e efficiency b u t have the purpose of enabling other o p t i m i z a t i o n steps).
solver previously shown. Further research w i l l a t t e m p t to extend R I C K , a l l o w i n g it to also incorporate necessary constraints. A "necessary c o n s t r a i n t " t h a t is not satisfied by a p a r t i a l solution w i l l not be satisfied by any extension of the p a r t i a l solution. For example, the cons t r a i n t t h a t "no rooms overlap" is a necessary constraint in the floor p l a n n i n g d o m a i n , since, if rooms overlap in a p a r t i a l s o l u t i o n , they continue to overlap in all extensions of t h a t p a r t i a l s o l u t i o n . T h e problem solver res u l t i n g f r o m i n c o r p o r a t i o n of this constraint w i l l have a generation space of 1008 candidates (384 of which are solutions) for this 9x9 example.
5
Related W o r k
K n o w l e d g e c o m p i l a t i o n as a design process. To facilitate the comparison of our work w i t h related work in knowledge c o m p i l a t i o n , it is useful to view knowledge c o m p i l a t i o n as a design process t h a t designs a problem solver f r o m the specification for a class of problems. We contrast three approaches according to their model of the design process and the manner in which domain k n o w l edge is used to produce reasonably efficient a l g o r i t h m s . Knowledge compilation as iterative re-design. Tappel [1980] defi nes test and constraint i n c o r p o r a t i o n as modifications to a data-flow graph representing the components of the a l g o r i t h m to be synthesized. A test refers to certain solution components; hence these solut i o n components must be generated before the test can be r u n . T a p p e r s approach moves a test backwards in the a l g o r i t h m ' s data-flow graph u n t i l it is placed j u s t after the generators of these referenced solution components. An a t t e m p t is also made to m o d i f y the generator so only values t h a t satisfy the test w i l l be enumerated.
588
Machine Learning
Knowledge compilation as schema instantiat i o n . K I D S [ S m i t h , 1988] focuses o n m a p p i n g declara t i v e k n o w l e d g e i n t o a global search a l g o r i t h m . A g l o b a l s e a r c h a l g o r i t h m s p l i t s a set d e f i n i n g a l l c a n d i d a t e s o l u tions of a p r o b l e m i n t o subsets a n d e x t r a c t s solutions f r o m t h e subsets w h e n p o s s i b l e . T h i s a p p r o a c h uses declarative domain knowledge in the f o r m of procedural s c h e m a s . F o r e x a m p l e , one g l o b a l s e a r c h s c h e m a e n u m e r ates a l l b o u n d e d sequences over a f i n i t e set. T h e m e t h o d finds the domain-specific schema t h a t best matches the p r o b l e m d o m a i n , a n d t h e n i n s t a n t i a t e s i t i n t o a n efficient a l g o r i t h m (using i n f o r m a t i o n d r a w n f r o m the probl e m s p e c i f i c a t i o n ) . C o n s t r a i n t s are f o r m u l a t e d a n d i n c o r p o r a t e d d u r i n g i n s t a n t i a t i o n o f the p r o c e d u r a l schema. K I D S i s able t o r e a s o n a b o u t p r o b l e m s p e c i f i c a t i o n s t h a t include f u n c t i o n a l constraints (constraints on I / O behavior) and optimality criteria. K n o w l e d g e compilation as t o p - d o w n refinem e n t . R I C K c o n s t r u c t s c o n s t r a i n e d g e n e r a t o r s o f sol u t i o n s whose feasibility is defined by p r o b l e m constraints. I n c o n t r a s t w i t h the i t e r a t i v e re-design app r o a c h e s , w h i c h i n c o r p o r a t e c o n s t r a i n t s after a c o m p l e t e p r o b l e m s o l v e r has b e e n c r e a t e d , R I C K refines t h e p r o b l e m constraints i n t o p a r t i a l solution generators (which are t h e n m e r g e d ) , t h u s s i m u l t a n e o u s l y d e s i g n i n g t h e p r o b l e m solver a n d i n c o r p o r a t i n g c o n s t r a i n t s . I n cont r a s t w i t h K I D S , R I C K designs t h e p r o b l e m solver b y r e f i n i n g t h e p r o b l e m d e s c r i p t i o n i n t o a c o r r e c t data repr e s e n t a t i o n (i.e., a r e p r e s e n t a t i o n of the generated solut i o n ) r a t h e r t h a n c h o o s i n g t h e p r o p e r procedural r e p r e s e n t a t i o n for the p r o b l e m . By using a least c o m m i t m e n t a p p r o a c h f o r r e p r e s e n t a t i o n s e l e c t i o n , R I C K decouples t h e issues o f i n c o r p o r a t i n g c o n s t r a i n t s a n d r e p r e s e n t i n g generated solutions. D i f f i c u l t i e s i n d e s i g n i n g a r e p r e s e n t a t i o n . Exp r e s s e d i n t e r m s o f a particular s o l u t i o n r e p r e s e n t a t i o n , s o m e c o n s t r a i n t s are local c o n s t r a i n i n g r e l a t i v e l y s m a l l portions of the entire solution, while others may be global c o n s t r a i n i n g t h e e n t i r e s o l u t i o n o r i n t e r r e l a t i n g several parts of the s o l u t i o n . T h e r e f o r e , whether a conT h e C A S E s t a t e m e n t defines a c o n d i t i o n a l generator range t h a t depends on the value of H S . [A B] is the gene r a t i o n sequence f r o m A to B, i n c r e m e n t e d by 1.
straint is local or global is a function of the solution representation. To incorporate as many constraints as possible i n t o a more constrained problem solver, R I C K must use a representation which maximizes the number of local constraints (the type of constraints R I C K can incorporate d u r i n g compilation). However, the odds are that no single representation language exists in which all the constraints are local. In other words, not all problem constraints can be incorporated using the method described in this paper. A n o t h e r research effort w i t h i n the K B S D E project [Voigt, 1989] focuses on the problem of procedurally embedding the "left over" (unincorporated) global constraints. O t h e r w o r k . Other related work includes the discussion by Steier and K a n t [1985] on "developmental evaluat i o n " , a framework which could be said to include our abstract, symbolic simulation approach; Cohen's program [1986], w h i c h translates a declarative specification i n t o a generate-and-test a l g o r i t h m ; and Van Baalen's program [1988], which iteratively designs useful, analogical problem representations (for solving verbal reasoning problems such as those found on college admissions tests) b u i l t f r o m a l i b r a r y of standard data structures.
6
Conclusions
Complete incorporation of a constraint i n t o a generator is a difficult task, especially when the constraint (expressed in terms of the generated parameters) has a structure t h a t is not factorable into constraints on the i n d i v i d u a l parameter generators. This paper has described and illustrated the results of the R I C K program which avoids this structure mismatch problem by viewing problem constraints as generators of partial solutions. R I C K incorporates a problem constraint by refining it i n t o a generator of p a r t i a l solutions t h a t are guaranteed to satisfy the constraint. These partial sol u t i o n generators are then merged i n t o a single abstract generator. D u r i n g merging, interactions between partial solution generators are resolved by " s i m u l a t i n g " the generators and caching only those generated combinations of values that are proven to be consistent. Since the constraints are fully incorporated i n t o the merged generator, further refinement of the merged generator i n t o a complete generator of p r i m i t i v e parameters w i l l not create a structure mismatch problem. R I C K produces problem solvers t h a t solve parameter instantiation problems for design domains. Thus, R I C K incorporates constraints defining structural relationships, but does not currently incorporate constraints t h a t restrict I / O behavior, or specify o p t i m i z a t i o n criteria. In particular, R I C K currently incorporates local constraints that are linear, algebraic constraints on composite objects. Further work w i l l a t t e m p t to extend the type of constraints t h a t R I C K can incorporate, and to extend the s t r u c t u r a l representation of the hierarchical solution. This includes generalizing R I C K to handle a hierarchical solution containing m u l t i p l e objects and necessary constraints on m u l t i p l e objects (i.e., some global constraints). Experiments are being conducted to test whether R I C K is insensitive to changes in the object hierarchy representation and constraint predicate defini-
tions. The goal of this study is to determine the power and generality of this approach to a l g o r i t h m synthesis.
Acknowledgements We would like to thank the members of the K B S D E group and the Knowledge Compilation Seminar. We are also grateful to the members of the Rutgers A I / D e s i g n Project for the stimulating environment they provide.
References [Braudaway, 1988] W. Braudaway. Constraint incorporation using constrained reformulation. Technical report LCSR-TR-100, Dept. of Computer Science, Rutgers Univ., A p r i l 1988. thesis proposal. [Cohen, 1986] D. Cohen. A u t o m a t i c compilation of logical specifications into efficient programs. In Proc. of AAAI-86, pages 20-25, Philadelphia, PA., August 1986. A A A I . [Dietterich and Bennett, 1986] T. Dietterich and J. Bennett. The test incorporation theory of problem solving (preliminary report). In Proceedings of the Workshop on Knowledge Compilation, pages 145-161, Oregon State Univ., September 1986. A A A I , Oregon State Univ. [Dietterich (ed.), 1986] T. Dietterich (ed.). In Proceedings of the Workshop on Knowledge Compilation. A A A I , Oregon State Univ., September 1986. [Korf, 1980] R. Korf. Toward a model of representation changes. Artificial Intelligence, 1 4 ( l ) : 4 1 - 7 8 , 1980. [Mostow, 1988] J. Mostow. A preliminary report on diogenes: Progress towards semi-automatic design of specialized heuristic search algorithms. In Proceedings of the Workshop on Automated Software Design, St. Paul, M N . , August 1988. A A A I . [Smith, 1988] D. S m i t h . Kids: a knowledge-based software development system. In Proceedings of the Workshop on Automated Software Design, St. Paul, M N . , August 1988. A A A I . [Steier and K a n t , 1985] D. Steier and E. K a n t . The roles of execution and analysis in algorithm design. IEEE Transactions on Software Engineering, SE11(11):1375-1386, November 1985. [Tappel, 1980] S. Tappel. Some algorithm design methods. In Proc. of AAAI-80, pages 64-67, Stanford Univ., August 1980. A A A I . [Tong, 1986] C. Tong. K B S D E : An environment for developing knowledge-based design tools. In T. Dietterich, editor, Proceedings of the Workshop on Knowledge Compilation, pages 127-138, Oregon State Univ., September 1986. [Van Baalen, 1988] J. Van Baalen. Overview of an approach to representation design. In Proc. of the AAAI-88, pages 392-397, St. Paul, M N . , August 1988. AAAI. [Voigt, 1989] K. Voigt. A u t o m a t i n g the construction of patchers t h a t satisfy global constraints. In Proc. of IJCAI-89, Detroit, M L , August 1989.
Braudaway and Tong
589