assert(3)
This commit is contained in:
parent
9378622d42
commit
ab56074bb1
43
C/cdmgr.c
43
C/cdmgr.c
@ -74,6 +74,49 @@ static void kill_first_log_iblock(LogUpdIndex *, LogUpdIndex *, PredEntry *);
|
|||||||
#define PredArity(p) (p->ArityOfPE)
|
#define PredArity(p) (p->ArityOfPE)
|
||||||
#define TRYCODE(G, F, N) ((N) < 5 ? (op_numbers)((int)F + (N)*3) : G)
|
#define TRYCODE(G, F, N) ((N) < 5 ? (op_numbers)((int)F + (N)*3) : G)
|
||||||
|
|
||||||
|
PredEntry *Yap_get_pred(Term t, Term tmod, const char *pname) {
|
||||||
|
Term t0 = t;
|
||||||
|
|
||||||
|
restart:
|
||||||
|
if (IsVarTerm(t)) {
|
||||||
|
Yap_ThrowError(INSTANTIATION_ERROR, t0, pname);
|
||||||
|
return NULL;
|
||||||
|
} else if (IsAtomTerm(t)) {
|
||||||
|
PredEntry *ap = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod));
|
||||||
|
return ap;
|
||||||
|
} else if (IsIntegerTerm(t) && tmod == IDB_MODULE) {
|
||||||
|
return Yap_FindLUIntKey(IntegerOfTerm(t));
|
||||||
|
} else if (IsPairTerm(t)) {
|
||||||
|
t = Yap_MkApplTerm(FunctorCsult, 1, &t);
|
||||||
|
goto restart;
|
||||||
|
} else if (IsApplTerm(t)) {
|
||||||
|
Functor fun = FunctorOfTerm(t);
|
||||||
|
if (IsExtensionFunctor(fun)) {
|
||||||
|
Yap_ThrowError(TYPE_ERROR_CALLABLE, t, pname);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (fun == FunctorModule) {
|
||||||
|
Term tmod = ArgOfTerm(1, t);
|
||||||
|
if (IsVarTerm(tmod)) {
|
||||||
|
Yap_ThrowError(INSTANTIATION_ERROR, t0, pname);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(tmod)) {
|
||||||
|
Yap_ThrowError(TYPE_ERROR_ATOM, t0, pname);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
t = ArgOfTerm(2, t);
|
||||||
|
goto restart;
|
||||||
|
}
|
||||||
|
PredEntry *ap = RepPredProp(Yap_GetPredPropByFunc(fun, tmod));
|
||||||
|
return ap;
|
||||||
|
} else {
|
||||||
|
Yap_ThrowError(TYPE_ERROR_CALLABLE, t0, pname);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void InitConsultStack(void) {
|
static void InitConsultStack(void) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
LOCAL_ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj) *
|
LOCAL_ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj) *
|
||||||
|
42
C/exec.c
42
C/exec.c
@ -159,48 +159,6 @@ Term Yap_ExecuteCallMetaCall(Term g, Term mod) {
|
|||||||
return Yap_MkApplTerm(PredMetaCall->FunctorOfPred, 4, ts);
|
return Yap_MkApplTerm(PredMetaCall->FunctorOfPred, 4, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
PredEntry *Yap_get_pred(Term t, Term tmod, const char *pname) {
|
|
||||||
Term t0 = t;
|
|
||||||
|
|
||||||
restart:
|
|
||||||
if (IsVarTerm(t)) {
|
|
||||||
Yap_ThrowError(INSTANTIATION_ERROR, t0, pname);
|
|
||||||
return NULL;
|
|
||||||
} else if (IsAtomTerm(t)) {
|
|
||||||
PredEntry *ap = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod));
|
|
||||||
return ap;
|
|
||||||
} else if (IsIntegerTerm(t) && tmod == IDB_MODULE) {
|
|
||||||
return Yap_FindLUIntKey(IntegerOfTerm(t));
|
|
||||||
} else if (IsPairTerm(t)) {
|
|
||||||
t = Yap_MkApplTerm(FunctorCsult, 1, &t);
|
|
||||||
goto restart;
|
|
||||||
} else if (IsApplTerm(t)) {
|
|
||||||
Functor fun = FunctorOfTerm(t);
|
|
||||||
if (IsExtensionFunctor(fun)) {
|
|
||||||
Yap_ThrowError(TYPE_ERROR_CALLABLE, t, pname);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (fun == FunctorModule) {
|
|
||||||
Term tmod = ArgOfTerm(1, t);
|
|
||||||
if (IsVarTerm(tmod)) {
|
|
||||||
Yap_Error(INSTANTIATION_ERROR, t0, pname);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!IsAtomTerm(tmod)) {
|
|
||||||
Yap_Error(TYPE_ERROR_ATOM, t0, pname);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
t = ArgOfTerm(2, t);
|
|
||||||
goto restart;
|
|
||||||
}
|
|
||||||
PredEntry *ap = RepPredProp(Yap_GetPredPropByFunc(fun, tmod));
|
|
||||||
return ap;
|
|
||||||
} else {
|
|
||||||
Yap_Error(TYPE_ERROR_CALLABLE, t0, pname);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Term Yap_TermToIndicator(Term t, Term mod) {
|
Term Yap_TermToIndicator(Term t, Term mod) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
@ -470,7 +470,7 @@
|
|||||||
LogUpdClause *lcl = PREG->y_u.OtILl.d;
|
LogUpdClause *lcl = PREG->y_u.OtILl.d;
|
||||||
UInt timestamp = IntegerOfTerm(((CELL *)(B_YREG+1))[ap->ArityOfPE]);
|
UInt timestamp = IntegerOfTerm(((CELL *)(B_YREG+1))[ap->ArityOfPE]);
|
||||||
|
|
||||||
/* fprintf(stderr,"- %p/%p %d %d %p\n",PREG,ap,timestamp,ap->TimeStampOfPred,PREG->y_u.OtILl.d->ClCode);*/
|
fprintf(stderr,"- %p/%p %lu/%lu %lu-%lu\n",PREG,ap,timestamp,ap->TimeStampOfPred,PREG->y_u.OtILl.d->ClTimeStart,PREG->y_u.OtILl.d->ClTimeEnd);
|
||||||
#if defined(YAPOR) || defined(THREADS)
|
#if defined(YAPOR) || defined(THREADS)
|
||||||
if (PP != ap) {
|
if (PP != ap) {
|
||||||
if (PP) UNLOCKPE(16,PP);
|
if (PP) UNLOCKPE(16,PP);
|
||||||
|
@ -32,8 +32,8 @@ path(X,Y,A,R) :-
|
|||||||
path(Z,Y,[Z|A],R).
|
path(Z,Y,[Z|A],R).
|
||||||
|
|
||||||
% using directed edges in both directions
|
% using directed edges in both directions
|
||||||
edge(X,Y) :- problog:dir_edge(Y,X).
|
edge(X,Y) :- dir_edge(Y,X).
|
||||||
edge(X,Y) :- problog:dir_edge(X,Y).
|
edge(X,Y) :- dir_edge(X,Y).
|
||||||
|
|
||||||
% checking whether node hasn't been visited before
|
% checking whether node hasn't been visited before
|
||||||
absent(_,[]).
|
absent(_,[]).
|
||||||
|
@ -98,3 +98,4 @@ test_example(33,path(5,4),0.57).
|
|||||||
test_example(34,path(6,4),0.51).
|
test_example(34,path(6,4),0.51).
|
||||||
test_example(35,path(6,5),0.69).
|
test_example(35,path(6,5),0.69).
|
||||||
|
|
||||||
|
:- set_problog_flag(init_method,([Query,X,Y],N,Bdd,graph2bdd(X,Y,N,Bdd))).
|
||||||
|
@ -363,7 +363,7 @@ reset_learning :-
|
|||||||
retractall(current_iteration(_)),
|
retractall(current_iteration(_)),
|
||||||
retractall(example_count(_)),
|
retractall(example_count(_)),
|
||||||
retractall(query_probability_intern(_,_)),
|
retractall(query_probability_intern(_,_)),
|
||||||
retractall(query_gradient_intern(_,_,_)),
|
retractall(query_gradient_intern(_,_,_,_)),
|
||||||
retractall(last_mse(_)),
|
retractall(last_mse(_)),
|
||||||
retractall(query_is_similar(_,_)),
|
retractall(query_is_similar(_,_)),
|
||||||
retractall(query_md5(_,_,_)),
|
retractall(query_md5(_,_,_)),
|
||||||
@ -392,7 +392,7 @@ do_learning(Iterations,Epsilon) :-
|
|||||||
Iterations>0,
|
Iterations>0,
|
||||||
do_learning_intern(Iterations,Epsilon).
|
do_learning_intern(Iterations,Epsilon).
|
||||||
do_learning(_,_) :-
|
do_learning(_,_) :-
|
||||||
format(user_error,'~n~Error: No training examples specified.~n~n',[]).
|
format(user_error,'~n~Error: Not raining examples specified.~n~n',[]).
|
||||||
|
|
||||||
|
|
||||||
do_learning_intern(0,_) :-
|
do_learning_intern(0,_) :-
|
||||||
@ -430,6 +430,7 @@ do_learning_intern(Iterations,Epsilon) :-
|
|||||||
(
|
(
|
||||||
retractall(last_mse(_)),
|
retractall(last_mse(_)),
|
||||||
logger_get_variable(mse_trainingset,Current_MSE),
|
logger_get_variable(mse_trainingset,Current_MSE),
|
||||||
|
writeln(Current_MSE:Last_MSE),
|
||||||
assertz(last_mse(Current_MSE)),
|
assertz(last_mse(Current_MSE)),
|
||||||
!,
|
!,
|
||||||
MSE_Diff is abs(Last_MSE-Current_MSE)
|
MSE_Diff is abs(Last_MSE-Current_MSE)
|
||||||
@ -444,7 +445,6 @@ do_learning_intern(Iterations,Epsilon) :-
|
|||||||
(problog_flag(rebuild_bdds,BDDFreq),BDDFreq>0,0 =:= CurrentIteration mod BDDFreq)
|
(problog_flag(rebuild_bdds,BDDFreq),BDDFreq>0,0 =:= CurrentIteration mod BDDFreq)
|
||||||
->
|
->
|
||||||
(
|
(
|
||||||
retractall(values_correct),
|
|
||||||
retractall(query_is_similar(_,_)),
|
retractall(query_is_similar(_,_)),
|
||||||
retractall(query_md5(_,_,_)),
|
retractall(query_md5(_,_,_)),
|
||||||
empty_bdd_directory,
|
empty_bdd_directory,
|
||||||
@ -627,12 +627,13 @@ init_one_query(QueryID,Query,Type) :-
|
|||||||
% check wether this BDD is similar to another BDD
|
% check wether this BDD is similar to another BDD
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
(
|
(
|
||||||
problog_flag(check_duplicate_bdds,true)
|
listing(query_md5),
|
||||||
|
problog_flag(check_duplicate_bdds,true)
|
||||||
->
|
->
|
||||||
(
|
(
|
||||||
calc_md5(Filename,Query_MD5),
|
calc_md5(Filename,Query_MD5),
|
||||||
(
|
(
|
||||||
query_md5(OtherQueryID,Query_MD5,Type)
|
query_md5(OtherQueryID,Query_MD5,Type)
|
||||||
->
|
->
|
||||||
(
|
(
|
||||||
assertz(query_is_similar(QueryID,OtherQueryID)),
|
assertz(query_is_similar(QueryID,OtherQueryID)),
|
||||||
@ -682,7 +683,7 @@ update_values :-
|
|||||||
problog:dynamic_probability_fact_extract(Term, Prob2),
|
problog:dynamic_probability_fact_extract(Term, Prob2),
|
||||||
inv_sigmoid(Prob2,Value),
|
inv_sigmoid(Prob2,Value),
|
||||||
format(Handle, '@x~q_~q~n~10f~n', [ID,GID, Value])))
|
format(Handle, '@x~q_~q~n~10f~n', [ID,GID, Value])))
|
||||||
; non_ground_fact(ID) ->
|
; non_ground_fact(ID) ->
|
||||||
inv_sigmoid(Prob,Value),
|
inv_sigmoid(Prob,Value),
|
||||||
format(Handle,'@x~q_*~n~10f~n',[ID,Value])
|
format(Handle,'@x~q_*~n~10f~n',[ID,Value])
|
||||||
;
|
;
|
||||||
@ -699,7 +700,6 @@ update_values :-
|
|||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% stop write current probabilities to file
|
% stop write current probabilities to file
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
assertz(values_correct).
|
assertz(values_correct).
|
||||||
|
|
||||||
|
|
||||||
@ -710,7 +710,7 @@ update_values :-
|
|||||||
%=
|
%=
|
||||||
%========================================================================
|
%========================================================================
|
||||||
|
|
||||||
update_query_cleanup(QueryID) :-
|
listing(
|
||||||
(
|
(
|
||||||
(query_is_similar(QueryID,_) ; query_is_similar(_,QueryID))
|
(query_is_similar(QueryID,_) ; query_is_similar(_,QueryID))
|
||||||
->
|
->
|
||||||
@ -734,7 +734,7 @@ update_query(QueryID,Symbol,What_To_Update) :-
|
|||||||
(
|
(
|
||||||
problog_flag(sigmoid_slope,Slope),
|
problog_flag(sigmoid_slope,Slope),
|
||||||
((What_To_Update=all;query_is_similar(_,QueryID)) -> Method='g' ; Method='l'),
|
((What_To_Update=all;query_is_similar(_,QueryID)) -> Method='g' ; Method='l'),
|
||||||
convert_filename_to_problog_path('simplecudd', Simplecudd),
|
convert_filename_to_problog_path('simplecudd', Simplecudd),
|
||||||
atomic_concat([Simplecudd,
|
atomic_concat([Simplecudd,
|
||||||
' -i "', Probabilities_File, '"',
|
' -i "', Probabilities_File, '"',
|
||||||
' -l "', Query_Directory,'/query_',QueryID, '"',
|
' -l "', Query_Directory,'/query_',QueryID, '"',
|
||||||
@ -744,7 +744,6 @@ update_query(QueryID,Symbol,What_To_Update) :-
|
|||||||
' > "',
|
' > "',
|
||||||
Output_Directory,
|
Output_Directory,
|
||||||
'values.pl"'],Command),
|
'values.pl"'],Command),
|
||||||
|
|
||||||
shell(Command,Error),
|
shell(Command,Error),
|
||||||
%shell('cat /home/vsc/Yap/bins/devel/outputvalues.pl',_),
|
%shell('cat /home/vsc/Yap/bins/devel/outputvalues.pl',_),
|
||||||
|
|
||||||
@ -816,7 +815,7 @@ my_load_intern(query_gradient(QueryID,XFactID,Type,Value),Handle,QueryID) :-
|
|||||||
!,
|
!,
|
||||||
atomic_concat(x,FactID,XFactID),
|
atomic_concat(x,FactID,XFactID),
|
||||||
% atom_number(StringFactID,FactID),
|
% atom_number(StringFactID,FactID),
|
||||||
assertz(query_gradient_intern(QueryID,FactID,Type,Value)),
|
assertz(query_gradient_intern(QueryID,XFactID,Type,Value)),
|
||||||
read(Handle,X),
|
read(Handle,X),
|
||||||
my_load_intern(X,Handle,QueryID).
|
my_load_intern(X,Handle,QueryID).
|
||||||
my_load_intern(X,Handle,QueryID) :-
|
my_load_intern(X,Handle,QueryID) :-
|
||||||
|
Reference in New Issue
Block a user