Re: [eclipse-clp-users] Defining domains for IntegerSet variables

From: Joachim Schimpf (Independent Contractor) <jschimpf_at_...5...>
Date: Tue, 03 Jun 2008 20:01:27 +0100
Patrice Boizumault wrote:
> Hie, 
> 
> We would like to use IntegerSet variables whose initial domains
> are not a single interval, but a UNION of intervals. 
> 
> Example : X1 :: [1,2]..[1,2,5,7] op [2]..[2,4,7] op [3,6]..[3,4,6,7] 
> 
> where op represents the union of 2 Sets of IntegerSets. 
> 
> Is there a simple way to state this in ECLiPSe, since union
> is defined for IntegerSets but not for Sets of IntegerSets ?
> (and we don't want to have to enumerate each of the intervals) 

Compute the union of the lower bounds and the union of the upper bounds
and then create the variable:

?- all_union([[1, 2], [2], [3, 6]], L),
    all_union([[1, 2, 5, 7], [2, 4, 7], [3, 4, 6, 7]], H),
    U :: L .. H.

L = [1, 2, 3, 6]
H = [1, 2, 3, 4, 5, 6, 7]
U = U{[1, 2, 3, 6] \/ ([] .. [4, 5, 7]) : _2702{4 .. 7}}
Yes (0.00s cpu)


You could also create N auxiliary variables and union those, but that
leaves an all_union constraint which you don't need:

?- X :: [1, 2] .. [1, 2, 5, 7],
    Y :: [2] .. [2, 4, 7],
    Z :: [3, 6] .. [3, 4, 6, 7],
    all_union([X, Y, Z], U).

X = X{[1, 2] \/ ([] .. [5, 7]) : _613{2 .. 4}}
Y = Y{[2] \/ ([] .. [4, 7]) : _736{1 .. 3}}
Z = Z{[3, 6] \/ ([] .. [4, 7]) : _864{2 .. 4}}
U = U{[1, 2, 3, 6] \/ ([] .. [4, 5, 7]) : _1342{4 .. 7}}
There are 12 delayed goals.
Yes (0.02s cpu)


-- Joachim
Received on Tue Jun 03 2008 - 12:01:41 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST