Re: Re: Re: Reading a file and converting the input to integers...

From: Andrew Eremin <a.eremin_at_icparc.ic.ac.uk>
Date: Thu 21 Oct 2004 10:29:25 AM GMT
Message-ID: <41778F85.7090602@icparc.ic.ac.uk>
Mark A. Hennessy wrote:
>   Thank you for your input. This now works fine. Now that I have the 
> data I have run into a problem of dynamically setting up the domains of 
> the variables. My code is as follows:
> 
> % Setup the Quasigroups With Holes Problem
> qwh_setup(Order,Holes,LatinSquare) :-
>   NumVars is Order * Order,
>   dim(LatinSquare, [NumVars]),
>   get_qwh(Order,Holes,IntegerDomains),
>   writeln(IntegerDomains),
>   (for(I,1,NumVars), param(Order) do
>       (Domain == -1 ->
>           LatinSquare[I] :: 1..Order
>        ;
>           LatinSquare[I] :: Domain..Domain
>       )
>   ),
>   writeln(LatinSquare).
> 
> When I try to do this I get the following error:
> 
> instantiation fault in LatinSquare[1] :: Domain .. Domain

I suspect you probably want something like:

   (for(I,1,NumVars),
    foreach(Domain, IntegerDomains),
    param(LatinSquare, Order) do
       (Domain == -1 ->
           LatinSquare[I] :: 1..Order
        ;
           LatinSquare[I] :: Domain..Domain
       )
   ),

CXurrently both Domain and LatinSquare are free variables within the loop.

-- 
Andrew Eremin
Research Assistant                   Tel: +44 (0)20 7594 8299
IC-Parc, Imperial College London     Fax: +44 (0)20 7594 8432
London SW7 2AZ                       Email: a.eremin@icparc.ic.ac.uk
Received on Thu Oct 21 11:30:45 2004

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