Re: [eclipse-clp-users] Combining lib(cardinal) and lib(fd)

From: Joachim Schimpf <joachim.schimpf_at_infotech.monash.edu.au>
Date: Tue, 20 Apr 2010 15:44:19 +1000
Philipp Marcus wrote:
> Hi,
> 
> I want to write a constraint like this (using propia, cardinal and fd):
> 
>     N `:: [] + [ ["B","F"], ["S"], ["S","F"] ]:[1],
>     A in N,
>     member("S",A) infers most
> 
> i.e. the set N can be either ["B","F"], ["S"] or ["S","F"]

If I understand correctly, you want to have a set of sets.  I'm not
intimately familiar with lib(cardinal) (it's a contributed library),
but it seems to support this, at least to some extent.

The following code works:

?- N `:: [] + [['B', 'F'], ['S'], ['F', 'S']] : [1],
   A `:: [] .. ['B', 'F', 'S'],
   A in N,
   'S' in A,
   set_labeling([N]).

N = [['F', 'S']]
A = ['F', 'S']
Yes (0.00s cpu, solution 1, maybe more)
N = [['S']]
A = ['S']
Yes (0.00s cpu, solution 2)


Notes:
1. I have used atoms 'S' instead of strings "S" as per my earlier advice.
2. lib(cardinal) does not currently work with propia, because it does not
define an msg/3 generalisation predicate. If someone wants to add this,
please refer to e.g. sd.ecl for an example.


-- Joachim
Received on Tue Apr 20 2010 - 05:42:46 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET