adds
This commit is contained in:
parent
a5951daea9
commit
4d3d9c408d
@ -1,32 +0,0 @@
|
||||
// cmake template file
|
||||
|
||||
/* Define to 1 if you have the <cuddInt.h> header file. */
|
||||
#ifndef HAVE_CUDDINT_H
|
||||
/* #undef HAVE_CUDDINT_H */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <cudd/cuddInt.h> header file. */
|
||||
#ifndef HAVE_CUDD_CUDDINT_H
|
||||
#define HAVE_CUDD_CUDDINT_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <cudd/cudd.h> header file. */
|
||||
#ifndef HAVE_CUDD_CUDD_H
|
||||
#define HAVE_CUDD_CUDD_H 1
|
||||
#endif
|
||||
|
||||
/*Define to 1 if you have the <cudd.h> header file. */
|
||||
#ifndef HAVE_CUDD_H
|
||||
/* #undef HAVE_CUDD_H */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <cudd/util.h> header file. */
|
||||
#ifndef HAVE_CUDD_UTIL_H
|
||||
#define HAVE_CUDD_UTIL_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <util.h> header file. */
|
||||
#ifndef HAVE_UTIL_H
|
||||
#define HAVE_UTIL_H 1
|
||||
#endif
|
||||
|
@ -1,2 +0,0 @@
|
||||
#define HAVE_RAPTOR2_RAPTOR2_H 1
|
||||
/* #undef HAVE_RAPTOR_H */
|
@ -1,26 +0,0 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
* This file is autogenerated from rconfig.h.cmake
|
||||
* during the cmake configuration of your project. If you need to make changes
|
||||
* edit the original file NOT THIS FILE.
|
||||
* --------------------------------------------------------------------------*/
|
||||
#ifndef RCONFIG_H
|
||||
#define RCONFIG_H
|
||||
|
||||
/* Define to 1 if you have the <alloca.h> header file. */
|
||||
#ifndef HAVE_R_H
|
||||
#define HAVE_R_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <alloca.h> header file. */
|
||||
#ifndef HAVE_R_EMBEDDED_H
|
||||
#define HAVE_R_EMBEDDED_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <alloca.h> header file. */
|
||||
#ifndef HAVE_R_INTERFACE_H
|
||||
#define HAVE_R_INTERFACE_H 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
/* Define to 1 if you have the <openssl/ripemd.h> header file. */
|
||||
#ifndef HAVE_APR_1_APR_MD5_H
|
||||
#define HAVE_APR_1_APR_MD5_H 1
|
||||
/* #undef HAVE_APR_1_APR_MD5_H */
|
||||
#endif
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
/* Define if you have libreadline */
|
||||
#ifndef HAVE_LIBREADLINE
|
||||
#define HAVE_LIBREADLINE 1
|
||||
/* #undef HAVE_LIBREADLINE */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <readline/history.h> header file. */
|
||||
#ifndef HAVE_READLINE_HISTORY_H
|
||||
#define HAVE_READLINE_HISTORY_H 1
|
||||
/* #undef HAVE_READLINE_HISTORY_H */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <readline/readline.h> header file. */
|
||||
#ifndef HAVE_READLINE_READLINE_H
|
||||
#define HAVE_READLINE_READLINE_H 1
|
||||
/* #undef HAVE_READLINE_READLINE_H */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LIBREADLINE) && defined(HAVE_READLINE_READLINE_H)
|
||||
@ -43,12 +43,12 @@ you don't. */
|
||||
|
||||
/* Define to 1 if you have the `rl_begin_undo_group' function. */
|
||||
#ifndef HAVE_RL_BEGIN_UNDO_GROUP
|
||||
#define HAVE_RL_BEGIN_UNDO_GROUP 1
|
||||
/* #undef HAVE_RL_BEGIN_UNDO_GROUP */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `rl_clear_pending_input' function. */
|
||||
#ifndef HAVE_RL_CLEAR_PENDING_INPUT
|
||||
#define HAVE_RL_CLEAR_PENDING_INPUT 1
|
||||
/* #undef HAVE_RL_CLEAR_PENDING_INPUT */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if the system has the type `rl_completion_func_t'). */
|
||||
@ -68,7 +68,7 @@ you don't. */
|
||||
|
||||
/* Define to 1 if you have the `rl_discard_argument' function. */
|
||||
#ifndef HAVE_RL_DISCARD_ARGUMENT
|
||||
#define HAVE_RL_DISCARD_ARGUMENT 1
|
||||
/* #undef HAVE_RL_DISCARD_ARGUMENT */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `rl_done' variable. */
|
||||
@ -78,12 +78,12 @@ you don't. */
|
||||
|
||||
/* Define to 1 if you have the `rl_filename_completion_function' function. */
|
||||
#ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION
|
||||
#define HAVE_RL_FILENAME_COMPLETION_FUNCTION 1
|
||||
#define HAVE_RL_FILENAME_COMPLETION_FUNCTION
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `rl_free_line_state' function. */
|
||||
#ifndef HAVE_RL_FREE_LINE_STATE
|
||||
#define HAVE_RL_FREE_LINE_STATE 1
|
||||
/* #undef HAVE_RL_FREE_LINE_STATE */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if the system has the type `rl_hook_func_t'. */
|
||||
@ -93,20 +93,20 @@ you don't. */
|
||||
|
||||
/* Define to 1 if you have the `rl_insert_close' function. */
|
||||
#ifndef HAVE_RL_INSERT_CLOSE
|
||||
#define HAVE_RL_INSERT_CLOSE 1
|
||||
/* #undef HAVE_RL_INSERT_CLOSE */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `rl_reset_after_signal' function. */
|
||||
#ifndef HAVE_RL_RESET_AFTER_SIGNAL
|
||||
#define HAVE_RL_RESET_AFTER_SIGNAL 1
|
||||
/* #undef HAVE_RL_RESET_AFTER_SIGNAL */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `rl_set_keyboard_input_timeout' function. */
|
||||
#ifndef HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT
|
||||
#define HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT 1
|
||||
/* #undef HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT */
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `rl_set_prompt' function. */
|
||||
#ifndef HAVE_RL_SET_PROMPT
|
||||
#define HAVE_RL_SET_PROMPT 1
|
||||
/* #undef HAVE_RL_SET_PROMPT */
|
||||
#endif
|
@ -1,183 +0,0 @@
|
||||
# - Try to find the CUD BDD RDF parsing library (http://librdf.org/CUDD /)
|
||||
# Once done this will define
|
||||
#
|
||||
# CUDD_FOUND - system has CUDD
|
||||
# CUDD_LIBRARIES - Link these to use CUDD
|
||||
# CUDD_INCLUDE_DIR - Include directory for using CUDD
|
||||
#
|
||||
#
|
||||
# Based on FindFontconfig Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
|
||||
MACRO ( FIND_CUDD )
|
||||
|
||||
ENDMACRO ()
|
||||
|
||||
|
||||
|
||||
# Check if we have cached results in case the last round was successful.
|
||||
if ( NOT( CUDD_INCLUDE_DIR AND CUDD_LIBRARIES ) OR NOT CUDD_FOUND )
|
||||
|
||||
set( CUDD_LDFLAGS )
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
|
||||
find_path(CUDD_INCLUDE_DIR
|
||||
NAMES cudd.h cudd.cudd.h
|
||||
$ENV{CUDD_DIR}/include
|
||||
$ENV{CUDD_DIR}
|
||||
/usr/local/yap/include
|
||||
/usr/local/Yap/include
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/include
|
||||
/usr/include/
|
||||
/sw/include # Fink
|
||||
/opt/local/include # MacPorts
|
||||
/opt/csw/include # Blastwave
|
||||
/opt/include
|
||||
/usr/freeware/include
|
||||
NO_DEFAULT_PATHS
|
||||
|
||||
)
|
||||
|
||||
find_path(CUDD_INCLUDE_DIR
|
||||
NAMES cudd.h
|
||||
)
|
||||
|
||||
find_library(CUDD_INTERFACE_LIBRARY
|
||||
NAMES cudd
|
||||
PATHS
|
||||
$ENV{CUDD_DIR}/lib
|
||||
$ENV{CUDD_DIR}/lib64
|
||||
$ENV{CUDD_DIR}/lib-dbg
|
||||
$ENV{CUDD_DIR}
|
||||
$ENV{CUDD_DIR}/cudd
|
||||
/usr/local/yap/lib
|
||||
/usr/local/Yap/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/usr/local/lib/cudd
|
||||
/usr/local/lib64/cudd
|
||||
/usr/lib/cudd
|
||||
/usr/lib64/cudd
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
if ( CUDD_INTERFACE_LIBRARY AND CUDD_INCLUDE_DIR )
|
||||
set( CUDD_FOUND ON )
|
||||
list( APPEND CUDD_LIBRARIES ${CUDD_INTERFACE_LIBRARY} )
|
||||
endif ()
|
||||
|
||||
find_library(CUDD_UTIL_LIBRARY
|
||||
NAMES cuddutil util
|
||||
PATHS
|
||||
$ENV{CUDD_DIR}/lib
|
||||
$ENV{CUDD_DIR}/lib64
|
||||
$ENV{CUDD_DIR}/lib-dbg
|
||||
$ENV{CUDD_DIR}
|
||||
$ENV{CUDD_DIR}/util
|
||||
/usr/local/yap/lib
|
||||
/usr/local/Yap/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/usr/local/lib/util
|
||||
/usr/local/lib64/util
|
||||
/usr/lib/util
|
||||
/usr/lib64/util
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
if ( CUDD_UTIL_LIBRARY )
|
||||
list( APPEND CUDD_LIBRARIES ${CUDD_UTIL_LIBRARY} )
|
||||
endif ()
|
||||
|
||||
find_library(CUDD_ST_LIBRARY
|
||||
NAMES cuddst st
|
||||
PATHS
|
||||
$ENV{CUDD_DIR}/lib
|
||||
$ENV{CUDD_DIR}/lib64
|
||||
$ENV{CUDD_DIR}/lib-dbg
|
||||
$ENV{CUDD_DIR}
|
||||
$ENV{CUDD_DIR}/st
|
||||
/usr/local/yap/lib
|
||||
/usr/local/Yap/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/usr/lib/st
|
||||
/usr/lib64/st
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
if ( CUDD_ST_LIBRARY )
|
||||
list( APPEND CUDD_LIBRARIES ${CUDD_ST_LIBRARY} )
|
||||
endif ()
|
||||
|
||||
find_library(CUDD_EPD_LIBRARY
|
||||
NAMES epd
|
||||
PATHS
|
||||
$ENV{CUDD_DIR}/lib
|
||||
$ENV{CUDD_DIR}/lib64
|
||||
$ENV{CUDD_DIR}/lib-dbg
|
||||
$ENV{CUDD_DIR}
|
||||
$ENV{CUDD_DIR}/epd
|
||||
/usr/local/yap/lib
|
||||
/usr/local/Yap/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/usr/lib/epd
|
||||
/usr/lib64/epd
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
if ( CUDD_MTR_LIBRARY )
|
||||
list( APPEND CUDD_LIBRARIES ${CUDD_MTR_LIBRARY} )
|
||||
endif ()
|
||||
|
||||
find_library(CUDD_MTR_LIBRARY
|
||||
NAMES mtr
|
||||
PATHS
|
||||
$ENV{CUDD_DIR}/lib
|
||||
$ENV{CUDD_DIR}/lib64
|
||||
$ENV{CUDD_DIR}/lib-dbg
|
||||
$ENV{CUDD_DIR}
|
||||
$ENV{CUDD_DIR}/mtr
|
||||
/usr/local/yap/lib
|
||||
/usr/local/Yap/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/usr/lib/mtr
|
||||
/usr/lib64/mtr
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
if ( CUDD_MTR_LIBRARY )
|
||||
list( APPEND CUDD_LIBRARIES ${CUDD_MTR_LIBRARY} )
|
||||
endif ()
|
||||
|
||||
|
||||
endif () # Check for cached values
|
@ -4,7 +4,10 @@
|
||||
|
||||
@brief Interface to the CUDD Library
|
||||
|
||||
CUDD represents a BDD as a tree of DdNode structures. Each tree has a manager DdManager and a list of booleaan variables, also represented as DdNode structures. Mapping from an Prolog tree to a ground BDD involves the following steps:
|
||||
CUDD represents a BDD as a tree of DdNode structures. Each tree has a manager
|
||||
DdManager and a list of booleaan variables, also represented as DdNode
|
||||
structures. Mapping from an Prolog tree to a ground BDD involves the following
|
||||
steps:
|
||||
|
||||
1. Collect all logical variables in the Prolog term, and map each
|
||||
variable $V$ to a boolean variable $i$ in the BDD. This is easily done
|
||||
@ -37,9 +40,9 @@ CUDD will generate better/faster code.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "YapInterface.h"
|
||||
#include "config.h"
|
||||
#include "cudd_config.h"
|
||||
#include "YapInterface.h"
|
||||
|
||||
#if HAVE_CUDD_UTIL_H
|
||||
#include <cudd/util.h>
|
||||
@ -52,76 +55,52 @@ CUDD will generate better/faster code.
|
||||
#include "cudd.h"
|
||||
#endif
|
||||
|
||||
static YAP_Functor FunctorDollarVar,
|
||||
FunctorCudd,
|
||||
FunctorAnd,
|
||||
FunctorAnd4,
|
||||
FunctorOr,
|
||||
FunctorOr4,
|
||||
FunctorLAnd,
|
||||
FunctorLOr,
|
||||
FunctorNot,
|
||||
FunctorMinus1,
|
||||
FunctorXor,
|
||||
FunctorNand,
|
||||
FunctorNor,
|
||||
FunctorTimes,
|
||||
FunctorImplies,
|
||||
FunctorPlus,
|
||||
FunctorMinus,
|
||||
FunctorTimes4,
|
||||
FunctorPlus4,
|
||||
FunctorOutAdd,
|
||||
FunctorOutPos,
|
||||
FunctorOutNeg;
|
||||
static YAP_Functor FunctorDollarVar, FunctorCudd, FunctorAnd, FunctorAnd4,
|
||||
FunctorOr, FunctorOr4, FunctorLAnd, FunctorLOr, FunctorNot, FunctorMinus1,
|
||||
FunctorXor, FunctorNand, FunctorNor, FunctorTimes, FunctorImplies,
|
||||
FunctorPlus, FunctorMinus, FunctorTimes4, FunctorPlus4, FunctorOutAdd,
|
||||
FunctorOutPos, FunctorOutNeg;
|
||||
|
||||
static YAP_Term TermMinusOne, TermZero, TermPlusOne, TermTrue, TermFalse;
|
||||
|
||||
void init_cudd(void);
|
||||
|
||||
static DdNode *
|
||||
cudd_and(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
static DdNode *cudd_and(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
DdNode *tmp;
|
||||
tmp = Cudd_bddAnd(manager, bdd1, bdd2);
|
||||
Cudd_Ref(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
cudd_nand(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
static DdNode *cudd_nand(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
DdNode *tmp;
|
||||
tmp = Cudd_bddNand(manager, bdd1, bdd2);
|
||||
Cudd_Ref(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
cudd_or(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
static DdNode *cudd_or(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
DdNode *tmp;
|
||||
tmp = Cudd_bddOr(manager, bdd1, bdd2);
|
||||
Cudd_Ref(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
cudd_nor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
static DdNode *cudd_nor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
DdNode *tmp;
|
||||
tmp = Cudd_bddNor(manager, bdd1, bdd2);
|
||||
Cudd_Ref(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
cudd_xor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
static DdNode *cudd_xor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
|
||||
DdNode *tmp;
|
||||
tmp = Cudd_bddXor(manager, bdd1, bdd2);
|
||||
Cudd_Ref(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
term_to_cudd(DdManager *manager, YAP_Term t)
|
||||
{
|
||||
static DdNode *term_to_cudd(DdManager *manager, YAP_Term t) {
|
||||
if (YAP_IsApplTerm(t)) {
|
||||
YAP_Functor f = YAP_FunctorOfTerm(t);
|
||||
if (f == FunctorDollarVar) {
|
||||
@ -260,7 +239,8 @@ term_to_cudd(DdManager *manager, YAP_Term t)
|
||||
else if (t == TermTrue)
|
||||
return Cudd_ReadOne(manager);
|
||||
else {
|
||||
YAP_Error(DOMAIN_ERROR_OUT_OF_RANGE, t, "unsupported atom %s in CUDD", YAP_AtomName(YAP_AtomOfTerm(t)));
|
||||
YAP_Error(DOMAIN_ERROR_OUT_OF_RANGE, t, "unsupported atom %s in CUDD",
|
||||
YAP_AtomName(YAP_AtomOfTerm(t)));
|
||||
return NULL;
|
||||
}
|
||||
} else if (YAP_IsVarTerm(t)) {
|
||||
@ -271,9 +251,7 @@ term_to_cudd(DdManager *manager, YAP_Term t)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_term_to_cudd(void)
|
||||
{
|
||||
static YAP_Bool p_term_to_cudd(void) {
|
||||
DdManager *manager;
|
||||
DdNode *t;
|
||||
|
||||
@ -288,13 +266,10 @@ p_term_to_cudd(void)
|
||||
t = term_to_cudd(manager, YAP_ARG1);
|
||||
if (!t)
|
||||
return FALSE;
|
||||
return
|
||||
YAP_Unify(YAP_ARG3, YAP_MkIntTerm((YAP_Int)t));
|
||||
return YAP_Unify(YAP_ARG3, YAP_MkIntTerm((YAP_Int)t));
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
add_times(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
{
|
||||
static DdNode *add_times(DdManager *manager, DdNode *x1, DdNode *x2) {
|
||||
DdNode *tmp;
|
||||
|
||||
tmp = Cudd_addApply(manager, Cudd_addTimes, x2, x1);
|
||||
@ -302,9 +277,7 @@ add_times(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
add_implies(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
{
|
||||
static DdNode *add_implies(DdManager *manager, DdNode *x1, DdNode *x2) {
|
||||
DdNode *tmp;
|
||||
|
||||
tmp = Cudd_addConst(manager, Cudd_addLeq(manager, x1, x2));
|
||||
@ -312,9 +285,7 @@ add_implies(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
add_plus(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
{
|
||||
static DdNode *add_plus(DdManager *manager, DdNode *x1, DdNode *x2) {
|
||||
DdNode *tmp;
|
||||
|
||||
tmp = Cudd_addApply(manager, Cudd_addPlus, x2, x1);
|
||||
@ -322,9 +293,7 @@ add_plus(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
add_minus(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
{
|
||||
static DdNode *add_minus(DdManager *manager, DdNode *x1, DdNode *x2) {
|
||||
DdNode *tmp;
|
||||
|
||||
tmp = Cudd_addApply(manager, Cudd_addMinus, x1, x2);
|
||||
@ -332,9 +301,7 @@ add_minus(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
add_lor(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
{
|
||||
static DdNode *add_lor(DdManager *manager, DdNode *x1, DdNode *x2) {
|
||||
DdNode *tmp;
|
||||
|
||||
tmp = Cudd_addApply(manager, Cudd_addOr, x1, x2);
|
||||
@ -342,9 +309,7 @@ add_lor(DdManager *manager, DdNode *x1, DdNode *x2)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static DdNode *
|
||||
term_to_add(DdManager *manager, YAP_Term t)
|
||||
{
|
||||
static DdNode *term_to_add(DdManager *manager, YAP_Term t) {
|
||||
if (YAP_IsApplTerm(t)) {
|
||||
YAP_Functor f = YAP_FunctorOfTerm(t);
|
||||
if (f == FunctorDollarVar) {
|
||||
@ -444,9 +409,7 @@ term_to_add(DdManager *manager, YAP_Term t)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_term_to_add(void)
|
||||
{
|
||||
static YAP_Bool p_term_to_add(void) {
|
||||
DdManager *manager = Cudd_Init(0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0);
|
||||
int sz = YAP_IntOfTerm(YAP_ARG2), i;
|
||||
DdNode *t;
|
||||
@ -458,23 +421,19 @@ p_term_to_add(void)
|
||||
YAP_Unify(YAP_ARG4, YAP_MkIntTerm((YAP_Int)t));
|
||||
}
|
||||
|
||||
static YAP_Bool complement(int i)
|
||||
{
|
||||
return i == 0 ? 1 : 0;
|
||||
}
|
||||
static YAP_Bool complement(int i) { return i == 0 ? 1 : 0; }
|
||||
|
||||
static YAP_Bool var(DdManager *manager, DdNode *n, YAP_Int *vals) {
|
||||
return (int)vals[Cudd_ReadPerm(manager, Cudd_NodeReadIndex(n))];
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
cudd_eval(DdManager *manager, DdNode *n, YAP_Int *vals )
|
||||
{
|
||||
static YAP_Bool cudd_eval(DdManager *manager, DdNode *n, YAP_Int *vals) {
|
||||
if (Cudd_IsConstant(n)) {
|
||||
// fprintf(stderr,"v=%f\n",Cudd_V(n));
|
||||
return Cudd_V(n);
|
||||
} else {
|
||||
// fprintf(stderr,"%x %d->%d %d\n",n->index,var(manager, n, vals),(Cudd_IsComplement(Cudd_E(n))!=0));
|
||||
// fprintf(stderr,"%x %d->%d %d\n",n->index,var(manager, n,
|
||||
// vals),(Cudd_IsComplement(Cudd_E(n))!=0));
|
||||
if (var(manager, n, vals) == 1)
|
||||
return cudd_eval(manager, Cudd_T(n), vals);
|
||||
else {
|
||||
@ -488,9 +447,7 @@ cudd_eval(DdManager *manager, DdNode *n, YAP_Int *vals )
|
||||
}
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
cudd_eval_top(DdManager *manager, DdNode *n, YAP_Int *vals )
|
||||
{
|
||||
static YAP_Bool cudd_eval_top(DdManager *manager, DdNode *n, YAP_Int *vals) {
|
||||
if (Cudd_IsComplement(n)) {
|
||||
return complement(cudd_eval(manager, Cudd_Regular(n), vals));
|
||||
} else {
|
||||
@ -498,9 +455,7 @@ cudd_eval_top(DdManager *manager, DdNode *n, YAP_Int *vals )
|
||||
}
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_eval_cudd(void)
|
||||
{
|
||||
static YAP_Bool p_eval_cudd(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n = (DdNode *)YAP_IntOfTerm(YAP_ARG2);
|
||||
size_t sz = YAP_ArityOfFunctor(YAP_FunctorOfTerm(YAP_ARG3));
|
||||
@ -509,7 +464,8 @@ p_eval_cudd(void)
|
||||
YAP_Term t = YAP_ARG3;
|
||||
YAP_Int i;
|
||||
|
||||
if (sz <= 0) return FALSE;
|
||||
if (sz <= 0)
|
||||
return FALSE;
|
||||
ar = (YAP_Int *)malloc(sz * sizeof(YAP_Int));
|
||||
if (!ar)
|
||||
return FALSE;
|
||||
@ -524,9 +480,7 @@ p_eval_cudd(void)
|
||||
return YAP_Unify(YAP_ARG4, YAP_MkIntTerm(val));
|
||||
}
|
||||
|
||||
static double
|
||||
add_eval(DdManager *manager, DdNode *n, YAP_Int *vals )
|
||||
{
|
||||
static double add_eval(DdManager *manager, DdNode *n, YAP_Int *vals) {
|
||||
if (Cudd_IsConstant(n)) {
|
||||
return Cudd_V(n);
|
||||
} else {
|
||||
@ -538,9 +492,7 @@ add_eval(DdManager *manager, DdNode *n, YAP_Int *vals )
|
||||
}
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_eval_add(void)
|
||||
{
|
||||
static YAP_Bool p_eval_add(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n = (DdNode *)YAP_IntOfTerm(YAP_ARG2);
|
||||
size_t sz = YAP_ArityOfFunctor(YAP_FunctorOfTerm(YAP_ARG3));
|
||||
@ -549,7 +501,8 @@ p_eval_add(void)
|
||||
YAP_Term t = YAP_ARG3;
|
||||
YAP_Int i;
|
||||
|
||||
if (sz <= 0) return FALSE;
|
||||
if (sz <= 0)
|
||||
return FALSE;
|
||||
ar = (YAP_Int *)malloc(sz * sizeof(YAP_Int));
|
||||
if (!ar)
|
||||
return FALSE;
|
||||
@ -569,9 +522,7 @@ typedef struct {
|
||||
YAP_Term val;
|
||||
} hash_table_entry;
|
||||
|
||||
static void
|
||||
insert(hash_table_entry *p,DdNode *key, YAP_Term val, size_t sz)
|
||||
{
|
||||
static void insert(hash_table_entry *p, DdNode *key, YAP_Term val, size_t sz) {
|
||||
size_t el = (((YAP_Term)key) / sizeof(DdNode *)) % sz;
|
||||
while (p[el].key) {
|
||||
el = (el + 1) % sz;
|
||||
@ -580,8 +531,7 @@ insert(hash_table_entry *p,DdNode *key, YAP_Term val, size_t sz)
|
||||
p[el].val = val;
|
||||
}
|
||||
|
||||
static YAP_Term lookup(hash_table_entry *p, DdNode *key, size_t sz)
|
||||
{
|
||||
static YAP_Term lookup(hash_table_entry *p, DdNode *key, size_t sz) {
|
||||
size_t el = (((YAP_Term)key) / sizeof(DdNode *)) % sz;
|
||||
while (p[el].key != key) {
|
||||
el = (el + 1) % sz;
|
||||
@ -589,15 +539,17 @@ static YAP_Term lookup(hash_table_entry *p, DdNode *key, size_t sz)
|
||||
return p[el].val;
|
||||
}
|
||||
|
||||
static YAP_Term
|
||||
build_prolog_cudd(DdManager *manager, DdNode *n, YAP_Term *ar, hash_table_entry *hash, YAP_Term t0, size_t sz)
|
||||
{
|
||||
static YAP_Term build_prolog_cudd(DdManager *manager, DdNode *n, YAP_Term *ar,
|
||||
hash_table_entry *hash, YAP_Term t0,
|
||||
size_t sz) {
|
||||
if (Cudd_IsConstant(n)) {
|
||||
YAP_Term t = YAP_MkIntTerm(Cudd_V(n));
|
||||
insert(hash, n, t, sz);
|
||||
return t0;
|
||||
} else {
|
||||
//fprintf(stderr,"%x %d->%d %d\n",n->index, Cudd_ReadPerm(manager,Cudd_NodeReadIndex(n)),var(manager, n, vals),Cudd_IsComplement(Cudd_E(n)));
|
||||
// fprintf(stderr,"%x %d->%d %d\n",n->index,
|
||||
// Cudd_ReadPerm(manager,Cudd_NodeReadIndex(n)),var(manager, n,
|
||||
// vals),Cudd_IsComplement(Cudd_E(n)));
|
||||
YAP_Term t[4], nt;
|
||||
YAP_Functor f;
|
||||
|
||||
@ -617,30 +569,20 @@ build_prolog_cudd(DdManager *manager, DdNode *n, YAP_Term *ar, hash_table_entry
|
||||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
max(int a, int b)
|
||||
{
|
||||
return a<b ? b : a;
|
||||
}
|
||||
static inline int max(int a, int b) { return a < b ? b : a; }
|
||||
|
||||
static YAP_Int
|
||||
get_vars(YAP_Term t3)
|
||||
{
|
||||
static YAP_Int get_vars(YAP_Term t3) {
|
||||
if (YAP_IsAtomTerm(t3))
|
||||
return 0;
|
||||
return YAP_ArityOfFunctor(YAP_FunctorOfTerm(t3));
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_cudd_reorder(void)
|
||||
{
|
||||
static YAP_Bool p_cudd_reorder(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
return Cudd_ReduceHeap(manager, CUDD_REORDER_EXACT, 1);
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_cudd_to_term(void)
|
||||
{
|
||||
static YAP_Bool p_cudd_to_term(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2), *node;
|
||||
YAP_Term t, t3 = YAP_ARG3, td;
|
||||
@ -648,7 +590,8 @@ p_cudd_to_term(void)
|
||||
int nodes = max(0, Cudd_ReadNodeCount(manager)) + vars + 1;
|
||||
size_t sz = nodes * 4;
|
||||
DdGen *dgen = Cudd_FirstNode(manager, n0, &node);
|
||||
hash_table_entry *hash = (hash_table_entry *)calloc(sz,sizeof(hash_table_entry));
|
||||
hash_table_entry *hash =
|
||||
(hash_table_entry *)calloc(sz, sizeof(hash_table_entry));
|
||||
YAP_Term *ar;
|
||||
|
||||
if (!dgen || !hash)
|
||||
@ -685,9 +628,9 @@ p_cudd_to_term(void)
|
||||
return YAP_Unify(YAP_ARG4, td) && YAP_Unify(YAP_ARG5, t);
|
||||
}
|
||||
|
||||
static YAP_Term
|
||||
build_prolog_add(DdManager *manager, DdNode *n, YAP_Term *ar, hash_table_entry *hash, YAP_Term t0, size_t sz)
|
||||
{
|
||||
static YAP_Term build_prolog_add(DdManager *manager, DdNode *n, YAP_Term *ar,
|
||||
hash_table_entry *hash, YAP_Term t0,
|
||||
size_t sz) {
|
||||
if (Cudd_IsConstant(n)) {
|
||||
YAP_Term t = YAP_MkFloatTerm(Cudd_V(n));
|
||||
insert(hash, n, t, sz);
|
||||
@ -708,9 +651,7 @@ build_prolog_add(DdManager *manager, DdNode *n, YAP_Term *ar, hash_table_entry *
|
||||
}
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_add_to_term(void)
|
||||
{
|
||||
static YAP_Bool p_add_to_term(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2), *node;
|
||||
YAP_Term t, t3 = YAP_ARG3;
|
||||
@ -718,7 +659,8 @@ p_add_to_term(void)
|
||||
int nodes = max(0, Cudd_ReadNodeCount(manager)) + vars + 1;
|
||||
size_t sz = nodes * 4;
|
||||
DdGen *dgen = Cudd_FirstNode(manager, n0, &node);
|
||||
hash_table_entry *hash = (hash_table_entry *)calloc(sz,sizeof(hash_table_entry));
|
||||
hash_table_entry *hash =
|
||||
(hash_table_entry *)calloc(sz, sizeof(hash_table_entry));
|
||||
YAP_Term *ar;
|
||||
|
||||
if (!dgen)
|
||||
@ -750,9 +692,7 @@ p_add_to_term(void)
|
||||
return YAP_Unify(YAP_ARG4, t);
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_cudd_size(void)
|
||||
{
|
||||
static YAP_Bool p_cudd_size(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2), *node;
|
||||
YAP_Int i = 0;
|
||||
@ -774,9 +714,8 @@ typedef struct {
|
||||
double val;
|
||||
} hash_table_entry_dbl;
|
||||
|
||||
static void
|
||||
insert2(hash_table_entry_dbl *p,DdNode *key, double val, size_t sz)
|
||||
{
|
||||
static void insert2(hash_table_entry_dbl *p, DdNode *key, double val,
|
||||
size_t sz) {
|
||||
size_t el = (((YAP_Term)key) / sizeof(DdNode *)) % sz;
|
||||
while (p[el].key) {
|
||||
el = (el + 1) % sz;
|
||||
@ -785,9 +724,7 @@ insert2(hash_table_entry_dbl *p,DdNode *key, double val, size_t sz)
|
||||
p[el].val = val;
|
||||
}
|
||||
|
||||
static double
|
||||
lookup2(hash_table_entry_dbl *p, DdNode *key, size_t sz)
|
||||
{
|
||||
static double lookup2(hash_table_entry_dbl *p, DdNode *key, size_t sz) {
|
||||
size_t el = (((YAP_Term)key) / sizeof(DdNode *)) % sz;
|
||||
while (p[el].key != key) {
|
||||
el = (el + 1) % sz;
|
||||
@ -795,14 +732,15 @@ lookup2(hash_table_entry_dbl *p, DdNode *key, size_t sz)
|
||||
return p[el].val;
|
||||
}
|
||||
|
||||
static double
|
||||
build_sp_cudd(DdManager *manager, DdNode *n, double *ar, hash_table_entry_dbl *hash, size_t sz)
|
||||
{
|
||||
static double build_sp_cudd(DdManager *manager, DdNode *n, double *ar,
|
||||
hash_table_entry_dbl *hash, size_t sz) {
|
||||
if (Cudd_IsConstant(n)) {
|
||||
insert2(hash, n, Cudd_V(n), sz);
|
||||
return Cudd_V(n);
|
||||
} else {
|
||||
//fprintf(stderr,"%x %d->%d %d\n",n->index, Cudd_ReadPerm(manager,Cudd_NodeReadIndex(n)),var(manager, n, vals),Cudd_IsComplement(Cudd_E(n)));
|
||||
// fprintf(stderr,"%x %d->%d %d\n",n->index,
|
||||
// Cudd_ReadPerm(manager,Cudd_NodeReadIndex(n)),var(manager, n,
|
||||
// vals),Cudd_IsComplement(Cudd_E(n)));
|
||||
double pl, pr, p, prob;
|
||||
|
||||
prob = ar[Cudd_ReadPerm(manager, Cudd_NodeReadIndex(n))];
|
||||
@ -818,9 +756,7 @@ build_sp_cudd(DdManager *manager, DdNode *n, double *ar, hash_table_entry_dbl *h
|
||||
}
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_cudd_to_p(void)
|
||||
{
|
||||
static YAP_Bool p_cudd_to_p(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2), *node;
|
||||
YAP_Term t3 = YAP_ARG3;
|
||||
@ -829,7 +765,8 @@ p_cudd_to_p(void)
|
||||
int nodes = max(Cudd_ReadNodeCount(manager), 0) + vars + 1;
|
||||
size_t sz = nodes * 4;
|
||||
DdGen *dgen = Cudd_FirstNode(manager, n0, &node);
|
||||
hash_table_entry_dbl *hash = (hash_table_entry_dbl *)calloc(sz,sizeof(hash_table_entry_dbl));
|
||||
hash_table_entry_dbl *hash =
|
||||
(hash_table_entry_dbl *)calloc(sz, sizeof(hash_table_entry_dbl));
|
||||
double *ar;
|
||||
|
||||
if (!dgen)
|
||||
@ -853,46 +790,50 @@ p_cudd_to_p(void)
|
||||
return YAP_Unify(YAP_ARG4, YAP_MkFloatTerm(p));
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_cudd_print(void)
|
||||
{
|
||||
static YAP_Bool p_cudd_print(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2);
|
||||
const char *s = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3));
|
||||
FILE *f;
|
||||
if (!strcmp(s, "user_output")) f = stdout;
|
||||
else if (!strcmp(s, "user_error")) f = stderr;
|
||||
else if (!strcmp(s, "user")) f = stdout;
|
||||
else f = fopen(s, "w");
|
||||
if (!strcmp(s, "user_output"))
|
||||
f = stdout;
|
||||
else if (!strcmp(s, "user_error"))
|
||||
f = stderr;
|
||||
else if (!strcmp(s, "user"))
|
||||
f = stdout;
|
||||
else
|
||||
f = fopen(s, "w");
|
||||
Cudd_DumpDot(manager, 1, &n0, NULL, NULL, f);
|
||||
if (f != stdout && f != stderr)
|
||||
fclose(f);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_cudd_print_with_names(void)
|
||||
{
|
||||
static YAP_Bool p_cudd_print_with_names(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2);
|
||||
const char *s = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3));
|
||||
const char **namesp;
|
||||
char **namesp;
|
||||
YAP_Term names = YAP_ARG4;
|
||||
FILE *f;
|
||||
YAP_Int len;
|
||||
YAP_Int i = 0;
|
||||
|
||||
if (!strcmp(s, "user_output")) f = stdout;
|
||||
else if (!strcmp(s, "user_error")) f = stderr;
|
||||
else if (!strcmp(s, "user")) f = stdout;
|
||||
else f = fopen(s, "w");
|
||||
if (!strcmp(s, "user_output"))
|
||||
f = stdout;
|
||||
else if (!strcmp(s, "user_error"))
|
||||
f = stderr;
|
||||
else if (!strcmp(s, "user"))
|
||||
f = stdout;
|
||||
else
|
||||
f = fopen(s, "w");
|
||||
if ((len = YAP_ListLength(names)) < 0)
|
||||
return FALSE;
|
||||
if ((namesp = malloc(sizeof(const char *) * len)) == NULL)
|
||||
return FALSE;
|
||||
while (YAP_IsPairTerm(names)) {
|
||||
YAP_Term hd = YAP_HeadOfTerm(names);
|
||||
const char *f;
|
||||
char *f;
|
||||
|
||||
if (YAP_IsAtomTerm(hd)) {
|
||||
const char *s = YAP_AtomName(YAP_AtomOfTerm(hd));
|
||||
@ -922,26 +863,20 @@ p_cudd_print_with_names(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_cudd_die(void)
|
||||
{
|
||||
static YAP_Bool p_cudd_die(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
Cudd_Quit(manager);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static YAP_Bool
|
||||
p_cudd_release_node(void)
|
||||
{
|
||||
static YAP_Bool p_cudd_release_node(void) {
|
||||
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
|
||||
DdNode *n0 = (DdNode *)YAP_IntOfTerm(YAP_ARG2);
|
||||
Cudd_RecursiveDeref(manager, n0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
init_cudd(void)
|
||||
{
|
||||
void init_cudd(void) {
|
||||
|
||||
FunctorDollarVar = YAP_MkFunctor(YAP_LookupAtom("$VAR"), 1);
|
||||
FunctorAnd = YAP_MkFunctor(YAP_LookupAtom("/\\"), 2);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -190,14 +190,13 @@ form
|
||||
variable=value
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "cudd_config.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include "config.h"
|
||||
#include "cudd_config.h"
|
||||
#if HAVE_UTIL_H
|
||||
#include <util.h>
|
||||
#endif
|
||||
@ -224,7 +223,8 @@ variable=value
|
||||
#define LOW(manager) Cudd_Not(Cudd_ReadOne(manager))
|
||||
#define NOT(node) Cudd_Not(node)
|
||||
#define GetIndex(node) Cudd_NodeReadIndex(node)
|
||||
#define GetMVar(manager, index, value, varmap) equality(manager,index,value,varmap)//Cudd_bddIthVar(manager, index)
|
||||
#define GetMVar(manager, index, value, varmap) \
|
||||
equality(manager, index, value, varmap) // Cudd_bddIthVar(manager, index)
|
||||
#define GetVar(manager, index) Cudd_bddIthVar(manager, index)
|
||||
#define NewVar(manager) Cudd_bddNewVar(manager)
|
||||
#define KillBDD(manager) Cudd_Quit(manager)
|
||||
@ -253,8 +253,7 @@ typedef struct _bddfileheader {
|
||||
int filetype;
|
||||
} bddfileheader;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int nVal, nBit, init;
|
||||
double *probabilities;
|
||||
int *booleanVars;
|
||||
@ -272,7 +271,6 @@ typedef struct _namedvars {
|
||||
int *bVar2mVar;
|
||||
} namedvars;
|
||||
|
||||
|
||||
typedef struct _hisnode {
|
||||
DdNode *key;
|
||||
double dvalue;
|
||||
@ -307,11 +305,15 @@ DdNode* D_BDDNor(DdManager *manager, DdNode *bdd1, DdNode *bdd2);
|
||||
DdNode *D_BDDXor(DdManager *manager, DdNode *bdd1, DdNode *bdd2);
|
||||
DdNode *D_BDDXnor(DdManager *manager, DdNode *bdd1, DdNode *bdd2);
|
||||
|
||||
DdNode* FileGenerateBDD(DdManager *manager, namedvars varmap, bddfileheader fileheader);
|
||||
DdNode *FileGenerateBDD(DdManager *manager, namedvars varmap,
|
||||
bddfileheader fileheader);
|
||||
DdNode *OnlineGenerateBDD(DdManager *manager, namedvars *varmap);
|
||||
DdNode* LineParser(DdManager *manager, namedvars varmap, DdNode **inter, int maxinter, char *function, int iline);
|
||||
DdNode* OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter, int maxinter, char *function, int iline);
|
||||
DdNode* BDD_Operator(DdManager *manager, DdNode *bdd1, DdNode *bdd2, char Operator, int inegoper);
|
||||
DdNode *LineParser(DdManager *manager, namedvars varmap, DdNode **inter,
|
||||
int maxinter, char *function, int iline);
|
||||
DdNode *OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter,
|
||||
int maxinter, char *function, int iline);
|
||||
DdNode *BDD_Operator(DdManager *manager, DdNode *bdd1, DdNode *bdd2,
|
||||
char Operator, int inegoper);
|
||||
int getInterBDD(char *function);
|
||||
char *getFileName(const char *function);
|
||||
int GetParam(char *inputline, int iParam);
|
||||
@ -325,9 +327,12 @@ namedvars InitNamedMultiVars(int varcnt, int varstart, int bvarcnt);
|
||||
void EnlargeNamedVars(namedvars *varmap, int newvarcnt);
|
||||
int AddNamedVarAt(namedvars varmap, const char *varname, int index);
|
||||
int AddNamedVar(namedvars varmap, const char *varname);
|
||||
int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varnamei, int *value);
|
||||
void SetNamedVarValuesAt(namedvars varmap, int index, double dvalue, int ivalue, void *dynvalue);
|
||||
int SetNamedVarValues(namedvars varmap, const char *varname, double dvalue, int ivalue, void *dynvalue);
|
||||
int AddNamedMultiVar(DdManager *mgr, namedvars varmap, const char *varnamei,
|
||||
int *value);
|
||||
void SetNamedVarValuesAt(namedvars varmap, int index, double dvalue, int ivalue,
|
||||
void *dynvalue);
|
||||
int SetNamedVarValues(namedvars varmap, const char *varname, double dvalue,
|
||||
int ivalue, void *dynvalue);
|
||||
int GetNamedVarIndex(const namedvars varmap, const char *varname);
|
||||
int RepairVarcnt(namedvars *varmap);
|
||||
char *GetNodeVarName(DdManager *manager, namedvars varmap, DdNode *node);
|
||||
@ -343,10 +348,12 @@ DdNode* LowNodeOf(DdManager *manager, DdNode *node);
|
||||
|
||||
hisqueue *InitHistory(int varcnt);
|
||||
void ReInitHistory(hisqueue *HisQueue, int varcnt);
|
||||
void AddNode(hisqueue *HisQueue, int varstart, DdNode *node, double dvalue, int ivalue, void *dynvalue);
|
||||
void AddNode(hisqueue *HisQueue, int varstart, DdNode *node, double dvalue,
|
||||
int ivalue, void *dynvalue);
|
||||
hisnode *GetNode(hisqueue *HisQueue, int varstart, DdNode *node);
|
||||
int GetNodeIndex(hisqueue *HisQueue, int varstart, DdNode *node);
|
||||
void onlinetraverse(DdManager *manager, namedvars varmap, hisqueue *HisQueue, DdNode *bdd);
|
||||
void onlinetraverse(DdManager *manager, namedvars varmap, hisqueue *HisQueue,
|
||||
DdNode *bdd);
|
||||
|
||||
/* Save-load */
|
||||
|
||||
@ -354,19 +361,27 @@ bddfileheader ReadFileHeader(char *filename);
|
||||
int CheckFileVersion(const char *version);
|
||||
|
||||
DdNode *LoadNodeDump(DdManager *manager, namedvars varmap, FILE *inputfile);
|
||||
DdNode * LoadNodeRec(DdManager *manager, namedvars varmap, hisqueue *Nodes, FILE *inputfile, nodeline current);
|
||||
DdNode * GetIfExists(DdManager *manager, namedvars varmap, hisqueue *Nodes, char *varname, int nodenum);
|
||||
DdNode *LoadNodeRec(DdManager *manager, namedvars varmap, hisqueue *Nodes,
|
||||
FILE *inputfile, nodeline current);
|
||||
DdNode *GetIfExists(DdManager *manager, namedvars varmap, hisqueue *Nodes,
|
||||
char *varname, int nodenum);
|
||||
|
||||
int SaveNodeDump(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename);
|
||||
void SaveExpand(DdManager *manager, namedvars varmap, hisqueue *Nodes, DdNode *Current, FILE *outputfile);
|
||||
int SaveNodeDump(DdManager *manager, namedvars varmap, DdNode *bdd,
|
||||
char *filename);
|
||||
void SaveExpand(DdManager *manager, namedvars varmap, hisqueue *Nodes,
|
||||
DdNode *Current, FILE *outputfile);
|
||||
void ExpandNodes(hisqueue *Nodes, int index, int nodenum);
|
||||
|
||||
/* Export */
|
||||
|
||||
int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename);
|
||||
int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename);
|
||||
int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd,
|
||||
char *filename);
|
||||
|
||||
DdNode *equality(DdManager *mgr, int varIndex, int value, namedvars varmap);
|
||||
hisnode* GetNodei1(int *bVar2mVar,hisqueue *HisQueue, int varstart, DdNode *node);
|
||||
void AddNode1(int *bVar2mVar, hisqueue *HisQueue, int varstart, DdNode *node, double dvalue, int ivalue, void *dynvalue);
|
||||
hisnode* GetNode1(int *bVar2mVar,hisqueue *HisQueue, int varstart, DdNode *node);
|
||||
hisnode *GetNodei1(int *bVar2mVar, hisqueue *HisQueue, int varstart,
|
||||
DdNode *node);
|
||||
void AddNode1(int *bVar2mVar, hisqueue *HisQueue, int varstart, DdNode *node,
|
||||
double dvalue, int ivalue, void *dynvalue);
|
||||
hisnode *GetNode1(int *bVar2mVar, hisqueue *HisQueue, int varstart,
|
||||
DdNode *node);
|
||||
|
@ -1,4 +1,3 @@
|
||||
package pt.up.fc.dcc.yap;
|
||||
|
||||
/**** using sqlite
|
||||
For example,the following:
|
||||
@ -25,6 +24,9 @@ The SQLiteStatement.simpleQueryForBlobFileDescriptor() API is not available. The
|
||||
|
||||
****/
|
||||
|
||||
import pt.up.fc.dcc.Yap.*;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@ -45,12 +47,14 @@ import org.sqlite.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import org.sqlite.database.SQLException;
|
||||
import org.sqlite.database.DatabaseErrorHandler;
|
||||
|
||||
class DoNotDeleteErrorHandler implements DatabaseErrorHandler {
|
||||
private static final String TAG = "DoNotDeleteErrorHandler";
|
||||
public void onCorruption(SQLiteDatabase dbObj) {
|
||||
Log.e(TAG, "Corruption reported by sqlite on database: " + dbObj.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
public class JavaYap extends Activity
|
||||
{
|
||||
TextView outputText = null;
|
||||
@ -242,8 +246,7 @@ public class JavaYap extends Activity
|
||||
System.loadLibrary("android");
|
||||
System.loadLibrary("log");
|
||||
System.loadLibrary("gmp");
|
||||
System.loadLibrary("sqliteX");
|
||||
System.loadLibrary("example");
|
||||
System.loadLibrary("YapDroid");
|
||||
}
|
||||
|
||||
private static native void load(AssetManager mgr);
|
||||
|
@ -1360,6 +1360,12 @@ not(G) :- \+ '$execute'(G).
|
||||
'$check_callable'(_,_).
|
||||
|
||||
|
||||
'$bootstrap' :-
|
||||
bootstrap('init.yap').
|
||||
module(user),
|
||||
'$live'.
|
||||
|
||||
|
||||
bootstrap(F) :-
|
||||
% '$open'(F, '$csult', Stream, 0, 0, F),
|
||||
% '$file_name'(Stream,File),
|
||||
|
Reference in New Issue
Block a user