:Merge /home/vsc/yap
This commit is contained in:
commit
47b13c3836
53
C/cdmgr.c
53
C/cdmgr.c
@ -74,6 +74,49 @@ static void kill_first_log_iblock(LogUpdIndex *, LogUpdIndex *, PredEntry *);
|
||||
#define PredArity(p) (p->ArityOfPE)
|
||||
#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) {
|
||||
CACHE_REGS
|
||||
LOCAL_ConsultLow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj) *
|
||||
@ -1420,7 +1463,7 @@ static int not_was_reconsulted(PredEntry *p, Term t, int mode) {
|
||||
// p->src.OwnerFile = Yap_ConsultingFile(PASS_REGS1);
|
||||
}
|
||||
LOCAL_LastAssertedPred = p;
|
||||
return TRUE; /* careful */
|
||||
ret>urn TRUE; /* careful */
|
||||
}
|
||||
|
||||
static yamop *addcl_permission_error(const char *file, const char *function,
|
||||
@ -1707,7 +1750,7 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref)
|
||||
PELOCK(20, p);
|
||||
/* we are redefining a prolog module predicate */
|
||||
if (Yap_constPred(p)) {
|
||||
addcl_permission_error(__FILE__, __FUNCTION__, __LINE__, p,
|
||||
addcl_permission_error(__FILE__, __FUNCTION__, __LINE__, tf,
|
||||
FALSE);
|
||||
UNLOCKPE(30, p);
|
||||
return false;
|
||||
@ -2146,7 +2189,7 @@ static Int p_purge_clauses(USES_REGS1) { /* '$purge_clauses'(+Func) */
|
||||
PELOCK(21, pred);
|
||||
if (pred->PredFlags & StandardPredFlag) {
|
||||
UNLOCKPE(33, pred);
|
||||
Yap_Error(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, Yap_PredicateToIndicator(pred), "assert/1");
|
||||
Yap_Error(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, Yap_PredicateIndicator(CurrentModule, t), "assert/1");
|
||||
return (FALSE);
|
||||
}
|
||||
purge_clauses(pred);
|
||||
@ -4042,7 +4085,11 @@ static Int
|
||||
| TabledPredFlag
|
||||
#endif /* TABLING */
|
||||
)) {
|
||||
<<<<<<< HEAD
|
||||
Yap_Error(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, Yap_PredicateIndicator(CurrentModule, t),
|
||||
=======
|
||||
Yap_Error(PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, Yap_PredicateToIndicator(ap),
|
||||
>>>>>>> ab56074bb1a1f428c5c0c2a1781e00b02bb58f03
|
||||
"dbload_get_space/4");
|
||||
return FALSE;
|
||||
}
|
||||
|
1
C/exec.c
1
C/exec.c
@ -201,7 +201,6 @@ restart:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Term Yap_TermToIndicator(Term t, Term mod) {
|
||||
CACHE_REGS
|
||||
// generate predicate indicator in this case
|
||||
|
@ -470,7 +470,7 @@
|
||||
LogUpdClause *lcl = PREG->y_u.OtILl.d;
|
||||
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 (PP != ap) {
|
||||
if (PP) UNLOCKPE(16,PP);
|
||||
|
@ -384,6 +384,10 @@ if (GMP_INCLUDE_DIRS)
|
||||
# READLINE_readline_LIBRARY, where to find the READLINE library.
|
||||
# READLINE_ncurses_LIBRARY, where to find the ncurses library [might not be defined]
|
||||
|
||||
if (ANDROID)
|
||||
option (WITH_READLINE "use Readline" OFF)
|
||||
else()
|
||||
|
||||
include(FindReadline)
|
||||
|
||||
option (WITH_READLINE "use Readline" ON)
|
||||
@ -392,13 +396,14 @@ if (GMP_INCLUDE_DIRS)
|
||||
#
|
||||
# ADD_SUBDIRECTORY(console/terminal)
|
||||
|
||||
if (READLINE_FOUND)
|
||||
if (READLINE_FOUND AND READLINE_INCLUDE_DIR)
|
||||
List(APPEND YAP_SYSTEM_OPTIONS readline)
|
||||
# required for configure
|
||||
include_directories( ${READLINE_INCLUDE_DIR}
|
||||
${READLINE_INCLUDE_DIR}/readline
|
||||
)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/H
|
||||
|
@ -32,8 +32,8 @@ path(X,Y,A,R) :-
|
||||
path(Z,Y,[Z|A],R).
|
||||
|
||||
% using directed edges in both directions
|
||||
edge(X,Y) :- problog:dir_edge(Y,X).
|
||||
edge(X,Y) :- problog:dir_edge(X,Y).
|
||||
edge(X,Y) :- dir_edge(Y,X).
|
||||
edge(X,Y) :- dir_edge(X,Y).
|
||||
|
||||
% checking whether node hasn't been visited before
|
||||
absent(_,[]).
|
||||
|
@ -109,4 +109,3 @@ test_example(33,path(5,4),0.57).
|
||||
test_example(34,path(6,4),0.51).
|
||||
test_example(35,path(6,5),0.69).
|
||||
|
||||
|
||||
|
@ -363,7 +363,7 @@ reset_learning :-
|
||||
retractall(current_iteration(_)),
|
||||
retractall(example_count(_)),
|
||||
retractall(query_probability_intern(_,_)),
|
||||
retractall(query_gradient_intern(_,_,_)),
|
||||
retractall(query_gradient_intern(_,_,_,_)),
|
||||
retractall(last_mse(_)),
|
||||
retractall(query_is_similar(_,_)),
|
||||
retractall(query_md5(_,_,_)),
|
||||
@ -392,7 +392,7 @@ do_learning(Iterations,Epsilon) :-
|
||||
Iterations>0,
|
||||
do_learning_intern(Iterations,Epsilon).
|
||||
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,_) :-
|
||||
@ -430,6 +430,7 @@ do_learning_intern(Iterations,Epsilon) :-
|
||||
(
|
||||
retractall(last_mse(_)),
|
||||
logger_get_variable(mse_trainingset,Current_MSE),
|
||||
writeln(Current_MSE:Last_MSE),
|
||||
assertz(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)
|
||||
->
|
||||
(
|
||||
retractall(values_correct),
|
||||
retractall(query_is_similar(_,_)),
|
||||
retractall(query_md5(_,_,_)),
|
||||
empty_bdd_directory,
|
||||
@ -627,12 +627,13 @@ init_one_query(QueryID,Query,Type) :-
|
||||
% 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)),
|
||||
@ -682,7 +683,7 @@ update_values :-
|
||||
problog:dynamic_probability_fact_extract(Term, Prob2),
|
||||
inv_sigmoid(Prob2,Value),
|
||||
format(Handle, '@x~q_~q~n~10f~n', [ID,GID, Value])))
|
||||
; non_ground_fact(ID) ->
|
||||
; non_ground_fact(ID) ->
|
||||
inv_sigmoid(Prob,Value),
|
||||
format(Handle,'@x~q_*~n~10f~n',[ID,Value])
|
||||
;
|
||||
@ -699,7 +700,6 @@ update_values :-
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% stop write current probabilities to file
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
assertz(values_correct).
|
||||
|
||||
|
||||
@ -710,7 +710,7 @@ update_values :-
|
||||
%=
|
||||
%========================================================================
|
||||
|
||||
update_query_cleanup(QueryID) :-
|
||||
listing(
|
||||
(
|
||||
(query_is_similar(QueryID,_) ; query_is_similar(_,QueryID))
|
||||
->
|
||||
@ -734,7 +734,7 @@ update_query(QueryID,Symbol,What_To_Update) :-
|
||||
(
|
||||
problog_flag(sigmoid_slope,Slope),
|
||||
((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,
|
||||
' -i "', Probabilities_File, '"',
|
||||
' -l "', Query_Directory,'/query_',QueryID, '"',
|
||||
@ -744,7 +744,6 @@ update_query(QueryID,Symbol,What_To_Update) :-
|
||||
' > "',
|
||||
Output_Directory,
|
||||
'values.pl"'],Command),
|
||||
|
||||
shell(Command,Error),
|
||||
%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),
|
||||
% atom_number(StringFactID,FactID),
|
||||
assertz(query_gradient_intern(QueryID,FactID,Type,Value)),
|
||||
assertz(query_gradient_intern(QueryID,XFactID,Type,Value)),
|
||||
read(Handle,X),
|
||||
my_load_intern(X,Handle,QueryID).
|
||||
my_load_intern(X,Handle,QueryID) :-
|
||||
|
Reference in New Issue
Block a user