succ  prec  indice 

Predicato "best_next_clause/8"


*
% Determines the clause which is an extension of Clause by a single
% literal and provides maximum information gain over the original
% clause. 
best_next_clause([], _, _, _, _, _, Clause, Clause).
best_next_clause([L|Ls], Nxs, Pxs, Clause, Info, Gain0, Best0, Best) :-
        add_literal(L, Clause, Best1),
        compute_gain(Nxs, Pxs, Info, Best1, Gain1),
%% TH: For debugging purposes 
        \+ \+ ( numbervars(Best1,0,_), 
                write('Gain: '), write(Gain1), write('  Clause: '), 
                print(Best1), nl ),
        ( Gain1 > Gain0 ->
              best_next_clause(Ls, Nxs, Pxs, Clause, Info, Gain1, Best1, Best)
        ; Gain1 =:= Gain0 ->
              choose_tie_clause(Best0, Best1, Best2),
              best_next_clause(Ls, Nxs, Pxs, Clause, Info, Gain0, Best2, Best)
        ; best_next_clause(Ls, Nxs, Pxs, Clause, Info, Gain0, Best0, Best)
        ).
% In the case of an information tie, the clause with the viewest
% number of variables is choosen. If both have the same number of
% variables this design causes problems !
choose_tie_clause((A1:-B1), (A2:-B2), C) :-
        variables_in(B1, V1),
        length(V1, N1),
        variables_in(B2, V2),
        length(V2, N2),
% TH: This was the initial formulation, which means: in case of a
%     variable tie ignore the refinement and take the first clause.
%     In this formulation neither the membertest example 'foil_3.pl'
%     nor 'foil_4.pl' will be processed correctly !
%       ( N2 < N1 -> 
%             C = (A2:-B2)  
%       ;  C = (A1:-B1) 
%       ).
% TH: In this formulation, which means: in case of a variable tie use
%     the refinement and ignore the previous possible clauses,
%     the membertest example 'foil_4.pl' will be processed correctly,
%     but 'foil_3.pl' will not terminate !
        ( N2 =< N1 -> 
              C = (A2:-B2)  
        ;  C = (A1:-B1) 
        ).
% TH: Obviously, this implies that chosing arbitrarily a clause in the
%     case of a variable tie is the wrong solution. It would be
%     better to specialize those clauses further and to decide one
%     step later, which branch to follow. Unfortunately, Quinlan 90
%     seems to give no answer to this problem !
*


 
 
 
 


 succ  prec  indice