20.4 DG_Weight.oz

We now turn to the implementation of the weighted set constraint

<DG_Weight.oz>=
functor 
import FS
export WeightC
define 
   %% the weighted product B*S of boolean B and set S
   %% B*S = {} if B=false
   %% B*S = S  if B=true
   proc {WeightC B S Result}
      {FS.subset Result S}
      B =<: {FS.reified.equal S Result}
      ({FS.card Result}\=:0) =<: B
   end 
end


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)