Portability issues

This commit is contained in:
Theofrastos Mantadelis 2010-09-28 21:22:32 +02:00
parent 39baf51c2d
commit 0cd5cec64b
20 changed files with 145 additions and 148 deletions

View File

@ -2,7 +2,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:14:21 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-08-24 15:14:21 +0200 (Di, 24. Aug 2010) $
% $Revision: 4671 $ % $Revision: 4671 $
% %
% This file is part of ProbLog % This file is part of ProbLog

View File

@ -230,7 +230,7 @@
problog_kbest_save/6, problog_kbest_save/6,
problog_max/3, problog_max/3,
problog_exact/3, problog_exact/3,
problog_exact_save/5, problog_exact_save/5,
problog_montecarlo/3, problog_montecarlo/3,
problog_dnf_sampling/3, problog_dnf_sampling/3,
problog_answers/2, problog_answers/2,
@ -320,7 +320,7 @@
:- use_module('problog/sampling'). :- use_module('problog/sampling').
:- use_module('problog/intervals'). :- use_module('problog/intervals').
:- use_module('problog/mc_DNF_sampling'). :- use_module('problog/mc_DNF_sampling').
:- use_module('problog/variable_elimination'). :- catch(use_module('problog/variable_elimination'),_,true).
% op attaching probabilities to facts % op attaching probabilities to facts
:- op( 550, yfx, :: ). :- op( 550, yfx, :: ).
@ -371,7 +371,7 @@
:- dynamic(dynamic_probability_fact_extract/2). :- dynamic(dynamic_probability_fact_extract/2).
% for storing continuous parts of proofs (Hybrid ProbLog) % for storing continuous parts of proofs (Hybrid ProbLog)
:- dynamic(hybrid_proof/3, hybrid_proof/4). :- dynamic([hybrid_proof/3, hybrid_proof/4]).
:- dynamic(hybrid_proof_disjoint/4). :- dynamic(hybrid_proof_disjoint/4).
% ProbLog files declare prob. facts as P::G % ProbLog files declare prob. facts as P::G
@ -381,7 +381,7 @@
% directory where problogbdd executable is located % directory where problogbdd executable is located
% automatically set during loading -- assumes it is in same place as this file (problog.yap) % automatically set during loading -- assumes it is in same place as this file (problog.yap)
:- initialization((getcwd(PD), set_problog_path(PD))). :- getcwd(PD), set_problog_path(PD).
@ -466,9 +466,7 @@
% Default inference method % Default inference method
%%%%%%%%%%%% %%%%%%%%%%%%
:- initialization( :- initialization(problog_define_flag(inference, problog_flag_validate_dummy, 'default inference method', exact, inference)).
problog_define_flag(inference, problog_flag_validate_dummy, 'default inference method', exact, inference)
).
problog_dir(PD):- problog_path(PD). problog_dir(PD):- problog_path(PD).
@ -580,7 +578,7 @@ term_expansion_intern((Annotation :: Head :- Body), Module, problog:ExpandedClau
% It's a decision with a body % It's a decision with a body
copy_term((Head,Body),(HeadCopy,_BodyCopy)), copy_term((Head,Body),(HeadCopy,_BodyCopy)),
functor(Head, Functor, Arity), functor(Head, Functor, Arity),
atom_concat(problog_, Functor, LongFunctor), atomic_concat([problog_,Functor],LongFunctor),
Head =.. [Functor|Args], Head =.. [Functor|Args],
append(Args,[LProb],LongArgs), append(Args,[LProb],LongArgs),
probclause_id(ID), probclause_id(ID),
@ -626,7 +624,7 @@ user:term_expansion(P::Goal,Goal) :-
term_expansion_intern(P :: Goal,Module,problog:ProbFact) :- term_expansion_intern(P :: Goal,Module,problog:ProbFact) :-
copy_term((P,Goal),(P_Copy,Goal_Copy)), copy_term((P,Goal),(P_Copy,Goal_Copy)),
functor(Goal, Name, Arity), functor(Goal, Name, Arity),
atom_concat(problog_, Name, ProblogName), atomic_concat([problog_,Name],ProblogName),
Goal =.. [Name|Args], Goal =.. [Name|Args],
append(Args,[LProb],L1), append(Args,[LProb],L1),
probclause_id(ID), probclause_id(ID),
@ -708,7 +706,7 @@ user:term_expansion(Goal, problog:ProbFact) :-
), ),
functor(Goal, Name, Arity), functor(Goal, Name, Arity),
atom_concat(problogcontinuous_, Name, ProblogName), atomic_concat([problogcontinuous_,Name],ProblogName),
probclause_id(ID), probclause_id(ID),
GaussianArg=gaussian(Mu_Arg,Sigma_Arg), GaussianArg=gaussian(Mu_Arg,Sigma_Arg),
@ -807,16 +805,16 @@ interval_merge((_ID,GroundID,_Type),Interval) :-
problog_assertz(P::Goal) :- problog_assert(P::Goal) :-
problog_assertz(user,P::Goal). problog_assert(user,P::Goal).
problog_assertz(Module, P::Goal) :- problog_assert(Module, P::Goal) :-
term_expansion_intern(P::Goal,Module,problog:ProbFact), term_expansion_intern(P::Goal,Module,problog:ProbFact),
assertz(problog:ProbFact). assertz(problog:ProbFact).
problog_retractall(Goal) :- problog_retractall(Goal) :-
Goal =.. [F|Args], Goal =.. [F|Args],
append([_ID|Args],[_Prob],Args2), append([_ID|Args],[_Prob],Args2),
atom_concat('problog_', F, F2), atomic_concat(['problog_',F],F2),
ProbLogGoal=..[F2|Args2], ProbLogGoal=..[F2|Args2],
retractall(problog:ProbLogGoal). retractall(problog:ProbLogGoal).
@ -964,7 +962,7 @@ probabilistic_fact(P2,Goal,ID) :-
-> ->
( (
Goal =.. [F|Args], Goal =.. [F|Args],
atom_concat('problog_', F, F2), atomic_concat('problog_',F,F2),
append([ID|Args],[P],Args2), append([ID|Args],[P],Args2),
Goal2 =..[F2|Args2], Goal2 =..[F2|Args2],
length(Args2,N), length(Args2,N),
@ -977,8 +975,8 @@ probabilistic_fact(P2,Goal,ID) :-
get_internal_fact(ID,ProblogTerm,_ProblogName,_ProblogArity), get_internal_fact(ID,ProblogTerm,_ProblogName,_ProblogArity),
ProblogTerm =.. [F,_ID|Args], ProblogTerm =.. [F,_ID|Args],
append(Args2,[P],Args), append(Args2,[P],Args),
atom_codes(F,[_p,_r,_o,_b,_l,_o,_g,_|F2Chars]), name(F,[_p,_r,_o,_b,_l,_o,_g,_|F2Chars]),
atom_codes(F2,F2Chars), name(F2,F2Chars),
Goal =.. [F2|Args2], Goal =.. [F2|Args2],
( (
dynamic_probability_fact(ID) dynamic_probability_fact(ID)
@ -1011,7 +1009,7 @@ prob_for_id(dummy,dummy,dummy).
get_fact_probability(A, Prob) :- get_fact_probability(A, Prob) :-
ground(A), ground(A),
\+ number(A), \+ number(A),
atom_codes(A, A_Codes), name(A, A_Codes),
once(append(Part1, [95|Part2], A_Codes)), % 95 = '_' once(append(Part1, [95|Part2], A_Codes)), % 95 = '_'
number_codes(ID, Part1), !, number_codes(ID, Part1), !,
% let's check whether Part2 contains an 'l' (l=low) % let's check whether Part2 contains an 'l' (l=low)
@ -1072,7 +1070,7 @@ set_fact_probability(ID,Prob) :-
get_internal_fact(ID,ProblogTerm,ProblogName,ProblogArity) :- get_internal_fact(ID,ProblogTerm,ProblogName,ProblogArity) :-
problog_predicate(Name,Arity), problog_predicate(Name,Arity),
atom_concat(problog_, Name, ProblogName), atomic_concat([problog_,Name],ProblogName),
ProblogArity is Arity+2, ProblogArity is Arity+2,
functor(ProblogTerm,ProblogName,ProblogArity), functor(ProblogTerm,ProblogName,ProblogArity),
arg(1,ProblogTerm,ID), arg(1,ProblogTerm,ID),
@ -1090,7 +1088,7 @@ get_continuous_fact_parameters(ID,Parameters) :-
get_internal_continuous_fact(ID,ProblogTerm,ProblogName,ProblogArity,ContinuousPos) :- get_internal_continuous_fact(ID,ProblogTerm,ProblogName,ProblogArity,ContinuousPos) :-
problog_continuous_predicate(Name,Arity,ContinuousPos), problog_continuous_predicate(Name,Arity,ContinuousPos),
atom_concat(problogcontinuous_, Name, ProblogName), atomic_concat([problogcontinuous_,Name],ProblogName),
ProblogArity is Arity+1, ProblogArity is Arity+1,
functor(ProblogTerm,ProblogName,ProblogArity), functor(ProblogTerm,ProblogName,ProblogArity),
arg(1,ProblogTerm,ID), arg(1,ProblogTerm,ID),
@ -1155,12 +1153,12 @@ get_fact(ID,OutsideTerm) :-
grounding_is_known(OutsideTerm,GID). grounding_is_known(OutsideTerm,GID).
recover_grounding_id(Atom,ID) :- recover_grounding_id(Atom,ID) :-
atom_codes(Atom,List), name(Atom,List),
reverse(List,Rev), reverse(List,Rev),
recover_number(Rev,NumRev), recover_number(Rev,NumRev),
reverse(NumRev,Num), reverse(NumRev,Num),
atom_codes(ID,Num). name(ID,Num).
recover_number([95|_],[]) :- !. % atom_codes('_',[95]) recover_number([95|_],[]) :- !. % name('_',[95])
recover_number([A|B],[A|C]) :- recover_number([A|B],[A|C]) :-
recover_number(B,C). recover_number(B,C).
@ -1294,9 +1292,9 @@ montecarlo_check(ComposedID) :-
fail. fail.
% (c) for unknown groundings of non-ground facts: generate a new sample (decompose the ID first) % (c) for unknown groundings of non-ground facts: generate a new sample (decompose the ID first)
montecarlo_check(ID) :- montecarlo_check(ID) :-
atom_codes(ID,IDN), name(ID,IDN),
recover_number(IDN,FactIDName), recover_number(IDN,FactIDName),
atom_codes(FactID,FactIDName), name(FactID,FactIDName),
new_sample_nonground(ID,FactID). new_sample_nonground(ID,FactID).
% sampling from ground fact: set array value to 1 (in) or 2 (out) % sampling from ground fact: set array value to 1 (in) or 2 (out)
@ -1332,10 +1330,10 @@ new_sample_nonground(ComposedID,ID) :-
% fail. % fail.
split_grounding_id(Composed,Fact,Grounding) :- split_grounding_id(Composed,Fact,Grounding) :-
atom_codes(Composed,C), name(Composed,C),
split_g_id(C,F,G), split_g_id(C,F,G),
atom_codes(Fact,F), name(Fact,F),
atom_codes(Grounding,G). name(Grounding,G).
split_g_id([95|Grounding],[],Grounding) :- !. split_g_id([95|Grounding],[],Grounding) :- !.
split_g_id([A|B],[A|FactID],GroundingID) :- split_g_id([A|B],[A|FactID],GroundingID) :-
split_g_id(B,FactID,GroundingID). split_g_id(B,FactID,GroundingID).
@ -3026,8 +3024,8 @@ bdd_par_file(BDDParFile) :-
require(Feature) :- require(Feature) :-
atom(Feature), atom(Feature),
atom_concat('problog_required_', Feature, Feature_Required), atomic_concat(['problog_required_',Feature],Feature_Required),
atom_concat(Feature_Required, '_depth', Feature_Depth), atomic_concat([Feature_Required,'_',depth],Feature_Depth),
(required(Feature) -> (required(Feature) ->
b_getval(Feature_Depth,Depth), b_getval(Feature_Depth,Depth),
Depth1 is Depth+1, Depth1 is Depth+1,
@ -3040,8 +3038,8 @@ require(Feature) :-
unrequire(Feature) :- unrequire(Feature) :-
atom(Feature), atom(Feature),
atom_concat('problog_required_', Feature, Feature_Required), atomic_concat(['problog_required_',Feature],Feature_Required),
atom_concat(Feature_Required, '_depth', Feature_Depth), atomic_concat([Feature_Required,'_',depth],Feature_Depth),
b_getval(Feature_Depth,Depth), b_getval(Feature_Depth,Depth),
(Depth=1 -> (Depth=1 ->
nb_delete(Feature_Required), nb_delete(Feature_Required),
@ -3054,7 +3052,7 @@ unrequire(Feature) :-
required(Feature) :- required(Feature) :-
atom(Feature), atom(Feature),
atom_concat('problog_required_', Feature, Feature_Required), atomic_concat(['problog_required_',Feature],Feature_Required),
catch(b_getval(Feature_Required,Val),error(existence_error(variable,Feature_Required),_),fail), catch(b_getval(Feature_Required,Val),error(existence_error(variable,Feature_Required),_),fail),
Val == required. Val == required.

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog
@ -204,15 +204,14 @@
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:-module(flags, [ :-module(flags, [problog_define_flag/4,
problog_define_flag/4, problog_define_flag/5,
problog_define_flag/5, problog_define_flag/6,
problog_define_flag/6, problog_defined_flag/5,
problog_defined_flag/5, problog_defined_flag_group/1,
problog_defined_flag_group/1, set_problog_flag/2,
set_problog_flag/2, reset_problog_flags/0,
reset_problog_flags/0, problog_flag/2]).
problog_flag/2]).
:- use_module(gflags). :- use_module(gflags).
@ -344,8 +343,17 @@ learning_init_handler(validating, (_,_,_,_,_)).
learning_init_handler(validated, _Value). learning_init_handler(validated, _Value).
learning_init_handler(stored, _Value). learning_init_handler(stored, _Value).
learning_prob_init_handler(message, '(Q,P,Query)'). learning_prob_init_handler(message, '(0,1] or uniform(l,h) ').
learning_prob_init_handler(validating, (_,_,_)). learning_prob_init_handler(validating, uniform(Low,High)) :-
number(Low),
number(High),
Low<High,
Low>0,
High =< 1.
learning_prob_init_handler(validating, N) :-
number(N),
N>0,
N =< 1.
%learning_prob_init_handler(validate, V_). %learning_prob_init_handler(validate, V_).
learning_prob_init_handler(validated, _Value). learning_prob_init_handler(validated, _Value).
learning_prob_init_handler(stored, _Value). learning_prob_init_handler(stored, _Value).

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog
@ -515,16 +515,15 @@ logger_write_header :-
bb_get(logger_filename,FName), bb_get(logger_filename,FName),
bb_get(logger_variables,Variables), bb_get(logger_variables,Variables),
open(FName,'append',Handle), open(FName,'append',Handle),
write(Handle,'# '), format(Handle,'#####################################################################~n',[]),
logger_write_header_intern(Variables,Handle), format(Handle,'# ~w~6+~w~7+~w~n',['Pos','Type','Name']),
write(Handle,'\n'), format(Handle,'#####################################################################~n',[]),
logger_write_header_intern(Variables,1,Handle),
format(Handle,'#####################################################################~n',[]),
close(Handle). close(Handle).
logger_write_header_intern([],_). logger_write_header_intern([],_,_).
logger_write_header_intern([(Name,_Type)],Handle) :- logger_write_header_intern([(Name,Type)|T],Position,Handle) :-
write(Handle,Name). format(Handle,'# ~q~6+~q~7+~q~n',[Position,Type,Name]),
logger_write_header_intern([(Name,_Type),Next|T],Handle) :- Position2 is Position+1,
bb_get(logger_delimiter,D), logger_write_header_intern(T,Position2,Handle).
write(Handle,Name),
write(Handle,D),
logger_write_header_intern([Next|T],Handle).

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-09-24 15:54:45 +0200 (Fri, 24 Sep 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4822 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-09-23 11:13:10 +0200 (Thu, 23 Sep 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4804 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-09-07 23:20:03 +0200 (Tue, 07 Sep 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4765 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog
@ -246,7 +246,7 @@
% load library modules % load library modules
:- use_module(library(tries)). :- use_module(library(tries)).
:- use_module(library(lists), [append/3, member/2, memberchk/2]). :- use_module(library(lists), [append/3, member/2, memberchk/2, delete/3]).
:- use_module(library(system), [delete_file/1, shell/1]). :- use_module(library(system), [delete_file/1, shell/1]).
:- use_module(library(ordsets), [ord_intersection/3, ord_union/3]). :- use_module(library(ordsets), [ord_intersection/3, ord_union/3]).
@ -260,10 +260,10 @@
% this is a test to determine whether YAP provides the needed trie library % this is a test to determine whether YAP provides the needed trie library
:- initialization( :- initialization(
( predicate_property(trie_disable_hash, imported_from(tries)) -> ( predicate_property(trie_disable_hash, imported_from(tries)) ->
trie_disable_hash trie_disable_hash
; print_message(warning,'The predicate tries:trie_disable_hash/0 does not exist. Please update trie library.') ; print_message(warning,'The predicate tries:trie_disable_hash/0 does not exist. Please update trie library.')
) )
). ).
%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-09-24 15:54:45 +0200 (Fri, 24 Sep 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4822 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog
@ -204,17 +204,11 @@
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% :- module(utils_learning, [empty_bdd_directory/0,
% Collected OS depended instructions empty_output_directory/0,
%%%%%%%% delete_file_silent/1,
:- module(utils_learning, [empty_bdd_directory/1, slice_n/4]).
empty_output_directory/1,
delete_file_silent/1
]).
% switch on all tests to reduce bug searching time
:- style_check(all).
:- yap_flag(unknown,error).
% load library modules % load library modules
:- use_module(library(lists), [append/3, member/2]). :- use_module(library(lists), [append/3, member/2]).
@ -222,28 +216,33 @@
% load our own modules % load our own modules
:- use_module(os). :- use_module(os).
:- use_module(flags).
%======================================================================== %========================================================================
%= %=
%= %=
%======================================================================== %========================================================================
empty_bdd_directory(Path) :- empty_bdd_directory :-
ground(Path), problog_flag(bdd_directory,Path),
!,
atom_codes('query_', PF1), % 'query_*' atom_codes('query_', PF1), % 'query_*'
directory_files(Path,List), directory_files(Path,List),
delete_files_with_matching_prefix(List,Path,[PF1]). delete_files_with_matching_prefix(List,Path,[PF1]).
empty_bdd_directory :-
throw(error(problog_flag_does_not_exist(bdd_directory))).
%======================================================================== %========================================================================
%= %=
%= %=
%======================================================================== %========================================================================
empty_output_directory(Path) :- empty_output_directory :-
ground(Path), problog_flag(output_directory,Path),
!,
concat_path_with_filename(Path,'log.dat',F1), concat_path_with_filename(Path,'log.dat',F1),
concat_path_with_filename(Path,'out.dat',F2), concat_path_with_filename(Path,'out.dat',F2),
@ -270,6 +269,9 @@ empty_output_directory(Path) :-
directory_files(Path,List), directory_files(Path,List),
delete_files_with_matching_prefix(List,Path,[PF1,PF2,PF3,PF4,PF5,PF6]). delete_files_with_matching_prefix(List,Path,[PF1,PF2,PF3,PF4,PF5,PF6]).
empty_output_directory :-
throw(error(problog_flag_does_not_exist(output_directory))).
%======================================================================== %========================================================================
%= %=
%= %=
@ -300,3 +302,18 @@ delete_files_with_matching_prefix([Name|T],Path,Prefixes) :-
), ),
delete_files_with_matching_prefix(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).

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog
@ -204,12 +204,7 @@
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- module(variable_elimination, [ :- module(variable_elimination, [trie_check_for_and_cluster/1, trie_replace_and_cluster/2, clean_up/0, variable_elimination_stats/3]).
trie_check_for_and_cluster/1,
trie_replace_and_cluster/2,
clean_up/0,
variable_elimination_stats/3
]).
:- use_module(library(lists), [append/3, delete/3, memberchk/2, reverse/2]). :- use_module(library(lists), [append/3, delete/3, memberchk/2, reverse/2]).
:- use_module(library(tries)). :- use_module(library(tries)).

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4672 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog

View File

@ -2,8 +2,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% $Date: 2010-09-24 15:54:45 +0200 (Fri, 24 Sep 2010) $ % $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
% $Revision: 4822 $ % $Revision: 4838 $
% %
% This file is part of ProbLog % This file is part of ProbLog
% http://dtai.cs.kuleuven.be/problog % http://dtai.cs.kuleuven.be/problog
@ -205,10 +205,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- module(learning,[ :- module(learning,[do_learning/1,
do_learning/1, do_learning/2,
do_learning/2, set_learning_flag/2,
set_learning_flag/2,
learning_flag/2, learning_flag/2,
learning_flags/0, learning_flags/0,
problog_help/0, problog_help/0,
@ -216,7 +215,7 @@
problog_flag/2, problog_flag/2,
problog_flags/0, problog_flags/0,
auto_alpha/0 auto_alpha/0
]). ]).
% switch on all the checks to reduce bug searching time % switch on all the checks to reduce bug searching time
:- style_check(all). :- style_check(all).
@ -500,7 +499,9 @@ do_learning_intern(Iterations,Epsilon) :-
-> ->
( (
retractall(values_correct), retractall(values_correct),
once(delete_all_queries), retractall(query_is_similar(_,_)),
retractall(query_md5(_,_,_)),
once(empty_bdd_directory),
once(init_queries) once(init_queries)
); true ); true
), ),
@ -551,7 +552,7 @@ init_learning :-
) )
-> ->
true; true;
delete_all_queries empty_bdd_directory
), ),
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -648,23 +649,6 @@ init_learning :-
format_learning(1,'~n',[]). format_learning(1,'~n',[]).
%========================================================================
%=
%=
%=
%========================================================================
delete_all_queries :-
problog_flag(bdd_directory,BDD_Directory),
empty_bdd_directory(BDD_Directory),
retractall(query_is_similar(_,_)),
retractall(query_md5(_,_,_)).
empty_output_directory :-
problog_flag(output_directory,Directory),
empty_output_directory(Directory).
%======================================================================== %========================================================================
%= This predicate goes over all training and test examples, %= This predicate goes over all training and test examples,
@ -1681,10 +1665,6 @@ init_logger :-
logger_define_variable(learning_rate,float), logger_define_variable(learning_rate,float),
logger_define_variable(alpha,float). logger_define_variable(alpha,float).
%======================================================================== :- initialization(init_flags).
%= :- initialization(init_logger).
%=
%========================================================================
:- initialization((init_flags,init_logger)).