4.4 Implementation

In this section, we present the Oz functor Dominance (see Section A.6) implementing a solver as described in the preceding section. It exports solutionPredicate which can be used as follows:

{ExploreAll {Dominance.solutionPredicate Desc}}

where Desc is a tree description in the form of a list where each element is of one of the forms described below:

dom(X R Y)

where X and Y are both atoms naming variables, and R is an atom or list of atoms from the set eq, above, below, side.

lab(X f(X1 ... Xn))

where X and Xi are atoms naming variables.

labeled(X)

where X is an atom naming a variable. This is a new constraint not mentioned in our abstract syntax but very convenient in practice: it simply states that X must be identified with some variable that is explicitly labeled in the input description.

<Dominance.oz>=
functor 
import FD FS
export SolutionPredicate
define 
   
<Dominance: SolutionPredicate> 
   
<Dominance: MakeNode> 
   
<Dominance: characteristic constraints> 
   
<Dominance: well-formedness clauses> 
   
<Dominance: Solver class> 
   
<Dominance: utilities> 
end

SolutionPredicate takes a tree description as argument and returns a procedure appropriate for encapsulated search. This procedure creates a solver object. This object is only needed for converting the description into constraints and starting the search.

<Dominance: SolutionPredicate>=
fun {SolutionPredicate Desc}
   proc {$ Info}
      {New Solver init(Desc Info) _}
   end 
end



Denys Duchier
Version 1.2.0 (20010221)