Dear Mark,
Regarding the point A, the simplest solution is to use FS.card. It links a
set S to its cardinality N. The nice thing is that N is an FD variable in
general. You can thus put any domain restriction on the cardinality N.
See the following example. Feed it to the compiler paragraph by paragraph.
It creates a set S with maximum five elements, and cardinality N. It then
constrains N to the domain [0 4#6], which represents the set {0, 4, 5, 6}.
The last two statements reduces the cardinality of S below 4, which
constrain N to 0 (its only possible value), which itself constrain S to the
empty set.
% constraining the cardinality of a set
declare
S={FS.var.upperBound 1#5}
N={FS.card S}
{Inspect S} {Inspect N}
N::[0 4#6] % constrain the cardinality to be either 0, or between 4 and
6
{FS.exclude 1 S}
{FS.exclude 2 S} % => S must be empty
Regarding point B, I suggest you to have a look at reified propagators
(Section 7.6 of documentation of module FS), or iterators like FS.forAllIn
(Section 7.7). It might be more efficient to consider the union of all sets
in the list (with FS.unionN), and to use reification on that union to
implement the condition.
Cheers,
Raphael
On Mon, Dec 21, 2009 at 6:02 PM, mark richardson <[email protected]>wrote:
> Hi,
>
> I have a problem model where a list of FD integers is linked to a list
> of FS's. I need to express that:
>
> In the list FD1#FS1..FDn#FSn,
> A) Cardinality of FS1..n (if non-empty) must be between minimum and
> maximum boundaries. Otherwise the set must be empty. In effect what I'm
> trying to achieve is (I think) {Or {FS.cardRange Min Max <set>} {FS.card
> <set> 0}}. I know from trying this that it doesn't seem to be possible
> to use such a construct within a solution script.
> B) If a set is non-empty, then for every 'x' in the set, the cardinality
> of the set corresponding to the item of the list where FDn==x is zero.
> In other words if I had as one item of the list 3#{4 8 12} then the list
> would also contain 4#{} 8#{} 12#{}. Ie 4, 8 and 12 must be mapped to
> empty sets.
>
> I have a feeling that this way of modelling my problem is just
> impossible but I would appreciate comments from anyone before I scrap
> the whole thing and start again.
>
> Regards
>
> Mark R
>
> --
> Mark Richardson MBCS
> Research Assistant
> University of Teesside, UK
> Email: [email protected]
> [email protected]
> Skype: mark.richardson.
>
>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users