# Is it a bug?

From: Anthony Karageorgos <mcaihak2_at_co.umist.ac.uk>
Date: Mon 24 Sep 2001 06:29:22 PM GMT
Message-ID: <BJEEIOCFNNCBEMBPJNENOEJKCHAA.mcaihak2@co.umist.ac.uk>
```Hi all,

I am trying to use ECliPSe to create a list of (not known in advance) number
of pairs [Ai,Bi] of subsets of an integer set RL as follows:

1. Get a subset A1 of a RL.
2. Get a subset B1of A1
3. Get the difference D of RL and A1.
4 if D <> [] then go to step 1 else finish

I have written two ECLiPSe predicates to test the above approach..

a) btest /2 to give me the first pair [A1,B1] and the remaining difference
D.

b) dtest /1 to give me a number of pairs created such that the list RL is
now empty.

Executing :- btest(PL,D). gives me indeed the results of the first step  If
I ask for more results, backtracking gives me correct results until I get
all possible solutions

Executing :- dtest(PL). gives me initially correct results. However, If I
ask for more solutions backtracking gives me only part of the solutions I
would expect.

Is it a bug, or I am doing something wrong? Could I do that for arbitrary
sets and not only for integer sets?

Thanks a lot.

Anthony

%---------------------------------------------------------------------------
-----------------------------------------
:- lib(fd_global).
:- lib(fd_sets).
:- lib(fd).

%-----------------------------------------
% After executing :-dtest(PL) I would expect solutions of the form:
% PL=[[A1,B1],[A2,B2],...[An,Bn]] where all A sets must be disjoint and
their union must be equal to RL.
%                                              and all B sets must be
subsets of the respective A sets.
% e.g.
% PL = [[[1,2,3,4,5],[1,2,3]]]
% PL = [[[1,2,3,],[2,3]],[[4,5],[4]]] etc
%-----------------------------------------

% -----------------------------------
% this example works (if I ask for more solutions I get all the solution
set)
% -----------------------------------
btest([Has,Plays],Rnew) :-
RL = [1,2,3,4,5],
alloc_role_set([Has,Plays],RL),
subtr_role_set(RL,[Has,Plays],Rnew),
insetdomain(Has,decreasing,small_first,in_notin),
insetdomain(Plays,decreasing,small_first,in_notin).

% ----------------------------------------------------------------------
% this example returns only part of the solutions
% ----------------------------------------------------------------------

dtest(X) :-
RL = [1,2,3,4,5],
ctest(RL,X),
label(X).

label([]).
label([[A,B]|X]) :-
insetdomain(A,decreasing,small_first,_),
insetdomain(B,decreasing,small_first,_),
label(X).

ctest([],[]).
ctest(RL,[[Has,Plays]|Agent]) :-
alloc_role_set([Has,Plays],RL),
subtr_role_set(RL,[Has,Plays],Rnew),
ctest(Rnew,Agent).

alloc_role_set([Has,Plays],RL) :-
minlist(RL,RLmin),
maxlist(RL,RLmax),
intset(Has,RLmin,RLmax),
intset(Plays,RLmin,RLmax),
Has includes Plays.               % All B sets must be subsets of the
respective A sets.

subtr_role_set(RL,[Has,_],Rnew) :-
difference(RL,Has,Rnew).

%---------------------------------------------------------------------------
-----------------------------------------

Anthony Karageorgos

Room L14
Dept. of Computation
UMIST
Manchester M60 1QD
UK

tel. +44-161-2003306
fax. +44-161-2003324

e-mail: mcaihak2@co.umist.ac.uk
```
Received on Mon Sep 24 19:32:52 2001

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:09 PM GMT GMT