## 9.2 A Domain-Splitting Distributor

In this section we program a distributor for the domain-splitting strategy (see *). The program is shown in Figure 9.2.

  `proc {SplitDistributor Is}
  {Space.waitStable}
  local
  Fs={Filter Is fun {$ I} {FD.reflect.size I}>1 end}
  in
  case Fs
  of nil then skip
  [] F|Fr then
  MinVar#_ = {FoldL Fr fun {$ Var#Size X}
  if {FD.reflect.size X}<Size then
  X#{FD.reflect.size X}
  else
  Var#Size
  end
  end F#{FD.reflect.size F}}
  Mid = {FD.reflect.mid MinVar}
  in
  choice MinVar =<: Mid {SplitDistributor Fs}
  [] MinVar >: Mid {SplitDistributor Fs}
  end
  end
  end
  end`

Figure 9.2: A distributor for a domain-splitting strategy.

As in the previous section we first discard all determined variables. Then we select the variable `MinVar` which has the smallest domain (as it is done for the first-fail distribution strategy). For the selected variable we determine the value that is in the middle of the least and largest possible value by

> `Mid = {FD.reflect.mid MinVar}`

After this is done we distribute with the constraint that `MinVar` should be smaller than or equal to `Mid`.