Portability issues
This commit is contained in:
parent
39baf51c2d
commit
0cd5cec64b
@ -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 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
|
@ -230,7 +230,7 @@
|
||||
problog_kbest_save/6,
|
||||
problog_max/3,
|
||||
problog_exact/3,
|
||||
problog_exact_save/5,
|
||||
problog_exact_save/5,
|
||||
problog_montecarlo/3,
|
||||
problog_dnf_sampling/3,
|
||||
problog_answers/2,
|
||||
@ -320,7 +320,7 @@
|
||||
:- use_module('problog/sampling').
|
||||
:- use_module('problog/intervals').
|
||||
:- use_module('problog/mc_DNF_sampling').
|
||||
:- use_module('problog/variable_elimination').
|
||||
:- catch(use_module('problog/variable_elimination'),_,true).
|
||||
|
||||
% op attaching probabilities to facts
|
||||
:- op( 550, yfx, :: ).
|
||||
@ -371,7 +371,7 @@
|
||||
:- dynamic(dynamic_probability_fact_extract/2).
|
||||
|
||||
% 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).
|
||||
|
||||
% ProbLog files declare prob. facts as P::G
|
||||
@ -381,7 +381,7 @@
|
||||
|
||||
% directory where problogbdd executable is located
|
||||
% 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
|
||||
%%%%%%%%%%%%
|
||||
|
||||
:- initialization(
|
||||
problog_define_flag(inference, problog_flag_validate_dummy, 'default inference method', exact, inference)
|
||||
).
|
||||
:- initialization(problog_define_flag(inference, problog_flag_validate_dummy, 'default inference method', exact, inference)).
|
||||
|
||||
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
|
||||
copy_term((Head,Body),(HeadCopy,_BodyCopy)),
|
||||
functor(Head, Functor, Arity),
|
||||
atom_concat(problog_, Functor, LongFunctor),
|
||||
atomic_concat([problog_,Functor],LongFunctor),
|
||||
Head =.. [Functor|Args],
|
||||
append(Args,[LProb],LongArgs),
|
||||
probclause_id(ID),
|
||||
@ -626,7 +624,7 @@ user:term_expansion(P::Goal,Goal) :-
|
||||
term_expansion_intern(P :: Goal,Module,problog:ProbFact) :-
|
||||
copy_term((P,Goal),(P_Copy,Goal_Copy)),
|
||||
functor(Goal, Name, Arity),
|
||||
atom_concat(problog_, Name, ProblogName),
|
||||
atomic_concat([problog_,Name],ProblogName),
|
||||
Goal =.. [Name|Args],
|
||||
append(Args,[LProb],L1),
|
||||
probclause_id(ID),
|
||||
@ -708,7 +706,7 @@ user:term_expansion(Goal, problog:ProbFact) :-
|
||||
),
|
||||
|
||||
functor(Goal, Name, Arity),
|
||||
atom_concat(problogcontinuous_, Name, ProblogName),
|
||||
atomic_concat([problogcontinuous_,Name],ProblogName),
|
||||
probclause_id(ID),
|
||||
|
||||
GaussianArg=gaussian(Mu_Arg,Sigma_Arg),
|
||||
@ -807,16 +805,16 @@ interval_merge((_ID,GroundID,_Type),Interval) :-
|
||||
|
||||
|
||||
|
||||
problog_assertz(P::Goal) :-
|
||||
problog_assertz(user,P::Goal).
|
||||
problog_assertz(Module, P::Goal) :-
|
||||
problog_assert(P::Goal) :-
|
||||
problog_assert(user,P::Goal).
|
||||
problog_assert(Module, P::Goal) :-
|
||||
term_expansion_intern(P::Goal,Module,problog:ProbFact),
|
||||
assertz(problog:ProbFact).
|
||||
|
||||
problog_retractall(Goal) :-
|
||||
Goal =.. [F|Args],
|
||||
append([_ID|Args],[_Prob],Args2),
|
||||
atom_concat('problog_', F, F2),
|
||||
atomic_concat(['problog_',F],F2),
|
||||
ProbLogGoal=..[F2|Args2],
|
||||
retractall(problog:ProbLogGoal).
|
||||
|
||||
@ -964,7 +962,7 @@ probabilistic_fact(P2,Goal,ID) :-
|
||||
->
|
||||
(
|
||||
Goal =.. [F|Args],
|
||||
atom_concat('problog_', F, F2),
|
||||
atomic_concat('problog_',F,F2),
|
||||
append([ID|Args],[P],Args2),
|
||||
Goal2 =..[F2|Args2],
|
||||
length(Args2,N),
|
||||
@ -977,8 +975,8 @@ probabilistic_fact(P2,Goal,ID) :-
|
||||
get_internal_fact(ID,ProblogTerm,_ProblogName,_ProblogArity),
|
||||
ProblogTerm =.. [F,_ID|Args],
|
||||
append(Args2,[P],Args),
|
||||
atom_codes(F,[_p,_r,_o,_b,_l,_o,_g,_|F2Chars]),
|
||||
atom_codes(F2,F2Chars),
|
||||
name(F,[_p,_r,_o,_b,_l,_o,_g,_|F2Chars]),
|
||||
name(F2,F2Chars),
|
||||
Goal =.. [F2|Args2],
|
||||
(
|
||||
dynamic_probability_fact(ID)
|
||||
@ -1011,7 +1009,7 @@ prob_for_id(dummy,dummy,dummy).
|
||||
get_fact_probability(A, Prob) :-
|
||||
ground(A),
|
||||
\+ number(A),
|
||||
atom_codes(A, A_Codes),
|
||||
name(A, A_Codes),
|
||||
once(append(Part1, [95|Part2], A_Codes)), % 95 = '_'
|
||||
number_codes(ID, Part1), !,
|
||||
% 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) :-
|
||||
problog_predicate(Name,Arity),
|
||||
atom_concat(problog_, Name, ProblogName),
|
||||
atomic_concat([problog_,Name],ProblogName),
|
||||
ProblogArity is Arity+2,
|
||||
functor(ProblogTerm,ProblogName,ProblogArity),
|
||||
arg(1,ProblogTerm,ID),
|
||||
@ -1090,7 +1088,7 @@ get_continuous_fact_parameters(ID,Parameters) :-
|
||||
|
||||
get_internal_continuous_fact(ID,ProblogTerm,ProblogName,ProblogArity,ContinuousPos) :-
|
||||
problog_continuous_predicate(Name,Arity,ContinuousPos),
|
||||
atom_concat(problogcontinuous_, Name, ProblogName),
|
||||
atomic_concat([problogcontinuous_,Name],ProblogName),
|
||||
ProblogArity is Arity+1,
|
||||
functor(ProblogTerm,ProblogName,ProblogArity),
|
||||
arg(1,ProblogTerm,ID),
|
||||
@ -1155,12 +1153,12 @@ get_fact(ID,OutsideTerm) :-
|
||||
grounding_is_known(OutsideTerm,GID).
|
||||
|
||||
recover_grounding_id(Atom,ID) :-
|
||||
atom_codes(Atom,List),
|
||||
name(Atom,List),
|
||||
reverse(List,Rev),
|
||||
recover_number(Rev,NumRev),
|
||||
reverse(NumRev,Num),
|
||||
atom_codes(ID,Num).
|
||||
recover_number([95|_],[]) :- !. % atom_codes('_',[95])
|
||||
name(ID,Num).
|
||||
recover_number([95|_],[]) :- !. % name('_',[95])
|
||||
recover_number([A|B],[A|C]) :-
|
||||
recover_number(B,C).
|
||||
|
||||
@ -1294,9 +1292,9 @@ montecarlo_check(ComposedID) :-
|
||||
fail.
|
||||
% (c) for unknown groundings of non-ground facts: generate a new sample (decompose the ID first)
|
||||
montecarlo_check(ID) :-
|
||||
atom_codes(ID,IDN),
|
||||
name(ID,IDN),
|
||||
recover_number(IDN,FactIDName),
|
||||
atom_codes(FactID,FactIDName),
|
||||
name(FactID,FactIDName),
|
||||
new_sample_nonground(ID,FactID).
|
||||
|
||||
% sampling from ground fact: set array value to 1 (in) or 2 (out)
|
||||
@ -1332,10 +1330,10 @@ new_sample_nonground(ComposedID,ID) :-
|
||||
% fail.
|
||||
|
||||
split_grounding_id(Composed,Fact,Grounding) :-
|
||||
atom_codes(Composed,C),
|
||||
name(Composed,C),
|
||||
split_g_id(C,F,G),
|
||||
atom_codes(Fact,F),
|
||||
atom_codes(Grounding,G).
|
||||
name(Fact,F),
|
||||
name(Grounding,G).
|
||||
split_g_id([95|Grounding],[],Grounding) :- !.
|
||||
split_g_id([A|B],[A|FactID],GroundingID) :-
|
||||
split_g_id(B,FactID,GroundingID).
|
||||
@ -3026,8 +3024,8 @@ bdd_par_file(BDDParFile) :-
|
||||
|
||||
require(Feature) :-
|
||||
atom(Feature),
|
||||
atom_concat('problog_required_', Feature, Feature_Required),
|
||||
atom_concat(Feature_Required, '_depth', Feature_Depth),
|
||||
atomic_concat(['problog_required_',Feature],Feature_Required),
|
||||
atomic_concat([Feature_Required,'_',depth],Feature_Depth),
|
||||
(required(Feature) ->
|
||||
b_getval(Feature_Depth,Depth),
|
||||
Depth1 is Depth+1,
|
||||
@ -3040,8 +3038,8 @@ require(Feature) :-
|
||||
|
||||
unrequire(Feature) :-
|
||||
atom(Feature),
|
||||
atom_concat('problog_required_', Feature, Feature_Required),
|
||||
atom_concat(Feature_Required, '_depth', Feature_Depth),
|
||||
atomic_concat(['problog_required_',Feature],Feature_Required),
|
||||
atomic_concat([Feature_Required,'_',depth],Feature_Depth),
|
||||
b_getval(Feature_Depth,Depth),
|
||||
(Depth=1 ->
|
||||
nb_delete(Feature_Required),
|
||||
@ -3054,7 +3052,7 @@ unrequire(Feature) :-
|
||||
|
||||
required(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),
|
||||
Val == required.
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -204,15 +204,14 @@
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:-module(flags, [
|
||||
problog_define_flag/4,
|
||||
problog_define_flag/5,
|
||||
problog_define_flag/6,
|
||||
problog_defined_flag/5,
|
||||
problog_defined_flag_group/1,
|
||||
set_problog_flag/2,
|
||||
reset_problog_flags/0,
|
||||
problog_flag/2]).
|
||||
:-module(flags, [problog_define_flag/4,
|
||||
problog_define_flag/5,
|
||||
problog_define_flag/6,
|
||||
problog_defined_flag/5,
|
||||
problog_defined_flag_group/1,
|
||||
set_problog_flag/2,
|
||||
reset_problog_flags/0,
|
||||
problog_flag/2]).
|
||||
|
||||
|
||||
:- use_module(gflags).
|
||||
@ -344,8 +343,17 @@ learning_init_handler(validating, (_,_,_,_,_)).
|
||||
learning_init_handler(validated, _Value).
|
||||
learning_init_handler(stored, _Value).
|
||||
|
||||
learning_prob_init_handler(message, '(Q,P,Query)').
|
||||
learning_prob_init_handler(validating, (_,_,_)).
|
||||
learning_prob_init_handler(message, '(0,1] or uniform(l,h) ').
|
||||
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(validated, _Value).
|
||||
learning_prob_init_handler(stored, _Value).
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -515,16 +515,15 @@ logger_write_header :-
|
||||
bb_get(logger_filename,FName),
|
||||
bb_get(logger_variables,Variables),
|
||||
open(FName,'append',Handle),
|
||||
write(Handle,'# '),
|
||||
logger_write_header_intern(Variables,Handle),
|
||||
write(Handle,'\n'),
|
||||
format(Handle,'#####################################################################~n',[]),
|
||||
format(Handle,'# ~w~6+~w~7+~w~n',['Pos','Type','Name']),
|
||||
format(Handle,'#####################################################################~n',[]),
|
||||
logger_write_header_intern(Variables,1,Handle),
|
||||
format(Handle,'#####################################################################~n',[]),
|
||||
close(Handle).
|
||||
|
||||
logger_write_header_intern([],_).
|
||||
logger_write_header_intern([(Name,_Type)],Handle) :-
|
||||
write(Handle,Name).
|
||||
logger_write_header_intern([(Name,_Type),Next|T],Handle) :-
|
||||
bb_get(logger_delimiter,D),
|
||||
write(Handle,Name),
|
||||
write(Handle,D),
|
||||
logger_write_header_intern([Next|T],Handle).
|
||||
logger_write_header_intern([],_,_).
|
||||
logger_write_header_intern([(Name,Type)|T],Position,Handle) :-
|
||||
format(Handle,'# ~q~6+~q~7+~q~n',[Position,Type,Name]),
|
||||
Position2 is Position+1,
|
||||
logger_write_header_intern(T,Position2,Handle).
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-09-24 15:54:45 +0200 (Fri, 24 Sep 2010) $
|
||||
% $Revision: 4822 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-09-23 11:13:10 +0200 (Thu, 23 Sep 2010) $
|
||||
% $Revision: 4804 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-09-07 23:20:03 +0200 (Tue, 07 Sep 2010) $
|
||||
% $Revision: 4765 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -246,7 +246,7 @@
|
||||
|
||||
% load library modules
|
||||
:- 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(ordsets), [ord_intersection/3, ord_union/3]).
|
||||
|
||||
@ -260,10 +260,10 @@
|
||||
|
||||
% this is a test to determine whether YAP provides the needed trie library
|
||||
:- initialization(
|
||||
( predicate_property(trie_disable_hash, imported_from(tries)) ->
|
||||
trie_disable_hash
|
||||
; print_message(warning,'The predicate tries:trie_disable_hash/0 does not exist. Please update trie library.')
|
||||
)
|
||||
( predicate_property(trie_disable_hash, imported_from(tries)) ->
|
||||
trie_disable_hash
|
||||
; print_message(warning,'The predicate tries:trie_disable_hash/0 does not exist. Please update trie library.')
|
||||
)
|
||||
).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-09-24 15:54:45 +0200 (Fri, 24 Sep 2010) $
|
||||
% $Revision: 4822 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -204,17 +204,11 @@
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
%%%%%%%%
|
||||
% Collected OS depended instructions
|
||||
%%%%%%%%
|
||||
:- module(utils_learning, [empty_bdd_directory/1,
|
||||
empty_output_directory/1,
|
||||
delete_file_silent/1
|
||||
]).
|
||||
:- module(utils_learning, [empty_bdd_directory/0,
|
||||
empty_output_directory/0,
|
||||
delete_file_silent/1,
|
||||
slice_n/4]).
|
||||
|
||||
% switch on all tests to reduce bug searching time
|
||||
:- style_check(all).
|
||||
:- yap_flag(unknown,error).
|
||||
|
||||
% load library modules
|
||||
:- use_module(library(lists), [append/3, member/2]).
|
||||
@ -222,27 +216,32 @@
|
||||
|
||||
% load our own modules
|
||||
:- use_module(os).
|
||||
:- use_module(flags).
|
||||
|
||||
%========================================================================
|
||||
%=
|
||||
%=
|
||||
%========================================================================
|
||||
|
||||
empty_bdd_directory(Path) :-
|
||||
ground(Path),
|
||||
empty_bdd_directory :-
|
||||
problog_flag(bdd_directory,Path),
|
||||
!,
|
||||
|
||||
atom_codes('query_', PF1), % 'query_*'
|
||||
|
||||
directory_files(Path,List),
|
||||
delete_files_with_matching_prefix(List,Path,[PF1]).
|
||||
empty_bdd_directory :-
|
||||
throw(error(problog_flag_does_not_exist(bdd_directory))).
|
||||
|
||||
%========================================================================
|
||||
%=
|
||||
%=
|
||||
%========================================================================
|
||||
|
||||
empty_output_directory(Path) :-
|
||||
ground(Path),
|
||||
empty_output_directory :-
|
||||
problog_flag(output_directory,Path),
|
||||
!,
|
||||
|
||||
concat_path_with_filename(Path,'log.dat',F1),
|
||||
concat_path_with_filename(Path,'out.dat',F2),
|
||||
@ -270,6 +269,9 @@ empty_output_directory(Path) :-
|
||||
directory_files(Path,List),
|
||||
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).
|
||||
|
||||
%========================================================================
|
||||
%= 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).
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -204,12 +204,7 @@
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:- module(variable_elimination, [
|
||||
trie_check_for_and_cluster/1,
|
||||
trie_replace_and_cluster/2,
|
||||
clean_up/0,
|
||||
variable_elimination_stats/3
|
||||
]).
|
||||
:- module(variable_elimination, [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(tries)).
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-08-24 15:23:06 +0200 (Tue, 24 Aug 2010) $
|
||||
% $Revision: 4672 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% $Date: 2010-09-24 15:54:45 +0200 (Fri, 24 Sep 2010) $
|
||||
% $Revision: 4822 $
|
||||
% $Date: 2010-09-28 21:04:43 +0200 (Tue, 28 Sep 2010) $
|
||||
% $Revision: 4838 $
|
||||
%
|
||||
% This file is part of ProbLog
|
||||
% http://dtai.cs.kuleuven.be/problog
|
||||
@ -205,10 +205,9 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
:- module(learning,[
|
||||
do_learning/1,
|
||||
do_learning/2,
|
||||
set_learning_flag/2,
|
||||
:- module(learning,[do_learning/1,
|
||||
do_learning/2,
|
||||
set_learning_flag/2,
|
||||
learning_flag/2,
|
||||
learning_flags/0,
|
||||
problog_help/0,
|
||||
@ -216,7 +215,7 @@
|
||||
problog_flag/2,
|
||||
problog_flags/0,
|
||||
auto_alpha/0
|
||||
]).
|
||||
]).
|
||||
|
||||
% switch on all the checks to reduce bug searching time
|
||||
:- style_check(all).
|
||||
@ -500,7 +499,9 @@ do_learning_intern(Iterations,Epsilon) :-
|
||||
->
|
||||
(
|
||||
retractall(values_correct),
|
||||
once(delete_all_queries),
|
||||
retractall(query_is_similar(_,_)),
|
||||
retractall(query_md5(_,_,_)),
|
||||
once(empty_bdd_directory),
|
||||
once(init_queries)
|
||||
); true
|
||||
),
|
||||
@ -551,7 +552,7 @@ init_learning :-
|
||||
)
|
||||
->
|
||||
true;
|
||||
delete_all_queries
|
||||
empty_bdd_directory
|
||||
),
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@ -648,23 +649,6 @@ init_learning :-
|
||||
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,
|
||||
@ -1681,10 +1665,6 @@ init_logger :-
|
||||
logger_define_variable(learning_rate,float),
|
||||
logger_define_variable(alpha,float).
|
||||
|
||||
%========================================================================
|
||||
%=
|
||||
%=
|
||||
%========================================================================
|
||||
:- initialization(init_flags).
|
||||
:- initialization(init_logger).
|
||||
|
||||
|
||||
:- initialization((init_flags,init_logger)).
|
||||
|
Reference in New Issue
Block a user