• Aucun résultat trouvé

UTIL propagation using CDDs

5.2 H-DPOP - Pruning the search space with hard constraints

5.2.1 UTIL propagation using CDDs

This phase is similar to the UTIL phase of DPOP, with the difference that the extensional representa-tions of UTIL messages from DPOP (hypercubes) are replaced with CDD messages and the associated utility vectors. The JOIN and PROJECT operators on hypercubes are redefined in the following for CDD messages.

5.2.1.1 Building CDDs from constraints:

Algorithm5describes the construction of CDDTree corresponding to the Hypercube with dimension setDim[dimSize]. Cis the partial assignment currently found to lead to a valid solution. Whenever a new domain value is added toC, a consistency check is performed in line 6 to see if the newly instantiated domain value will lead to a solution. This is a key step in pruning the search space as

Algorithm 5Construction of a CDDtree ProcedureConstructCDD

input :Dim[dimSize],C[dimSize],currentLevel output : The root of the CDDTree

1 ifdimSize == 0||currentLevel == dimSizethen returnnull

2 Xk=node at currentLevel,Dk=Xk.domain

3 S=∅,Dk=∅

4 foralld∈Dkdo

5 C[currentLevel] =d

6 ifisConsistent(C,currentLevel)== truethen

7 u=ConstructCDD(Dim,C,currentLevel+ 1)

8 ifu==null||(u=null ∩ u= 0)then

9 S=S∪ {< d, u >}

10 Dk =Dk∪ {d}

11 ifDk =∅then return0

12 v=mkNode(Xk,S,Dk)

13 returnv

ProceduremkNode

input :Xk,S,DkwhereXk= variable, S=children,Dk= valid values

output : A CDDNode corrresponding to variableXkwith given domain and children set

14 v={(Xk∈r, u) :d, d∈r⇐⇒< d, u >, < d, u >∈S}

//i.e. Xk→d and Xk→dpoint to same node u

15 ifhtable.get(v.hashKey())==nullthen

16 htable.add(v.hashKey(), v)//htable contains all discovered nodes

17 returnv else

//i.e. ∃v s.t. v≡v

18 returnv

(a) Hypercube Join (b) CDDMessage join

Figure 5.2:H-DPOP: comparative view of joining hypercubes vs. joining CDDs

inconsistent combinations are ruled out via this check. ParametercurrentLevel denotes the current level in CDDTree under exploration. Its initial value is zero denoting the CDDroot.

The procedureConstructCDDis based on a depth-first backtrack search algorithm (see [34]).

SetS(initially empty) consists of the branches of the CDDNode, andDkconsists of values of variable Xkwhich can lead to valid combinations. Next, for each value in the domain ofXk(=Dk), we check if it can lead to a feasible solution (line 6). If no, it is ruled out otherwise we recursively invoke ConstructCDDto find the CDDNodeufor the next level (currentlevel+1, line 7). Ifuis a 1-terminal (null node) or is not a 0-terminal , we add the branch (d,u) toS, and insert d toDk(lines 8 to 10). If Dk =∅after all iterations are over, a 0-terminal is returned. Otherwise,mkNodeis called to return the CDDNode for the current variable with given children and domain set (SandDkrespectively).

ProceduremkNodeis shown in algorithm5. In line 14, an intermediate nodevis created such that for everyd∈r,Xk→dleads to the same child nodeu. Next we check if an equivalent nodevexists for nodevto satisfy property (2) of a reduced CDD (line 15). If an equivalent node exists we reuse that node otherwise insertvtoVand returnv(line 17).

5.2.1.2 Implementing the JOIN operator on CDD messages

In Algorithm6we describe the method for combining two CDD messages. The extra parameter leafDi-mensionspecifies which variable should be placed at the leaf level in the resulting combined CDDTree

(line 2). Each node places itself as theleafDimensionwhile combining CDD messages from its chil-dren. This is an optimization which ensures that each node can project itself out of the resulting CDD message very efficiently (see functionprojectMine, algorithm7) before sending the message to its parent. The union of dimensions of combining messages forms the dimensions of combined message (line 1). With this new set of dimensions, a new CDD message is constructed with an empty UtilAr-ray. The for loop in line 5 iterates over all the paths of the newly formed CDDTree, finds the relevant contributions from individual CDD messages (functionfindUtil, line 7), and sets the utility of the current path in the combined message (line 9). Finally, the combined CDD message is returned after setting the utility of each path. Figure5.2shows the join of hypercubes and CDDs.

The procedurefindUtil(algorithm6) returns the utility value corresponding to CDDMessage’s local contribution for the input source path with the specified set of dimensionsunionDim. The Array myPathstores the local contribution of the CDDMessage to inputsrcPath. It is initialized with values fromsrcPathfor the corresponding dimensions inmyDimandunionDim(line 13). The utility value for myPathis extracted fromUtilArrayby finding the index of this path (line 14). To increase performance, each CDDMessage hashes every path of its CDDTree with value as path index and key as the path itself.

5.2.1.3 Implementing the PROJECT operator on CDD messages

ProcedureprojectMine(algorithm7) is used by a node to project out its own dimension after it has joined the UTIL messages from its children and the relations with its parent/pseudo parents. Since thecombineCDDMessagesfunction places the dimension of the current node as the leaf level of CDDTree, projecting out the current node is very efficient: we iterate through all the paths (line 2) and choose the best utility among paths having the same prefix, except for the leaf level (line 7). We also need to reconstruct the CDD message and initialize the utility array after the projection operation to keep the CDD size optimal. Finally the newly formed CDDMessage is returned to be sent to the parent of the current node.

5.2.1.4 TheisConsistentplug-in mechanism

TheisConsistent(see algorithm5, line 6) function is like a gateway to the constraint problem being solved and uses hard constraint propagation for pruning the search space. Until now existing DCOP algorithms like ADOPT or DPOP did not try to take advantage of domain specific knowledge while solving a particular DCOP instance. H-DPOP is unique in this sense as it provides the constraint optimization algorithm with knowledge about the problem domain through this modular plug-in mech-anism. Our results show that this knowledge can help reducing the size of the UTIL messages by up to 99%. This function is problem-specific and encapsulates the pruning logic into the H-DPOP algorithm.

The input to this function is the constraint arrayC, which is a partial assignment. The function then processes this input using hard constraint propagation and determines ifCrepresents a feasible

combi-Algorithm 6Combining two CDDMessages: JOIN operation ProcedurecombineCDDMessages

input :Msg1,Msg2,leafDimension

output : Combined CDDMessage of Msg1 and Msg2 begin

1 Dim[]union=M sg1.DimensionArray∪M sg2.DimensionArray

2 Rearrangeunionarray to makeleaf Dimensionas the last one

3 CDDRoot=ConstructCDD(union, new Array(union.length), 0)∩each path∈ {M sg1∪M sg2}

4 combinedMsg= newCDDMessage(CDDRoot, union, CDDRoot.pathsCount) //pathsCount represents total paths from root to leaves end

5foreachpath of CDDTree with root = CDDRoot do

6 path= current path under consideration

7 util1= Msg1.findUtil(union, path)

8 util2= Msg2.findUtil(union, path)

9 combinedMsg.setUtility(util1+util2, path.index)

10returncombinedMsg ProcedurefindUtil input :unionDim,srcPath

output : The utility value corresponding to local contribution tosrcPath

11myDim = this.DimensionArray

12InitializemyPath= new Vector(myDim.length)

13myPath=

<(di=srcP ath[j])>: i∈[0, myDim.length]∩ ∃j s.t. srcDim[j].id=myDim[i].id

14index= htable.getvalueByKey(myPath)

15returnthis.UtilArray[index]

Algorithm 7PROJECT operation for a CDDMessage

ProcedureprojectMine: projects out the last dimension of this CDDMessage output : returns the new CDDMessage

1 InitializeBestUtilities= new Vector()

2 foreachpath of CDDTree of this CDDMessagedo

3 path = currentPath under consideration

4 pathPrefix = path.prefix(0, path.size-1)

5 ifutility already set for pathPrefixthen

6 continue

else

7 util=

M ax(Pi.util:Pi.prefix(0,Pi.size−1)=pathP ref ix∩Pi∈ {paths of CDDT ree})

8 BestUtilities.set(util, pathPrefix)

9InitializenewDim[]to this.DimensionArray[0] to [totalSize-1]

10 newT ree=constructCDD(newDim, new Array(newDim.length), 0)

11 newM sg= newCDDMessage(newTree.root, newDim, newTree.pathsCount)

12 InitializenewM sg.UtilArray fromBestU tilities

13 returnnewMsg

nation. For the server problem described in Section5.1,isConsistentsimply returnsfalsefor all partial assignments where several variables take the same value, because the hard constraints do not allow this.

Procedure 7isConsistent(C, currentIndex) output : true if C is valid, false otherwise fori= 0tocurrentIndex−1 do

ifC[i] ==C[currentIndex]then returnfalse returntrue

The next section discusses the relationship between H-DPOP and search algorithms.