Re: [eclipse-clp-users] saving the resolution list of a call

From: Christian Wirth <tyrion_at_...215...>
Date: Sun, 16 May 2010 17:22:16 +0200
At first, thanks to all your suggestions to this and the backtracking 
question.
I integrated all your ideas and it's already a lot faster ... but not 
fast enough. It now takes a bit more then twice the time of a normal CALL.

Here is my current source code:

%requiered by problem
expand(d_true(X,S),Y,Y) :- !,call(d_true(X,S)).
expand(d_does(P,M,S),X,X) :- !,call(d_does(P,M,S)).
expand((A\=B),X,X) :- !,call(A\=B).

expand((X1;Y1),ResListIn,ResListOut) :- 
!,expand(X1,ResListIn,ResListOut);expand(Y1,ResListIn,ResListOut).    
%OR clauses should not be added                          
expand((X1,Y1),ResListIn,ResListOut) :- 
!,expand(X1,ResListIn,ResListTmp),expand(Y1,ResListTmp,ResListOut).

expand(\+(X1),ResListIn,ResListOut) :- 
!,not(expand(X1,ResListIn,ResListOut)). %negation should not be added

expand(X,ResListIn,[F/A|ResListOut]) :- 
functor(X,F,A),clause(X,C),((C=true)->(ResListOut=ResListIn);(join_string([F,A,"rec"],"/",String1),(containsKey(String1)->(ResListOut=ResListIn,call(X));(expand(C,ResListIn,ResListOut))))).

containsKey(Key) :- clause(logicStorage(Key,_)).

logicStorage is a dynamic predicate and contains all recursive 
predicates. The resolutionlist of those predicates should not be saved.
And ideas how to increase the speed further ? If requiered, i would also 
be willing to make changes to the eclipse source code to have this 
resolution list available.

cheers Christian



Am 14.05.2010 17:56, schrieb Marco Gavanelli:
> Christian Wirth wrote:
>> Hi,
>>
>> i also need to save the resolution list of a call, meaning a list of 
>> all called predicates in the called order (without and/or, but that 
>> could be extracted later).
>>
>> Something like this (only an example, not tested):
>>
>> rescall(true,_) :- !.
>>
>> rescall((A,B),Res) :- rescall(A,Res),rescall(B,Res).
>> rescall((A;B),Res) :- rescall(A,Res);rescall(B,Res).
>>
>> rescall(X,Res) :- 
>> not(booleanfunctor(X)),functor(X,F,A),member(F/A,Res),clause(X,C),rescall(C,Res). 
>>
>
> This member looks definitely slow, as each time it has to scan the 
> whole Res list from the beginning.
>
> Why not
>
> rescall(X,[F/A|Res]) :-
> not(booleanfunctor(X)),functor(X,F,A),clause(X,C),rescall(C,Res).
>
> Of course, then you have to change something in the other clauses as 
> well. You could use something like append (but adapted for difference 
> lists) in the clause:
>
> rescall((A,B),Res) :- rescall(A,Res),rescall(B,Res).
>
> but then you would be again scanning the list from the beginning.
>
> So, you could make available the variable that terminates the 
> difference list as another parameter:
>
> rescall(true,X,X):- !.
> rescall((A,B),Res,END) :-
>     rescall(A,Res,EndTemp), rescall(B,EndTemp,END).
>
> % Here I am not sure I understand what you want:
> % rescall((A;B),Res) :- rescall(A,Res);rescall(B,Res).
>
> rescall(X,[F/A|Res],End) :-
>     not(booleanfunctor(X)),
>     functor(X,F,A),
>     clause(X,C),
>     rescall(C,Res,End).
>
> Cheers,
> Marco
>
Received on Sun May 16 2010 - 15:21:36 CEST

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