Re: knapsack_random_search

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Wed 04 Feb 2004 02:08:04 PM GMT
Message-ID: <4020FCC4.1010602@icparc.ic.ac.uk>
Martina Stuber wrote:
> Hello,
> 
> I have a big problem, but I think it is quite simple. I just want to run the
> knapsack example with random search. But I don`t succeed give over the
> knapsack_data. How must I call the programm, to tell him the right instance?
> The call is:
> knap(rw, Instance, Cost) :- knap_rw(Instance, 1000, Cost).
> 
> How can I declare the instance and how can I give over the data?
> It would be fine,if someone could help me.
> 
> Kind regards,
>                         Martina Stuber.
> 
> 
> 


The first argument to knap_rw/3 is the id of the data set, the sample data
is simply numbered from 1 to 100.  To run data set 23:

?- knap_rw(23, 1000, Cost).
Found solution with profit 164
Found solution with profit 166
Found solution with profit 201
Found solution with profit 219
Found solution with profit 235
Found solution with profit 254
Found solution with profit 256
Found solution with profit 257
Found solution with profit 264
Found solution with profit 274
Cost = 274
There are 64 delayed goals.
Yes (0.28s cpu)


You can add your own data sets by adding facts for knapsack_data/5
at the end of the file. The first argument is the id for the data set:
knapsack_data(Id, N, Profits, Weights, Capacity).


-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Wed Feb 04 14:09:40 2004

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