How to work List and Array together on QAP

From: Sirirat Muenvanichakul <muenvanichakul.siriat_at_cwru.edu>
Date: Tue 06 Apr 2004 05:02:32 AM GMT
Message-id: <404402403bd4.403bd4404402@cwru.edu>
Dear,

I'm struck and I'd like to ask you a suggestion on my program. This program is regarding quadratic assignment problem (QAP), which mathematical model as followed. 

Min  F(i,k) * D(Yi,Yk)
St.   alldifferent(Y1,Y2,...,Yn)

The codes of this problem, which n is 4, are as below 

:- lib(fd).
:- lib(branch_and_bound).
main(N,Cost,Layouts):-
    length(Layouts, N),
    Layouts :: 1..N,
    alldifferent(Layouts),    
    D=[]([] ( 0, 5, 7, 4), 
        [] ( 8, 0, 5, 10),
        [] ( 4, 5, 0, 8),
        [] ( 2, 3, 7, 0)),
    F=[]( [] ( 0, 10, 7, 11), 
        [] ( 8, 0, 5, 10),
        [] ( 5, 5, 0, 8),
        [] ( 9, 3, 7, 0)),

    (for(I, 1, 4), fromto(0, In1, Out2, Objective), 
        param(D, F, Layouts, K)
    do 
        (for(K,1,4), fromto(In1, In2, C+In2, Out2),
            param(D, F, Layouts,I)
        do 
            element(I,Layouts,X),
            element(K,Layouts,Y),
            C #= F[I,K] * D[X,Y]
    )
),
Cost #= Objective,
min_max(labeling(Layouts),Cost).


After compiling, the error message is "instantiation fault in element(1, [_13534........", 
but it was all right if the last line was moved out. 

Is there another way to code? 
A different between F[I,K] and D[X,Y]: F[I,K] is an array, but D[X,Y] is a list. 
I don't know how to call out any elements of list.
Could you please suggest me. 

Thank you very much for your answer
Sirirat. 
Received on Tue Apr 06 06:08:50 2004

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