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([]) :- problog_control(on,internal_strategy).
set_strategy([Term|R]) :- set_strategy([Term|R]) :-
strategy_entry(Term,LogProb,Decision), strategy_entry(Term,LogProb,Decision),
(ground(Decision)-> (user:problog_user_ground(Decision)->
decision_fact(ID,Decision), decision_fact(ID,Decision),
grounding_id(ID,Decision,ID2), grounding_id(ID,Decision,ID2),
%format("Setting ~q/~q to ~q~n",[Decision,ID2,Prob]), %format("Setting ~q/~q to ~q~n",[Decision,ID2,Prob]),
@ -427,7 +427,7 @@ unset_strategy([]) :-
problog_control(off,internal_strategy). problog_control(off,internal_strategy).
unset_strategy([Term|R]) :- unset_strategy([Term|R]) :-
strategy_entry(Term,LogProb,Decision), strategy_entry(Term,LogProb,Decision),
(ground(Decision)-> (user:problog_user_ground(Decision)->
decision_fact(ID,Decision), decision_fact(ID,Decision),
grounding_id(ID,Decision,ID2), grounding_id(ID,Decision,ID2),
%format("Unsetting ~q/~q to ~q~n",[Decision,ID2,Prob]), %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) $ % $Date: 2010-11-09 02:47:35 +0100 (Tue, 09 Nov 2010) $
% $Revision: 4970 $ % $Revision: 4991 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog
@ -881,13 +881,15 @@ problog_predicate(Name, Arity, ProblogName,Mod) :-
% non-ground probabilistic facts % non-ground probabilistic facts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- multifile(user:problog_user_ground/1).
user:problog_user_ground(Goal) :-
ground(Goal).
non_ground_fact_grounding_id(Goal,ID) :- non_ground_fact_grounding_id(Goal,ID) :-
ground(Goal), user:problog_user_ground(Goal), !,
!, (grounding_is_known(Goal,ID) ->
( true
grounding_is_known(Goal,ID) ;
->
true;
( (
nb_getval(non_ground_fact_grounding_id_counter,ID), nb_getval(non_ground_fact_grounding_id_counter,ID),
ID2 is ID+1, ID2 is ID+1,