This commit is contained in:
Vitor Santos Costa
2018-10-05 10:26:34 +01:00
parent 724681dde8
commit 5ea98bcf53
7 changed files with 1346 additions and 192 deletions

View File

@@ -14,8 +14,8 @@
% will run 20 iterations of learning with default settings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- use_module(library(problog)).
:- use_module(library(problog_learning)).
:- use_module(library(matrix)).
:- use_module(('../problog_lbfgs')).
%%%%
% background knowledge
@@ -99,3 +99,7 @@ test_example(33,path(5,4),0.57).
test_example(34,path(6,4),0.51).
test_example(35,path(6,5),0.69).
:- set_problog_flag(init_method,(Query,_,BDD,
problog_exact_lbdd(user:Query,BDD))).

View File

@@ -6,24 +6,23 @@
:- use_module(library(bdd)).
:- use_module(library(bhash)).
problog_exact_lbdd(Goal,Prob,Status) :-
problog_control(on, exact),
problog_low_lbdd(Goal,0,Prob,Status),
problog_control(off, exact).
problog_exact_lbdd(Goal,BDD) :-
problog_low_lbdd(Goal, 0, _, _, BDD).
problog_low_lbdd(Goal, Threshold, _, _) :-
problog_low_lbdd(Goal, Threshold, _, _, _) :-
init_problog_low(Threshold),
problog_control(off, up),
timer_start(sld_time),
problog_call(Goal),
add_solution,
fail.
problog_low_lbdd(_, _, Prob, ok) :-
problog_low_lbdd(_, _, Prob, ok, bdd(Dir, Tree, MapList)) :-
timer_stop(sld_time,SLD_Time),
problog_var_set(sld_time, SLD_Time),
nb_getval(problog_completed_proofs, Trie_Completed_Proofs),
tabled_trie_to_bdd(Trie_Completed_Proofs, BDD, MapList),
trie_to_bdd(Trie_Completed_Proofs, BDD, MapList),
bind_maplist(MapList, BoundVars),
bdd_tree(BDD, bdd(Dir, Tree, _Vars)),
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
(problog_flag(verbose, true)->
problog_statistics
@@ -73,6 +72,23 @@ problog_fl_bdd(_,Prob) :-
(problog_flag(retain_tables, true) -> retain_tabling; true),
clear_tabling.
problog_full_bdd(Goal,_K, _) :-
init_problog_low(0.0),
problog_control(off, up),
timer_start(sld_time),
problog_call(Goal),
add_solution,
fail.
problog_full_bdd(_,Prob) :-
timer_stop(sld_time,SLD_Time),
problog_var_set(sld_time, SLD_Time),
nb_getval(problog_completed_proofs, Trie_Completed_Proofs),
tabled_trie_to_bdd(Trie_Completed_Proofs, BDD, MapList),
bind_maplist(MapList, BoundVars),
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
(problog_flag(retain_tables, true) -> retain_tabling; true),
clear_tabling.
bind_maplist([], []).
bind_maplist([Node-_|MapList], [ProbFact|BoundVars]) :-
get_fact_probability(Node,ProbFact),

File diff suppressed because it is too large Load Diff