From d1839b730c219bf43628b430e97d59666f4d1f67 Mon Sep 17 00:00:00 2001 From: Theofrastos Mantadelis Date: Wed, 6 Oct 2010 12:59:18 +0200 Subject: [PATCH 1/3] ProbLog versioning, ProbLog Tabling warning message instead of error --- packages/ProbLog/problog.yap | 5 +-- packages/ProbLog/problog/os.yap | 12 +++++-- packages/ProbLog/problog/print.yap | 47 +++++++++++++++------------- packages/ProbLog/problog/tabling.yap | 9 +++--- 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/packages/ProbLog/problog.yap b/packages/ProbLog/problog.yap index 873c53837..fe47bad99 100644 --- a/packages/ProbLog/problog.yap +++ b/packages/ProbLog/problog.yap @@ -2,8 +2,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2010-10-05 18:15:57 +0200 (Tue, 05 Oct 2010) $ -% $Revision: 4876 $ +% $Date: 2010-10-06 12:56:13 +0200 (Wed, 06 Oct 2010) $ +% $Revision: 4877 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog @@ -249,6 +249,7 @@ non_ground_fact/1, export_facts/1, problog_help/0, + problog_version/0, show_inference/0, problog_dir/1, set_problog_flag/2, diff --git a/packages/ProbLog/problog/os.yap b/packages/ProbLog/problog/os.yap index 6d3f11a14..42bcea592 100644 --- a/packages/ProbLog/problog/os.yap +++ b/packages/ProbLog/problog/os.yap @@ -2,8 +2,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2010-10-05 18:15:57 +0200 (Tue, 05 Oct 2010) $ -% $Revision: 4876 $ +% $Date: 2010-10-06 12:56:13 +0200 (Wed, 06 Oct 2010) $ +% $Revision: 4877 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog @@ -212,6 +212,7 @@ convert_filename_to_working_path/2, convert_filename_to_problog_path/2, concat_path_with_filename/3, + concat_path_with_filename2/3, split_path_file/3, check_existance/1, calc_md5/2]). @@ -249,6 +250,13 @@ concat_path_with_filename(Path, File_Name, Result):- path_seperator(Path_Seperator), atomic_concat([Path_Absolute, Path_Seperator, File_Name], Result). +concat_path_with_filename2(Path, File_Name, Result):- + nonvar(File_Name), + nonvar(Path), + path_seperator(Path_Seperator), + (atomic_concat(Path_Absolute, Path_Seperator, Path) ; Path_Absolute = Path), + atomic_concat([Path_Absolute, Path_Seperator, File_Name], Result). + %======================================================================== %= Calculate the MD5 checksum of +Filename by calling md5sum %= in case m5sum is not installed, try md5, otherwise fail diff --git a/packages/ProbLog/problog/print.yap b/packages/ProbLog/problog/print.yap index 60395b476..70fabd14d 100644 --- a/packages/ProbLog/problog/print.yap +++ b/packages/ProbLog/problog/print.yap @@ -2,8 +2,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2010-10-05 18:15:57 +0200 (Tue, 05 Oct 2010) $ -% $Revision: 4876 $ +% $Date: 2010-10-06 12:56:13 +0200 (Wed, 06 Oct 2010) $ +% $Revision: 4877 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog @@ -222,7 +222,8 @@ show_inference/0, problog_flags/0, problog_flags/1, - problog_help/0]). + problog_help/0, + problog_version/0]). % load library modules :- use_module(library(lists), [member/2]). @@ -231,7 +232,7 @@ % load our own modules :- use_module(flags). :- use_module(variables). -:- use_module(os, [check_existance/1, convert_filename_to_problog_path/2]). +:- use_module(os, [check_existance/1, convert_filename_to_problog_path/2, concat_path_with_filename2/3]). :- use_module(version_control, [get_version/3]). @@ -299,8 +300,7 @@ make_column_format([HC|TC], [HS|TS], Format, Acc):- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% problog_help :- - print_version, - format('~nProbLog inference currently offers the following inference methods:~n',[]), + format('~2nProbLog inference currently offers the following inference methods:~n',[]), show_inference, problog:problog_path(PD), format('~nProbLog directory: ~q~n',[PD]), @@ -314,28 +314,33 @@ problog_help :- nl, flush_output. -print_version :- +problog_version :- + MainProblogFiles = ['problog.yap', 'problog_learning.yap', 'dtproblog.yap'], nl, - print_group_line('Version Information'), - check_existance('problog.yap'), - convert_filename_to_problog_path('problog.yap', Path), - get_version(Path, Version, Revision), - format('~w~35+ Last Modified at:~w~65+Revision:~w~n', ['problog.yap', Version, Revision]), + print_group_line_bold('Version Information'), + print_version(MainProblogFiles, ''), + print_sep_line, convert_filename_to_problog_path('problog', ProblogPath), directory_files(ProblogPath, ProblogFiles), - print_version(ProblogFiles), - print_sep_line. + sort(ProblogFiles, ProblogFilesS), + print_version(ProblogFilesS, 'problog'), + print_sep_line_bold. -print_version([]). -print_version([H|T]):- - atom_concat('.', _, H), !, - print_version(T). -print_version([H|T]):- - atom_concat('problog/', H, FileName), +print_version([], _Path). +print_version([H|T], Path):- + atom_concat(_, '.yap', H), !, + (Path == '' -> + FileName = H + ; + concat_path_with_filename2(Path, H, FileName) + ), + check_existance(FileName), convert_filename_to_problog_path(FileName, FilePath), get_version(FilePath, Version, Revision), format('~w~35+ Last Modified at:~w~65+Revision:~w~n', [FileName, Version, Revision]), - print_version(T). + print_version(T, Path). +print_version([_H|T], Path):- + print_version(T, Path). show_inference :- diff --git a/packages/ProbLog/problog/tabling.yap b/packages/ProbLog/problog/tabling.yap index 3559a446f..7ba047a96 100644 --- a/packages/ProbLog/problog/tabling.yap +++ b/packages/ProbLog/problog/tabling.yap @@ -2,8 +2,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $ -% $Revision: 4838 $ +% $Date: 2010-10-06 12:56:13 +0200 (Wed, 06 Oct 2010) $ +% $Revision: 4877 $ % % This file is part of ProbLog % http://dtai.cs.kuleuven.be/problog @@ -328,8 +328,9 @@ problog_table(Name/Arity, Module) :- atom_concat(['problog_', Name, '_tabled'], ExactName), % Monte carlo tabling - table(Module:MCName/Arity), - assertz(problog_tabled(Module:Name/Arity)), + catch((table(Module:MCName/Arity), + assertz(problog_tabled(Module:Name/Arity))), _, + (format(user_error, 'Warning: Tabling was not enabled over compilation, montecarlo tabling is disabled!~nPredicate: ~q~n', [Module:MCName/Arity]))), findall(_,( OriginalPred =.. [OriginalName|Args], From 1342d2dab252a9d53defa6a2a886f2c0b6a625e8 Mon Sep 17 00:00:00 2001 From: Theofrastos Mantadelis Date: Wed, 6 Oct 2010 13:24:25 +0200 Subject: [PATCH 2/3] SimpleCUDD versioning --- packages/ProbLog/simplecudd/general.c | 2 ++ packages/ProbLog/simplecudd/general.h | 2 ++ packages/ProbLog/simplecudd/problogbdd.c | 2 ++ packages/ProbLog/simplecudd/problogmath.c | 2 ++ packages/ProbLog/simplecudd/problogmath.h | 4 ++-- packages/ProbLog/simplecudd/simplecudd.c | 13 ++++++++++++- packages/ProbLog/simplecudd/simplecudd.h | 2 ++ 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/ProbLog/simplecudd/general.c b/packages/ProbLog/simplecudd/general.c index e13bf5cae..b34b7dd5b 100644 --- a/packages/ProbLog/simplecudd/general.c +++ b/packages/ProbLog/simplecudd/general.c @@ -7,6 +7,8 @@ * * * Author: Theofrastos Mantadelis * * File: general.c * +* $Date:: 2010-10-06 13:20:59 +0200 (Wed, 06 Oct 2010) $ * +* $Revision:: 4880 $ * * * ******************************************************************************** * * diff --git a/packages/ProbLog/simplecudd/general.h b/packages/ProbLog/simplecudd/general.h index a872cc386..4b22bef5d 100644 --- a/packages/ProbLog/simplecudd/general.h +++ b/packages/ProbLog/simplecudd/general.h @@ -7,6 +7,8 @@ * * * Author: Theofrastos Mantadelis * * File: general.h * +* $Date:: 2010-10-06 13:20:59 +0200 (Wed, 06 Oct 2010) $ * +* $Revision:: 4880 $ * * * ******************************************************************************** * * diff --git a/packages/ProbLog/simplecudd/problogbdd.c b/packages/ProbLog/simplecudd/problogbdd.c index 1370b21b4..12a435d4b 100644 --- a/packages/ProbLog/simplecudd/problogbdd.c +++ b/packages/ProbLog/simplecudd/problogbdd.c @@ -7,6 +7,8 @@ * * * Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * * File: problogbdd.c * +* $Date:: 2010-10-06 13:22:55 +0200 (Wed, 06 Oct 2010) $ * +* $Revision:: 4881 $ * * * ******************************************************************************** * * diff --git a/packages/ProbLog/simplecudd/problogmath.c b/packages/ProbLog/simplecudd/problogmath.c index cdeb9bbaa..d768fb790 100644 --- a/packages/ProbLog/simplecudd/problogmath.c +++ b/packages/ProbLog/simplecudd/problogmath.c @@ -7,6 +7,8 @@ * * * Author: Bernd Gutmann * * File: problogmath.c * +* $Date:: 2010-10-06 13:20:59 +0200 (Wed, 06 Oct 2010) $ * +* $Revision:: 4880 $ * * * ******************************************************************************** * * diff --git a/packages/ProbLog/simplecudd/problogmath.h b/packages/ProbLog/simplecudd/problogmath.h index 8734d6f88..2df38c626 100644 --- a/packages/ProbLog/simplecudd/problogmath.h +++ b/packages/ProbLog/simplecudd/problogmath.h @@ -7,8 +7,8 @@ * * * Author: Bernd Gutmann * * File: problogmath.h * -* $Date:: 2010-02-18 18:04:54 +0100 (Thu, 18 Feb 2010) $ * -* $Revision:: 3623 $ * +* $Date:: 2010-10-06 13:20:59 +0200 (Wed, 06 Oct 2010) $ * +* $Revision:: 4880 $ * * * ******************************************************************************** * * diff --git a/packages/ProbLog/simplecudd/simplecudd.c b/packages/ProbLog/simplecudd/simplecudd.c index caa67134b..07698b2f8 100644 --- a/packages/ProbLog/simplecudd/simplecudd.c +++ b/packages/ProbLog/simplecudd/simplecudd.c @@ -7,6 +7,8 @@ * * * Author: Theofrastos Mantadelis * * File: simplecudd.c * +* $Date:: 2010-10-06 13:20:59 +0200 (Wed, 06 Oct 2010) $ * +* $Revision:: 4880 $ * * * ******************************************************************************** * * @@ -1710,7 +1712,16 @@ void onlinetraverse(DdManager *manager, namedvars varmap, hisqueue *HisQueue, Dd switch(inputline[1]) { case '?': printf("Available instructions:\n\t@c : current node\n\t@n,[BFS, DFS] : expand and go to next node\n\t@t,[BFS, DFS] : throw and go to next node\n"); - printf("\t@h : high node of current\n\t@l : low node of current\n\t@v,[variable] : variable values\n\t@e terminates\n"); + printf("\t@h : high node of current\n\t@l : low node of current\n\t@v,[variable] : variable values\n\t@r restart traverse from parent node\n\t@e terminates\n"); + break; + case 'r': + curnode = bdd; + iQsize = 0; + iRoot = 1; + free(Q); + Q = (DdNode **) malloc(sizeof(DdNode *) * iQsize); + Q2 = NULL; + ReInitHistory(his, varmap.varcnt); break; case 'c': if (iRoot) { diff --git a/packages/ProbLog/simplecudd/simplecudd.h b/packages/ProbLog/simplecudd/simplecudd.h index 688e80d1e..577e79d83 100644 --- a/packages/ProbLog/simplecudd/simplecudd.h +++ b/packages/ProbLog/simplecudd/simplecudd.h @@ -7,6 +7,8 @@ * * * Author: Theofrastos Mantadelis * * File: simplecudd.h * +* $Date:: 2010-10-06 13:20:59 +0200 (Wed, 06 Oct 2010) $ * +* $Revision:: 4880 $ * * * ******************************************************************************** * * From 284fc9ab8bfad3ad6e1d577ec385bb20371e4050 Mon Sep 17 00:00:00 2001 From: Theofrastos Mantadelis Date: Wed, 6 Oct 2010 18:27:40 +0200 Subject: [PATCH 3/3] corrected a small bug with export --- packages/ProbLog/simplecudd/problogbdd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/ProbLog/simplecudd/problogbdd.c b/packages/ProbLog/simplecudd/problogbdd.c index 12a435d4b..c556ded4a 100644 --- a/packages/ProbLog/simplecudd/problogbdd.c +++ b/packages/ProbLog/simplecudd/problogbdd.c @@ -7,8 +7,8 @@ * * * Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * * File: problogbdd.c * -* $Date:: 2010-10-06 13:22:55 +0200 (Wed, 06 Oct 2010) $ * -* $Revision:: 4881 $ * +* $Date:: 2010-10-06 18:06:08 +0200 (Wed, 06 Oct 2010) $ * +* $Revision:: 4883 $ * * * ******************************************************************************** * * @@ -347,6 +347,7 @@ int main(int argc, char **arg) { MyManager.f = LOW(MyManager.manager); MyManager.varmap = InitNamedVars(1, 0); bdd = OnlineGenerateBDD(MyManager.manager, &MyManager.varmap); + bakbdd = bdd; ivarcnt = GetVarCount(MyManager.manager); } else if(params.independent_forest>0){ // the flag to create a forest of independent bdds is set