modules
This commit is contained in:
parent
1cde9d0eed
commit
9ea395c031
@ -539,7 +539,8 @@ static Int current_source_module(USES_REGS1) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t, NULL);
|
||||
return false;
|
||||
}
|
||||
LOCAL_SourceModule = t;
|
||||
Yap_DebugPlWriteln(t);
|
||||
LOCAL_SourceModule = CurrentModule = t;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,7 @@ scanl_([H1|T1], [H2|T2], [H3|T3], [H4|T4], Goal, V, [VH|VT]) :-
|
||||
goal_expansion(checklist(Meta, List), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -732,7 +732,7 @@ goal_expansion(checklist(Meta, List), Mod:Goal) :-
|
||||
goal_expansion(maplist(Meta, List), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -753,7 +753,7 @@ goal_expansion(maplist(Meta, List), Mod:Goal) :-
|
||||
goal_expansion(maplist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -774,7 +774,7 @@ goal_expansion(maplist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion(maplist(Meta, L1, L2, L3), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -795,7 +795,7 @@ goal_expansion(maplist(Meta, L1, L2, L3), Mod:Goal) :-
|
||||
goal_expansion(maplist(Meta, L1, L2, L3, L4), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -816,7 +816,7 @@ goal_expansion(maplist(Meta, L1, L2, L3, L4), Mod:Goal) :-
|
||||
goal_expansion(maplist(Meta, L1, L2, L3, L4, L5), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -837,7 +837,7 @@ goal_expansion(maplist(Meta, L1, L2, L3, L4, L5), Mod:Goal) :-
|
||||
goal_expansion(selectlist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -860,7 +860,7 @@ goal_expansion(selectlist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion(selectlist(Meta, ListIn, ListIn1, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -883,7 +883,7 @@ goal_expansion(selectlist(Meta, ListIn, ListIn1, ListOut), Mod:Goal) :-
|
||||
goal_expansion(selectlists(Meta, ListIn, ListIn1, ListOut, ListOut1), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -907,7 +907,7 @@ goal_expansion(selectlists(Meta, ListIn, ListIn1, ListOut, ListOut1), Mod:Goal)
|
||||
goal_expansion(include(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -930,7 +930,7 @@ goal_expansion(include(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion(exclude(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -953,7 +953,7 @@ goal_expansion(exclude(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion(partition(Meta, ListIn, List1, List2), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -976,7 +976,7 @@ goal_expansion(partition(Meta, ListIn, List1, List2), Mod:Goal) :-
|
||||
goal_expansion(partition(Meta, ListIn, List1, List2, List3), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1016,7 +1016,7 @@ goal_expansion(partition(Meta, ListIn, List1, List2, List3), Mod:Goal) :-
|
||||
goal_expansion(convlist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1039,7 +1039,7 @@ goal_expansion(convlist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion(convlist(Meta, ListIn, ListExtra, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1062,7 +1062,7 @@ goal_expansion(convlist(Meta, ListIn, ListExtra, ListOut), Mod:Goal) :-
|
||||
goal_expansion(sumlist(Meta, List, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1083,7 +1083,7 @@ goal_expansion(sumlist(Meta, List, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion(foldl(Meta, List, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1104,7 +1104,7 @@ goal_expansion(foldl(Meta, List, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion(foldl(Meta, List1, List2, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1125,7 +1125,7 @@ goal_expansion(foldl(Meta, List1, List2, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion(foldl(Meta, List1, List2, List3, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1146,7 +1146,7 @@ goal_expansion(foldl(Meta, List1, List2, List3, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion(foldl2(Meta, List, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1167,7 +1167,7 @@ goal_expansion(foldl2(Meta, List, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
goal_expansion(foldl2(Meta, List1, List2, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1188,7 +1188,7 @@ goal_expansion(foldl2(Meta, List1, List2, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
goal_expansion(foldl2(Meta, List1, List2, List3, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1209,7 +1209,7 @@ goal_expansion(foldl2(Meta, List1, List2, List3, AccIn, AccOut, W0, W), Mod:Goal
|
||||
goal_expansion(foldl3(Meta, List, AccIn, AccOut, W0, W, X0, X), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1230,7 +1230,7 @@ goal_expansion(foldl3(Meta, List, AccIn, AccOut, W0, W, X0, X), Mod:Goal) :-
|
||||
goal_expansion(foldl4(Meta, List, AccIn, AccOut, W0, W, X0, X, Y0, Y), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1251,7 +1251,7 @@ goal_expansion(foldl4(Meta, List, AccIn, AccOut, W0, W, X0, X, Y0, Y), Mod:Goal)
|
||||
goal_expansion(mapnodes(Meta, InTerm, OutTerm), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1283,7 +1283,7 @@ goal_expansion(mapnodes(Meta, InTerm, OutTerm), Mod:Goal) :-
|
||||
goal_expansion(checknodes(Meta, Term), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
@ -1313,7 +1313,7 @@ goal_expansion(checknodes(Meta, Term), Mod:Goal) :-
|
||||
goal_expansion(sumnodes(Meta, Term, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
prolog_load_context(module, Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
% the new goal
|
||||
|
@ -653,7 +653,7 @@ Unify _NElems_ with the type of the elements in _Matrix_.
|
||||
:- use_module(library(maplist)).
|
||||
:- use_module(library(mapargs)).
|
||||
:- use_module(library(lists)).
|
||||
|
||||
:- start_low_level_trace.
|
||||
( X <== '[]'(Dims0, array) of T ) :-
|
||||
var(X),
|
||||
( T== ints -> true ; T== floats),
|
||||
@ -661,6 +661,7 @@ Unify _NElems_ with the type of the elements in _Matrix_.
|
||||
foldl( norm_dim, Dims0, Dims, Bases, 1, _Size ),
|
||||
matrix_new( T , Dims, _, X ),
|
||||
matrix_base(X, Bases).
|
||||
:- stop_low_level_trace.
|
||||
( X <== '[]'(Dims0, array) of T ) :-
|
||||
atom(X),
|
||||
( T== ints -> true ; T== floats),
|
||||
|
@ -10,55 +10,44 @@
|
||||
* support routines for BDD evaluation.
|
||||
*
|
||||
*/
|
||||
:- module(lbdd,[
|
||||
set_tunable/3,
|
||||
prob2log/4,
|
||||
log2prob/4,
|
||||
bind_maplist/3,
|
||||
get_prob/2,
|
||||
gradient/3,
|
||||
query_probabilities/2,
|
||||
evalp/2,
|
||||
query_gradients/4
|
||||
|
||||
]
|
||||
).
|
||||
|
||||
|
||||
:- use_module('../problog').
|
||||
:- use_module('flags').
|
||||
:- use_module('logger').
|
||||
|
||||
set_tunable(I,Slope,P) :-
|
||||
X <== P[I],
|
||||
sigmoid(X,Slope,Pr),
|
||||
(Pr > 0.99
|
||||
->
|
||||
NPr = 0.99
|
||||
;
|
||||
Pr < 0.01
|
||||
->
|
||||
NPr = 0.01 ;
|
||||
Pr = NPr ),
|
||||
set_fact_probability(I,NPr).
|
||||
|
||||
%========================================================================
|
||||
%= Updates all values of query_probability/2 and query_gradient/4
|
||||
%= should be called always before these predicates are accessed
|
||||
%= if the old values are still valid, nothing happens
|
||||
%========================================================================
|
||||
|
||||
update_values :-
|
||||
values_correct,
|
||||
!.
|
||||
update_values :-
|
||||
\+ values_correct,
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% delete old values
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
retractall(query_probability_intern(_,_)),
|
||||
retractall(query_gradient_intern(_,_,_,_)),
|
||||
|
||||
|
||||
assertz(values_correct).
|
||||
|
||||
update_query_cleanup(QueryID) :-
|
||||
(
|
||||
(query_is_similar(QueryID,_) ; query_is_similar(_,QueryID))
|
||||
->
|
||||
% either this query is similar to another or vice versa,
|
||||
% therefore we don't delete anything
|
||||
true;
|
||||
retractall(query_gradient_intern(QueryID,_,_,_))
|
||||
).
|
||||
|
||||
|
||||
update_query(QueryID,Symbol,What_To_Update) :-
|
||||
(
|
||||
query_is_similar(QueryID,_)
|
||||
->
|
||||
% we don't have to evaluate the BDD
|
||||
format_learning(4,'#',[]);
|
||||
(
|
||||
problog_flag(sigmoid_slope,Slope),
|
||||
((What_To_Update=all;query_is_similar(_,QueryID)) -> Method='g' ; Method='l'),
|
||||
gradient(QueryID, Method, Slope),
|
||||
format_learning(4,'~w',[Symbol])
|
||||
)
|
||||
).
|
||||
|
||||
|
||||
prob2log(_X,Slope,FactID,V) :-
|
||||
get_fact_probability(FactID, V0),
|
||||
inv_sigmoid(V0, Slope, V).
|
||||
|
@ -799,20 +799,50 @@ set_fact(FactID, Slope, P ) :-
|
||||
set_fact_probability(FactID, NPr).
|
||||
|
||||
|
||||
set_tunable(I,Slope,P) :-
|
||||
X <== P[I],
|
||||
sigmoid(X,Slope,Pr),
|
||||
(Pr > 0.99
|
||||
->
|
||||
NPr = 0.99
|
||||
;
|
||||
Pr < 0.01
|
||||
->
|
||||
NPr = 0.01 ;
|
||||
Pr = NPr ),
|
||||
set_fact_probability(I,NPr).
|
||||
update_query_cleanup(QueryID) :-
|
||||
(
|
||||
(query_is_similar(QueryID,_) ; query_is_similar(_,QueryID))
|
||||
->
|
||||
% either this query is similar to another or vice versa,
|
||||
% therefore we don't delete anything
|
||||
true;
|
||||
retractall(query_gradient_intern(QueryID,_,_,_))
|
||||
).
|
||||
|
||||
:- include(problog/lbdd).
|
||||
|
||||
update_query(QueryID,Symbol,What_To_Update) :-
|
||||
(
|
||||
query_is_similar(QueryID,_)
|
||||
->
|
||||
% we don't have to evaluate the BDD
|
||||
format_learning(4,'#',[]);
|
||||
(
|
||||
problog_flag(sigmoid_slope,Slope),
|
||||
((What_To_Update=all;query_is_similar(_,QueryID)) -> Method='g' ; Method='l'),
|
||||
gradient(QueryID, Method, Slope),
|
||||
format_learning(4,'~w',[Symbol])
|
||||
)
|
||||
).
|
||||
|
||||
|
||||
update_values :-
|
||||
values_correct,
|
||||
!.
|
||||
update_values :-
|
||||
\+ values_correct,
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% delete old values
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
retractall(query_probability_intern(_,_)),
|
||||
retractall(query_gradient_intern(_,_,_,_)),
|
||||
|
||||
|
||||
assertz(values_correct).
|
||||
|
||||
|
||||
|
||||
:- use_module(problog/lbdd).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% start calculate gradient
|
||||
|
@ -1 +1,82 @@
|
||||
:- module(myddas,[
|
||||
db_open/5,
|
||||
db_open/4,
|
||||
db_open/2,
|
||||
db_open/1,
|
||||
db_open/0,
|
||||
db_close/1,
|
||||
db_close/0,
|
||||
|
||||
db_verbose/1,
|
||||
db_module/1,
|
||||
db_is_database_predicate/3,
|
||||
%#ifdef MYDDAS_STATS
|
||||
db_stats/1,
|
||||
db_stats/2,
|
||||
db_stats_time/2,
|
||||
%#endif
|
||||
db_sql/2,
|
||||
db_sql/3,
|
||||
db_sql_select/3,
|
||||
db_prolog_select/2,
|
||||
db_prolog_select/3,
|
||||
db_prolog_select_multi/3,
|
||||
db_command/2,
|
||||
db_assert/2,
|
||||
db_assert/1,
|
||||
db_create_table/3,
|
||||
db_export_view/4,
|
||||
db_update/2,
|
||||
db_describe/2,
|
||||
db_describe/3,
|
||||
db_show_tables/2,
|
||||
db_show_tables/1,
|
||||
db_get_attributes_types/2,
|
||||
db_get_attributes_types/3,
|
||||
db_number_of_fields/2,
|
||||
db_number_of_fields/3,
|
||||
% myddas_shared.c
|
||||
c_db_connection_type/2,
|
||||
c_db_add_preds/4,
|
||||
c_db_preds_conn/4,
|
||||
c_db_connection/1,
|
||||
c_db_check_if_exists_pred/3,
|
||||
c_db_delete_predicate/2,
|
||||
c_db_multi_queries_number/2,
|
||||
%#ifdef MYDDAS_STATS
|
||||
c_db_stats/2,
|
||||
c_db_stats_walltime/1,
|
||||
c_db_stats_translate/2,
|
||||
c_db_stats_time/2,
|
||||
%#endif
|
||||
%#ifdef DEBUG
|
||||
c_db_check/0,
|
||||
%#endif
|
||||
c_db_initialize_myddas/0,
|
||||
c_db_connection_type/2,
|
||||
c_db_add_preds/4,
|
||||
c_db_preds_conn/4,
|
||||
c_db_connection/1,
|
||||
c_db_check_if_exists_pred/3,
|
||||
c_db_delete_predicate/2,
|
||||
c_db_multi_queries_number/2,
|
||||
%#ifdef MYDDAS_STATS
|
||||
c_db_stats/2,
|
||||
c_db_stats_walltime/1,
|
||||
c_db_stats_translate/2,
|
||||
c_db_stats_time/2,
|
||||
%#endif
|
||||
%#ifdef DEBUG
|
||||
c_db_check/0,
|
||||
%#endif
|
||||
% myddas_top_level.ypp
|
||||
%#ifdef MYDDAS_TOP_LEVEL
|
||||
db_top_level/4,
|
||||
db_top_level/5,
|
||||
db_datalog_select/3,
|
||||
%#endif
|
||||
% myddas_assert_predicates.ypp
|
||||
% myddas_mysql.ypp,
|
||||
db_multi_queries_number/2
|
||||
]).
|
||||
:- include( myddas/myddas_core ).
|
||||
|
@ -123,7 +123,7 @@
|
||||
#ifdef MYDDAS_TOP_LEVEL
|
||||
db_top_level/4,
|
||||
db_top_level/5,
|
||||
db_datalog_select/3,
|
||||
n db_datalog_select/3,
|
||||
#endif
|
||||
% myddas_assert_predicates.ypp
|
||||
% myddas_mysql.ypp,
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
:- use_module(library(lists)).
|
||||
:- use_module(library(maplist)).
|
||||
:- use_module(myddas_core).
|
||||
:- use_module(library(myddas)).
|
||||
|
||||
main :-
|
||||
init,
|
||||
|
@ -43,7 +43,7 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x,
|
||||
YAP_Term call;
|
||||
YAP_Bool result;
|
||||
lbfgsfloatval_t rc=0.0;
|
||||
YAP_Term v, t1, t12;
|
||||
YAP_Term v=YAP_MkVarTerm(), t1, t12;
|
||||
YAP_Term t[6], t2[2];
|
||||
|
||||
YAP_Term t_0 = YAP_MkIntTerm((YAP_Int)&rc);
|
||||
|
@ -538,7 +538,7 @@ load_files(Files0,Opts) :-
|
||||
'$qload_file'(Stream, Mod, F, FilePl, File, ImportList, TOpts),
|
||||
close( Stream ),
|
||||
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
||||
'$current_module'(M, Mod),
|
||||
current_source_module(M, Mod),
|
||||
working_directory( _, OldD),
|
||||
'$lf_opt'('$location', TOpts, ParentF:_Line),
|
||||
'$reexport'( TOpts, ParentF, Reexport, ImportList, File ),
|
||||
@ -546,7 +546,7 @@ load_files(Files0,Opts) :-
|
||||
working_directory( _, OldD),
|
||||
set_prolog_flag(compiling,false),
|
||||
'$exec_initialization_goals',
|
||||
'$current_module'(_M, Mod).
|
||||
current_source_module(_M, Mod).
|
||||
'$start_lf'(_, Mod, Stream, TOpts, UserFile, File, _Reexport, _Imports) :-
|
||||
'$do_lf'(Mod, Stream, UserFile, File, TOpts).
|
||||
|
||||
@ -598,7 +598,7 @@ consult(V) :-
|
||||
consult(M0:Fs) :- !,
|
||||
'$consult'(Fs, M0).
|
||||
consult(Fs) :-
|
||||
'$current_module'(M0),
|
||||
current_source_module(M0,M0),
|
||||
'$consult'(Fs, M0).
|
||||
|
||||
'$consult'(Fs,Module) :-
|
||||
@ -735,7 +735,7 @@ db_files(Fs) :-
|
||||
'__NB_getval__'('$if_level', OldIfLevel, OldIfLevel=0),
|
||||
nb_setval('$if_level',0),
|
||||
% take care with [a:f], a is the ContextModule
|
||||
'$current_module'(SourceModule, ContextModule),
|
||||
current_source_module(SourceModule, ContextModule),
|
||||
'$lf_opt'(consult, TOpts, Reconsult0),
|
||||
'$lf_opt'('$options', TOpts, Opts),
|
||||
'$lf_opt'('$location', TOpts, ParentF:Line),
|
||||
@ -769,7 +769,7 @@ db_files(Fs) :-
|
||||
'$loop'(Stream,Reconsult),
|
||||
'$lf_opt'(imports, TOpts, Imports),
|
||||
'$import_to_current_module'(File, ContextModule, Imports, _, TOpts),
|
||||
'$current_module'(Mod, SourceModule),
|
||||
current_source_module(Mod, SourceModule),
|
||||
%`writeln(( ContextModule/Mod )),
|
||||
set_prolog_flag(verbose_load, VerboseLoad),
|
||||
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
||||
@ -889,7 +889,7 @@ db_files(Fs) :-
|
||||
'$full_filename'(X, Y ),
|
||||
'$including'(Old, Y),
|
||||
'$lf_opt'(stream, TOpts, OldStream),
|
||||
'$current_module'(Mod),
|
||||
current_source_module(Mod,Mod),
|
||||
( open(Y, read, Stream) ->
|
||||
true ;
|
||||
'$do_error'(permission_error(input,stream,Y),include(X))
|
||||
@ -1011,7 +1011,7 @@ prolog_load_context(file, FileName) :-
|
||||
).
|
||||
prolog_load_context(module, X) :-
|
||||
'__NB_getval__'('$consulting_file', _, fail),
|
||||
'$current_module'(X).
|
||||
'current_module'(X).
|
||||
prolog_load_context(source, F0) :-
|
||||
( source_location(F0, _) /*,
|
||||
'$input_context'(Context),
|
||||
@ -1250,7 +1250,7 @@ unload_file( F0 ) :-
|
||||
% stub to prevent modules defined within the prolog module.
|
||||
%
|
||||
module(Mod, Decls) :-
|
||||
'$current_module'(prolog, Mod), !,
|
||||
current_source_module(prolog, Mod), !,
|
||||
'$export_preds'(Decls).
|
||||
|
||||
'$export_preds'([]).
|
||||
|
@ -238,14 +238,14 @@ meta_predicate(P) :-
|
||||
functor(G, F, Arity ),
|
||||
'$meta_predicate'(F, GM, Arity, PredDef),
|
||||
!,
|
||||
'$meta_expand'(G, PredDef, GM, HVars, GF).
|
||||
'$meta_expand'(G, PredDef, BM, HVars, GF).
|
||||
'$meta_expansion'(GF, BM, _HVars, BM:GF).
|
||||
|
||||
'$expand_goal'(G0, GF, GS, HM, SM, BM, HVars-H) :-
|
||||
'$yap_strip_module'( BM:G0, M0N, G0N),
|
||||
'$user_expansion'(HVars,M0N:G0N, M1:G1),
|
||||
'$import_expansion'(HVars, M1:G1, M2:G2),
|
||||
'$meta_expansion'(G2, M2, HVars, MG3),
|
||||
'$meta_expansion'(M2:G2, M1, HVars, MG3),
|
||||
'$yap_strip_module'(MG3, M4, B4),
|
||||
'$end_goal_expansion'(B4, GF, GS, HM, SM, M4, H).
|
||||
|
||||
@ -465,7 +465,7 @@ meta_predicate(P) :-
|
||||
% has to be last!!!
|
||||
'$expand_a_clause'(MHB, Cl1, ClO) :- % MHB is the original clause, SM0 the current source, Cl1 and ClO output clauses
|
||||
source_module(SM0),
|
||||
'$yap_strip_module'(MHB, SM, HB), % remove layers of modules over the clause. SM is the head module.
|
||||
'$yap_strip_module'(SM0:MHB, SM, HB), % remove layers of modules over the clause. SM is the head module.
|
||||
'$head_and_body'(HB, H, B), % HB is H :- B.
|
||||
'$yap_strip_module'(SM:H, HM, NH), % further module expansion
|
||||
'$not_imported'(NH, HM),
|
||||
|
@ -66,7 +66,7 @@ name with the `:/2` operator.
|
||||
source_location(F,Line),
|
||||
'__NB_getval__'( '$user_source_file', F0 , fail),
|
||||
'$add_module_on_file'(N, F, Line,F0, Ps),
|
||||
'$current_module'(_M0,N).
|
||||
current_source_module(_M0,N).
|
||||
|
||||
'$mk_system_predicates'( Ps, _N ) :-
|
||||
lists:member(Name/A , Ps),
|
||||
|
@ -25,7 +25,7 @@
|
||||
live :-
|
||||
repeat,
|
||||
yap_flag(verbose,normal),
|
||||
'$current_module'(Module),
|
||||
current_source_module(Module,Module),
|
||||
( Module==user ->
|
||||
true % '$compile_mode'(_,0)
|
||||
;
|
||||
@ -706,7 +706,7 @@ write_query_answer( Bindings ) :-
|
||||
'$loop'(Stream,exo) :-
|
||||
prolog_flag(agc_margin,Old,0),
|
||||
prompt1(': '), prompt(_,' '),
|
||||
'$current_module'(OldModule),
|
||||
source_module(OldModule,OldModule),
|
||||
repeat,
|
||||
'$system_catch'(dbload_from_stream(Stream, OldModule, exo), '$db_load', Error,
|
||||
user:'$LoopError'(Error, top)),
|
||||
@ -715,7 +715,7 @@ write_query_answer( Bindings ) :-
|
||||
'$loop'(Stream,db) :-
|
||||
prolog_flag(agc_margin,Old,0),
|
||||
prompt1(': '), prompt(_,' '),
|
||||
'$current_module'(OldModule),
|
||||
source_module(OldModule,OldModule),
|
||||
repeat,
|
||||
'$system_catch'(dbload_from_stream(Stream, OldModule, db), '$db_load', Error, user:'$LoopError'(Error, db)
|
||||
),
|
||||
@ -732,7 +732,7 @@ write_query_answer( Bindings ) :-
|
||||
|
||||
'$boot_loop'(Stream,Where) :-
|
||||
repeat,
|
||||
'$current_module'( OldModule, OldModule ),
|
||||
source_module( OldModule, OldModule ),
|
||||
read_clause(Stream, Command, [module(OldModule), syntax_errors(dec10),variable_names(_Vars), term_position(_Pos)]),
|
||||
(Command == end_of_file
|
||||
->
|
||||
|
Reference in New Issue
Block a user