RE: Lists

From: Stefano Novello <Stefano-N_at_parc-technologies.com>
Date: Fri 02 Mar 2001 06:46:15 PM GMT
Message-ID: <0B9686DD2E83D411B67200508B9A9DA205AD6A@LON-SRV2>
Hello Farouk,

(Cond -> ThenPart ; ElsePart)
is standard if then else, rather than an implication constraint,
so Cond should contain only things that are guaranteed to fail or
succeed immediately
rather than leaving constraints around.
2 - possible suggestions.

A)
Use reified constraints from fd:
e.g.
	B isd (V1 + V3 + V7 + V8 #<= 1 #/\ V2 + V4 + V5 + V6 #<= 1
You would need to 
modify all the subsequent constraints to take into account B.
B is 0 or 1 or [0,1] depending on the condition.
e.g.
X #= V5*C1j + V6*C2j + V7*C3j + V8*C4j + Cj
C0j #= X + (1-B)*Ci

B)
Look at chrs again. The condition could go in the guard of the chr.

regards,
Stefano Novello
 

-----Original Message-----
From: owner-eclipse-users@icparc.ic.ac.uk
[mailto:owner-eclipse-users@icparc.ic.ac.uk]On Behalf Of FAROUK AMINU
Sent: 02 March 2001 15:33
To: Warwick Harvey
Cc: fruehwir@informatik.uni-muenchen.de; FAROUK AMINU;
eclipse-users@icparc.ic.ac.uk
Subject: Re: [eclipse-users] Lists


>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 18:47:23 2001

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