Some ProbLog improvements related with tabling efficiency, more to come soon

This commit is contained in:
Theofrastos Mantadelis
2010-11-03 19:22:11 +01:00
parent 362ecc2f16
commit c804d105b6
8 changed files with 1025 additions and 589 deletions

View File

@@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Date: 2010-09-29 13:24:43 +0200 (Wed, 29 Sep 2010) $
% $Revision: 4845 $
% $Date: 2010-10-20 18:06:47 +0200 (Wed, 20 Oct 2010) $
% $Revision: 4969 $
%
% This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog
@@ -205,9 +205,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- module(utils_learning, [empty_bdd_directory/0,
empty_output_directory/0,
delete_file_silent/1,
slice_n/4]).
empty_output_directory/0]).
% load library modules
@@ -217,6 +215,7 @@
% load our own modules
:- use_module(os).
:- use_module(flags).
:- use_module(utils).
%========================================================================
%=
@@ -246,19 +245,8 @@ empty_output_directory :-
concat_path_with_filename(Path,'log.dat',F1),
concat_path_with_filename(Path,'out.dat',F2),
(
file_exists(F1)
->
delete_file_silent(F1);
true
),
(
file_exists(F2)
->
delete_file_silent(F2);
true
),
delete_file_silent(F1),
delete_file_silent(F2),
atom_codes('values_', PF1), % 'values_*_q_*.dat'
atom_codes('factprobs_', PF2), % 'factprobs_*.pl'
@@ -272,16 +260,7 @@ empty_output_directory :-
empty_output_directory :-
throw(error(problog_flag_does_not_exist(output_directory))).
%========================================================================
%=
%=
%========================================================================
delete_file_silent(File) :-
file_exists(File),
delete_file(File),
!.
delete_file_silent(_).
%========================================================================
%=
@@ -304,17 +283,3 @@ delete_files_with_matching_prefix([Name|T],Path,Prefixes) :-
delete_files_with_matching_prefix(T,Path,Prefixes).
%========================================================================
%= Split a list into the first n elements and the tail
%= +List +Integer -Prefix -Residuum
%========================================================================
slice_n([],_,[],[]) :-
!.
slice_n([H|T],N,[H|T2],T3) :-
N>0,
!,
N2 is N-1,
slice_n(T,N2,T2,T3).
slice_n(L,_,[],L).