learn again
This commit is contained in:
parent
e441f30c4c
commit
8ce16f64d9
@ -14,7 +14,7 @@
|
||||
% will run 20 iterations of learning with default settings
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:- use_module(library(problog_lbdd)).
|
||||
:- use_module(library(problog)).
|
||||
:- use_module(library(problog_learning_lbdd)).
|
||||
|
||||
%%%%
|
||||
|
@ -1,4 +1,4 @@
|
||||
%%% -*- Mode: Prolog; -*-
|
||||
1%%% -*- Mode: Prolog; -*-
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
@ -246,14 +246,17 @@
|
||||
:- dynamic(query_md5/3).
|
||||
|
||||
:- multifile(user:example/4).
|
||||
:- multifile(user:problog_drop_example/1).
|
||||
user:example(A,B,C,=) :-
|
||||
current_predicate(user:example/3),
|
||||
user:example(A,B,C).
|
||||
user:example(A,B,C),
|
||||
\+ user:problog_drop_example(B).
|
||||
|
||||
:- multifile(user:test_example/4).
|
||||
user:test_example(A,B,C,=) :-
|
||||
current_predicate(user:test_example/3),
|
||||
user:test_example(A,B,C).
|
||||
user:test_example(A,B,C),
|
||||
\+ user:problog_drop_example(B).
|
||||
|
||||
|
||||
%========================================================================
|
||||
@ -514,7 +517,7 @@ init_learning :-
|
||||
->
|
||||
(
|
||||
format_learning(2,'Theory uses continuous facts.~nWill use problog_exact/3 as initalization method.~2n',[]),
|
||||
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile)))
|
||||
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog:problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile)))
|
||||
);
|
||||
true
|
||||
),
|
||||
@ -524,7 +527,7 @@ init_learning :-
|
||||
->
|
||||
(
|
||||
format_learning(2,'Theory uses tabling.~nWill use problog_exact/3 as initalization method.~2n',[]),
|
||||
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile)))
|
||||
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog:problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile)))
|
||||
);
|
||||
true
|
||||
),
|
||||
|
@ -243,19 +243,27 @@
|
||||
:- dynamic(query_md5/2).
|
||||
|
||||
|
||||
% used to identify queries which have identical proofs
|
||||
:- dynamic(query_is_similar/2).
|
||||
:- dynamic(query_md5/3).
|
||||
|
||||
% used to identify queries which have identical proofs
|
||||
:- dynamic(query_is_similar/2).
|
||||
:- dynamic(query_md5/3).
|
||||
|
||||
:- multifile(user:example/4).
|
||||
:- multifile(user:problog_discard_example/1).
|
||||
user:example(A,B,C,=) :-
|
||||
current_predicate(user:example/3),
|
||||
user:example(A,B,C).
|
||||
user:example(A,B,C),
|
||||
\+ user:problog_discard_example(B).
|
||||
|
||||
:- multifile(user:test_example/4).
|
||||
user:test_example(A,B,C,=) :-
|
||||
current_predicate(user:test_example/3),
|
||||
user:test_example(A,B,C).
|
||||
user:test_example(A,B,C),
|
||||
\+ user:problog_discard_example(B).
|
||||
|
||||
|
||||
|
||||
%========================================================================
|
||||
@ -604,7 +612,7 @@ bdd_input_file(Filename) :-
|
||||
concat_path_with_filename(Dir,'input.txt',Filename).
|
||||
|
||||
init_one_query(QueryID,Query,Type) :-
|
||||
format_learning(3,' ~q example ~q: ~q~n',[Type,QueryID,Query]),
|
||||
% format_learning(3,' ~q example ~q: ~q~n',[Type,QueryID,Query]),
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% if BDD file does not exist, call ProbLog
|
||||
@ -614,18 +622,19 @@ init_one_query(QueryID,Query,Type) :-
|
||||
->
|
||||
format_learning(3,' Reuse existing BDD ~q~n~n',[QueryID]);
|
||||
(
|
||||
b_setval(problog_required_keep_ground_ids,false),
|
||||
problog_flag(libbdd_init_method,(Query,Bdd,Call)),
|
||||
Bdd = bdd(Dir, Tree, MapList),
|
||||
% trace,
|
||||
once(Call),
|
||||
rb_new(H0),
|
||||
maplist_to_hash(MapList, H0, Hash),
|
||||
% writeln(Dir:Tree:MapList),
|
||||
Tree \= [],
|
||||
% writeln(Dir:Tree:MapList),
|
||||
tree_to_grad(Tree, Hash, [], Grad),
|
||||
%% %writeln(Call:Tree),
|
||||
recordz(QueryID,bdd(Dir, Grad, MapList),_)
|
||||
recordz(QueryID,bdd(Dir, Grad, MapList),_)
|
||||
)
|
||||
),
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% check wether this BDD is similar to another BDD
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@ -636,7 +645,7 @@ init_one_query(QueryID,Query,Type) :-
|
||||
;
|
||||
true
|
||||
),!.
|
||||
|
||||
init_one_query(_QueryID,_Query,_Type).
|
||||
|
||||
|
||||
|
||||
|
@ -44,8 +44,13 @@ complex_to_andor([Els], Map0, MapF, V) :-
|
||||
|
||||
complex_to_and(int(A1,[endlist]), Map0, MapF, V) :- !,
|
||||
check(Map0, A1, V, MapF).
|
||||
complex_to_and(atom(A1,[endlist]), Map0, MapF, V) :- !,
|
||||
check(Map0, A1, V, MapF).
|
||||
complex_to_and(functor(not,1,[int(A1,[endlist])]), Map0, MapF, not(V)) :- !,
|
||||
check(Map0, A1, V, MapF).
|
||||
complex_to_and(atom(A1,Els), Map0, MapF, and(V,T2)) :- !,
|
||||
check(Map0, A1, V, MapI),
|
||||
complex_to_andor(Els, MapI, MapF, T2).
|
||||
complex_to_and(int(A1,Els), Map0, MapF, and(V,T2)) :- !,
|
||||
check(Map0, A1, V, MapI),
|
||||
complex_to_andor(Els, MapI, MapF, T2).
|
||||
@ -79,6 +84,8 @@ tabled_complex_to_andor([Els], Map0, MapF, Tab0, TabF, V) :-
|
||||
|
||||
tabled_complex_to_and(int(A1,[endlist]), Map0, MapF, Tab, Tab, V) :- !,
|
||||
check(Map0, A1, V, MapF).
|
||||
tabled_complex_to_and(atom(A1,[endlist]), Map0, MapF, Tab, Tab, V) :- !,
|
||||
check(Map0, A1, V, MapF).
|
||||
tabled_complex_to_and(functor(not,1,[int(A1,[endlist])]), Map0, MapF, Tab, Tab, not(V)) :- !,
|
||||
check(Map0, A1, V, MapF).
|
||||
tabled_complex_to_and(T, Map, Map, Tab, Tab, V) :-
|
||||
|
Reference in New Issue
Block a user