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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
161
CMakeLists.txt
161
CMakeLists.txt
@ -67,7 +67,62 @@ if (POLICY CMP0068)
|
|||||||
cmake_policy(SET CMP0068 NEW)
|
cmake_policy(SET CMP0068 NEW)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
## options: compilation flags
|
||||||
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
||||||
|
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_MMAP "Use MMAP for shared memory allocation" ON "NOT WITH_YAPOR_THOR" OFF)
|
||||||
|
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_SHM "Use SHM for shared memory allocation" ON "NOT WITH_YAPOR_THOR; NOT WITH_SYSTEM_MMAP" OFF)
|
||||||
|
OPTION(WITH_CALL_TRACER "support for procedure-call tracing" ${DEBUG})
|
||||||
|
option(WITH_YAP_DLL "compile YAP as a DLL" ON)
|
||||||
|
option(WITH_YAP_STATIC "compile YAP statically" OFF)
|
||||||
|
option(WITH_YAP_CONDOR "allow YAP to be used from condor" OFF)
|
||||||
|
option(WITH_YAP_DLL "compile YAP as a DLL" ON)
|
||||||
|
if (WITH_YAP_CONDOR)
|
||||||
|
set(WITH_YAP_STATIC ON)
|
||||||
|
set(WITH_YAP_DLL OFF)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
## options: libraries
|
||||||
|
option(WITH_THREADED_CODE "threaded code" ON)
|
||||||
|
option(WITH_MPI "Interface to OpenMPI/MPICH" ON)
|
||||||
|
option(WITH_READLINE "use readline or libedit" ON)
|
||||||
|
option(WITH_JIT "just in Time Clause Compilation" OFF)
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
option(WITH_BREW "brew" ON)
|
||||||
|
if (not WITH_BREW)
|
||||||
|
option(WITH_MACPORTS "mac-ports" ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option (WITH_EXTENSIONS "packages and libraries that add value to YAP" ON)
|
||||||
|
if (ANDROID)
|
||||||
|
OPTION(WITH_MYDDAS " Enable MYDDAS driver" ON)
|
||||||
|
OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ON)
|
||||||
|
elseif(WITH_EXTENSIONS)
|
||||||
|
if (WITH_MYDDAS)
|
||||||
|
OPTION(WITH_MYSQL " Enable MYDDAS MYSQL driver" ON)
|
||||||
|
OPTION(WITH_ODBC " Enable MYDDAS ODBC driver" ON)
|
||||||
|
OPTION(WITH_POSTGRES " Enable MYDDAS POSTGRES driver" ON)
|
||||||
|
OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ON)
|
||||||
|
endif()
|
||||||
|
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
||||||
|
OPTION(WITH_RAPTOR " Enable the RAPTOR RDF library" ON)
|
||||||
|
OPTION(WITH_XML2 " Enable the RAPTOR XML2 library" ON)
|
||||||
|
OPTION(WITH_XML " Enable the Prolog XML library" ON)
|
||||||
|
OPTION(WITH_CLPBN" Enable the CLPBN and PFL probabilistic languages" ON)
|
||||||
|
IF (WITH_CLPBN)
|
||||||
|
OPTION(WITH_HORUS " Enable the HORUS inference libraray for CLPBN and PFL" ON)
|
||||||
|
ENDIF()
|
||||||
|
option(WITH_PROBLOG "include Problog-I." ON)
|
||||||
|
OPTION(WITH_CPLINT " Enable the cplint probabilistic language" ON)
|
||||||
|
option(WITH_GECODE "interface gecode constraint solver" ON)
|
||||||
|
option(WITH_LBFGS "interface with lbfgs" ON)
|
||||||
|
option(WITH_PRISM "use PRISM system in YAP" ON)
|
||||||
|
option(WITH_PYTHON "Allow Python->YAP and YAP->Python" ON)
|
||||||
|
option(WITH_R "Use R Interface" ON)
|
||||||
|
option(WITH_JAVA "Try to use Java (currently Java 6,7,8)" ON)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||||
@ -232,7 +287,6 @@ if (APPLE)
|
|||||||
|
|
||||||
set(PATH $ENV{PATH})
|
set(PATH $ENV{PATH})
|
||||||
|
|
||||||
option(WITH_BREW "brew" ON)
|
|
||||||
if (WITH_MACPORTS)
|
if (WITH_MACPORTS)
|
||||||
# Add MacPorts
|
# Add MacPorts
|
||||||
# Detect if the "port" command is valid on this system; if so, return full path
|
# Detect if the "port" command is valid on this system; if so, return full path
|
||||||
@ -252,7 +306,6 @@ IF (${DETECT_MACPORTS} EQUAL 0)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
option(WITH_BREW "brew" ON)
|
|
||||||
|
|
||||||
if (WITH_BREW)
|
if (WITH_BREW)
|
||||||
EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_BREW OUTPUT_VARIABLE BREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_BREW OUTPUT_VARIABLE BREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
@ -344,7 +397,6 @@ if (GMP_FOUND)
|
|||||||
|
|
||||||
endif (GMP_FOUND)
|
endif (GMP_FOUND)
|
||||||
|
|
||||||
option(WITH_READLINE "use readline or libedit" ON)
|
|
||||||
|
|
||||||
if (WITH_READLINE)
|
if (WITH_READLINE)
|
||||||
include(FindReadline)
|
include(FindReadline)
|
||||||
@ -500,7 +552,6 @@ endif ()
|
|||||||
# set_property( DIRECTORY APPEND_STRING PROPERTY -fsanitize=memory;-fsanitize-memory-track-origins=2)
|
# set_property( DIRECTORY APPEND_STRING PROPERTY -fsanitize=memory;-fsanitize-memory-track-origins=2)
|
||||||
if (HAVE_GCC)
|
if (HAVE_GCC)
|
||||||
# replace instructions codes by the address of their code
|
# replace instructions codes by the address of their code
|
||||||
option(WITH_THREADED_CODE "threaded code" ON)
|
|
||||||
if (WITH_THREADED_CODE)
|
if (WITH_THREADED_CODE)
|
||||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS THREADED_CODE=1)
|
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS THREADED_CODE=1)
|
||||||
endif (WITH_THREADED_CODE)
|
endif (WITH_THREADED_CODE)
|
||||||
@ -509,8 +560,6 @@ endif (HAVE_GCC)
|
|||||||
#
|
#
|
||||||
#option (YAP_SWI_IO ON)
|
#option (YAP_SWI_IO ON)
|
||||||
|
|
||||||
OPTION(WITH_CALL_TRACER
|
|
||||||
"support for procedure-call tracing" ON)
|
|
||||||
#TODO:
|
#TODO:
|
||||||
if (WITH_CALL_TRACER)
|
if (WITH_CALL_TRACER)
|
||||||
list(APPEND YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS})
|
list(APPEND YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS})
|
||||||
@ -523,11 +572,13 @@ include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src )
|
|||||||
|
|
||||||
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
||||||
|
|
||||||
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
|
||||||
|
|
||||||
|
IF (WITH_MYDDAS)
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
else()
|
else()
|
||||||
|
|
||||||
|
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
||||||
|
|
||||||
if (MYSQL_FOUND)
|
if (MYSQL_FOUND)
|
||||||
add_definitions(= -DMYDDAS_MYSQL=1)
|
add_definitions(= -DMYDDAS_MYSQL=1)
|
||||||
endif ()
|
endif ()
|
||||||
@ -539,9 +590,9 @@ endif ()
|
|||||||
if (MYSQL_POSTGRES)
|
if (MYSQL_POSTGRES)
|
||||||
add_definitions(= -DMYDDAS_POSTGRES=1)
|
add_definitions(= -DMYDDAS_POSTGRES=1)
|
||||||
endif ()
|
endif ()
|
||||||
endif()
|
endif(ANDROID)
|
||||||
|
endif(WITH_MYDDAS)
|
||||||
|
|
||||||
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
|
||||||
|
|
||||||
IF (WITH_SWIG)
|
IF (WITH_SWIG)
|
||||||
find_host_package(SWIG)
|
find_host_package(SWIG)
|
||||||
@ -551,15 +602,11 @@ IF (WITH_SWIG)
|
|||||||
ENDIF (WITH_SWIG)
|
ENDIF (WITH_SWIG)
|
||||||
|
|
||||||
|
|
||||||
option(WITH_PYTHON
|
|
||||||
"Allow Python->YAP and YAP->Python" ON)
|
|
||||||
|
|
||||||
IF (WITH_PYTHON)
|
IF (WITH_PYTHON)
|
||||||
include(python )
|
include(python )
|
||||||
ENDIF (WITH_PYTHON)
|
ENDIF (WITH_PYTHON)
|
||||||
|
|
||||||
option(WITH_R
|
|
||||||
"Use R Interface" ON)
|
|
||||||
|
|
||||||
IF (WITH_R)
|
IF (WITH_R)
|
||||||
find_host_package(LibR)
|
find_host_package(LibR)
|
||||||
@ -733,26 +780,24 @@ if (NOT WIN32)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
option(WITH_JIT
|
|
||||||
"just in Time Clause Compilation" OFF)
|
|
||||||
if (WITH_JIT)
|
if (WITH_JIT)
|
||||||
add_subDIRECTORY(JIT)
|
add_subDIRECTORY(JIT)
|
||||||
endif (WITH_JIT)
|
endif (WITH_JIT)
|
||||||
|
|
||||||
|
|
||||||
|
if (WITH_XML2 OR WITH_RAPTOR)
|
||||||
|
|
||||||
add_subDIRECTORY(packages/raptor)
|
add_subDIRECTORY(packages/raptor)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
if (WITH_XML)
|
||||||
|
|
||||||
add_subDIRECTORY(packages/xml)
|
add_subDIRECTORY(packages/xml)
|
||||||
|
|
||||||
|
endif ()
|
||||||
|
|
||||||
OPTION(WITH_CLPBN " Enable the CLPBN and PFL probabilistic languages" ON)
|
|
||||||
|
|
||||||
OPTION(WITH_CPLINT " Enable the cplint probabilistic language" ON)
|
|
||||||
|
|
||||||
OPTION(WITH_HORUS " Enable the CLPBN and PFL probabilistic languages" ON)
|
|
||||||
|
|
||||||
find_host_package(Doxygen)
|
|
||||||
|
|
||||||
option(WITH_DOCS "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
|
|
||||||
|
|
||||||
IF (WITH_CLPBN)
|
IF (WITH_CLPBN)
|
||||||
add_subDIRECTORY(packages/CLPBN)
|
add_subDIRECTORY(packages/CLPBN)
|
||||||
@ -762,39 +807,29 @@ IF (WITH_CPLINT)
|
|||||||
add_subDIRECTORY(packages/cplint)
|
add_subDIRECTORY(packages/cplint)
|
||||||
ENDIF (WITH_CPLINT)
|
ENDIF (WITH_CPLINT)
|
||||||
|
|
||||||
# please install doxygen for prolog first
|
|
||||||
# git clone http://www.github.com/vscosta/doxygen-yap
|
|
||||||
# cd doxygen-yap
|
|
||||||
# mkdir -p build
|
|
||||||
# cd build
|
|
||||||
# make; sudo make install
|
|
||||||
option(WITH_DOCS
|
|
||||||
"generate YAP docs" OFF)
|
|
||||||
|
|
||||||
IF (WITH_DOCS)
|
IF (WITH_DOCS)
|
||||||
get_target_property(YAP_SOURCES libYap SOURCES)
|
get_target_property(YAP_SOURCES libYap SOURCES)
|
||||||
|
|
||||||
add_subDIRECTORY(docs)
|
add_subDIRECTORY(docs)
|
||||||
|
|
||||||
|
|
||||||
|
find_host_package(Doxygen)
|
||||||
|
|
||||||
ENDIF (WITH_DOCS)
|
ENDIF (WITH_DOCS)
|
||||||
|
|
||||||
# add_subDIRECTORY (packages/cuda)
|
# add_subDIRECTORY (packages/cuda)
|
||||||
|
|
||||||
option(WITH_GECODE
|
|
||||||
"interface gecode constraint solver" ON)
|
|
||||||
if (WITH_GECODE)
|
if (WITH_GECODE)
|
||||||
add_subDIRECTORY(packages/gecode)
|
add_subDIRECTORY(packages/gecode)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
option(WITH_LBFGS
|
|
||||||
"interface with lbfgs" ON)
|
|
||||||
|
|
||||||
if (WITH_LBFGS)
|
if (WITH_LBFGS)
|
||||||
add_subDIRECTORY(packages/yap-lbfgs)
|
add_subDIRECTORY(packages/yap-lbfgs)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
option(WITH_JAVA "Try to use Java (currently Java 6,7,8)" ON)
|
|
||||||
|
|
||||||
if (WITH_JAVA)
|
if (WITH_JAVA)
|
||||||
#detect java setup, as it is shared between different installations.
|
#detect java setup, as it is shared between different installations.
|
||||||
@ -857,18 +892,35 @@ endif (JNI_FOUND)
|
|||||||
|
|
||||||
|
|
||||||
endif (Java_Development_FOUND)
|
endif (Java_Development_FOUND)
|
||||||
endif(WITH_JAVA)
|
|
||||||
|
|
||||||
add_subDIRECTORY(packages/jpl)
|
add_subDIRECTORY(packages/jpl)
|
||||||
|
|
||||||
|
endif(WITH_JAVA)
|
||||||
|
|
||||||
|
if (WITH_CUDD)
|
||||||
|
|
||||||
add_subDIRECTORY(packages/bdd)
|
add_subDIRECTORY(packages/bdd)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WITH_PROBLOG)
|
||||||
|
|
||||||
add_subDIRECTORY(packages/ProbLog)
|
add_subDIRECTORY(packages/ProbLog)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WITH_MINISAT)
|
||||||
|
|
||||||
add_subDIRECTORY(packages/swi-minisat2)
|
add_subDIRECTORY(packages/swi-minisat2)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WITH_CLPQR)
|
||||||
|
|
||||||
add_subDIRECTORY(packages/clpqr)
|
add_subDIRECTORY(packages/clpqr)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
#todo: use cmake target builds
|
#todo: use cmake target builds
|
||||||
# option (USE_MAXPERFORMANCE
|
# option (USE_MAXPERFORMANCE
|
||||||
@ -886,28 +938,9 @@ add_subDIRECTORY(packages/clpqr)
|
|||||||
# option (USE_CYGWIN
|
# option (USE_CYGWIN
|
||||||
# "use cygwin library in WIN32" OFF)
|
# "use cygwin library in WIN32" OFF)
|
||||||
|
|
||||||
option(WITH_PRISM
|
|
||||||
"use PRISM system in YAP" ON)
|
|
||||||
#TODO:
|
#TODO:
|
||||||
|
|
||||||
|
|
||||||
option(WITH_YAP_DLL
|
|
||||||
"compile YAP as a DLL" ON)
|
|
||||||
#TODO:
|
|
||||||
|
|
||||||
option(WITH_YAP_STATIC
|
|
||||||
"compile YAP statically" OFF)
|
|
||||||
#TODO:
|
|
||||||
|
|
||||||
option(WITH_YAP_CONDOR
|
|
||||||
"allow YAP to be used from condor" OFF)
|
|
||||||
|
|
||||||
if (WITH_YAP_CONDOR)
|
|
||||||
# use default allocator
|
|
||||||
set(YAP_STATIC ON)
|
|
||||||
set(YAP_DLL OFF)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#TODO: detect arch before allow this option
|
#TODO: detect arch before allow this option
|
||||||
# OPTION(WIN64
|
# OPTION(WIN64
|
||||||
# "compile YAP for win64" OFF)
|
# "compile YAP for win64" OFF)
|
||||||
@ -952,20 +985,12 @@ install(TARGETS libYap yap-bin
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_MMAP "Use MMAP for shared memory allocation" ON
|
if (WITH_MPI)
|
||||||
"NOT WITH_YAPOR_THOR" OFF)
|
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_SHM "Use SHM for shared memory allocation" ON
|
|
||||||
"NOT WITH_YAPOR_THOR; NOT WITH_SYSTEM_MMAP" OFF)
|
|
||||||
|
|
||||||
if (NOT ANDROID)
|
|
||||||
|
|
||||||
add_subDIRECTORY(library/lammpi)
|
add_subDIRECTORY(library/lammpi)
|
||||||
|
|
||||||
if (MPI_C_FOUND)
|
if (MPI_C_FOUND)
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(WITH_MPI ON "Interface to OpenMPI/MPICH"
|
|
||||||
"MPI_C_FOUND" OFF)
|
|
||||||
macro_optional_add_subDIRECTORY(library/mpi)
|
macro_optional_add_subDIRECTORY(library/mpi)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS} ")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS} ")
|
||||||
include_directories(${MPI_C_INCLUDE_PATH})
|
include_directories(${MPI_C_INCLUDE_PATH})
|
||||||
@ -981,7 +1006,7 @@ if (MPI_C_FOUND)
|
|||||||
endif ()
|
endif ()
|
||||||
endif (MPI_C_FOUND)
|
endif (MPI_C_FOUND)
|
||||||
|
|
||||||
endif(NOT ANDROID)
|
endif(WITH_MPI)
|
||||||
|
|
||||||
## add_subDIRECTORY(utils)
|
## add_subDIRECTORY(utils)
|
||||||
|
|
||||||
|
@ -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)
|
||||||
@ -449,16 +449,12 @@ 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,11 +487,48 @@ 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(_,_,_,_)).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
@ -503,7 +536,7 @@ init_learning :-
|
|||||||
% 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,30 +560,10 @@ 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]),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
% build BDD script for every example
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
once(init_queries),
|
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
% done
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
assertz(current_iteration(0)),
|
|
||||||
assertz(learning_initialized),
|
|
||||||
|
|
||||||
format_learning(1,'~n',[]).
|
|
||||||
|
|
||||||
empty_bdd_directory :-
|
empty_bdd_directory :-
|
||||||
current_key(_,I),
|
current_key(_,I),
|
||||||
integer(I),
|
integer(I),
|
||||||
@ -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),
|
||||||
example_count(Example_Count),
|
(user:training_example(QueryID,Query,TrueQueryProb,_Type),
|
||||||
|
once(update_query(QueryID,'+',probability)),
|
||||||
bb_put(error_train_line_search,0.0),
|
|
||||||
forall(user:example(QueryID,_Query,QueryProb,Type),
|
|
||||||
(
|
|
||||||
once(update_query(QueryID,'.',probability)),
|
|
||||||
query_probability(QueryID,CurrentProb),
|
query_probability(QueryID,CurrentProb),
|
||||||
|
format(Handle,'ex(~q,training,~q,~q,~10f,~10f).~n',[Iteration,QueryID,Query,TrueQueryProb,CurrentProb]),
|
||||||
|
|
||||||
once(update_query_cleanup(QueryID)),
|
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),
|
||||||
|
|
||||||
|
length(AllSquaredErrors,Length),
|
||||||
|
|
||||||
(
|
(
|
||||||
(Type == '='; (Type == '<', CurrentProb>QueryProb); (Type=='>',CurrentProb<QueryProb))
|
Length>0
|
||||||
->
|
->
|
||||||
(
|
(
|
||||||
bb_get(error_train_line_search,Old_Error),
|
sum_list(AllSquaredErrors,SumAllSquaredErrors),
|
||||||
New_Error is Old_Error + (CurrentProb-QueryProb)**2,
|
min_list(AllSquaredErrors,MinError),
|
||||||
bb_put(error_train_line_search,New_Error)
|
max_list(AllSquaredErrors,MaxError),
|
||||||
);true
|
MSE is SumAllSquaredErrors/Length
|
||||||
)
|
);(
|
||||||
|
MSE=0.0,
|
||||||
|
MinError=0.0,
|
||||||
|
MaxError=0.0
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
bb_delete(error_train_line_search,Error),
|
|
||||||
MSE is Error/Example_Count,
|
logger_set_variable(mse_trainingset,MSE),
|
||||||
format_learning(3,' (~8f)~n',[MSE]),
|
logger_set_variable(mse_min_trainingset,MinError),
|
||||||
retractall(values_correct).
|
logger_set_variable(mse_max_trainingset,MaxError),
|
||||||
|
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),
|
||||||
@ -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),
|
||||||
@ -852,13 +861,13 @@ 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) :-
|
||||||
@ -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,3 +1,4 @@
|
|||||||
|
if (WITH_ODBC)
|
||||||
|
|
||||||
set( YAPODBC_SOURCES
|
set( YAPODBC_SOURCES
|
||||||
myddas_odbc.c
|
myddas_odbc.c
|
||||||
@ -37,3 +38,5 @@ set_target_properties (YAPodbc PROPERTIES
|
|||||||
else()
|
else()
|
||||||
add_definitions (-DMYDDAS_ODBC=0)
|
add_definitions (-DMYDDAS_ODBC=0)
|
||||||
endif (ODBC_FOUND)
|
endif (ODBC_FOUND)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
if (WITH_POSTGRES)
|
||||||
|
|
||||||
set( YAPPOSTGRES_SOURCES
|
set( YAPPOSTGRES_SOURCES
|
||||||
myddas_postgres.c
|
myddas_postgres.c
|
||||||
)
|
)
|
||||||
@ -33,3 +35,5 @@ install(TARGETS YAPpostgres
|
|||||||
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
|
||||||
)
|
)
|
||||||
endif (PostgreSQL_FOUND)
|
endif (PostgreSQL_FOUND)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
if (WITH_SQLITE3)
|
||||||
|
|
||||||
message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
|
message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
|
||||||
|
|
||||||
set (SQLITE_EXTRA
|
set (SQLITE_EXTRA
|
||||||
@ -66,3 +68,5 @@ endif()
|
|||||||
install(FILES ${SQLITE_EXTRA}
|
install(FILES ${SQLITE_EXTRA}
|
||||||
DESTINATION ${libpl}
|
DESTINATION ${libpl}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
@ -591,6 +591,7 @@ 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},
|
||||||
@ -600,6 +601,7 @@ 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) {
|
||||||
|
|
||||||
@ -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