Re: Using timeout

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Wed 06 Aug 2003 03:29:52 PM GMT
Message-ID: <3F311EF0.6A9B271D@icparc.ic.ac.uk>
Pedro Leite Rocha wrote:
> 
> Hello. I'm new at usinge eclipse, and I have this problem I wanna solve. I
> want my computer to try finding the best solution for 5 hours max, but I'm
> having some trouble with the timeout library. The program I wrote gives me
> the solution in two arrays of two dimensions. I want the program to give
> me the last solution it found. How do I do that?


It depends a bit on what solvers you are using. If you use fd or ic,
the easiest is to use lib(branch_and_bound), which has a timeout option:

:- lib(ic).
:- lib(branch_and_bound).

?- X::0..10000000,
   Cost #= -X,
   bb_min(labeling([X]), Cost, bb_options with [timeout:1]).

Found a solution with cost 0
Found a solution with cost -1
...
Found a solution with cost -247
Branch-and-bound timeout!
X = 247
Cost = -247
Yes (0.58s cpu)

The branch-and-bound procedure bb_min keeps finding better solutions
until the timeout occurs. It then returns the best result so far.


-- 
 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 Aug 06 16:30:40 2003

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