## 7.9 Distribution

Given a set M, let and denote the greatest lower bound and the least upper bound currently known for M. Also define .

`distribute`

  > > `{FS.distribute +Dist *Ms}`

  The vector `Ms` is distributed according to the specification `Dist`. The following values for `Dist` are supported:

  - `naive` is equivalent to `generic`, i. e. the default settings apply.

  - > `generic(order: +Order <= order
    > filter: +Filter <= true
    > select: +Select <= id
    > element: +Element <= element
    > rrobin: +RRobin <= false
    > weights: +Weights <= {FS.makeWeights nil}
    > procedure:+Proc <= proc {$} skip end)`

    - `Order`

      - `naive` selects the left-most variable.

      - > `order(sel: +Sel <= min
        > cost: +Cost <= card
        > comp: +Comp <= unknown)`

        - `Sel = min` selects the left-most variable `S` from `Ss` with the minimal cost according to `Cost`.

        - `Sel = max` selects the left-most variable `S` from `Ss` with the maximal cost according to `Cost`.

        - `Cost = card`: The cost is the cardinality of the set determined by `Comp`.

        - `Cost = weightSum`: The cost is the sum of the weights associated with the elements of the set determined by `Comp`.

        - `Cost = weightMin`: The cost is the minimal weight determined by `Comp`.

        - `Cost = weightMax`: The cost is the maximal weight associated with an element of the set determined by `Comp`.

        - `Comp = unknown` selects .

        - `Comp = lowerBound` selects .

        - `Comp = upperBound` selects .

      - > `fun {Order +Ss} ... end`

    - `Filter` determines if an element `S` of `Ss` is choosen for distribution. That is the case if `{IsDet S`} and the filter yields `true`.

      - `true` skips values in `Ss`.

      - > `fun {Filter +E} ... end`

    - `Select` is used to access the actual finite set variable. Self-defined functions resp. procedures have to apply an appropriate selection function by themselves.

      - `id` is the identity function.

      - > `fun {Select +E} ... end`

    - `Element`

      - > `element(sel: +Sel <= min
        > wrt: +Wrt <= unknown)`

        - `Sel = min` selects the minimal element with respect to `Wrt`.

        - `Sel = max` selects the maximal element with respect to `Wrt`.

        - `Wrt = unknown` chooses an element from . and interprets it as an integer.

        - `Wrt = weight` chooses an element from and takes its weight as selection criterion.

      - > `fun {Element +E} ... end`

    - `RRobin`

      - `true` causes the distribution to step through the variable list in a round-robin fashion.

      - `false` causes the distribution to completely enumerate the head of the variable list and then proceeds with the head of the tail of the variable list.

    - `Weights` must be a list of the form `[E#W ...]`. The variable `E` denotes an element and `W` the element's weight. An list element of the form `default#W` assigns to all not explicitely mentioned elements the weight `W`. If there is no element `default#W` then `default#0` is implicitely added.

    - `Proc` is applied when stability is reached. Since this application may cause instability, distribution is continued when stability is reached again.