make user functions return bool

This commit is contained in:
Vítor Santos Costa 2015-02-03 02:37:25 +00:00
parent 5a668febd9
commit 2f621e5b47
14 changed files with 111 additions and 89 deletions

View File

@ -65,17 +65,17 @@ int ex,cycle;
DdNode *** nodesToVisit;
int * NnodesToVisit;
double * example_prob;
static int ret_prob(void);
static YAP_Bool ret_prob(void);
double Prob(DdNode *node,int comp_par);
static int end_bdd(void);
static int init_test(void);
static int add_var(void);
static int init(void);
static int end(void);
static int EM(void);
static int Q(void);
static YAP_Bool end_bdd(void);
static YAP_Bool init_test(void);
static YAP_Bool add_var(void);
static YAP_Bool init(void);
static YAP_Bool end(void);
static YAP_Bool EM(void);
static YAP_Bool Q(void);
double ProbPath(DdNode *node, int comp_par, int nex);
static int rec_deref(void);
static YAP_Bool rec_deref(void);
int indexMvar(DdNode *node);
void Forward(DdNode *node, int nex);
void GetForward(DdNode *node, double ForwProbPath);
@ -91,7 +91,7 @@ void add_or_replace_node(tablerow *tab, DdNode *node, double value);
void add_node(tablerow *tab, DdNode *node, double value);
void destroy_table(tablerow *tab,int varcnt);
static int init(void)
static YAP_Bool init(void)
{
int j,i;
YAP_Term arg1,arg2,list;
@ -130,7 +130,7 @@ static int init(void)
return 1;
}
static int init_bdd(void)
static YAP_Bool init_bdd(void)
{
mgr_ex=(DdManager **) realloc(mgr_ex, (ex+1)* sizeof(DdManager *));
mgr_ex[ex]=Cudd_Init(0,0,UNIQUE_SLOTS,CACHE_SLOTS,5120);
@ -157,7 +157,7 @@ static int init_bdd(void)
return 1;
}
static int end_bdd(void)
static YAP_Bool end_bdd(void)
{
ex=ex+1;
@ -166,7 +166,7 @@ static int end_bdd(void)
static int init_test(void)
static YAP_Bool init_test(void)
{
YAP_Term arg1;
@ -202,7 +202,7 @@ static int init_test(void)
}
static int end_test(void)
static YAP_Bool end_test(void)
{
free(bVar2mVar_ex[ex]);
free(vars_ex[ex]);
@ -257,7 +257,7 @@ static double Expectation(DdNode **nodes_ex,int lenNodes)
return CLL;
}
static int end(void)
static YAP_Bool end(void)
{
int r,i;
@ -299,7 +299,7 @@ static int end(void)
}
static int ret_prob(void)
static YAP_Bool ret_prob(void)
{
YAP_Term arg1,arg2,out;
DdNode * node;
@ -376,7 +376,7 @@ so that it is not recomputed
static int add_var(void)
static YAP_Bool add_var(void)
{
YAP_Term arg1,arg2,arg3,arg4,out,probTerm,probTerm_temp;
variable * v;
@ -416,7 +416,7 @@ static int add_var(void)
return YAP_Unify(out,arg4);
}
static int equality(void)
static YAP_Bool equality(void)
{
YAP_Term arg1,arg2,arg3,out;
int varIndex;
@ -454,7 +454,7 @@ static int equality(void)
return(YAP_Unify(out,arg3));
}
static int one(void)
static YAP_Bool one(void)
{
YAP_Term arg,out;
DdNode * node;
@ -466,7 +466,7 @@ static int one(void)
return(YAP_Unify(out,arg));
}
static int zero(void)
static YAP_Bool zero(void)
{
YAP_Term arg,out;
DdNode * node;
@ -478,7 +478,7 @@ static int zero(void)
return(YAP_Unify(out,arg));
}
static int bdd_not(void)
static YAP_Bool bdd_not(void)
{
YAP_Term arg1,arg2,out;
DdNode * node;
@ -491,7 +491,7 @@ static int bdd_not(void)
return(YAP_Unify(out,arg2));
}
static int and(void)
static YAP_Bool and(void)
{
YAP_Term arg1,arg2,arg3,out;
DdNode * node1, *node2,*nodeout;
@ -507,7 +507,7 @@ static int and(void)
return(YAP_Unify(out,arg3));
}
static int or(void)
static YAP_Bool or(void)
{
YAP_Term arg1,arg2,arg3,out;
DdNode * node1,*node2,*nodeout;
@ -523,7 +523,7 @@ static int or(void)
return(YAP_Unify(out,arg3));
}
static int garbage_collect(void)
static YAP_Bool garbage_collect(void)
{
YAP_Term arg1,arg2,out;
YAP_Int nodes,clearCache;
@ -536,7 +536,7 @@ static int garbage_collect(void)
return(YAP_Unify(out,arg2));
}
static int bdd_to_add(void)
static YAP_Bool bdd_to_add(void)
{
YAP_Term arg1,arg2,out;
DdNode * node1,*node2;
@ -549,7 +549,7 @@ static int bdd_to_add(void)
return(YAP_Unify(out,arg2));
}
static int create_dot(void)
static YAP_Bool create_dot(void)
{
char * onames[]={"Out"};
char ** inames;
@ -600,7 +600,7 @@ static int create_dot(void)
}
static int rec_deref(void)
static YAP_Bool rec_deref(void)
{
YAP_Term arg1;
DdNode * node;
@ -903,7 +903,7 @@ void Maximization(void)
}
}
static int randomize(void)
static YAP_Bool randomize(void)
{
int i,j,e,rule;
double * theta,p0;
@ -951,7 +951,7 @@ static int randomize(void)
return 1;
}
static int EM(void)
static YAP_Bool EM(void)
{
YAP_Term arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,
out1,out2,out3,nodesTerm,ruleTerm,tail,pair,compoundTerm;
@ -1049,7 +1049,7 @@ static int EM(void)
}
static int Q(void)
static YAP_Bool Q(void)
{
YAP_Term arg1,arg2,arg3,arg4,out,out1,
term,nodesTerm,ruleTerm,tail,pair,compoundTerm;
@ -1116,7 +1116,7 @@ static int Q(void)
return (YAP_Unify(out,arg3));
}
static int paths_to_non_zero(void)
static YAP_Bool paths_to_non_zero(void)
{
double paths;
YAP_Term arg1,arg2,out;
@ -1130,7 +1130,7 @@ static int paths_to_non_zero(void)
return(YAP_Unify(out,arg2));
}
static int paths(void)
static YAP_Bool paths(void)
{
double paths;
YAP_Term arg1,arg2,out;
@ -1144,7 +1144,7 @@ static int paths(void)
return(YAP_Unify(out,arg2));
}
static int dag_size(void)
static YAP_Bool dag_size(void)
{
int size;
YAP_Term arg1,arg2,out;

View File

@ -1,8 +1,10 @@
#CHECK: CUDA
macro_optional_find_package (CUDA ON)
macro_log_feature (CUDA_FOUND "CUDA"
"CUDA GGPU Programming "
macro_log_feature (CUDA_FOUND "CUDA"
"CUDA GGPU Programming "
"http://www.r.org" FALSE)
if (CUDA_FOUND)
# CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc.
# CUDA_VERSION_MINOR -- The minor version.
@ -51,4 +53,3 @@ if (CUDA_FOUND)
endif (CUDA_FOUND)

View File

@ -23,7 +23,7 @@ CC=@CC@
NVCC=@NVCC@
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include @CUDA_CPPFLAGS@
NVCCFLAGS=@CUDA_CPPFLAGS@ -I$(srcdir) -I../.. -I$(srcdir)/../../include
LDFLAGS=@LDFLAGS@
CUDA_LDFLAGS=@CUDA_LDFLAGS@
#
#
# You shouldn't need to change what follows.

View File

@ -24,7 +24,7 @@ else
PKG_CUDA="packages/cuda"
case "$target_os" in
*darwin*)
CUDA_LDFLAGS="$LDFLAGS"
CUDA_LDFLAGS="$LDFLAGS $LIBS"
CUDA_CPPFLAGS="-arch=sm_20 -Xcompiler -fPIC -O3 "
CUDA_SHLIB_LD="$NVCC --shared -L../.. -lYap "
;;

View File

@ -115,7 +115,7 @@ int32_t Cuda_Erase(predicate *pe)
return TRUE;
}
static int
static YAP_Bool
load_facts( void ) {
int32_t nrows = YAP_IntOfTerm(YAP_ARG1);
@ -164,7 +164,7 @@ load_facts( void ) {
static int currentFact = 0;
static predicate *currentPred = NULL;
static int
static YAP_Bool
cuda_init_facts( void ) {
int32_t nrows = YAP_IntOfTerm(YAP_ARG1);
@ -198,7 +198,7 @@ cuda_init_facts( void ) {
}
}
static int
static YAP_Bool
cuda_load_fact( void ) {
YAP_Term th = YAP_ARG1;
@ -225,7 +225,7 @@ cuda_load_fact( void ) {
return TRUE;
}
static int
static YAP_Bool
load_rule( void ) {
// maximum of 2K symbols per rule, should be enough for ILP
int32_t vec[2048], *ptr = vec, *nvec;
@ -303,14 +303,14 @@ load_rule( void ) {
return YAP_Unify(YAP_ARG4, YAP_MkIntTerm((YAP_Int)pred));
}
static int
static YAP_Bool
cuda_erase( void )
{
predicate *ptr = (predicate *)YAP_IntOfTerm(YAP_ARG1);
return Cuda_Erase( ptr );
}
static int
static YAP_Bool
cuda_eval( void )
{
int32_t *mat;
@ -336,7 +336,7 @@ cuda_eval( void )
return YAP_Unify(YAP_ARG2, out);
}
static int
static YAP_Bool
cuda_coverage( void )
{
int32_t *mat;
@ -384,7 +384,7 @@ cuda_coverage( void )
} while ( TRUE );
}
static int cuda_count( void )
static YAP_Bool cuda_count( void )
{
int32_t *mat;
predicate *ptr = (predicate *)YAP_IntOfTerm(YAP_ARG1);
@ -396,7 +396,7 @@ static int cuda_count( void )
return YAP_Unify(YAP_ARG2, YAP_MkIntTerm(n));
}
static int cuda_statistics( void )
static YAP_Bool cuda_statistics( void )
{
Cuda_Statistics();
return TRUE;

View File

@ -4,9 +4,10 @@
#CHECK: GECODE
macro_optional_find_package (Gecode ON)
macro_log_feature (GECODE_FOUND "libgecode"
"Use Generic Constraint Development Environment (GECODE) library"
macro_log_feature (GECODE_FOUND "libgecode"
"Use Generic Constraint Development Environment (GECODE) library"
"http://www.gecode.org" FALSE)
if (GECODE_FOUND)
#DEFINES:
# GECODE_INCLUDE_DIR
@ -17,7 +18,7 @@ if (GECODE_FOUND)
string(SUBSTRING ${GECODE_VERSION} 0 1 GECODE_MAJOR )
set (GECODE_SOURCES gecode${GECODE_MAJOR}_yap.cc
set (GECODE_SOURCES gecode${GECODE_MAJOR}_yap.cc
gecode${GECODE_MAJOR}-common.icc
${GECODE_VERSION}/gecode_yap_cc_impl_auto_generated.icc
${GECODE_VERSION}/gecode_yap_cc_init_auto_generated.icc
@ -34,7 +35,7 @@ if (GECODE_FOUND)
VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_library (gecode SHARED ${GECODE_SOURCES})
target_link_libraries(gecode libYap ${GECODE_LIBRARIES})
@ -42,7 +43,7 @@ if (GECODE_FOUND)
set_target_properties (gecode PROPERTIES PREFIX "")
include_directories (${GECODE_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${GECODE_VERSION})
install(TARGETS gecode
LIBRARY DESTINATION ${dlls}
)

View File

@ -11,6 +11,7 @@ else
if test -d "$use_gecode"; then
CPPFLAGS="$CPPFLAGS -I $use_gecode/include"
GECODE_EXTRALIBS="-L $use_gecode/lib"
GECODE_INCLUDES=" $use_gecode/include"
GECODE_PATH="$use_gecode/bin"
dnl gecode is usually in /usr/local
elif test -d /usr/local/include/gecode -a x$SYSROOT = x; then
@ -47,7 +48,7 @@ if test "$use_gecode" != no; then
fi
if test "$use_gecode" = yes; then
GECODE_PATH=`which fzn-gecode`
GECODE_PATH=`dirname "$GECODE_PATH"`
GECODE_PATH=`dirname "$GECODE_PATH"`
else
GECODE_PATH="$use_gecode"
fi
@ -116,8 +117,6 @@ CPPFLAGS="$CPPFLAGS -I \"$GECODE_INCLUDES\""
AC_CHECK_HEADER(gecode/support/config.hpp)
CPPFLAGS="$saved_CPPFLAGS"
AC_SUBST(GECODE_EXTRALIBS)
AC_SUBST(GECODE_INCLUDES)
AC_SUBST(GECODE_VERSION)
@ -128,3 +127,5 @@ if test "$PKG_GECODE" = "packages/gecode"; then
AC_CONFIG_FILES([packages/gecode/Makefile])
fi
CPPFLAGS="$saved_CPPFLAGS"

View File

@ -40,17 +40,26 @@ macro_optional_find_package(ODBC ON)
macro_optional_find_package(MySQL ON)
macro_optional_find_package(Sqlite3 ON)
if (ODBC_FOUND OR MYSQL_FOUND or SQLITE3_FOUND)
macro_log_feature (ODBC_FOUND "ODBC"
"Use ODBC Data-Base Interface "
"http://www.unixodbc.org" FALSE)
macro_log_feature (MYSQL_FOUND "MySQL"
"Use MYSQL Data-Base Interface "
"http://www.mysql.org" FALSE)
macro_log_feature (SQLITE3_FOUND "SQLite3"
"SQL Light Data-Base "
"http://www.sqlite3.org" FALSE)
if (ODBC_FOUND OR MYSQL_FOUND OR SQLITE3_FOUND)
add_library (myddas SHARED ${MYDDAS_SOURCES})
target_link_libraries(myddas libYap)
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 MySQL.
macro_log_feature (ODBC_FOUND "ODBC"
"Use ODBC Data-Base Interface "
"http://www.unixodbc.org" FALSE)
add_definitions (-DMYDDAS_ODBC=1)
add_definitions (-DMYDDAS_ODBC=1)
target_link_libraries(myddas ${ODBC_LIBRARIES})
include_directories (${ODBC_INCLUDE_DIRECTORIES})
endif (ODBC_FOUND)
@ -61,10 +70,7 @@ if (ODBC_FOUND OR MYSQL_FOUND or SQLITE3_FOUND)
# SQLITE3_LIBRARY_RELEASE - Where the release library is
# SQLITE3_LIBRARY_DEBUG - Where the debug library is
# SQLITE3_FOUND - Set to TRUE if we found everything (library, includes and executable)
macro_log_feature (SQLITE3_FOUND "SQLite3"
"SQL Light Data-Base "
"http://www.sqlite3.org" FALSE)
add_definitions (-DMYDDAS_SQLITE3=1)
add_definitions (-DMYDDAS_SQLITE3=1)
target_link_libraries(myddas ${SQLITE3_LIBRARIES})
include_directories (${SQLITE3_INCLUDE_DIR})
endif (SQLITE3_FOUND)
@ -73,16 +79,13 @@ if (ODBC_FOUND OR MYSQL_FOUND or SQLITE3_FOUND)
# MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
# MYSQL_LIBRARIES - List of libraries when using MySQL.
# MYSQL_FOUND - True if MySQL found.
macro_log_feature (MYSQL_FOUND "MySQL"
"Use MYSQL Data-Base Interface "
"http://www.mysql.org" FALSE)
add_definitions (-DMYDDAS_MYSQL=1)
add_definitions (-DMYDDAS_MYSQL=1)
target_link_libraries(myddas ${MYSQL_LIBRARIES})
include_directories (${MYSQL_INCLUDE_DIR})
endif (MYSQL_FOUND)
add_custom_target (plmyddas ALL DEPENDS ${GENERATED_SOURCES} ) # WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
endif (ODBC_FOUND OR MYSQL_FOUND)
endif (ODBC_FOUND OR MYSQL_FOUND OR SQLITE3_FOUND)
cmake_dependent_option (WITH_MYDDAS_Stats
"enable the MYDDAS library statistics support" OFF

View File

@ -13,6 +13,8 @@ AC_ARG_WITH(myddas,
CPPFLAGS="$CPPFLAGS -I${yap_cv_myddas}/include "
ODBC_LDFLAGS="-L${yap_cv_myddas}/lib "
ODBC_CFLAGS="-I${yap_cv_myddas}/include "
SQLITE3_LDFLAGS="-L${yap_cv_myddas}/lib "
SQLITE3_CFLAGS="-I${yap_cv_myddas}/include "
fi,
[yap_cv_myddas=/usr])
@ -87,6 +89,18 @@ then
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_TOP_LEVEL"
fi
#from SWI PROSQLITE library.
AC_CHECK_LIB(sqlite3, sqlite3_open,
MYDDAS_LIBS+="-lsqlite3"
havelib=yes)
AC_CHECK_HEADERS(sqlite3.h, [], [yap_cv_sqlite3="no"])
if test "$yap_cv_odbc" = yes
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_SQLITE3"
fi
LIBS="$OLD_LIBS"
else
ENABLE_MYDDAS=""

@ -1 +1 @@
Subproject commit 9972458293415b2d72276bd67875767bfeed00df
Subproject commit d0d1ee4d58373cc611676103e0a50a3ae451a023

View File

@ -28,7 +28,8 @@ AC_ARG_WITH(prosqlite,
PROSQLITE_DIR=/usr
elif test "$withval" = no; then
yap_cv_prosqlite=no
else
else
PROSQLITE_DIR=$withval
fi,
[PROSQLITE_DIR=/usr ])

View File

@ -3,11 +3,12 @@
set (PYTHON_SOURCES
python.c)
macro_optional_find_package(PythonInterp ON)
macro_optional_find_package (PythonLibs ON)
macro_log_feature (PYTHONLIBS_FOUND "Python"
"Use Python System"
"http://www.python.org" FALSE)
macro_optional_find_package(PythonInterp ON)
macro_optional_find_package (PythonLibs ON)
macro_log_feature (PYTHONLIBS_FOUND "Python"
"Use Python System"
"http://www.python.org" FALSE)
if (PYTHONLIBS_FOUND) # PYTHONLIBS_FOUND - have the Python libs been found
# PYTHON_LIBRARIES - path to the python library
# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
@ -33,7 +34,7 @@ if (PYTHONLIBS_FOUND) # PYTHONLIBS_FOUND - have the Python l
# If also calling find_package(PythonInterp), call find_package(PythonInterp)
# first to get the currently active Python version by default with a consistent
# version of PYTHON_LIBRARIES.
add_library (python SHARED ${PYTHON_SOURCES})
target_link_libraries(python libYap ${PYTHON_LIBRARIES})
@ -41,7 +42,7 @@ if (PYTHONLIBS_FOUND) # PYTHONLIBS_FOUND - have the Python l
set_target_properties (python PROPERTIES PREFIX "")
include_directories (${PYTHON_INCLUDE_DIRS})
install(TARGETS python
LIBRARY DESTINATION ${dlls}
)
@ -50,5 +51,5 @@ if (PYTHONLIBS_FOUND) # PYTHONLIBS_FOUND - have the Python l
DESTINATION ${libpl}
)
endif (PYTHONLIBS_FOUND)

@ -1 +1 @@
Subproject commit 36f99e3c3c978fef25f899dc4fab1ffee334d73c
Subproject commit 34d9f645721645aac9f4f40c815fe4fe2c6511e6

View File

@ -145,7 +145,7 @@ static int progress(
Set the current value for `x[I]`. Only possible when the optimizer is
initialized but not running.
*/
static int set_x_value(void) {
static YAP_Bool set_x_value(void) {
YAP_Term t1=YAP_ARG1;
YAP_Term t2=YAP_ARG2;
int i=0;
@ -182,7 +182,7 @@ static int set_x_value(void) {
Get the current value for `x[I]`. Only possible when the optimizer is
initialized or running.
*/
static int get_x_value(void) {
static YAP_Bool get_x_value(void) {
YAP_Term t1=YAP_ARG1;
YAP_Term t2=YAP_ARG2;
int i=0;
@ -213,7 +213,7 @@ static int get_x_value(void) {
partial derivative of _F_ with respect to `x[I]`). Can only be called
from the evaluate call back predicate.
*/
static int set_g_value(void) {
static YAP_Bool set_g_value(void) {
YAP_Term t1=YAP_ARG1;
YAP_Term t2=YAP_ARG2;
int i=0;
@ -250,7 +250,7 @@ static int set_g_value(void) {
Get the current value for `g[I]` (the partial derivative of _F_ with respect to `x[I]`). Only possible when the optimizer is
initialized or running.
*/
static int get_g_value(void) {
static YAP_Bool get_g_value(void) {
YAP_Term t1=YAP_ARG1;
YAP_Term t2=YAP_ARG2;
int i=0;
@ -314,7 +314,7 @@ terminate with an error. If _Continue_ is set to 0 (int) the
optimization process will continue for one more iteration, any other
value will terminate the optimization process.
*/
static int optimizer_initialize(void) {
static YAP_Bool optimizer_initialize(void) {
YAP_Term t1 = YAP_ARG1;
int temp_n=0;
@ -356,7 +356,7 @@ Status (int) is the status code returned by libLBFGS. Anything except
0 indicates an error, see the documentation of libLBFGS for the
meaning.
*/
static int optimizer_run(void) {
static YAP_Bool optimizer_run(void) {
int ret = 0;
YAP_Term t1 = YAP_ARG1;
YAP_Term t2 = YAP_ARG2;
@ -394,7 +394,7 @@ static int optimizer_run(void) {
static int optimizer_finalize( void ) {
static YAP_Bool optimizer_finalize( void ) {
if (optimizer_status == OPTIMIZER_STATUS_NONE) {
printf("Error: Optimizer is not initialized.\n");
return FALSE;
@ -419,7 +419,7 @@ static int optimizer_finalize( void ) {
Set the parameter Name to Value. Only possible while the optimizer
is not running.
*/
static int optimizer_set_parameter( void ) {
static YAP_Bool optimizer_set_parameter( void ) {
YAP_Term t1 = YAP_ARG1;
YAP_Term t2 = YAP_ARG2;
@ -579,7 +579,7 @@ static int optimizer_set_parameter( void ) {
Get the current Value for Name
*/
static int optimizer_get_parameter( void ) {
static YAP_Bool optimizer_get_parameter( void ) {
YAP_Term t1 = YAP_ARG1;
YAP_Term t2 = YAP_ARG2;