Merge ssh://xato/home/vsc/yap
This commit is contained in:
commit
e117d51d98
@ -12,11 +12,15 @@ WITH_VARS="swig|yes|WITH_SWIG \
|
|||||||
mpi|yes|WITH_MPI \
|
mpi|yes|WITH_MPI \
|
||||||
gecode|yes|WITH_GECODE \
|
gecode|yes|WITH_GECODE \
|
||||||
docs|yes|WITH_DOCS \
|
docs|yes|WITH_DOCS \
|
||||||
r|yes|WITH_REAL \
|
r|yes|WITH_R \
|
||||||
|
myddas|yes|WITH_MYDDAS \
|
||||||
cudd|yes|WITH_CUDD \
|
cudd|yes|WITH_CUDD \
|
||||||
xml2|yes|WITH_XML2 \
|
xml2|yes|WITH_XML2 \
|
||||||
raptor|yes|WITH_RAPTOR \
|
raptor|yes|WITH_RAPTOR \
|
||||||
python|yes|WITH_PYTHON \
|
python|yes|WITH_PYTHON \
|
||||||
openssl|yes|WITH_OPENSSL\
|
openssl|yes|WITH_OPENSSL\
|
||||||
|
java|yes|WITH_JAVA
|
||||||
|
lbfgs|yes|WITH_LBFGS
|
||||||
|
extensions|yes|WITH_EXTENSIONS
|
||||||
readline|yes|WITH_READLINE \
|
readline|yes|WITH_READLINE \
|
||||||
gmp|yes|WITH_GMP"
|
gmp|yes|WITH_GMP"
|
||||||
|
@ -1811,27 +1811,6 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void completeInnerCall(bool on_cut, yamop *old_CP, yamop *old_P) {
|
|
||||||
if (on_cut) {
|
|
||||||
P = old_P;
|
|
||||||
ENV = (CELL *)ENV[E_E];
|
|
||||||
CP = old_CP;
|
|
||||||
LOCAL_AllowRestart = TRUE;
|
|
||||||
// we are back to user code again, need slots */
|
|
||||||
} else {
|
|
||||||
P = old_P;
|
|
||||||
ENV = B->cp_env;
|
|
||||||
ENV = (CELL *)ENV[E_E];
|
|
||||||
CP = old_CP;
|
|
||||||
HR = B->cp_h;
|
|
||||||
TR = B->cp_tr;
|
|
||||||
B = B->cp_b;
|
|
||||||
LOCAL_AllowRestart = FALSE;
|
|
||||||
SET_ASP(ENV, E_CB * sizeof(CELL));
|
|
||||||
// make sure the slots are ok.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
choiceptr myB, handler;
|
choiceptr myB, handler;
|
||||||
|
@ -25,7 +25,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
*
|
*
|
||||||
* @brief record and other forms of storing terms.
|
* @brief record and other forms of storing terms.
|
||||||
*
|
*
|
||||||
* /
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup Internal_Database Internal Data Base
|
/** @defgroup Internal_Database Internal Data Base
|
||||||
|
@ -623,6 +623,10 @@
|
|||||||
|
|
||||||
BOp(undef_p, e);
|
BOp(undef_p, e);
|
||||||
/* save S for module name */
|
/* save S for module name */
|
||||||
|
if (LOCAL_DoingUndefp) {
|
||||||
|
PREG=FAILCODE;
|
||||||
|
JMPNext();
|
||||||
|
}
|
||||||
LOCAL_DoingUndefp = true;
|
LOCAL_DoingUndefp = true;
|
||||||
saveregs();
|
saveregs();
|
||||||
undef_goal(PASS_REGS1);
|
undef_goal(PASS_REGS1);
|
||||||
|
119
C/text.c
119
C/text.c
@ -59,54 +59,6 @@ typedef struct TextBuffer_manager {
|
|||||||
} text_buffer_t;
|
} text_buffer_t;
|
||||||
|
|
||||||
int AllocLevel(void) { return LOCAL_TextBuffer->lvl; }
|
int AllocLevel(void) { return LOCAL_TextBuffer->lvl; }
|
||||||
int push_text_stack__(USES_REGS1) {
|
|
||||||
int i = LOCAL_TextBuffer->lvl;
|
|
||||||
i++;
|
|
||||||
LOCAL_TextBuffer->lvl = i;
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pop_text_stack__(int i) {
|
|
||||||
int lvl = LOCAL_TextBuffer->lvl;
|
|
||||||
while (lvl >= i) {
|
|
||||||
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
|
||||||
while (p) {
|
|
||||||
struct mblock *np = p->next;
|
|
||||||
free(p);
|
|
||||||
p = np;
|
|
||||||
}
|
|
||||||
LOCAL_TextBuffer->first[lvl] = NULL;
|
|
||||||
LOCAL_TextBuffer->last[lvl] = NULL;
|
|
||||||
lvl--;
|
|
||||||
}
|
|
||||||
LOCAL_TextBuffer->lvl = lvl;
|
|
||||||
return lvl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *pop_output_text_stack__(int i, const void *export) {
|
|
||||||
int lvl = LOCAL_TextBuffer->lvl;
|
|
||||||
while (lvl >= i) {
|
|
||||||
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
|
||||||
while (p) {
|
|
||||||
struct mblock *np = p->next;
|
|
||||||
if (p + 1 == export) {
|
|
||||||
size_t sz = p->sz - sizeof(struct mblock);
|
|
||||||
memmove(p, p + 1, sz);
|
|
||||||
export = p;
|
|
||||||
} else {
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
p = np;
|
|
||||||
}
|
|
||||||
LOCAL_TextBuffer->first[lvl] = NULL;
|
|
||||||
LOCAL_TextBuffer->last[lvl] = NULL;
|
|
||||||
lvl--;
|
|
||||||
}
|
|
||||||
LOCAL_TextBuffer->lvl = lvl;
|
|
||||||
return (void *)export;
|
|
||||||
}
|
|
||||||
|
|
||||||
// void pop_text_stack(int i) { LOCAL_TextBuffer->lvl = i; }
|
// void pop_text_stack(int i) { LOCAL_TextBuffer->lvl = i; }
|
||||||
void insert_block(struct mblock *o) {
|
void insert_block(struct mblock *o) {
|
||||||
int lvl = o->lvl;
|
int lvl = o->lvl;
|
||||||
@ -138,6 +90,68 @@ void release_block(struct mblock *o) {
|
|||||||
o->next->prev = o->prev;
|
o->next->prev = o->prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int push_text_stack__(USES_REGS1) {
|
||||||
|
int i = LOCAL_TextBuffer->lvl;
|
||||||
|
i++;
|
||||||
|
LOCAL_TextBuffer->lvl = i;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pop_text_stack__(int i) {
|
||||||
|
int lvl = LOCAL_TextBuffer->lvl;
|
||||||
|
while (lvl >= i) {
|
||||||
|
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
||||||
|
while (p) {
|
||||||
|
struct mblock *np = p->next;
|
||||||
|
free(p);
|
||||||
|
p = np;
|
||||||
|
}
|
||||||
|
LOCAL_TextBuffer->first[lvl] = NULL;
|
||||||
|
LOCAL_TextBuffer->last[lvl] = NULL;
|
||||||
|
lvl--;
|
||||||
|
}
|
||||||
|
LOCAL_TextBuffer->lvl = lvl;
|
||||||
|
return lvl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pop_output_text_stack__(int i, const void *export) {
|
||||||
|
int lvl = LOCAL_TextBuffer->lvl;
|
||||||
|
bool found = false;
|
||||||
|
while (lvl >= i) {
|
||||||
|
struct mblock *p = LOCAL_TextBuffer->first[lvl];
|
||||||
|
while (p) {
|
||||||
|
struct mblock *np = p->next;
|
||||||
|
if (p + 1 == export) {
|
||||||
|
found = true;
|
||||||
|
} else {
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
p = np;
|
||||||
|
}
|
||||||
|
LOCAL_TextBuffer->first[lvl] = NULL;
|
||||||
|
LOCAL_TextBuffer->last[lvl] = NULL;
|
||||||
|
lvl--;
|
||||||
|
}
|
||||||
|
LOCAL_TextBuffer->lvl = lvl;
|
||||||
|
if (found) {
|
||||||
|
if (lvl) {
|
||||||
|
struct mblock *o = (struct mblock *)export-1;
|
||||||
|
o->lvl = lvl;
|
||||||
|
o->prev = o->next = 0;
|
||||||
|
insert_block(o);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
struct mblock *p = (struct mblock *)export-1;
|
||||||
|
size_t sz = p->sz - sizeof(struct mblock);
|
||||||
|
memmove(p, p + 1, sz);
|
||||||
|
export = p;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (void *)export;
|
||||||
|
}
|
||||||
|
|
||||||
void *Malloc(size_t sz USES_REGS) {
|
void *Malloc(size_t sz USES_REGS) {
|
||||||
int lvl = LOCAL_TextBuffer->lvl;
|
int lvl = LOCAL_TextBuffer->lvl;
|
||||||
if (sz == 0)
|
if (sz == 0)
|
||||||
@ -1027,10 +1041,11 @@ bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
|
|||||||
void **bufv;
|
void **bufv;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
int i, j;
|
int i, j;
|
||||||
// int lvl = push_text_stack();
|
|
||||||
|
int lvl = push_text_stack();
|
||||||
bufv = Malloc(tot * sizeof(unsigned char *));
|
bufv = Malloc(tot * sizeof(unsigned char *));
|
||||||
if (!bufv) {
|
if (!bufv) {
|
||||||
// pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i = 0, j = 0; i < tot; i++) {
|
for (i = 0, j = 0; i < tot; i++) {
|
||||||
@ -1038,7 +1053,7 @@ bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
|
|||||||
unsigned char *nbuf = Yap_readText(inp + i PASS_REGS);
|
unsigned char *nbuf = Yap_readText(inp + i PASS_REGS);
|
||||||
|
|
||||||
if (!nbuf) {
|
if (!nbuf) {
|
||||||
// pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// if (!nbuf[0])
|
// if (!nbuf[0])
|
||||||
@ -1054,7 +1069,7 @@ bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
|
|||||||
buf = concat(tot, bufv PASS_REGS);
|
buf = concat(tot, bufv PASS_REGS);
|
||||||
}
|
}
|
||||||
bool rc = write_Text(buf, out PASS_REGS);
|
bool rc = write_Text(buf, out PASS_REGS);
|
||||||
// pop_text_stack( lvl );
|
pop_text_stack( lvl );
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
771
CMakeLists.txt
771
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
@ -977,7 +977,7 @@ PredEntry *YAPPredicate::getPred(Term &t, Term &m, CELL *&out) {
|
|||||||
} else {
|
} else {
|
||||||
ap = RepPredProp(PredPropByFunc(f, m));
|
ap = RepPredProp(PredPropByFunc(f, m));
|
||||||
if (out)
|
if (out)
|
||||||
memmove(out, RepAppl(t) + 1, ap->ArityOfPE * sizeof(CELL));
|
memmove(out, (const CELL *)RepAppl(t) + 1, ap->ArityOfPE * sizeof(CELL));
|
||||||
else
|
else
|
||||||
out = RepAppl(t) + 1;
|
out = RepAppl(t) + 1;
|
||||||
}
|
}
|
||||||
|
@ -525,8 +525,9 @@ public:
|
|||||||
mk(t);
|
mk(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// type check for unbound
|
||||||
bool unbound() { return IsUnboundVar(VarOfTerm(gt())); }
|
bool unbound() { return IsUnboundVar(VarOfTerm(gt())); }
|
||||||
inline bool isVar() { return true; } /// type check for unbound
|
inline bool isVar() { return true; }
|
||||||
inline bool isAtom() { return false; } /// type check for atom
|
inline bool isAtom() { return false; } /// type check for atom
|
||||||
inline bool isInteger() { return false; } /// type check for integer
|
inline bool isInteger() { return false; } /// type check for integer
|
||||||
inline bool isFloat() { return false; } /// type check for floating-point
|
inline bool isFloat() { return false; } /// type check for floating-point
|
||||||
|
12
configure
vendored
12
configure
vendored
@ -165,7 +165,7 @@ print_help() {
|
|||||||
--mandir=DIR man documentation [DATAROOTDIR/man]
|
--mandir=DIR man documentation [DATAROOTDIR/man]
|
||||||
--docdir=DIR documentation root [DATAROOTDIR/doc/PROJECT_NAME]
|
--docdir=DIR documentation root [DATAROOTDIR/doc/PROJECT_NAME]
|
||||||
|
|
||||||
--generator=Generator Specify the tool used to send callss
|
--generator=GENERATOR Specify the tool used to send callss
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
first=y
|
first=y
|
||||||
@ -220,6 +220,8 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while [ $# != 0 ]; do
|
while [ $# != 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--cmake="*)
|
"--cmake="*)
|
||||||
@ -291,10 +293,10 @@ while [ $# != 0 ]; do
|
|||||||
"--docdir")
|
"--docdir")
|
||||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "$2")"; shift;;
|
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "$2")"; shift;;
|
||||||
|
|
||||||
"-G="|"--generator="*)
|
"--generator="*)
|
||||||
CMAKE_ARGS+="-G"${1#*=};;
|
CMAKE_ARGS="$CMAKE_ARGS -G ${1#*=}";;
|
||||||
"-G"|"--generator")
|
"-G")
|
||||||
CMAKE_ARGS+="-G$"$2; shift;;
|
CMAKE_ARGS="$CMAKE_ARGS -G $2"; shift;;
|
||||||
|
|
||||||
"CC="*)
|
"CC="*)
|
||||||
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER=$(quote "${1#*=}")";;
|
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER=$(quote "${1#*=}")";;
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
with the `use_module(library(lists))` command.
|
with the `use_module(library(lists))` command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
:- include(pl/bootlists).
|
%:- include(pl/bootlists).
|
||||||
|
|
||||||
/** @pred list_concat(+ _Lists_,? _List_)
|
/** @pred list_concat(+ _Lists_,? _List_)
|
||||||
|
|
||||||
|
@ -769,11 +769,11 @@ static Int real_path(USES_REGS1) {
|
|||||||
int lvl = push_text_stack();
|
int lvl = push_text_stack();
|
||||||
rc0 = myrealpath(cmd PASS_REGS);
|
rc0 = myrealpath(cmd PASS_REGS);
|
||||||
if (!rc0) {
|
if (!rc0) {
|
||||||
|
pop_text_stack(lvl);
|
||||||
PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, NULL);
|
PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, NULL);
|
||||||
}
|
}
|
||||||
bool out = Yap_unify(MkAtomTerm(Yap_LookupAtom(rc0)), ARG2);
|
bool out = Yap_unify(MkAtomTerm(Yap_LookupAtom(rc0)), ARG2);
|
||||||
pop_output_text_stack(lvl, rc0);
|
pop_text_stack(lvl);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ problog_low_lbdd(_, _, Prob, ok, bdd(Dir, Tree, MapList)) :-
|
|||||||
bind_maplist(MapList, BoundVars),
|
bind_maplist(MapList, BoundVars),
|
||||||
bdd_tree(BDD, bdd(Dir, Tree, _Vars)),
|
bdd_tree(BDD, bdd(Dir, Tree, _Vars)),
|
||||||
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
|
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
|
||||||
|
bdd_close(BDD),
|
||||||
(problog_flag(verbose, true)->
|
(problog_flag(verbose, true)->
|
||||||
problog_statistics
|
problog_statistics
|
||||||
;
|
;
|
||||||
@ -37,7 +38,8 @@ problog_low_lbdd(_, _, Prob, ok, bdd(Dir, Tree, MapList)) :-
|
|||||||
problog_kbest_bdd(Goal, K, Prob, ok) :-
|
problog_kbest_bdd(Goal, K, Prob, ok) :-
|
||||||
problog_kbest_to_bdd(Goal, K, BDD, MapList),
|
problog_kbest_to_bdd(Goal, K, BDD, MapList),
|
||||||
bind_maplist(MapList, BoundVars),
|
bind_maplist(MapList, BoundVars),
|
||||||
bdd_to_probability_sum_product(BDD, BoundVars, Prob).
|
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
|
||||||
|
bdd_close(BDD).
|
||||||
|
|
||||||
problog_kbest_as_bdd(Goal, K, bdd(Dir, Tree, MapList)) :-
|
problog_kbest_as_bdd(Goal, K, bdd(Dir, Tree, MapList)) :-
|
||||||
problog_kbest_to_bdd(Goal, K, BDD, MapList),
|
problog_kbest_to_bdd(Goal, K, BDD, MapList),
|
||||||
@ -70,6 +72,7 @@ problog_fl_bdd(_,Prob) :-
|
|||||||
bind_maplist(MapList, BoundVars),
|
bind_maplist(MapList, BoundVars),
|
||||||
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
|
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
|
||||||
(problog_flag(retain_tables, true) -> retain_tabling; true),
|
(problog_flag(retain_tables, true) -> retain_tabling; true),
|
||||||
|
bdd_close(BDD),
|
||||||
clear_tabling.
|
clear_tabling.
|
||||||
|
|
||||||
problog_full_bdd(Goal,_K, _) :-
|
problog_full_bdd(Goal,_K, _) :-
|
||||||
@ -86,6 +89,7 @@ problog_full_bdd(_,Prob) :-
|
|||||||
tabled_trie_to_bdd(Trie_Completed_Proofs, BDD, MapList),
|
tabled_trie_to_bdd(Trie_Completed_Proofs, BDD, MapList),
|
||||||
bind_maplist(MapList, BoundVars),
|
bind_maplist(MapList, BoundVars),
|
||||||
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
|
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
|
||||||
|
bdd_close(BDD),
|
||||||
(problog_flag(retain_tables, true) -> retain_tabling; true),
|
(problog_flag(retain_tables, true) -> retain_tabling; true),
|
||||||
clear_tabling.
|
clear_tabling.
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ do_learning_intern(Iterations,Epsilon) :-
|
|||||||
true
|
true
|
||||||
),
|
),
|
||||||
|
|
||||||
% update_values,
|
update_values,
|
||||||
|
|
||||||
(
|
(
|
||||||
last_mse(Last_MSE)
|
last_mse(Last_MSE)
|
||||||
@ -450,15 +450,11 @@ do_learning_intern(Iterations,Epsilon) :-
|
|||||||
),
|
),
|
||||||
|
|
||||||
(
|
(
|
||||||
(problog_flag(rebuild_bdds,BDDFreq),BDDFreq>0,0 =:= CurrentIteration mod BDDFreq)
|
|
||||||
->
|
|
||||||
(
|
|
||||||
retractall(values_correct),
|
retractall(values_correct),
|
||||||
retractall(query_is_similar(_,_)),
|
retractall(query_is_similar(_,_)),
|
||||||
retractall(query_md5(_,_,_)),
|
retractall(query_md5(_,_,_)),
|
||||||
empty_bdd_directory,
|
empty_bdd_directory,
|
||||||
init_queries
|
init_queries
|
||||||
); true
|
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
@ -491,10 +487,47 @@ init_learning :-
|
|||||||
init_learning :-
|
init_learning :-
|
||||||
check_examples,
|
check_examples,
|
||||||
|
|
||||||
|
retractall(current_iteration(_)),
|
||||||
|
assert(current_iteration(0)),
|
||||||
% empty_output_directory,
|
% empty_output_directory,
|
||||||
logger_write_header,
|
logger_write_header,
|
||||||
|
|
||||||
format_learning(1,'Initializing everything~n',[]),
|
format_learning(1,'Initializing everything~n',[]),
|
||||||
|
|
||||||
|
succeeds_n_times(user:test_example(_,_,_,_),TestExampleCount),
|
||||||
|
format_learning(3,'~q test examples~n',[TestExampleCount]),
|
||||||
|
|
||||||
|
succeeds_n_times(user:example(_,_,_,_),TrainingExampleCount),
|
||||||
|
assertz(example_count(TrainingExampleCount)),
|
||||||
|
format_learning(3,'~q training examples~n',[TrainingExampleCount]),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
% build BDD script for every example
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
once(init_queries),
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
% done
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
assertz(current_iteration(-1)),
|
||||||
|
assertz(learning_initialized),
|
||||||
|
|
||||||
|
format_learning(1,'~n',[]).
|
||||||
|
|
||||||
|
%========================================================================
|
||||||
|
%= 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 :-
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
% delete old values
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
retractall(query_probability_intern(_,_)),
|
||||||
|
retractall(query_gradient_intern(_,_,_,_)).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -502,8 +535,8 @@ init_learning :-
|
|||||||
% Check, if continuous facts are used.
|
% Check, if continuous facts are used.
|
||||||
% if yes, switch to problog_exact
|
% if yes, switch to problog_exact
|
||||||
% continuous facts are not supported yet.
|
% continuous facts are not supported yet.
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
set_default_gradient_method,
|
set_default_gradient_method :-
|
||||||
( problog_flag(continuous_facts, true )
|
( problog_flag(continuous_facts, true )
|
||||||
->
|
->
|
||||||
problog_flag(init_method,(_,_,_,_,OldCall)),
|
problog_flag(init_method,(_,_,_,_,OldCall)),
|
||||||
@ -527,31 +560,11 @@ init_learning :-
|
|||||||
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile)))
|
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile)))
|
||||||
);
|
);
|
||||||
true
|
true
|
||||||
),
|
).
|
||||||
|
|
||||||
succeeds_n_times(user:test_example(_,_,_,_),TestExampleCount),
|
|
||||||
format_learning(3,'~q test examples~n',[TestExampleCount]),
|
|
||||||
|
|
||||||
succeeds_n_times(user:example(_,_,_,_),TrainingExampleCount),
|
|
||||||
assertz(example_count(TrainingExampleCount)),
|
|
||||||
format_learning(3,'~q training examples~n',[TrainingExampleCount]),
|
|
||||||
|
|
||||||
|
|
||||||
|
empty_bdd_directory :-
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
% build BDD script for every example
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
once(init_queries),
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
% done
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
assertz(current_iteration(0)),
|
|
||||||
assertz(learning_initialized),
|
|
||||||
|
|
||||||
format_learning(1,'~n',[]).
|
|
||||||
|
|
||||||
empty_bdd_directory :-
|
|
||||||
current_key(_,I),
|
current_key(_,I),
|
||||||
integer(I),
|
integer(I),
|
||||||
recorded(I,bdd(_,_,_),R),
|
recorded(I,bdd(_,_,_),R),
|
||||||
@ -560,21 +573,6 @@ init_learning :-
|
|||||||
empty_bdd_directory.
|
empty_bdd_directory.
|
||||||
|
|
||||||
|
|
||||||
set_default_gradient_method :-
|
|
||||||
problog_flag(continuous_facts, true),
|
|
||||||
!,
|
|
||||||
% problog_flag(init_method,OldMethod),
|
|
||||||
format_learning(2,'Theory uses continuous facts.~nWill use problog_exact/3 as initalization method.~2n',[]),
|
|
||||||
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile))).
|
|
||||||
set_default_gradient_method :-
|
|
||||||
problog_tabled(_), problog_flag(fast_proofs,false),
|
|
||||||
!,
|
|
||||||
format_learning(2,'Theory uses tabling.~nWill use problog_exact/3 as initalization method.~2n',[]),
|
|
||||||
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile))).
|
|
||||||
%set_default_gradient_method :-
|
|
||||||
% problog_flag(init_method,(gene(X,Y),N,Bdd,graph2bdd(X,Y,N,Bdd))),
|
|
||||||
% !.
|
|
||||||
set_default_gradient_method.
|
|
||||||
|
|
||||||
%========================================================================
|
%========================================================================
|
||||||
%= This predicate goes over all training and test examples,
|
%= This predicate goes over all training and test examples,
|
||||||
@ -584,6 +582,7 @@ set_default_gradient_method.
|
|||||||
|
|
||||||
|
|
||||||
init_queries :-
|
init_queries :-
|
||||||
|
empty_bdd_directory,
|
||||||
format_learning(2,'Build BDDs for examples~n',[]),
|
format_learning(2,'Build BDDs for examples~n',[]),
|
||||||
forall(user:test_example(ID,Query,_Prob,_),init_one_query(ID,Query,test)),
|
forall(user:test_example(ID,Query,_Prob,_),init_one_query(ID,Query,test)),
|
||||||
forall(user:example(ID,Query,_Prob,_),init_one_query(ID,Query,training)).
|
forall(user:example(ID,Query,_Prob,_),init_one_query(ID,Query,training)).
|
||||||
@ -703,41 +702,56 @@ ground_truth_difference :-
|
|||||||
%= -Float
|
%= -Float
|
||||||
%========================================================================
|
%========================================================================
|
||||||
|
|
||||||
mse_trainingset_only_for_linesearch(MSE) :-
|
mse_trainingset :-
|
||||||
|
current_iteration(Iteration),
|
||||||
|
create_training_predictions_file_name(Iteration,File_Name),
|
||||||
|
open(File_Name, write,Handle),
|
||||||
|
format_learning(2,'MSE_Training ',[]),
|
||||||
update_values,
|
update_values,
|
||||||
|
findall(t(LogCurrentProb,SquaredError),
|
||||||
|
(user:training_example(QueryID,Query,TrueQueryProb,_Type),
|
||||||
|
once(update_query(QueryID,'+',probability)),
|
||||||
|
query_probability(QueryID,CurrentProb),
|
||||||
|
format(Handle,'ex(~q,training,~q,~q,~10f,~10f).~n',[Iteration,QueryID,Query,TrueQueryProb,CurrentProb]),
|
||||||
|
|
||||||
example_count(Example_Count),
|
once(update_query_cleanup(QueryID)),
|
||||||
|
SquaredError is (CurrentProb-TrueQueryProb)**2,
|
||||||
|
LogCurrentProb is log(CurrentProb)
|
||||||
|
),
|
||||||
|
All),
|
||||||
|
maplist(tuple, All, AllLogs, AllSquaredErrors),
|
||||||
|
sum_list( AllLogs, LLH_Training_Queries),
|
||||||
|
close(Handle),
|
||||||
|
|
||||||
bb_put(error_train_line_search,0.0),
|
length(AllSquaredErrors,Length),
|
||||||
forall(user:example(QueryID,_Query,QueryProb,Type),
|
|
||||||
(
|
(
|
||||||
once(update_query(QueryID,'.',probability)),
|
Length>0
|
||||||
query_probability(QueryID,CurrentProb),
|
->
|
||||||
once(update_query_cleanup(QueryID)),
|
(
|
||||||
(
|
sum_list(AllSquaredErrors,SumAllSquaredErrors),
|
||||||
(Type == '='; (Type == '<', CurrentProb>QueryProb); (Type=='>',CurrentProb<QueryProb))
|
min_list(AllSquaredErrors,MinError),
|
||||||
->
|
max_list(AllSquaredErrors,MaxError),
|
||||||
(
|
MSE is SumAllSquaredErrors/Length
|
||||||
bb_get(error_train_line_search,Old_Error),
|
);(
|
||||||
New_Error is Old_Error + (CurrentProb-QueryProb)**2,
|
MSE=0.0,
|
||||||
bb_put(error_train_line_search,New_Error)
|
MinError=0.0,
|
||||||
);true
|
MaxError=0.0
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
),
|
|
||||||
bb_delete(error_train_line_search,Error),
|
logger_set_variable(mse_trainingset,MSE),
|
||||||
MSE is Error/Example_Count,
|
logger_set_variable(mse_min_trainingset,MinError),
|
||||||
format_learning(3,' (~8f)~n',[MSE]),
|
logger_set_variable(mse_max_trainingset,MaxError),
|
||||||
retractall(values_correct).
|
logger_set_variable(llh_training_queries,LLH_Training_Queries),
|
||||||
|
format_learning(2,' (~8f)~n',[MSE]).
|
||||||
|
|
||||||
|
tuple(t(X,Y),X,Y).
|
||||||
|
|
||||||
mse_testset :-
|
mse_testset :-
|
||||||
current_iteration(Iteration),
|
current_iteration(Iteration),
|
||||||
create_test_predictions_file_name(Iteration,File_Name),
|
create_test_predictions_file_name(Iteration,File_Name),
|
||||||
open(File_Name,'write',Handle),
|
open(File_Name, write,Handle),
|
||||||
format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n",[]),
|
|
||||||
format(Handle,"% Iteration, train/test, QueryID, Query, GroundTruth, Prediction %~n",[]),
|
|
||||||
format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n",[]),
|
|
||||||
|
|
||||||
format_learning(2,'MSE_Test ',[]),
|
format_learning(2,'MSE_Test ',[]),
|
||||||
update_values,
|
update_values,
|
||||||
bb_put(llh_test_queries,0.0),
|
bb_put(llh_test_queries,0.0),
|
||||||
@ -745,7 +759,7 @@ mse_testset :-
|
|||||||
(user:test_example(QueryID,Query,TrueQueryProb,Type),
|
(user:test_example(QueryID,Query,TrueQueryProb,Type),
|
||||||
once(update_query(QueryID,'+',probability)),
|
once(update_query(QueryID,'+',probability)),
|
||||||
query_probability(QueryID,CurrentProb),
|
query_probability(QueryID,CurrentProb),
|
||||||
format(Handle,'ex(~q,test,~q,~q,~10f,~10f).~n',[Iteration,QueryID,Query,TrueQueryProb,CurrentProb]),
|
format(Handle,'ex(~q,test,~q,~q,~10f,~10f).~n',[Iteration,QueryID,Query,TrueQueryProb,CurrentProb]),
|
||||||
|
|
||||||
once(update_query_cleanup(QueryID)),
|
once(update_query_cleanup(QueryID)),
|
||||||
(
|
(
|
||||||
@ -821,11 +835,6 @@ save_old_probabilities :-
|
|||||||
gradient_descent :-
|
gradient_descent :-
|
||||||
problog_flag(sigmoid_slope,Slope),
|
problog_flag(sigmoid_slope,Slope),
|
||||||
% current_iteration(Iteration),
|
% current_iteration(Iteration),
|
||||||
% create_training_predictions_file_name(Iteration,File_Name),
|
|
||||||
Handle = user_error,
|
|
||||||
format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n",[]),
|
|
||||||
format(Handle,"% Iteration, train/test, QueryID, Query, GroundTruth, Prediction %~n",[]),
|
|
||||||
format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n",[]),
|
|
||||||
findall(FactID,tunable_fact(FactID,GroundTruth),L), length(L,N),
|
findall(FactID,tunable_fact(FactID,GroundTruth),L), length(L,N),
|
||||||
% leash(0),trace,
|
% leash(0),trace,
|
||||||
lbfgs_initialize(N,X,0,Solver),
|
lbfgs_initialize(N,X,0,Solver),
|
||||||
@ -842,7 +851,7 @@ set_tunable(I,Slope,P) :-
|
|||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% start calculate gradient
|
% start calculate gradient
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
user:evaluate(LLH_Training_Queries, X,Grad,N,_,_) :-
|
user:evaluate(LLH_Training_Queries, X,Grad,N,_,_) :-
|
||||||
%Handle = user_error,
|
%Handle = user_error,
|
||||||
example_count(TrainingExampleCount),
|
example_count(TrainingExampleCount),
|
||||||
@ -852,20 +861,20 @@ user:evaluate(LLH_Training_Queries, X,Grad,N,_,_) :-
|
|||||||
N1 is N-1,
|
N1 is N-1,
|
||||||
forall(between(0,N1,I),
|
forall(between(0,N1,I),
|
||||||
(Grad[I] <== 0.0, S <== X[I], sigmoid(S,Slope, P), Probs[I] <== P)
|
(Grad[I] <== 0.0, S <== X[I], sigmoid(S,Slope, P), Probs[I] <== P)
|
||||||
), nl,
|
),
|
||||||
forall(
|
forall(
|
||||||
full_example(QueryID,QueryProb,BDD),
|
full_example(QueryID,QueryProb,BDD),
|
||||||
compute_grad(QueryID, BDD, QueryProb,Grad, Probs, Slope,LLs)
|
compute_grad(QueryID, BDD, QueryProb,Grad, Probs, Slope,LLs)
|
||||||
),
|
),
|
||||||
LLH_Training_Queries <== sum(LLs),
|
LLH_Training_QueriesSum <== sum(LLs),
|
||||||
writeln(LLH_Training_Queries).
|
LLH_Training_Queries is LLH_Training_QueriesSum/TrainingExampleCount .
|
||||||
%wrap(X, Grad, GradCount).
|
%wrap(X, Grad, GradCount).
|
||||||
|
|
||||||
full_example(QueryID,QueryProb,BDD) :-
|
full_example(QueryID,QueryProb,BDD) :-
|
||||||
user:example(QueryID,_Query,QueryProb,_),
|
user:example(QueryID,_Query,QueryProb,_),
|
||||||
recorded(QueryID,BDD,_),
|
recorded(QueryID,BDD,_),
|
||||||
BDD = bdd(_Dir, _GradTree, MapList),
|
BDD = bdd(_Dir, _GradTree, MapList),
|
||||||
MapList = [_|_].
|
MapList = [_|_].
|
||||||
|
|
||||||
compute_grad(QueryID,BDD,QueryProb, Grad, Probs, Slope, LLs) :-
|
compute_grad(QueryID,BDD,QueryProb, Grad, Probs, Slope, LLs) :-
|
||||||
BDD = bdd(_Dir, _GradTree, MapList),
|
BDD = bdd(_Dir, _GradTree, MapList),
|
||||||
@ -876,7 +885,7 @@ compute_grad(QueryID,BDD,QueryProb, Grad, Probs, Slope, LLs) :-
|
|||||||
LLs[QueryID] <== LL,
|
LLs[QueryID] <== LL,
|
||||||
%writeln( qprobability(BDD,Slope,BDDProb) ),
|
%writeln( qprobability(BDD,Slope,BDDProb) ),
|
||||||
forall(
|
forall(
|
||||||
member(I-_, MapList),
|
member(I-_, MapList),
|
||||||
gradientpair(I, BDD,Slope,BDDProb, QueryProb, Grad, Probs)
|
gradientpair(I, BDD,Slope,BDDProb, QueryProb, Grad, Probs)
|
||||||
).
|
).
|
||||||
|
|
||||||
@ -984,7 +993,7 @@ user:progress(FX,X,_G,X_Norm,G_Norm,Step,_N,Iteration,Ls,0) :-
|
|||||||
NextIteration is CurrentIteration+1,
|
NextIteration is CurrentIteration+1,
|
||||||
assertz(current_iteration(NextIteration)),
|
assertz(current_iteration(NextIteration)),
|
||||||
save_model,
|
save_model,
|
||||||
set_problog_flag(mse_trainset, FX),
|
logger_set_variable(mse_trainingset, FX),
|
||||||
X0 <== X[0], sigmoid(X0,Slope,P0),
|
X0 <== X[0], sigmoid(X0,Slope,P0),
|
||||||
X1 <== X[1], sigmoid(X1,Slope,P1),
|
X1 <== X[1], sigmoid(X1,Slope,P1),
|
||||||
format('~d. Iteration : (x0,x1)=(~4f,~4f) f(X)=~4f |X|=~4f |X\'|=~4f Step=~4f Ls=~4f~n',[Iteration,P0 ,P1,FX,X_Norm,G_Norm,Step,Ls]).
|
format('~d. Iteration : (x0,x1)=(~4f,~4f) f(X)=~4f |X|=~4f |X\'|=~4f Step=~4f Ls=~4f~n',[Iteration,P0 ,P1,FX,X_Norm,G_Norm,Step,Ls]).
|
||||||
|
@ -863,6 +863,9 @@ static YAP_Bool p_cudd_print_with_names(void) {
|
|||||||
|
|
||||||
static YAP_Bool p_cudd_die(void) {
|
static YAP_Bool p_cudd_die(void) {
|
||||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||||
|
//Cudd_FreeTree(manager);
|
||||||
|
//cuddFreeTable(manager);
|
||||||
|
Cudd_CheckZeroRef(manager);
|
||||||
Cudd_Quit(manager);
|
Cudd_Quit(manager);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -640,7 +640,7 @@ static JNIEnv*
|
|||||||
jni_env(void) /* economically gets a JNIEnv pointer, valid for this thread */
|
jni_env(void) /* economically gets a JNIEnv pointer, valid for this thread */
|
||||||
{ JNIEnv *env;
|
{ JNIEnv *env;
|
||||||
|
|
||||||
switch( (*jvm)->GetEnv(jvm, (void**)&env, JNI_VERSION_1_8) )
|
switch( (*jvm)->GetEnv(jvm, (void**)&env, JNI_VERSION_1_4) )
|
||||||
{ case JNI_OK:
|
{ case JNI_OK:
|
||||||
return env;
|
return env;
|
||||||
case JNI_EDETACHED:
|
case JNI_EDETACHED:
|
||||||
@ -5675,7 +5675,7 @@ static foreign_t
|
|||||||
int i;
|
int i;
|
||||||
term_t head;
|
term_t head;
|
||||||
term_t list;
|
term_t list;
|
||||||
char *s;
|
char *s = NULL;
|
||||||
|
|
||||||
if ( jvm_dia == NULL ) /* presumably, JVM is already started, so default options cannot now be set */
|
if ( jvm_dia == NULL ) /* presumably, JVM is already started, so default options cannot now be set */
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
if (WITH_MYSQL)
|
||||||
|
|
||||||
set(MYSQL_SOURCES
|
set(MYSQL_SOURCES
|
||||||
myddas_mysql.c
|
myddas_mysql.c
|
||||||
myddas_util.c
|
myddas_util.c
|
||||||
@ -51,3 +53,5 @@
|
|||||||
"enable the MYDDAS top-level (REPL) support for MySQL" OFF
|
"enable the MYDDAS top-level (REPL) support for MySQL" OFF
|
||||||
'USE_MYDDAS AND MYSQL_FOUND' OFF)
|
'USE_MYDDAS AND MYSQL_FOUND' OFF)
|
||||||
#TODO:
|
#TODO:
|
||||||
|
|
||||||
|
endif()
|
||||||
|
@ -1,39 +1,42 @@
|
|||||||
|
if (WITH_ODBC)
|
||||||
set( YAPODBC_SOURCES
|
|
||||||
myddas_odbc.c
|
set( YAPODBC_SOURCES
|
||||||
)
|
myddas_odbc.c
|
||||||
|
|
||||||
set(SO_MAJOR 1)
|
|
||||||
set(SO_MINOR 0)
|
|
||||||
set(SO_PATCH 0)
|
|
||||||
|
|
||||||
macro_optional_find_package(ODBC ON)
|
|
||||||
|
|
||||||
if (ODBC_FOUND)
|
|
||||||
# ODBC_INCLUDE_DIRECTORIES, where to find sql.h
|
|
||||||
# ODBC_LIBRARIES, the libraries to link against to use ODBC
|
|
||||||
# ODBC_FOUND. If false, you cannot build anything that requires Odbc.
|
|
||||||
add_lib(YAPodbc ${YAPODBC_SOURCES})
|
|
||||||
target_link_libraries(YAPodbc libYap ${ODBC_LIBRARIES})
|
|
||||||
include_directories (${ODBC_INCLUDE_DIRECTORIES} ..)
|
|
||||||
|
|
||||||
set_target_properties (YAPodbc PROPERTIES
|
|
||||||
POSITION_INDEPENDENT_CODE ON
|
|
||||||
PREFIX ""
|
|
||||||
)
|
|
||||||
|
|
||||||
list (APPEND MYDDAS_FLAGS -DMYDDAS_ODBC=1)
|
|
||||||
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
|
|
||||||
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
|
|
||||||
-DMYDDAS_ODBC=1)
|
|
||||||
|
|
||||||
|
|
||||||
install(TARGETS YAPodbc
|
|
||||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
|
||||||
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
|
||||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
else()
|
set(SO_MAJOR 1)
|
||||||
add_definitions (-DMYDDAS_ODBC=0)
|
set(SO_MINOR 0)
|
||||||
|
set(SO_PATCH 0)
|
||||||
|
|
||||||
|
macro_optional_find_package(ODBC ON)
|
||||||
|
|
||||||
|
if (ODBC_FOUND)
|
||||||
|
# ODBC_INCLUDE_DIRECTORIES, where to find sql.h
|
||||||
|
# ODBC_LIBRARIES, the libraries to link against to use ODBC
|
||||||
|
# ODBC_FOUND. If false, you cannot build anything that requires Odbc.
|
||||||
|
add_lib(YAPodbc ${YAPODBC_SOURCES})
|
||||||
|
target_link_libraries(YAPodbc libYap ${ODBC_LIBRARIES})
|
||||||
|
include_directories (${ODBC_INCLUDE_DIRECTORIES} ..)
|
||||||
|
|
||||||
|
set_target_properties (YAPodbc PROPERTIES
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
PREFIX ""
|
||||||
|
)
|
||||||
|
|
||||||
|
list (APPEND MYDDAS_FLAGS -DMYDDAS_ODBC=1)
|
||||||
|
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
|
||||||
|
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
|
-DMYDDAS_ODBC=1)
|
||||||
|
|
||||||
|
|
||||||
|
install(TARGETS YAPodbc
|
||||||
|
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
add_definitions (-DMYDDAS_ODBC=0)
|
||||||
endif (ODBC_FOUND)
|
endif (ODBC_FOUND)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
@ -1,35 +1,39 @@
|
|||||||
|
|
||||||
set( YAPPOSTGRES_SOURCES
|
if (WITH_POSTGRES)
|
||||||
myddas_postgres.c
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SO_MAJOR 1)
|
set( YAPPOSTGRES_SOURCES
|
||||||
set(SO_MINOR 0)
|
myddas_postgres.c
|
||||||
set(SO_PATCH 0)
|
|
||||||
|
|
||||||
macro_optional_find_package(PostgreSQL ON)
|
|
||||||
|
|
||||||
if (PostgreSQL_FOUND)
|
|
||||||
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
|
|
||||||
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
|
|
||||||
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
|
|
||||||
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
|
|
||||||
add_lib(YAPpostgres ${YAPPOSTGRES_SOURCES})
|
|
||||||
target_link_libraries(YAPpostgres libYap ${PostgreSQL_LIBRARIES})
|
|
||||||
include_directories (${PostgreSQL_INCLUDE_DIRS} ..)
|
|
||||||
set_target_properties (YAPpostgres PROPERTIES
|
|
||||||
POSITION_INDEPENDENT_CODE ON
|
|
||||||
PREFIX ""
|
|
||||||
)
|
|
||||||
|
|
||||||
list (APPEND MYDDAS_FLAGS -DMYDDAS_POSTGRES=1)
|
|
||||||
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
|
|
||||||
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
|
|
||||||
-DMYDDAS_POSTGRES=1)
|
|
||||||
|
|
||||||
install(TARGETS YAPpostgres
|
|
||||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
|
||||||
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
|
||||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
|
||||||
)
|
)
|
||||||
endif (PostgreSQL_FOUND)
|
|
||||||
|
set(SO_MAJOR 1)
|
||||||
|
set(SO_MINOR 0)
|
||||||
|
set(SO_PATCH 0)
|
||||||
|
|
||||||
|
macro_optional_find_package(PostgreSQL ON)
|
||||||
|
|
||||||
|
if (PostgreSQL_FOUND)
|
||||||
|
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
|
||||||
|
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
|
||||||
|
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
|
||||||
|
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
|
||||||
|
add_lib(YAPpostgres ${YAPPOSTGRES_SOURCES})
|
||||||
|
target_link_libraries(YAPpostgres libYap ${PostgreSQL_LIBRARIES})
|
||||||
|
include_directories (${PostgreSQL_INCLUDE_DIRS} ..)
|
||||||
|
set_target_properties (YAPpostgres PROPERTIES
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
PREFIX ""
|
||||||
|
)
|
||||||
|
|
||||||
|
list (APPEND MYDDAS_FLAGS -DMYDDAS_POSTGRES=1)
|
||||||
|
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
|
||||||
|
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
|
-DMYDDAS_POSTGRES=1)
|
||||||
|
|
||||||
|
install(TARGETS YAPpostgres
|
||||||
|
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
)
|
||||||
|
endif (PostgreSQL_FOUND)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
@ -1,68 +1,72 @@
|
|||||||
message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
|
if (WITH_SQLITE3)
|
||||||
|
|
||||||
set (SQLITE_EXTRA
|
message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
|
||||||
chinook.db
|
|
||||||
sqlitest.yap)
|
|
||||||
|
|
||||||
set( YAPSQLITE3_SOURCES
|
set (SQLITE_EXTRA
|
||||||
myddas_sqlite3.c
|
chinook.db
|
||||||
src/sqlite3.h
|
sqlitest.yap)
|
||||||
src/sqlite3ext.h
|
|
||||||
)
|
set( YAPSQLITE3_SOURCES
|
||||||
|
myddas_sqlite3.c
|
||||||
|
src/sqlite3.h
|
||||||
|
src/sqlite3ext.h
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#sqlite3 is now in the system
|
#sqlite3 is now in the system
|
||||||
|
|
||||||
set (SQLITE3_FOUND ON CACHE PRIVATE "")
|
set (SQLITE3_FOUND ON CACHE PRIVATE "")
|
||||||
|
|
||||||
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
add_definitions(-DSQLITE_FCNTL_MMAP_SIZE=0 )
|
add_definitions(-DSQLITE_FCNTL_MMAP_SIZE=0 )
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA=1 )
|
||||||
|
|
||||||
|
add_definitions(-DSQLITE_ENABLE_JSON1=1 )
|
||||||
|
|
||||||
|
add_definitions(-DSQLITE_ENABLE_RBU=1 )
|
||||||
|
|
||||||
|
add_definitions(-DSQLITE_ENABLE_RTREE=1 )
|
||||||
|
add_definitions(-DSQLITE_ENABLE_FTS5=1 )
|
||||||
|
|
||||||
|
SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
|
||||||
|
|
||||||
|
|
||||||
|
if (ANDROID )
|
||||||
|
add_library( YAPsqlite3 OBJECT
|
||||||
|
${YAPSQLITE3_SOURCES} )
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
list(APPEND YAPSQLITE3_SOURCES src/sqlite3.c)
|
||||||
|
|
||||||
|
|
||||||
|
add_library( YAPsqlite3 SHARED
|
||||||
|
${YAPSQLITE3_SOURCES})
|
||||||
|
|
||||||
|
target_link_libraries(YAPsqlite3 libYap )
|
||||||
|
|
||||||
|
set_target_properties(YAPsqlite3
|
||||||
|
PROPERTIES
|
||||||
|
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
||||||
|
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
PREFIX ""
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS YAPsqlite3
|
||||||
|
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(FILES ${SQLITE_EXTRA}
|
||||||
|
DESTINATION ${libpl}
|
||||||
|
)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA=1 )
|
|
||||||
|
|
||||||
add_definitions(-DSQLITE_ENABLE_JSON1=1 )
|
|
||||||
|
|
||||||
add_definitions(-DSQLITE_ENABLE_RBU=1 )
|
|
||||||
|
|
||||||
add_definitions(-DSQLITE_ENABLE_RTREE=1 )
|
|
||||||
add_definitions(-DSQLITE_ENABLE_FTS5=1 )
|
|
||||||
|
|
||||||
SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
|
|
||||||
|
|
||||||
|
|
||||||
if (ANDROID )
|
|
||||||
add_library( YAPsqlite3 OBJECT
|
|
||||||
${YAPSQLITE3_SOURCES} )
|
|
||||||
|
|
||||||
else()
|
|
||||||
|
|
||||||
list(APPEND YAPSQLITE3_SOURCES src/sqlite3.c)
|
|
||||||
|
|
||||||
|
|
||||||
add_library( YAPsqlite3 SHARED
|
|
||||||
${YAPSQLITE3_SOURCES})
|
|
||||||
|
|
||||||
target_link_libraries(YAPsqlite3 libYap )
|
|
||||||
|
|
||||||
set_target_properties(YAPsqlite3
|
|
||||||
PROPERTIES
|
|
||||||
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
|
|
||||||
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
|
|
||||||
POSITION_INDEPENDENT_CODE ON
|
|
||||||
PREFIX ""
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS YAPsqlite3
|
|
||||||
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
|
|
||||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
|
||||||
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(FILES ${SQLITE_EXTRA}
|
|
||||||
DESTINATION ${libpl}
|
|
||||||
)
|
|
||||||
|
@ -591,7 +591,8 @@ static long get_len_of_range(long lo, long hi, long step) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if PY_MAJOR_VERSION >= 3
|
#if PY_MAJOR_VERSION >= 3
|
||||||
static PyStructSequence_Field pnull[] = {
|
/*
|
||||||
|
static PyStructSequence_Field pnull[] = {
|
||||||
{"A1", NULL}, {"A2", NULL}, {"A3", NULL}, {"A4", NULL}, {"A5", NULL},
|
{"A1", NULL}, {"A2", NULL}, {"A3", NULL}, {"A4", NULL}, {"A5", NULL},
|
||||||
{"A6", NULL}, {"A7", NULL}, {"A8", NULL}, {"A9", NULL}, {"A9", NULL},
|
{"A6", NULL}, {"A7", NULL}, {"A8", NULL}, {"A9", NULL}, {"A9", NULL},
|
||||||
{"A10", NULL}, {"A11", NULL}, {"A12", NULL}, {"A13", NULL}, {"A14", NULL},
|
{"A10", NULL}, {"A11", NULL}, {"A12", NULL}, {"A13", NULL}, {"A14", NULL},
|
||||||
@ -600,7 +601,8 @@ static PyStructSequence_Field pnull[] = {
|
|||||||
{"A24", NULL}, {"A25", NULL}, {"A26", NULL}, {"A27", NULL}, {"A28", NULL},
|
{"A24", NULL}, {"A25", NULL}, {"A26", NULL}, {"A27", NULL}, {"A28", NULL},
|
||||||
{"A29", NULL}, {"A29", NULL}, {"A30", NULL}, {"A31", NULL}, {"A32", NULL},
|
{"A29", NULL}, {"A29", NULL}, {"A30", NULL}, {"A31", NULL}, {"A32", NULL},
|
||||||
{NULL, NULL}};
|
{NULL, NULL}};
|
||||||
|
*/
|
||||||
|
|
||||||
static PyObject *structseq_str(PyObject *iobj) {
|
static PyObject *structseq_str(PyObject *iobj) {
|
||||||
|
|
||||||
/* buffer and type size were chosen well considered. */
|
/* buffer and type size were chosen well considered. */
|
||||||
@ -763,7 +765,7 @@ PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
|
|||||||
PyStructSequence_Desc *desc = calloc(sizeof(PyStructSequence_Desc), 1);
|
PyStructSequence_Desc *desc = calloc(sizeof(PyStructSequence_Desc), 1);
|
||||||
desc->name = PyMem_Malloc(strlen(s) + 1);
|
desc->name = PyMem_Malloc(strlen(s) + 1);
|
||||||
desc->doc = "YAPTerm";
|
desc->doc = "YAPTerm";
|
||||||
desc->fields = pnull;
|
desc->fields = NULL;
|
||||||
desc->n_in_sequence = arity;
|
desc->n_in_sequence = arity;
|
||||||
if (PyStructSequence_InitType2(typp, desc) < 0)
|
if (PyStructSequence_InitType2(typp, desc) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -166,7 +166,7 @@ listing(Stream, [MV|MVs]) :- !,
|
|||||||
->
|
->
|
||||||
format( Stream, ':- dynamic ~q/~d.~n', [N,Ar])
|
format( Stream, ':- dynamic ~q/~d.~n', [N,Ar])
|
||||||
;
|
;
|
||||||
\ format( Stream, ':- dynamic ~q:~q/~d.~n', [M,N,Ar])
|
format( Stream, ':- dynamic ~q:~q/~d.~n', [M,N,Ar])
|
||||||
),
|
),
|
||||||
fail.
|
fail.
|
||||||
'$list_clauses'(Stream, M, Pred) :-
|
'$list_clauses'(Stream, M, Pred) :-
|
||||||
|
@ -49,6 +49,7 @@ prolog:'$protect' :-
|
|||||||
sub_atom(Name,0,1,_, '$'),
|
sub_atom(Name,0,1,_, '$'),
|
||||||
functor(P,Name,Arity),
|
functor(P,Name,Arity),
|
||||||
% '$hide_predicate'(P,M),
|
% '$hide_predicate'(P,M),
|
||||||
|
'$stash_predicate'(P,M),
|
||||||
fail.
|
fail.
|
||||||
prolog:'$protect' :-
|
prolog:'$protect' :-
|
||||||
current_atom(Name),
|
current_atom(Name),
|
||||||
|
Reference in New Issue
Block a user