Re: [eclipse-clp-users] How to Have all the solution of a problem

From: Alexandre Saidi <Alexandre.Saidi_at_...37...>
Date: Fri, 5 Mar 2010 09:31:30 +0100
Dear Meriem Djefel,

As Kish said, you better use « fail » to have all solutions, rather than the « all solutin » trick (like bagof/setof/..).
Actually, bagof DO things by placing a « fail » in order to force the « retry » .
Bagof/findall/setof then store each solution (by inserting fancy clauses).

Taking a look at the bagof code may tell you much more  (a simple version) :

% want a list of all of the solutions to « Goal » formatted by « Termes » 
bagof(Termes, Goal, List_of_Termes) :- 
	call(Goal),
	put_the_solution_into_the_knowledge_base(Goal), 	%e.g. by assert.
	fail.

bagof(_, _, List_of_Termes) :- 
	gather_solutions_into_a_list(Goal , List_of_Termes). %if any.

Be careful, upon the one (bagof/findall/..) you may use, some fail if there is NO solution, some succeed anyway and return an empty list when there’s no Solution to « Goal » .

Alex

Le 4 mars 2010 à 22:12, Kish Shen a écrit :

> Meriem Djefel wrote:
>> Deal all,
>> I have two questions :
>> 1. I want to how  we can have all the solution of a problem in 
> eclipse without use the command *more *to have the next solution.
> 
> As Christian says, if you want to collect all the solutions, you can use 
>  findall and friends. Note that these copy each solution.
> 
> If all you want is to print all the solutions, you can print a solution, 
> and call fail to force backtracking to get the next solution; this is 
> essentially what 'more' does..
> 
>> 2. I have also an error in my code when I write : VitesseMaxi 
> $::[400,450] in the following constraint :
>> (
>>                    (VitesseMaxi $= 600 , DistanceVol #::[800, 1000], 
> ReservoirSupp #= 300);
>>                    (VitesseMaxi $::[400,450] , DistanceVol #= 1600, 
> ReservoirSupp #= 300);
>>                    (VitesseMaxi $::[400,450] , DistanceVol #= 1400, 
> ReservoirSupp #= 200);
>>                    (VitesseMaxi $= 550 , DistanceVol #:: [800,1000], 
> ReservoirSupp #= 200);
>>                    (VitesseMaxi $= [450,400] , DistanceVol #= 1200, 
> ReservoirSupp #= 100);
>>                    (VitesseMaxi $= 500 , DistanceVol #:: [800,1000], 
> ReservoirSupp #= 100)
>> );
> 
> You didn't say which solver you are using, but you seem to be using ic.
> The '$' variant of constraints (like $::) are for reals, and as the 
> manual says, for reals, you have a real interval, i.e. a single 
> contineous interval, and you cannot set  individual values like 400, 450
> to such an interval (you can do that in a finite domain, where the 
> domain consists of integer values, rather than a contineous interval).
> Why are you using the $ variant of constraints for VitesseMaxi, when you 
> actually assigning integer values to it?
> 
> Cheers,
> 
> Kish
> 
> 
> -- 
> This e-mail may contain confidential and privileged material for the
> sole use of the intended recipient. Any review, use, distribution or
> disclosure by others is strictly prohibited. If you are not the intended
> recipient (or authorized to receive for the recipient), please contact
> the sender by reply e-mail and delete all copies of this message.
> Cisco Systems Limited (Company Number: 02558939), is registered in
> England and Wales with its registered office at 1 Callaghan Square,
> Cardiff, South Glamorgan CF10 5BT.
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users

 -------------------------------
Alexandre Saidi
Maitre de Conférences
Ecole Centrale de Lyon-Dép. MI
LIRIS-CNRS UMR 5205
Tél : 0472186530, Fax : 0472186443
Received on Fri Mar 05 2010 - 08:49:52 CET

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST