# Re: Lists

From: FAROUK AMINU <f.aminu_at_lancaster.ac.uk>
Date: Fri 02 Mar 2001 03:33:22 PM GMT
Message-ID: <Pine.GSO.4.21.0103021509530.8746-100000@unixc.lancs.ac.uk>
```>Anyway, Farouk, what was it you were trying to do which led you to
>believe that nesting lists was not possible?

Dear Dr. Warwick,

Actually, I have written a simple predicate to compute some values for me
but depending on some binary variables. In effect I have about 32 binary
variables and the predicate I used is given below:

trial_cost([],[],[],[],[],[],[]).

trial_cost([V1,V2,V3,V4,V5,V6,V7,V8|RestV],[Ci,Cj|RestC],[C0i,C0j|RestC0],

[C1i,C1j|RestC1],[C2i,C2j|RestC2],[C3i,C3j|RestC3],[C4i,C4j|RestC4]):-

V1 + V2 + V3 + V4 #= 1,
V5 + V6 + V7 + V8 #= 1,
C0i #= V1*C1i + V2*C2i + V3*C3i + V4*C4i + Ci,

(V1 + V3 + V7 + V8 #<= 1, V2 + V4 + V5 + V6 #<= 1 ->
C0j #= V5*C1j + V6*C2j + V7*C3j + V8*C4j + Cj;
C0j #= V5*C1j + V6*C2j + V7*C3j + V8*C4j + Cj +Ci),

trial_cost(RestV,RestC,RestC0,RestC1,RestC2,RestC3,RestC4).

When I run the program, the predicate worked but the following constraint
V1 + V3 + V7 + V8 #<= 1, V2 + V4 + V5 + V6 #<= 1 did not seem to be
working the way I wanted. The recursion worked for blocks of eight
variables, but what I thought it might do is to consider next
V5,V6,V7,V8,V9,V10,V11,V12 and implement
V5 + V7 + V11 + V12 #<= 1, V6 + V8 + V9 + V10 #<= 1
and to continue in this way to the end of the 32 binary variables. But as
I said it considered first 8 vars, then next 8, then
next 8, then next 8.

I then thought perhaps I can implement the predicate with the first
argument as a list of lists this might easy the implementation of my
constraint by the predicate. But when I tried to do this it became a bit
difficult because ECLiPSe refused to accept this and hence my question.

Thanking you very much.

With Regards,

Farouk

===============================================================================
UMARU FAROUK AMINU
DEPARTMENT OF MANAGEMENT SCIENCE
LANCASTER UNIVERSITY
LANCASTER
LA1 4YX
U.K.

+44 (0)1524 593865 (School)
+44 (0)1524 383619 (Home)
+44 (0)1524 844885 (Fax)
```
Received on Fri Mar 02 15:34:07 2001

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