Added a user modifiable ground handler for ProbLog probabilistic facts

This commit is contained in:
Theofrastos Mantadelis 2010-11-09 02:51:24 +01:00
parent a278bda787
commit 94d6c3cebd
2 changed files with 14 additions and 12 deletions

View File

@ -408,7 +408,7 @@ set_strategy(_) :-
set_strategy([]) :- problog_control(on,internal_strategy).
set_strategy([Term|R]) :-
strategy_entry(Term,LogProb,Decision),
(ground(Decision)->
(user:problog_user_ground(Decision)->
decision_fact(ID,Decision),
grounding_id(ID,Decision,ID2),
%format("Setting ~q/~q to ~q~n",[Decision,ID2,Prob]),
@ -427,7 +427,7 @@ unset_strategy([]) :-
problog_control(off,internal_strategy).
unset_strategy([Term|R]) :-
strategy_entry(Term,LogProb,Decision),
(ground(Decision)->
(user:problog_user_ground(Decision)->
decision_fact(ID,Decision),
grounding_id(ID,Decision,ID2),
%format("Unsetting ~q/~q to ~q~n",[Decision,ID2,Prob]),

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Date: 2010-10-21 10:47:36 +0200 (Thu, 21 Oct 2010) $
% $Revision: 4970 $
% $Date: 2010-11-09 02:47:35 +0100 (Tue, 09 Nov 2010) $
% $Revision: 4991 $
%
% This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog
@ -881,19 +881,21 @@ problog_predicate(Name, Arity, ProblogName,Mod) :-
% non-ground probabilistic facts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- multifile(user:problog_user_ground/1).
user:problog_user_ground(Goal) :-
ground(Goal).
non_ground_fact_grounding_id(Goal,ID) :-
ground(Goal),
!,
(
grounding_is_known(Goal,ID)
->
true;
(
user:problog_user_ground(Goal), !,
(grounding_is_known(Goal,ID) ->
true
;
(
nb_getval(non_ground_fact_grounding_id_counter,ID),
ID2 is ID+1,
nb_setval(non_ground_fact_grounding_id_counter,ID2),
assertz(grounding_is_known(Goal,ID))
)
)
).
non_ground_fact_grounding_id(Goal,_) :-
format(user_error,'The current program uses non-ground facts.~n', []),