Merge branch 'master' of git.dcc.fc.up.pt:yap-6.3
Conflicts: C/exo_udi.c
This commit is contained in:
commit
7d67d6108e
10
C/absmi.c
10
C/absmi.c
@ -968,7 +968,7 @@ Yap_absmi(int inp)
|
|||||||
CACHE_Y(YREG);
|
CACHE_Y(YREG);
|
||||||
{
|
{
|
||||||
struct index_t *i = (struct index_t *)(PREG->u.lp.l);
|
struct index_t *i = (struct index_t *)(PREG->u.lp.l);
|
||||||
S_YREG[-1] = (CELL)EXO_OFFSET_TO_ADDRESS(i,i->links[(CELL)(SREG-i->cls)/i->arity]);
|
S_YREG[-1] = (CELL)LINK_TO_ADDRESS(i,i->links[EXO_ADDRESS_TO_OFFSET(i, SREG)]);
|
||||||
}
|
}
|
||||||
S_YREG--;
|
S_YREG--;
|
||||||
/* store arguments for procedure */
|
/* store arguments for procedure */
|
||||||
@ -991,7 +991,7 @@ Yap_absmi(int inp)
|
|||||||
ENDOp();
|
ENDOp();
|
||||||
|
|
||||||
/* check if enough space between trail and codespace */
|
/* check if enough space between trail and codespace */
|
||||||
/* try_exo Pred,Label */
|
/* try_exo_udi Pred,Label */
|
||||||
Op(try_exo_udi, lp);
|
Op(try_exo_udi, lp);
|
||||||
/* check if enough space between trail and codespace */
|
/* check if enough space between trail and codespace */
|
||||||
check_trail(TR);
|
check_trail(TR);
|
||||||
@ -1091,10 +1091,10 @@ Yap_absmi(int inp)
|
|||||||
CACHE_Y(B);
|
CACHE_Y(B);
|
||||||
{
|
{
|
||||||
struct index_t *it = (struct index_t *)(PREG->u.lp.l);
|
struct index_t *it = (struct index_t *)(PREG->u.lp.l);
|
||||||
CELL offset = EXO_ADDRESS_TO_OFFSET(it,(CELL *)((CELL *)(B+1))[it->arity]);
|
BITS32 offset = ADDRESS_TO_LINK(it,(BITS32 *)((CELL *)(B+1))[it->arity]);
|
||||||
d0 = it->links[offset];
|
d0 = it->links[offset];
|
||||||
((CELL *)(B+1))[it->arity] = (CELL)EXO_OFFSET_TO_ADDRESS(it, d0);
|
((CELL *)(B+1))[it->arity] = (CELL)LINK_TO_ADDRESS(it, d0);
|
||||||
SREG = it->cls+it->arity*offset;
|
SREG = EXO_OFFSET_TO_ADDRESS(it, offset);
|
||||||
}
|
}
|
||||||
if (d0) {
|
if (d0) {
|
||||||
/* After retry, cut should be pointing at the parent
|
/* After retry, cut should be pointing at the parent
|
||||||
|
@ -159,7 +159,7 @@ Yap_AllocCodeSpace(size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline char *
|
static inline char *
|
||||||
call_realloc(char *p, unsigned long int size)
|
call_realloc(char *p, size_t size)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
char *out;
|
char *out;
|
||||||
|
@ -1521,7 +1521,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat, UInt extra_size, struc
|
|||||||
* for the number of links
|
* for the number of links
|
||||||
*/
|
*/
|
||||||
flag = DBComplex;
|
flag = DBComplex;
|
||||||
CodeAbs += CellPtr(dbg->lr) - CellPtr(dbg->LinkAr);
|
CodeAbs += (NOfLinks+(sizeof(CELL)/sizeof(BITS32)-1))/(sizeof(CELL)/sizeof(BITS32));
|
||||||
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
|
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
|
||||||
LOCAL_Error_Size = (UInt)DBLength(CodeAbs);
|
LOCAL_Error_Size = (UInt)DBLength(CodeAbs);
|
||||||
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
|
LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR;
|
||||||
|
187
C/exo.c
187
C/exo.c
@ -46,20 +46,153 @@
|
|||||||
#define FNV32_OFFSET 2166136261
|
#define FNV32_OFFSET 2166136261
|
||||||
#define FNV64_OFFSET ((UInt)14695981039346656037)
|
#define FNV64_OFFSET ((UInt)14695981039346656037)
|
||||||
|
|
||||||
|
/*MurmurHash3 from: https://code.google.com/p/smhasher/wiki/MurmurHash3*/
|
||||||
|
BITS32 rotl32 ( BITS32, int8_t);
|
||||||
|
|
||||||
|
inline BITS32 rotl32 ( BITS32 x, int8_t r )
|
||||||
|
{
|
||||||
|
return (x << r) | (x >> (32 - r));
|
||||||
|
}
|
||||||
|
#define ROTL32(x,y) rotl32(x,y)
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Finalization mix - force all bits of a hash block to avalanche
|
||||||
|
|
||||||
|
BITS32 fmix32 ( BITS32 );
|
||||||
|
inline BITS32 fmix32 ( BITS32 h )
|
||||||
|
{
|
||||||
|
h ^= h >> 16;
|
||||||
|
h *= 0x85ebca6b;
|
||||||
|
h ^= h >> 13;
|
||||||
|
h *= 0xc2b2ae35;
|
||||||
|
h ^= h >> 16;
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
extern inline BITS32
|
||||||
|
HASH_MURMUR3_32 (UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
||||||
|
|
||||||
|
extern inline BITS32
|
||||||
|
HASH_MURMUR3_32 (UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
||||||
|
{
|
||||||
|
UInt hash;
|
||||||
|
UInt j=0;
|
||||||
|
int len = 0;
|
||||||
|
const BITS32 c1 = 0xcc9e2d51;
|
||||||
|
const BITS32 c2 = 0x1b873593;
|
||||||
|
|
||||||
|
hash = FNV32_OFFSET; /*did not find what seed to use yet*/
|
||||||
|
|
||||||
|
while (j < arity) {
|
||||||
|
if (bnds[j]) {
|
||||||
|
unsigned char *i=(unsigned char*)(cl+j);
|
||||||
|
unsigned char *m=(unsigned char*)(cl+(j+1));
|
||||||
|
|
||||||
|
while (i < m) {
|
||||||
|
BITS32 k1 = i[0];
|
||||||
|
|
||||||
|
k1 *= c1;
|
||||||
|
k1 = ROTL32(k1,15);
|
||||||
|
k1 *= c2;
|
||||||
|
|
||||||
|
hash ^= k1;
|
||||||
|
hash = ROTL32(hash,13);
|
||||||
|
hash = hash*5+0xe6546b64;
|
||||||
|
i++;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------
|
||||||
|
// tail not used becouse len is block multiple
|
||||||
|
|
||||||
|
//----------
|
||||||
|
// finalization
|
||||||
|
|
||||||
|
hash ^= len;
|
||||||
|
|
||||||
|
hash = fmix32(hash);
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*DJB2*/
|
||||||
|
#define DJB2_OFFSET 5381
|
||||||
|
|
||||||
|
extern inline BITS32
|
||||||
|
HASH_DJB2(UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
||||||
|
|
||||||
|
extern inline BITS32
|
||||||
|
HASH_DJB2(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
||||||
|
{
|
||||||
|
BITS32 hash;
|
||||||
|
UInt j=0;
|
||||||
|
|
||||||
|
hash = DJB2_OFFSET;
|
||||||
|
while (j < arity) {
|
||||||
|
if (bnds[j]) {
|
||||||
|
unsigned char *i=(unsigned char*)(cl+j);
|
||||||
|
unsigned char *m=(unsigned char*)(cl+(j+1));
|
||||||
|
|
||||||
|
while (i < m) {
|
||||||
|
BITS32 h5 = hash << 5;
|
||||||
|
hash += h5 + i[0]; /* hash * 33 + i[0] */
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern inline BITS32
|
||||||
|
HASH_RS(UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
||||||
|
|
||||||
|
/* RS Hash Function */
|
||||||
|
extern inline BITS32
|
||||||
|
HASH_RS(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
||||||
|
{
|
||||||
|
UInt hash=0;
|
||||||
|
UInt j=0;
|
||||||
|
|
||||||
|
UInt b = 378551;
|
||||||
|
UInt a = 63689;
|
||||||
|
|
||||||
|
while (j < arity) {
|
||||||
|
if (bnds[j]) {
|
||||||
|
unsigned char *i=(unsigned char*)(cl+j);
|
||||||
|
unsigned char *m=(unsigned char*)(cl+(j+1));
|
||||||
|
|
||||||
|
while (i < m) {
|
||||||
|
hash = hash * a + i[0];
|
||||||
|
a = a * b;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern inline BITS32
|
||||||
|
HASH_FVN_1A(UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
||||||
|
|
||||||
/* Simple hash function:
|
/* Simple hash function:
|
||||||
|
FVN-1A
|
||||||
first component is the base key.
|
first component is the base key.
|
||||||
hash0 spreads extensions coming from different elements.
|
hash0 spreads extensions coming from different elements.
|
||||||
spread over j quadrants.
|
spread over j quadrants.
|
||||||
*/
|
*/
|
||||||
static BITS32
|
extern inline BITS32
|
||||||
HASH(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
HASH_FVN_1A(UInt ar, CELL *cl, UInt bnds[], UInt sz)
|
||||||
{
|
{
|
||||||
UInt hash;
|
UInt hash;
|
||||||
UInt j=0;
|
UInt j=0;
|
||||||
|
|
||||||
hash = FNV32_OFFSET;
|
hash = FNV32_OFFSET;
|
||||||
while (j < arity) {
|
while (j < ar) {
|
||||||
if (bnds[j]) {
|
if (bnds[j]) {
|
||||||
unsigned char *i=(unsigned char*)(cl+j);
|
unsigned char *i=(unsigned char*)(cl+j);
|
||||||
unsigned char *m=(unsigned char*)(cl+(j+1));
|
unsigned char *m=(unsigned char*)(cl+(j+1));
|
||||||
@ -75,6 +208,19 @@ HASH(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#define TEST_HASH_DJB 1
|
||||||
|
|
||||||
|
#if defined TEST_HASH_MURMUR
|
||||||
|
# define HASH(...) HASH_MURMUR3_32(__VA_ARGS__)
|
||||||
|
#elif defined TEST_HASH_DJB
|
||||||
|
# define HASH(...) HASH_DJB2(__VA_ARGS__)
|
||||||
|
#elif defined TEST_HASH_RS
|
||||||
|
# define HASH(...) HASH_RS(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
/* Default: TEST_HASH_FVN */
|
||||||
|
# define HASH(...) HASH_FVN_1A(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
static BITS32
|
static BITS32
|
||||||
NEXT(UInt hash)
|
NEXT(UInt hash)
|
||||||
{
|
{
|
||||||
@ -97,8 +243,8 @@ MATCH(CELL *clp, CELL *kvp, UInt arity, UInt bnds[])
|
|||||||
static void
|
static void
|
||||||
ADD_TO_TRY_CHAIN(CELL *kvp, CELL *cl, struct index_t *it)
|
ADD_TO_TRY_CHAIN(CELL *kvp, CELL *cl, struct index_t *it)
|
||||||
{
|
{
|
||||||
BITS32 old = (kvp-it->cls)/it->arity;
|
BITS32 old = EXO_ADDRESS_TO_OFFSET(it, kvp);
|
||||||
BITS32 new = (cl-it->cls)/it->arity;
|
BITS32 new = EXO_ADDRESS_TO_OFFSET(it, cl);
|
||||||
BITS32 *links = it->links;
|
BITS32 *links = it->links;
|
||||||
BITS32 tmp = links[old]; /* points to the end of the chain */
|
BITS32 tmp = links[old]; /* points to the end of the chain */
|
||||||
|
|
||||||
@ -178,7 +324,7 @@ LOOKUP(struct index_t *it, UInt arity, UInt j, UInt bnds[])
|
|||||||
return FAILCODE;
|
return FAILCODE;
|
||||||
} else if (MATCH(kvp, XREGS+1, arity, bnds)) {
|
} else if (MATCH(kvp, XREGS+1, arity, bnds)) {
|
||||||
S = kvp;
|
S = kvp;
|
||||||
if (!it->is_key && it->links[(S-it->cls)/arity])
|
if (!it->is_key && it->links[EXO_ADDRESS_TO_OFFSET(it, S)])
|
||||||
return it->code;
|
return it->code;
|
||||||
else
|
else
|
||||||
return NEXTOP(NEXTOP(it->code,lp),lp);
|
return NEXTOP(NEXTOP(it->code,lp),lp);
|
||||||
@ -203,10 +349,10 @@ fill_hash(UInt bmap, struct index_t *it, UInt bnds[])
|
|||||||
}
|
}
|
||||||
for (i=0; i < it->hsize; i++) {
|
for (i=0; i < it->hsize; i++) {
|
||||||
if (it->key[i]) {
|
if (it->key[i]) {
|
||||||
UInt offset = it->key[i]/arity;
|
BITS32 offset = it->key[i];
|
||||||
UInt last = it->links[offset];
|
BITS32 last = it->links[offset];
|
||||||
if (last) {
|
if (last) {
|
||||||
/* the chain used to point straight to the last, and the last back to the origibal first */
|
/* the chain used to point straight to the last, and the last back to the original first */
|
||||||
it->links[offset] = it->links[last];
|
it->links[offset] = it->links[last];
|
||||||
it->links[last] = 0;
|
it->links[last] = 0;
|
||||||
}
|
}
|
||||||
@ -225,7 +371,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
|
|||||||
size_t sz, dsz;
|
size_t sz, dsz;
|
||||||
yamop *ptr;
|
yamop *ptr;
|
||||||
UInt *bnds = LOCAL_ibnds;
|
UInt *bnds = LOCAL_ibnds;
|
||||||
|
|
||||||
sz = (CELL)NEXTOP(NEXTOP((yamop*)NULL,lp),lp)+ap->ArityOfPE*(CELL)NEXTOP((yamop *)NULL,x) +(CELL)NEXTOP(NEXTOP((yamop *)NULL,p),l);
|
sz = (CELL)NEXTOP(NEXTOP((yamop*)NULL,lp),lp)+ap->ArityOfPE*(CELL)NEXTOP((yamop *)NULL,x) +(CELL)NEXTOP(NEXTOP((yamop *)NULL,p),l);
|
||||||
if (!(i = (struct index_t *)Yap_AllocCodeSpace(sizeof(struct index_t)+sz))) {
|
if (!(i = (struct index_t *)Yap_AllocCodeSpace(sizeof(struct index_t)+sz))) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -244,7 +390,7 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
|
|||||||
i->bmap = bmap;
|
i->bmap = bmap;
|
||||||
i->is_key = FALSE;
|
i->is_key = FALSE;
|
||||||
i->hsize = 2*ncls;
|
i->hsize = 2*ncls;
|
||||||
dsz = sizeof(BITS32)*(ncls+i->hsize);
|
dsz = sizeof(BITS32)*(ncls+1+i->hsize);
|
||||||
if (count) {
|
if (count) {
|
||||||
if (!(base = (CELL *)Yap_AllocCodeSpace(dsz))) {
|
if (!(base = (CELL *)Yap_AllocCodeSpace(dsz))) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -259,9 +405,10 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
|
|||||||
}
|
}
|
||||||
i->size = sz+dsz+sizeof(struct index_t);
|
i->size = sz+dsz+sizeof(struct index_t);
|
||||||
i->key = (BITS32 *)base;
|
i->key = (BITS32 *)base;
|
||||||
i->links = (BITS32 *)(base+i->hsize);
|
i->links = (BITS32 *)base+i->hsize;
|
||||||
i->ncollisions = i->nentries = i->ntrys = 0;
|
i->ncollisions = i->nentries = i->ntrys = 0;
|
||||||
i->cls = (CELL *)((ADDR)ap->cs.p_code.FirstClause+2*sizeof(struct index_t *));
|
i->cls = (CELL *)((ADDR)ap->cs.p_code.FirstClause+2*sizeof(struct index_t *));
|
||||||
|
i->bcls= i->cls-i->arity;
|
||||||
*ip = i;
|
*ip = i;
|
||||||
while (count) {
|
while (count) {
|
||||||
if (!fill_hash(bmap, i, bnds)) {
|
if (!fill_hash(bmap, i, bnds)) {
|
||||||
@ -270,13 +417,13 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
|
|||||||
if (i->is_key) {
|
if (i->is_key) {
|
||||||
sz = i->hsize*sizeof(BITS32);
|
sz = i->hsize*sizeof(BITS32);
|
||||||
} else {
|
} else {
|
||||||
sz = (ncls+i->hsize)*sizeof(BITS32);
|
sz = (ncls+1+i->hsize)*sizeof(BITS32);
|
||||||
}
|
}
|
||||||
if (base != (CELL *)Yap_ReallocCodeSpace((char *)base, sz))
|
if (base != (CELL *)Yap_ReallocCodeSpace((char *)base, sz))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
bzero(base, sz);
|
bzero(base, sz);
|
||||||
i->key = (CELL *)base;
|
i->key = (BITS32 *)base;
|
||||||
i->links = (CELL *)(base+i->hsize);
|
i->links = (BITS32 *)(base+i->hsize);
|
||||||
i->ncollisions = i->nentries = i->ntrys = 0;
|
i->ncollisions = i->nentries = i->ntrys = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -295,13 +442,13 @@ add_index(struct index_t **ip, UInt bmap, PredEntry *ap, UInt count)
|
|||||||
if (i->is_key) {
|
if (i->is_key) {
|
||||||
sz = i->hsize*sizeof(BITS32);
|
sz = i->hsize*sizeof(BITS32);
|
||||||
} else {
|
} else {
|
||||||
sz = (ncls+i->hsize)*sizeof(BITS32);
|
sz = (ncls+1+i->hsize)*sizeof(BITS32);
|
||||||
}
|
}
|
||||||
if (base != (CELL *)Yap_ReallocCodeSpace((char *)base, sz))
|
if (base != (CELL *)Yap_ReallocCodeSpace((char *)base, sz))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
bzero(base, sz);
|
bzero(base, sz);
|
||||||
i->key = (CELL *)base;
|
i->key = (BITS32 *)base;
|
||||||
i->links = (CELL *)(base+i->hsize);
|
i->links = (BITS32 *)base+i->hsize;
|
||||||
i->ncollisions = i->nentries = i->ntrys = 0;
|
i->ncollisions = i->nentries = i->ntrys = 0;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -398,8 +545,8 @@ CELL
|
|||||||
Yap_NextExo(choiceptr cptr, struct index_t *it)
|
Yap_NextExo(choiceptr cptr, struct index_t *it)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
CELL offset = ADDRESS_TO_LINK(it,(CELL *)((CELL *)(B+1))[it->arity]);
|
BITS32 offset = ADDRESS_TO_LINK(it,(BITS32 *)((CELL *)(B+1))[it->arity]);
|
||||||
CELL next = it->links[offset];
|
BITS32 next = it->links[offset];
|
||||||
((CELL *)(B+1))[it->arity] = (CELL)LINK_TO_ADDRESS(it, next);
|
((CELL *)(B+1))[it->arity] = (CELL)LINK_TO_ADDRESS(it, next);
|
||||||
S = it->cls+it->arity*offset;
|
S = it->cls+it->arity*offset;
|
||||||
return next;
|
return next;
|
||||||
|
343
C/exo_udi.c
343
C/exo_udi.c
@ -41,94 +41,174 @@ static int
|
|||||||
compar(const void *ip0, const void *jp0) {
|
compar(const void *ip0, const void *jp0) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
BITS32 *ip = (BITS32 *)ip0, *jp = (BITS32 *)jp0;
|
BITS32 *ip = (BITS32 *)ip0, *jp = (BITS32 *)jp0;
|
||||||
BITS32 *bs = LOCAL_exo_base;
|
Term i = EXO_OFFSET_TO_ADDRESS(LOCAL_exo_it, *ip)[LOCAL_exo_arg];
|
||||||
Int i = bs[LOCAL_exo_arity*(*ip)+LOCAL_exo_arg];
|
Term j = EXO_OFFSET_TO_ADDRESS(LOCAL_exo_it, *jp)[LOCAL_exo_arg];
|
||||||
Int j = bs[LOCAL_exo_arity*(*jp)+LOCAL_exo_arg];
|
//fprintf(stderr, "%ld-%ld\n", IntOfTerm(i), IntOfTerm(j));
|
||||||
return IntOfTerm(i)-IntOfTerm(j);
|
return IntOfTerm(i)-IntOfTerm(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
compare(const BITS32 *ip, Int j USES_REGS) {
|
compare(const BITS32 *ip, Int j USES_REGS) {
|
||||||
BITS32 *bs = LOCAL_exo_base;
|
Term i = EXO_OFFSET_TO_ADDRESS(LOCAL_exo_it, *ip)[LOCAL_exo_arg];
|
||||||
Int i = bs[LOCAL_exo_arity*(*ip)+LOCAL_exo_arg];
|
|
||||||
//fprintf(stderr, "%ld-%ld\n", IntOfTerm(i), j);
|
//fprintf(stderr, "%ld-%ld\n", IntOfTerm(i), j);
|
||||||
return IntOfTerm(i)-j;
|
return IntOfTerm(i)-j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
static void
|
same_free(BITS32 i, BITS32 j, struct index_t *it) {
|
||||||
IntervalUDIRefitIndex(struct index_t **ip, UInt b[] USES_REGS)
|
CELL *ip = EXO_OFFSET_TO_ADDRESS(it, i);
|
||||||
{
|
CELL *jp = EXO_OFFSET_TO_ADDRESS(it, j);
|
||||||
size_t sz;
|
UInt m = it->udi_free_args, m0 = 1, x;
|
||||||
struct index_t *it = *ip;
|
for (x=0; x< it->arity; x++) {
|
||||||
UInt arity = it->arity;
|
if (m0 & m) {
|
||||||
yamop *code;
|
if (ip[x] != jp[x])
|
||||||
|
return FALSE;
|
||||||
/* hard-wired implementation for the Interval case */
|
m -= m0;
|
||||||
Int i = it->udi_arg;
|
if (!m)
|
||||||
/* it is bound, use hash */
|
return TRUE;
|
||||||
if (it->bmap & b[i]) return;
|
}
|
||||||
/* no constraints, nothing to gain */
|
m0 <<= 1;
|
||||||
if (!IsAttVar(VarOfTerm(XREGS[i+1]))) return;
|
}
|
||||||
LOCAL_exo_base = it->cls;
|
return TRUE;
|
||||||
LOCAL_exo_arity = it->arity;
|
|
||||||
LOCAL_exo_arg = i;
|
|
||||||
if (!it->key) {
|
|
||||||
UInt ncls = it->ap->cs.p_code.NOfClauses, i;
|
|
||||||
BITS32 *sorted;
|
|
||||||
/* handle ll variables */
|
|
||||||
sz = sizeof(BITS32)*(ncls);
|
|
||||||
/* allocate space */
|
|
||||||
if (!(it->udi_data = (BITS32*)Yap_AllocCodeSpace(sz)))
|
|
||||||
return;
|
|
||||||
sorted = (BITS32*)it->udi_data;
|
|
||||||
for (i=0; i< ncls; i++)
|
|
||||||
sorted[i] = i;
|
|
||||||
qsort(sorted, (size_t)ncls, sizeof(BITS32), compar);
|
|
||||||
it->links = NULL;
|
|
||||||
} else {
|
|
||||||
BITS32 *sorted0, *sorted;
|
|
||||||
|
|
||||||
/* be conservative */
|
|
||||||
sz = sizeof(BITS32)*(2*it->ntrys+it->nentries);
|
|
||||||
/* allocate space */
|
|
||||||
if (!(it->udi_data = (BITS32*)Yap_AllocCodeSpace(sz)))
|
|
||||||
return;
|
|
||||||
sorted0 = sorted = (BITS32 *)it->udi_data;
|
|
||||||
sorted++; /* leave an initial hole */
|
|
||||||
for (i=0; i < it->hsize; i++) {
|
|
||||||
if (it->key[i]) {
|
|
||||||
BITS32 *s0 = sorted;
|
|
||||||
BITS32 offset = it->key[i]/arity, offset0 = offset;
|
|
||||||
|
|
||||||
*sorted++ = 0;
|
|
||||||
do {
|
|
||||||
*sorted++ = offset;
|
|
||||||
offset = it->links[offset];
|
|
||||||
} while (offset);
|
|
||||||
// S = it->cls+it->arity*offset0; Yap_DebugPlWrite(S[1]);
|
|
||||||
// fprintf(stderr, " key[i]=%d offset=%d %d\n", it->key[i], offset0, (sorted-s0)-1);
|
|
||||||
if (sorted-s0 == 2) {
|
|
||||||
it->links[offset0] = 0;
|
|
||||||
sorted = s0;
|
|
||||||
} else {
|
|
||||||
/* number of elements comes first */
|
|
||||||
*s0 = sorted - (s0+1);
|
|
||||||
qsort(s0+1, (size_t)*s0, sizeof(BITS32), compar);
|
|
||||||
it->links[offset0] = s0-sorted0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sz = sizeof(BITS32)*(sorted-sorted0);
|
|
||||||
it->udi_data = (BITS32 *)Yap_ReallocCodeSpace((char *)it->udi_data, sz);
|
|
||||||
}
|
|
||||||
it->is_udi = TRUE;
|
|
||||||
code = it->code;
|
|
||||||
code->opc = Yap_opcode(_try_exo_udi);
|
|
||||||
code = NEXTOP(code, lp);
|
|
||||||
code->opc = Yap_opcode(_retry_exo_udi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static UInt free_args(UInt b[], UInt arity, UInt i) {
|
||||||
|
UInt j;
|
||||||
|
UInt rc = 0;
|
||||||
|
|
||||||
|
for (j=0; j<arity; j++) {
|
||||||
|
if (i !=j && b[j] == 0)
|
||||||
|
rc |= 1<<j;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chain(BITS32 *p0, BITS32 *el, BITS32 n, struct index_t *it) {
|
||||||
|
UInt i;
|
||||||
|
|
||||||
|
for (i=0; i<n; i++) {
|
||||||
|
UInt j, k = i;
|
||||||
|
if (p0[i])
|
||||||
|
continue;
|
||||||
|
p0[i] = i;
|
||||||
|
for (j=i+1; j<n; j++) {
|
||||||
|
if (same_free(el[i], el[j], it)) {
|
||||||
|
p0[j] = k;
|
||||||
|
k = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Int
|
||||||
|
NEXT_DIFFERENT(Int x0, Int x, BITS32 *p, Int xe)
|
||||||
|
{
|
||||||
|
while (x <= xe) {
|
||||||
|
x++;
|
||||||
|
if (p[x] < x0 || p[x] >= x)
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Int
|
||||||
|
BIGGEST_EL(Int x0, BITS32 *p, Int xe)
|
||||||
|
{
|
||||||
|
Int x = x0;
|
||||||
|
|
||||||
|
while (x <= xe) {
|
||||||
|
if (p[x] == x0)
|
||||||
|
x0 = x;
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
return x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
IntervalUDIRefitIndex(struct index_t **ip, UInt b[] USES_REGS)
|
||||||
|
{
|
||||||
|
size_t sz;
|
||||||
|
struct index_t *it = *ip;
|
||||||
|
yamop *code;
|
||||||
|
|
||||||
|
/* hard-wired implementation for the Interval case */
|
||||||
|
Int i = it->udi_arg;
|
||||||
|
/* it is bound, use hash */
|
||||||
|
if (it->bmap & b[i]) return;
|
||||||
|
/* no constraints, nothing to gain */
|
||||||
|
//if (!IsAttVar(VarOfTerm(Deref(XREGS[i+1])))) return;
|
||||||
|
LOCAL_exo_it = it;
|
||||||
|
LOCAL_exo_base = it->bcls;
|
||||||
|
LOCAL_exo_arity = it->arity;
|
||||||
|
LOCAL_exo_arg = i;
|
||||||
|
it->udi_free_args = free_args(b, it->arity, i);
|
||||||
|
if (!it->key) {
|
||||||
|
UInt ncls = it->ap->cs.p_code.NOfClauses, i;
|
||||||
|
BITS32 *sorted;
|
||||||
|
/* handle ll variables */
|
||||||
|
sz = sizeof(BITS32)*(ncls);
|
||||||
|
/* allocate space */
|
||||||
|
if (!(it->udi_data = (BITS32*)Yap_AllocCodeSpace(sz)))
|
||||||
|
return;
|
||||||
|
sorted = (BITS32*)it->udi_data;
|
||||||
|
for (i=0; i< ncls; i++)
|
||||||
|
sorted[i] = i;
|
||||||
|
qsort(sorted, (size_t)ncls, sizeof(BITS32), compar);
|
||||||
|
it->links = NULL;
|
||||||
|
} else {
|
||||||
|
BITS32 *sorted0, *sorted;
|
||||||
|
|
||||||
|
/* be conservative */
|
||||||
|
if (it->udi_free_args)
|
||||||
|
sz = sizeof(BITS32)*(3*it->ntrys+3*it->nentries);
|
||||||
|
else
|
||||||
|
sz = sizeof(BITS32)*(2*it->ntrys+2*it->nentries);
|
||||||
|
/* allocate space */
|
||||||
|
if (!(it->udi_data = (BITS32*)Yap_AllocCodeSpace(sz)))
|
||||||
|
return;
|
||||||
|
sorted0 = sorted = (BITS32 *)it->udi_data;
|
||||||
|
sorted++; /* leave an initial hole */
|
||||||
|
for (i=0; i < it->hsize; i++) {
|
||||||
|
if (it->key[i]) {
|
||||||
|
BITS32 *s0 = sorted;
|
||||||
|
BITS32 offset = it->key[i], offset0 = offset;
|
||||||
|
|
||||||
|
*sorted++ = 0;
|
||||||
|
do {
|
||||||
|
*sorted++ = offset;
|
||||||
|
offset = it->links[offset];
|
||||||
|
} while (offset);
|
||||||
|
// S = EXO_OFFSET_TO_ADDRESS(it, offset0); Yap_DebugPlWrite(S[0]);
|
||||||
|
// fprintf(stderr, " key[i]=%d offset=%d %d\n", it->key[i], offset0, (sorted-s0)-1);
|
||||||
|
if (sorted-s0 == 2) {
|
||||||
|
it->links[offset0] = 0;
|
||||||
|
sorted = s0;
|
||||||
|
} else {
|
||||||
|
/* number of elements comes first */
|
||||||
|
*s0 = sorted - (s0+1);
|
||||||
|
qsort(s0+1, (size_t)*s0, sizeof(BITS32), compar);
|
||||||
|
it->links[offset0] = s0-sorted0;
|
||||||
|
// fprintf(stderr," %d links %d=%d \n", offset0, s0-sorted0, s0[0]);
|
||||||
|
if (it->udi_free_args) {
|
||||||
|
bzero(sorted, sizeof(BITS32)*(*s0));
|
||||||
|
/* chain elements with same unbound vars together */
|
||||||
|
chain(sorted, s0+1, *s0, it);
|
||||||
|
sorted += *s0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sz = sizeof(BITS32)*(sorted-sorted0);
|
||||||
|
it->udi_data = (BITS32 *)Yap_ReallocCodeSpace((char *)it->udi_data, sz);
|
||||||
|
}
|
||||||
|
it->is_udi = i+1;
|
||||||
|
code = it->code;
|
||||||
|
code->opc = Yap_opcode(_try_exo_udi);
|
||||||
|
code = NEXTOP(code, lp);
|
||||||
|
code->opc = Yap_opcode(_retry_exo_udi);
|
||||||
|
}
|
||||||
|
|
||||||
static BITS32 *
|
static BITS32 *
|
||||||
binary_search(BITS32 *start, BITS32 *end, Int x USES_REGS)
|
binary_search(BITS32 *start, BITS32 *end, Int x USES_REGS)
|
||||||
{
|
{
|
||||||
@ -154,9 +234,11 @@ Interval(struct index_t *it, Term min, Term max, Term op, BITS32 off USES_REGS)
|
|||||||
BITS32 n;
|
BITS32 n;
|
||||||
BITS32 *pt;
|
BITS32 *pt;
|
||||||
BITS32 *end;
|
BITS32 *end;
|
||||||
|
BITS32 *pt0, *end0;
|
||||||
Atom at;
|
Atom at;
|
||||||
|
|
||||||
LOCAL_exo_base = it->cls;
|
LOCAL_exo_it = it;
|
||||||
|
LOCAL_exo_base = it->bcls;
|
||||||
LOCAL_exo_arity = it->arity;
|
LOCAL_exo_arity = it->arity;
|
||||||
LOCAL_exo_arg = it->udi_arg;
|
LOCAL_exo_arg = it->udi_arg;
|
||||||
if (!it->links) {
|
if (!it->links) {
|
||||||
@ -164,11 +246,15 @@ Interval(struct index_t *it, Term min, Term max, Term op, BITS32 off USES_REGS)
|
|||||||
n = it->nels;
|
n = it->nels;
|
||||||
pt = c;
|
pt = c;
|
||||||
end = c+(n-1);
|
end = c+(n-1);
|
||||||
|
pt0 = pt;
|
||||||
|
end0 = end+1;
|
||||||
} else if (it->links[off]) {
|
} else if (it->links[off]) {
|
||||||
c = (BITS32 *)it->udi_data;
|
c = (BITS32 *)it->udi_data;
|
||||||
n = c[it->links[off]];
|
n = c[it->links[off]];
|
||||||
pt = c+(it->links[off]+1);
|
pt0 = pt = c+(it->links[off]+1);
|
||||||
end = c+(it->links[off]+n);
|
end = c+(it->links[off]+n);
|
||||||
|
end0 = end+1;
|
||||||
|
// fprintf(stderr," %d links %d=%d \n", off, it->links[off], n);
|
||||||
} else {
|
} else {
|
||||||
if (!IsVarTerm(min)) {
|
if (!IsVarTerm(min)) {
|
||||||
Int x;
|
Int x;
|
||||||
@ -257,24 +343,67 @@ Interval(struct index_t *it, Term min, Term max, Term op, BITS32 off USES_REGS)
|
|||||||
end = pt1;
|
end = pt1;
|
||||||
}
|
}
|
||||||
if (IsVarTerm(op)) {
|
if (IsVarTerm(op)) {
|
||||||
S = it->cls+it->arity*pt[0];
|
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||||
if (pt < end ) {
|
if (pt < end ) {
|
||||||
YENV[-2] = (CELL)( pt+1 );
|
|
||||||
YENV[-1] = (CELL)( end );
|
YENV[-1] = (CELL)( end );
|
||||||
|
YENV[-2] = (CELL)( pt+1 );
|
||||||
YENV -= 2;
|
YENV -= 2;
|
||||||
return it->code;
|
return it->code;
|
||||||
}
|
}
|
||||||
return NEXTOP(NEXTOP(it->code,lp),lp);
|
return NEXTOP(NEXTOP(it->code,lp),lp);
|
||||||
}
|
}
|
||||||
at = AtomOfTerm(op);
|
at = AtomOfTerm(op);
|
||||||
if (at == AtomAny || at == AtomMin) {
|
if (at == AtomAny || at == AtomMinimum) {
|
||||||
S = it->cls+it->arity*pt[0];
|
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||||
} else if (at == AtomMax) {
|
} else if (at == AtomMaximum) {
|
||||||
S = it->cls+it->arity*end[0];
|
S = EXO_OFFSET_TO_ADDRESS(it, end[0]);
|
||||||
} else if (at == AtomUnique) {
|
} else if (at == AtomUnique) {
|
||||||
if (end-2 > pt)
|
if (end-2 > pt)
|
||||||
return FAILCODE;
|
return FAILCODE;
|
||||||
S = it->cls+it->arity*pt[0];
|
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||||
|
} else if (at == AtomMin) {
|
||||||
|
Int x0, xe, x;
|
||||||
|
|
||||||
|
if (!(it->udi_free_args)) {
|
||||||
|
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||||
|
} else {
|
||||||
|
x0 = pt-pt0;
|
||||||
|
xe = end-pt0;
|
||||||
|
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||||
|
x = NEXT_DIFFERENT(x0, x0, end0, xe);
|
||||||
|
if (x < xe ) {
|
||||||
|
YENV[-5] = (CELL)( pt0 ); // base for array of pointed pointers
|
||||||
|
YENV[-4] = MkIntegerTerm( x ); // where we are in pt0 array
|
||||||
|
YENV[-3] = MkIntegerTerm( xe ); // our visit will end here
|
||||||
|
YENV[-2] = MkIntegerTerm( x0 ); // our visit started here
|
||||||
|
YENV[-1] = (CELL)( end0 ); // base for array into pt
|
||||||
|
YENV -= 5;
|
||||||
|
return it->code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NEXTOP(NEXTOP(it->code,lp),lp);
|
||||||
|
} else if (at == AtomMax) {
|
||||||
|
Int x0, xe, x, y;
|
||||||
|
|
||||||
|
if (!(it->udi_free_args)) {
|
||||||
|
S = EXO_OFFSET_TO_ADDRESS(it, end[0]);
|
||||||
|
} else {
|
||||||
|
x0 = pt-pt0;
|
||||||
|
xe = end-pt0;
|
||||||
|
y = BIGGEST_EL( x0, end0, xe );
|
||||||
|
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||||
|
x = NEXT_DIFFERENT(x0, x0, end0, xe);
|
||||||
|
if (x < xe ) {
|
||||||
|
YENV[-5] = (CELL)( pt0 ); // base for array of pointed pointers
|
||||||
|
YENV[-4] = MkIntegerTerm( -x ); // where we are in pt0 array
|
||||||
|
YENV[-3] = MkIntegerTerm( xe ); // our visit will end here
|
||||||
|
YENV[-2] = MkIntegerTerm( x0 ); // our visit started here
|
||||||
|
YENV[-1] = (CELL)( end0 ); // base for array into pt
|
||||||
|
YENV -= 5;
|
||||||
|
return it->code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NEXTOP(NEXTOP(it->code,lp),lp);
|
||||||
}
|
}
|
||||||
return NEXTOP(NEXTOP(it->code,lp),lp);
|
return NEXTOP(NEXTOP(it->code,lp),lp);
|
||||||
}
|
}
|
||||||
@ -284,7 +413,7 @@ IntervalEnterUDIIndex(struct index_t *it USES_REGS)
|
|||||||
{
|
{
|
||||||
Int i = it->udi_arg;
|
Int i = it->udi_arg;
|
||||||
Term t = XREGS[i+1], a1;
|
Term t = XREGS[i+1], a1;
|
||||||
BITS32 off = EXO_ADDRESS_TO_OFFSET(it, S)/it->arity;
|
BITS32 off = EXO_ADDRESS_TO_OFFSET(it, S);
|
||||||
// printf("off=%d it=%p %p---%p\n", off, it, it->cls, S);
|
// printf("off=%d it=%p %p---%p\n", off, it, it->cls, S);
|
||||||
attvar_record *attv;
|
attvar_record *attv;
|
||||||
|
|
||||||
@ -310,14 +439,40 @@ IntervalEnterUDIIndex(struct index_t *it USES_REGS)
|
|||||||
static int
|
static int
|
||||||
IntervalRetryUDIIndex(struct index_t *it USES_REGS)
|
IntervalRetryUDIIndex(struct index_t *it USES_REGS)
|
||||||
{
|
{
|
||||||
CELL *w = (CELL*)(B+1);
|
CELL *w = (CELL*)(B+1)+it->arity;
|
||||||
BITS32 *end = (BITS32 *) w[it->arity+2],
|
if (IsVarTerm(w[2])) {
|
||||||
*pt = (BITS32 *) w[it->arity+1];
|
BITS32 *end = (BITS32 *) w[2],
|
||||||
BITS32 f = *pt;
|
*pt = (BITS32 *) w[1];
|
||||||
|
BITS32 f = *pt;
|
||||||
|
|
||||||
S = it->cls+it->arity*f;
|
S = EXO_OFFSET_TO_ADDRESS(it, f);
|
||||||
if (pt++ == end) return FALSE;
|
if (pt++ == end) return FALSE;
|
||||||
w[it->arity+1] = (CELL)pt;
|
w[1] = (CELL)pt;
|
||||||
|
} else {
|
||||||
|
BITS32 *pt0 = (BITS32 *)w[1];
|
||||||
|
Int x = IntegerOfTerm( w[2] );
|
||||||
|
Int xe = IntegerOfTerm( w[3] );
|
||||||
|
Int x0 = IntegerOfTerm( w[4] );
|
||||||
|
BITS32 *base = (BITS32 *)w[5];
|
||||||
|
if ( x > 0) {
|
||||||
|
//Yap_DebugPlWrite( EXO_OFFSET_TO_ADDRESS(it, el[i])[1] ); fprintf(stderr,"\n");
|
||||||
|
S = EXO_OFFSET_TO_ADDRESS(it, pt0[x]);
|
||||||
|
//fprintf(stderr,"S=%p x=%d/%d %d %d %p %p \n", S, x, base[x], x0, xe, pt0, base);
|
||||||
|
x = NEXT_DIFFERENT(x0, x, base, xe);
|
||||||
|
if (x > xe) return FALSE;
|
||||||
|
w[2] = MkIntegerTerm(x);
|
||||||
|
} else {
|
||||||
|
x = -x;
|
||||||
|
//Yap_DebugPlWrite( EXO_OFFSET_TO_ADDRESS(it, el[i])[1] ); fprintf(stderr,"\n");
|
||||||
|
S = EXO_OFFSET_TO_ADDRESS(it, pt0[BIGGEST_EL(x, base, xe) ]);
|
||||||
|
x = NEXT_DIFFERENT(x0, x, base, xe);
|
||||||
|
// fprintf(stderr,"S=%p x=%d/%d %d %d %p %p \n", S, x, base[x], x0, xe, pt0, base);
|
||||||
|
if (x > xe) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
w[2] = MkIntegerTerm(-x);
|
||||||
|
}
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
C/globals.c
13
C/globals.c
@ -1025,7 +1025,7 @@ p_nb_linkval( USES_REGS1 )
|
|||||||
static Int
|
static Int
|
||||||
p_nb_create_accumulator( USES_REGS1 )
|
p_nb_create_accumulator( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1), acct, to;
|
Term t = Deref(ARG1), acct, to, t2;
|
||||||
CELL *destp;
|
CELL *destp;
|
||||||
|
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
@ -1043,6 +1043,10 @@ p_nb_create_accumulator( USES_REGS1 )
|
|||||||
to = CopyTermToArena(t, LOCAL_GlobalArena, TRUE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
|
to = CopyTermToArena(t, LOCAL_GlobalArena, TRUE, TRUE, 2, &LOCAL_GlobalArena, garena_overflow_size(ArenaPt(LOCAL_GlobalArena) PASS_REGS) PASS_REGS);
|
||||||
if (to == 0L)
|
if (to == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
t2 = Deref(ARG2);
|
||||||
|
if (IsVarTerm(t2)) {
|
||||||
|
return Yap_unify(t2, Yap_MkApplTerm(FunctorGNumber,1,&to) );
|
||||||
|
}
|
||||||
destp = RepAppl(Deref(ARG2));
|
destp = RepAppl(Deref(ARG2));
|
||||||
destp[1] = to;
|
destp[1] = to;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1083,7 +1087,7 @@ p_nb_add_to_accumulator( USES_REGS1 )
|
|||||||
/* forget it if it was something else */
|
/* forget it if it was something else */
|
||||||
destp[1] = new;
|
destp[1] = new;
|
||||||
} else {
|
} else {
|
||||||
/* long, do we have spapce or not ?? */
|
/* long, do we have space or not ?? */
|
||||||
if (IsLongIntTerm(t0)) {
|
if (IsLongIntTerm(t0)) {
|
||||||
CELL *target = RepAppl(t0);
|
CELL *target = RepAppl(t0);
|
||||||
CELL *source = RepAppl(new);
|
CELL *source = RepAppl(new);
|
||||||
@ -1130,7 +1134,7 @@ p_nb_add_to_accumulator( USES_REGS1 )
|
|||||||
static Int
|
static Int
|
||||||
p_nb_accumulator_value( USES_REGS1 )
|
p_nb_accumulator_value( USES_REGS1 )
|
||||||
{
|
{
|
||||||
Term t = Deref(ARG1), to;
|
Term t = Deref(ARG1);
|
||||||
Functor f;
|
Functor f;
|
||||||
|
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
@ -1145,8 +1149,7 @@ p_nb_accumulator_value( USES_REGS1 )
|
|||||||
if (f != FunctorGNumber) {
|
if (f != FunctorGNumber) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
to = Yap_CopyTerm(RepAppl(t)[1]);
|
return Yap_unify(ArgOfTerm(1,t), ARG2);
|
||||||
return Yap_unify(to, ARG2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,8 +102,9 @@ typedef greg_t context_reg;
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define CONTEXT_PC NULL
|
#ifdef LOW_PROF
|
||||||
#define CONTEXT_BP NULL
|
#undef LOW_PROF
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
84
C/heapgc.c
84
C/heapgc.c
@ -2004,6 +2004,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
|
|||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
op = rtp->opc;
|
op = rtp->opc;
|
||||||
opnum = Yap_op_from_opcode(op);
|
opnum = Yap_op_from_opcode(op);
|
||||||
|
// fprintf(stderr, "%s\n", Yap_op_names[opnum]);
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
}
|
}
|
||||||
if (aux_sg_fr && gc_B == SgFr_gen_cp(aux_sg_fr)) {
|
if (aux_sg_fr && gc_B == SgFr_gen_cp(aux_sg_fr)) {
|
||||||
@ -2166,11 +2167,37 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
|
|||||||
case _table_answer_resolution:
|
case _table_answer_resolution:
|
||||||
{
|
{
|
||||||
CELL *vars_ptr, vars;
|
CELL *vars_ptr, vars;
|
||||||
init_substitution_pointer(gc_B, vars_ptr, CONS_CP(gc_B)->cp_dep_fr);
|
dep_fr_ptr dep_fr = CONS_CP(gc_B)->cp_dep_fr;
|
||||||
vars = *vars_ptr++;
|
ans_node_ptr ans_node = DepFr_last_answer(dep_fr);
|
||||||
while (vars--) {
|
if (TrNode_child(ans_node)) {
|
||||||
mark_external_reference(vars_ptr PASS_REGS);
|
/* unconsumed answers */
|
||||||
vars_ptr++;
|
#ifdef MODE_DIRECTED_TABLING
|
||||||
|
if (IS_ANSWER_INVALID_NODE(TrNode_child(ans_node))) {
|
||||||
|
ans_node_ptr old_ans_node;
|
||||||
|
old_ans_node = ans_node;
|
||||||
|
ans_node = TrNode_child(ans_node);
|
||||||
|
do {
|
||||||
|
ans_node = TrNode_child(ans_node);
|
||||||
|
} while (IS_ANSWER_INVALID_NODE(ans_node));
|
||||||
|
TrNode_child(old_ans_node) = ans_node;
|
||||||
|
} else
|
||||||
|
#endif /* MODE_DIRECTED_TABLING */
|
||||||
|
ans_node = TrNode_child(ans_node);
|
||||||
|
if (gc_B == DepFr_leader_cp(dep_fr)) { \
|
||||||
|
/* gc_B is a generator-consumer node */ \
|
||||||
|
/* never here if batched scheduling */ \
|
||||||
|
TABLING_ERROR_CHECKING(generator_consumer, IS_BATCHED_GEN_CP(gc_B)); \
|
||||||
|
vars_ptr = (CELL *) (GEN_CP(gc_B) + 1); \
|
||||||
|
vars_ptr += SgFr_arity(GEN_CP(gc_B)->cp_sg_fr); \
|
||||||
|
} else { \
|
||||||
|
vars_ptr = (CELL *) (CONS_CP(gc_B) + 1); \
|
||||||
|
} \
|
||||||
|
|
||||||
|
vars = *vars_ptr++;
|
||||||
|
while (vars--) {
|
||||||
|
mark_external_reference(vars_ptr PASS_REGS);
|
||||||
|
vars_ptr++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nargs = 0;
|
nargs = 0;
|
||||||
@ -3113,18 +3140,43 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
|
|||||||
case _table_answer_resolution:
|
case _table_answer_resolution:
|
||||||
{
|
{
|
||||||
CELL *vars_ptr, vars;
|
CELL *vars_ptr, vars;
|
||||||
sweep_environments(gc_B->cp_env, EnvSize(gc_B->cp_cp), EnvBMap(gc_B->cp_cp) PASS_REGS);
|
dep_fr_ptr dep_fr = CONS_CP(gc_B)->cp_dep_fr;
|
||||||
init_substitution_pointer(gc_B, vars_ptr, CONS_CP(gc_B)->cp_dep_fr);
|
ans_node_ptr ans_node = DepFr_last_answer(dep_fr);
|
||||||
vars = *vars_ptr++;
|
if (TrNode_child(ans_node)) {
|
||||||
while (vars--) {
|
/* unconsumed answers */
|
||||||
CELL cp_cell = *vars_ptr;
|
#ifdef MODE_DIRECTED_TABLING
|
||||||
if (MARKED_PTR(vars_ptr)) {
|
if (IS_ANSWER_INVALID_NODE(TrNode_child(ans_node))) {
|
||||||
UNMARK(vars_ptr);
|
ans_node_ptr old_ans_node;
|
||||||
if (HEAP_PTR(cp_cell)) {
|
old_ans_node = ans_node;
|
||||||
into_relocation_chain(vars_ptr, GET_NEXT(cp_cell) PASS_REGS);
|
ans_node = TrNode_child(ans_node);
|
||||||
}
|
do {
|
||||||
|
ans_node = TrNode_child(ans_node);
|
||||||
|
} while (IS_ANSWER_INVALID_NODE(ans_node));
|
||||||
|
TrNode_child(old_ans_node) = ans_node;
|
||||||
|
} else
|
||||||
|
#endif /* MODE_DIRECTED_TABLING */
|
||||||
|
ans_node = TrNode_child(ans_node);
|
||||||
|
if (gc_B == DepFr_leader_cp(dep_fr)) { \
|
||||||
|
/* gc_B is a generator-consumer node */
|
||||||
|
/* never here if batched scheduling */
|
||||||
|
TABLING_ERROR_CHECKING(generator_consumer, IS_BATCHED_GEN_CP(gc_B));
|
||||||
|
vars_ptr = (CELL *) (GEN_CP(gc_B) + 1);
|
||||||
|
vars_ptr += SgFr_arity(GEN_CP(gc_B)->cp_sg_fr);
|
||||||
|
} else {
|
||||||
|
vars_ptr = (CELL *) (CONS_CP(gc_B) + 1); \
|
||||||
|
}
|
||||||
|
sweep_environments(gc_B->cp_env, EnvSize(gc_B->cp_cp), EnvBMap(gc_B->cp_cp) PASS_REGS);
|
||||||
|
vars = *vars_ptr++;
|
||||||
|
while (vars--) {
|
||||||
|
CELL cp_cell = *vars_ptr;
|
||||||
|
if (MARKED_PTR(vars_ptr)) {
|
||||||
|
UNMARK(vars_ptr);
|
||||||
|
if (HEAP_PTR(cp_cell)) {
|
||||||
|
into_relocation_chain(vars_ptr, GET_NEXT(cp_cell) PASS_REGS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vars_ptr++;
|
||||||
}
|
}
|
||||||
vars_ptr++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
47
C/parser.c
47
C/parser.c
@ -70,7 +70,7 @@ typedef struct jmp_buff_struct {
|
|||||||
|
|
||||||
static void GNextToken( CACHE_TYPE1 );
|
static void GNextToken( CACHE_TYPE1 );
|
||||||
static void checkfor(Term, JMPBUFF * CACHE_TYPE);
|
static void checkfor(Term, JMPBUFF * CACHE_TYPE);
|
||||||
static Term ParseArgs(Atom, JMPBUFF * CACHE_TYPE);
|
static Term ParseArgs(Atom, Term, JMPBUFF *, Term CACHE_TYPE);
|
||||||
static Term ParseList(JMPBUFF * CACHE_TYPE);
|
static Term ParseList(JMPBUFF * CACHE_TYPE);
|
||||||
static Term ParseTerm(int, JMPBUFF * CACHE_TYPE);
|
static Term ParseTerm(int, JMPBUFF * CACHE_TYPE);
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ checkfor(Term c, JMPBUFF *FailBuff USES_REGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
ParseArgs(Atom a, JMPBUFF *FailBuff USES_REGS)
|
ParseArgs(Atom a, Term close, JMPBUFF *FailBuff, Term arg1 USES_REGS)
|
||||||
{
|
{
|
||||||
int nargs = 0;
|
int nargs = 0;
|
||||||
Term *p, t;
|
Term *p, t;
|
||||||
@ -335,6 +335,27 @@ ParseArgs(Atom a, JMPBUFF *FailBuff USES_REGS)
|
|||||||
|
|
||||||
NextToken;
|
NextToken;
|
||||||
p = (Term *) ParserAuxSp;
|
p = (Term *) ParserAuxSp;
|
||||||
|
if (arg1) {
|
||||||
|
*p = arg1;
|
||||||
|
nargs++;
|
||||||
|
ParserAuxSp = (char *)(p+1);
|
||||||
|
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)
|
||||||
|
&& LOCAL_tokptr->TokInfo == close) {
|
||||||
|
|
||||||
|
func = Yap_MkFunctor(a, 1);
|
||||||
|
if (func == NULL) {
|
||||||
|
LOCAL_ErrorMessage = "Heap Overflow";
|
||||||
|
FAIL;
|
||||||
|
}
|
||||||
|
t = Yap_MkApplTerm(func, nargs, p);
|
||||||
|
if (H > ASP-4096) {
|
||||||
|
LOCAL_ErrorMessage = "Stack Overflow";
|
||||||
|
return TermNil;
|
||||||
|
}
|
||||||
|
NextToken;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
Term *tp = (Term *)ParserAuxSp;
|
Term *tp = (Term *)ParserAuxSp;
|
||||||
if (ParserAuxSp+1 > LOCAL_TrailTop) {
|
if (ParserAuxSp+1 > LOCAL_TrailTop) {
|
||||||
@ -380,7 +401,7 @@ ParseArgs(Atom a, JMPBUFF *FailBuff USES_REGS)
|
|||||||
return TermNil;
|
return TermNil;
|
||||||
}
|
}
|
||||||
/* check for possible overflow against local stack */
|
/* check for possible overflow against local stack */
|
||||||
checkfor((Term) ')', FailBuff PASS_REGS);
|
checkfor(close, FailBuff PASS_REGS);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +540,7 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
|
|||||||
}
|
}
|
||||||
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)
|
if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)
|
||||||
&& Unsigned(LOCAL_tokptr->TokInfo) == 'l')
|
&& Unsigned(LOCAL_tokptr->TokInfo) == 'l')
|
||||||
t = ParseArgs((Atom) t, FailBuff PASS_REGS);
|
t = ParseArgs((Atom) t, (Term)')', FailBuff, 0L PASS_REGS);
|
||||||
else
|
else
|
||||||
t = MkAtomTerm((Atom)t);
|
t = MkAtomTerm((Atom)t);
|
||||||
break;
|
break;
|
||||||
@ -710,6 +731,24 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
|
|||||||
}
|
}
|
||||||
curprio = opprio;
|
curprio = opprio;
|
||||||
continue;
|
continue;
|
||||||
|
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '(' &&
|
||||||
|
IsPosfixOp(AtomEmptyBrackets, &opprio, &oplprio PASS_REGS)
|
||||||
|
&& opprio <= prio && oplprio >= curprio) {
|
||||||
|
t = ParseArgs(AtomEmptyBrackets, (Term)')', FailBuff, t PASS_REGS);
|
||||||
|
curprio = opprio;
|
||||||
|
continue;
|
||||||
|
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '[' &&
|
||||||
|
IsPosfixOp(AtomEmptySquareBrackets, &opprio, &oplprio PASS_REGS)
|
||||||
|
&& opprio <= prio && oplprio >= curprio) {
|
||||||
|
t = ParseArgs(AtomEmptySquareBrackets, (Term)']', FailBuff, t PASS_REGS);
|
||||||
|
curprio = opprio;
|
||||||
|
continue;
|
||||||
|
} else if (Unsigned(LOCAL_tokptr->TokInfo) == '{' &&
|
||||||
|
IsPosfixOp(AtomEmptyCurlyBrackets, &opprio, &oplprio PASS_REGS)
|
||||||
|
&& opprio <= prio && oplprio >= curprio) {
|
||||||
|
t = ParseArgs(AtomEmptyCurlyBrackets, (Term)'}', FailBuff, t PASS_REGS);
|
||||||
|
curprio = opprio;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (LOCAL_tokptr->Tok <= Ord(WString_tok))
|
if (LOCAL_tokptr->Tok <= Ord(WString_tok))
|
||||||
|
41
C/write.c
41
C/write.c
@ -320,7 +320,7 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */
|
|||||||
ob = protect_open_number(wglb, last_minus, sgn);
|
ob = protect_open_number(wglb, last_minus, sgn);
|
||||||
#if THREADS
|
#if THREADS
|
||||||
/* old style writing */
|
/* old style writing */
|
||||||
int found_dot = FALSE, found_exp = FALSE;
|
int found_dot = FALSE;
|
||||||
char *pt = s;
|
char *pt = s;
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
@ -348,7 +348,6 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */
|
|||||||
found_dot = TRUE;
|
found_dot = TRUE;
|
||||||
wrputs(".0", stream);
|
wrputs(".0", stream);
|
||||||
}
|
}
|
||||||
found_exp = TRUE;
|
|
||||||
default:
|
default:
|
||||||
wrputc(ch, stream);
|
wrputc(ch, stream);
|
||||||
}
|
}
|
||||||
@ -751,7 +750,6 @@ check_infinite_loop(Term t, struct rewind_term *x, struct write_globs *wglb)
|
|||||||
static void
|
static void
|
||||||
write_list(Term t, int direction, int depth, struct write_globs *wglb, struct rewind_term *rwt)
|
write_list(Term t, int direction, int depth, struct write_globs *wglb, struct rewind_term *rwt)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
|
||||||
Term ti;
|
Term ti;
|
||||||
struct rewind_term nrwt;
|
struct rewind_term nrwt;
|
||||||
nrwt.parent = rwt;
|
nrwt.parent = rwt;
|
||||||
@ -975,7 +973,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
} else if (!wglb->Ignore_ops &&
|
} else if (!wglb->Ignore_ops &&
|
||||||
Arity == 1 &&
|
( Arity == 1 || atom == AtomEmptyBrackets || atom == AtomEmptyCurlyBrackets || atom == AtomEmptySquareBrackets) &&
|
||||||
Yap_IsPosfixOp(atom, &op, &lp)) {
|
Yap_IsPosfixOp(atom, &op, &lp)) {
|
||||||
Term tleft = ArgOfTerm(1, t);
|
Term tleft = ArgOfTerm(1, t);
|
||||||
|
|
||||||
@ -995,7 +993,40 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
if (bracket_left) {
|
if (bracket_left) {
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
putAtom(atom, wglb->Quote_illegal, wglb);
|
if (Arity > 1) {
|
||||||
|
if (atom == AtomEmptyBrackets) {
|
||||||
|
wrputc('(', wglb->stream);
|
||||||
|
} else if (atom == AtomEmptySquareBrackets) {
|
||||||
|
wrputc('[', wglb->stream);
|
||||||
|
} else if (atom == AtomEmptyCurlyBrackets) {
|
||||||
|
wrputc('{', wglb->stream);
|
||||||
|
}
|
||||||
|
lastw = separator;
|
||||||
|
for (op = 2; op <= Arity; ++op) {
|
||||||
|
if (op == wglb->MaxArgs) {
|
||||||
|
wrputc('.', wglb->stream);
|
||||||
|
wrputc('.', wglb->stream);
|
||||||
|
wrputc('.', wglb->stream);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
writeTerm(from_pointer(RepAppl(t)+op, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt);
|
||||||
|
restore_from_write(&nrwt, wglb);
|
||||||
|
if (op != Arity) {
|
||||||
|
wrputc(',', wglb->stream);
|
||||||
|
lastw = separator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (atom == AtomEmptyBrackets) {
|
||||||
|
wrputc(')', wglb->stream);
|
||||||
|
} else if (atom == AtomEmptySquareBrackets) {
|
||||||
|
wrputc(']', wglb->stream);
|
||||||
|
} else if (atom == AtomEmptyCurlyBrackets) {
|
||||||
|
wrputc('}', wglb->stream);
|
||||||
|
}
|
||||||
|
lastw = separator;
|
||||||
|
} else {
|
||||||
|
putAtom(atom, wglb->Quote_illegal, wglb);
|
||||||
|
}
|
||||||
if (op > p) {
|
if (op > p) {
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
|
11
H/YapTerm.h
11
H/YapTerm.h
@ -101,10 +101,19 @@ typedef void *Atom;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef UInt CELL;
|
typedef UInt CELL;
|
||||||
|
#if HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef uint16_t BITS16;
|
||||||
|
typedef int16_t SBITS16;
|
||||||
|
typedef uint32_t BITS32;
|
||||||
|
#else
|
||||||
typedef UShort BITS16;
|
typedef UShort BITS16;
|
||||||
typedef Short SBITS16;
|
typedef Short SBITS16;
|
||||||
typedef UInt BITS32;
|
typedef UInt BITS32;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define WordSize sizeof(BITS16)
|
#define WordSize sizeof(BITS16)
|
||||||
#define CellSize sizeof(CELL)
|
#define CellSize sizeof(CELL)
|
||||||
|
17
H/clause.h
17
H/clause.h
@ -172,12 +172,13 @@ typedef struct index_t {
|
|||||||
UInt nentries;
|
UInt nentries;
|
||||||
UInt hsize;
|
UInt hsize;
|
||||||
BITS32 *key;
|
BITS32 *key;
|
||||||
CELL *cls;
|
CELL *cls, *bcls;
|
||||||
BITS32 *links;
|
BITS32 *links;
|
||||||
size_t size;
|
size_t size;
|
||||||
yamop *code;
|
yamop *code;
|
||||||
BITS32 *udi_data;
|
BITS32 *udi_data;
|
||||||
void *udi_first, *udi_next;
|
void *udi_first, *udi_next;
|
||||||
|
UInt udi_free_args;
|
||||||
UInt udi_arg;
|
UInt udi_arg;
|
||||||
} Index_t;
|
} Index_t;
|
||||||
|
|
||||||
@ -186,30 +187,30 @@ INLINE_ONLY EXTERN inline BITS32 EXO_ADDRESS_TO_OFFSET(struct index_t *it, CELL
|
|||||||
INLINE_ONLY EXTERN inline BITS32
|
INLINE_ONLY EXTERN inline BITS32
|
||||||
EXO_ADDRESS_TO_OFFSET(struct index_t *it, CELL* ptr)
|
EXO_ADDRESS_TO_OFFSET(struct index_t *it, CELL* ptr)
|
||||||
{
|
{
|
||||||
return 1+(ptr-it->cls);
|
return (ptr-it->cls)/it->arity+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it, UInt off);
|
INLINE_ONLY EXTERN inline CELL *EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32 off);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline CELL *
|
INLINE_ONLY EXTERN inline CELL *
|
||||||
EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32 off)
|
EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32 off)
|
||||||
{
|
{
|
||||||
if (off == 0L)
|
if (off == 0L)
|
||||||
return NULL;
|
return NULL;
|
||||||
return (it->cls-1)+off;
|
return (it->cls)+(off-1)*it->arity;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline BITS32 ADDRESS_TO_LINK(struct index_t *it, CELL *ptr);
|
INLINE_ONLY EXTERN inline BITS32 ADDRESS_TO_LINK(struct index_t *it, BITS32 *ptr);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline BITS32
|
INLINE_ONLY EXTERN inline BITS32
|
||||||
ADDRESS_TO_LINK(struct index_t *it, CELL* ptr)
|
ADDRESS_TO_LINK(struct index_t *it, BITS32* ptr)
|
||||||
{
|
{
|
||||||
return ptr-it->links;
|
return ptr-it->links;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline CELL *LINK_TO_ADDRESS(struct index_t *it, BITS32 off);
|
INLINE_ONLY EXTERN inline BITS32 *LINK_TO_ADDRESS(struct index_t *it, BITS32 off);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline CELL *
|
INLINE_ONLY EXTERN inline BITS32 *
|
||||||
LINK_TO_ADDRESS(struct index_t *it, BITS32 off)
|
LINK_TO_ADDRESS(struct index_t *it, BITS32 off)
|
||||||
{
|
{
|
||||||
return it->links+off;
|
return it->links+off;
|
||||||
|
@ -403,6 +403,8 @@
|
|||||||
|
|
||||||
#define LOCAL_ibnds LOCAL->ibnds_
|
#define LOCAL_ibnds LOCAL->ibnds_
|
||||||
#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_
|
#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_
|
||||||
|
#define LOCAL_exo_it LOCAL->exo_it_
|
||||||
|
#define REMOTE_exo_it(wid) REMOTE(wid)->exo_it_
|
||||||
#define LOCAL_exo_base LOCAL->exo_base_
|
#define LOCAL_exo_base LOCAL->exo_base_
|
||||||
#define REMOTE_exo_base(wid) REMOTE(wid)->exo_base_
|
#define REMOTE_exo_base(wid) REMOTE(wid)->exo_base_
|
||||||
#define LOCAL_exo_arity LOCAL->exo_arity_
|
#define LOCAL_exo_arity LOCAL->exo_arity_
|
||||||
|
@ -227,7 +227,8 @@ typedef struct worker_local {
|
|||||||
Functor FunctorVar_;
|
Functor FunctorVar_;
|
||||||
|
|
||||||
UInt ibnds_[256];
|
UInt ibnds_[256];
|
||||||
void* exo_base_;
|
struct index_t* exo_it_;
|
||||||
|
CELL* exo_base_;
|
||||||
UInt exo_arity_;
|
UInt exo_arity_;
|
||||||
UInt exo_arg_;
|
UInt exo_arg_;
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
AtomArrayType = Yap_LookupAtom("array_type");
|
AtomArrayType = Yap_LookupAtom("array_type");
|
||||||
AtomArrow = Yap_LookupAtom("->");
|
AtomArrow = Yap_LookupAtom("->");
|
||||||
AtomAssert = Yap_LookupAtom(":-");
|
AtomAssert = Yap_LookupAtom(":-");
|
||||||
|
AtomEmptyBrackets = Yap_LookupAtom("()");
|
||||||
|
AtomEmptySquareBrackets = Yap_LookupAtom("[]");
|
||||||
|
AtomEmptyCurlyBrackets = Yap_LookupAtom("{}");
|
||||||
AtomAt = Yap_LookupAtom("at");
|
AtomAt = Yap_LookupAtom("at");
|
||||||
AtomAtom = Yap_LookupAtom("atom");
|
AtomAtom = Yap_LookupAtom("atom");
|
||||||
AtomAtomic = Yap_LookupAtom("atomic");
|
AtomAtomic = Yap_LookupAtom("atomic");
|
||||||
@ -156,6 +159,7 @@
|
|||||||
AtomLT = Yap_LookupAtom("<");
|
AtomLT = Yap_LookupAtom("<");
|
||||||
AtomLastExecuteWithin = Yap_FullLookupAtom("$last_execute_within");
|
AtomLastExecuteWithin = Yap_FullLookupAtom("$last_execute_within");
|
||||||
AtomLeash = Yap_FullLookupAtom("$leash");
|
AtomLeash = Yap_FullLookupAtom("$leash");
|
||||||
|
AtomLeast = Yap_LookupAtom("least");
|
||||||
AtomLength = Yap_FullLookupAtom("length");
|
AtomLength = Yap_FullLookupAtom("length");
|
||||||
AtomList = Yap_LookupAtom("list");
|
AtomList = Yap_LookupAtom("list");
|
||||||
AtomLive = Yap_FullLookupAtom("$live");
|
AtomLive = Yap_FullLookupAtom("$live");
|
||||||
@ -164,14 +168,17 @@
|
|||||||
AtomLocalSp = Yap_LookupAtom("local_sp");
|
AtomLocalSp = Yap_LookupAtom("local_sp");
|
||||||
AtomLocalTrie = Yap_LookupAtom("local_trie");
|
AtomLocalTrie = Yap_LookupAtom("local_trie");
|
||||||
AtomMax = Yap_LookupAtom("max");
|
AtomMax = Yap_LookupAtom("max");
|
||||||
|
AtomMaximum = Yap_LookupAtom("maximum");
|
||||||
AtomMaxArity = Yap_LookupAtom("max_arity");
|
AtomMaxArity = Yap_LookupAtom("max_arity");
|
||||||
AtomMaxFiles = Yap_LookupAtom("max_files");
|
AtomMaxFiles = Yap_LookupAtom("max_files");
|
||||||
AtomMegaClause = Yap_FullLookupAtom("$mega_clause");
|
AtomMegaClause = Yap_FullLookupAtom("$mega_clause");
|
||||||
AtomMetaCall = Yap_FullLookupAtom("$call");
|
AtomMetaCall = Yap_FullLookupAtom("$call");
|
||||||
AtomMfClause = Yap_FullLookupAtom("$mf_clause");
|
AtomMfClause = Yap_FullLookupAtom("$mf_clause");
|
||||||
AtomMin = Yap_LookupAtom("min");
|
AtomMin = Yap_LookupAtom("min");
|
||||||
|
AtomMinimum = Yap_LookupAtom("minimum");
|
||||||
AtomMinus = Yap_LookupAtom("-");
|
AtomMinus = Yap_LookupAtom("-");
|
||||||
AtomModify = Yap_LookupAtom("modify");
|
AtomModify = Yap_LookupAtom("modify");
|
||||||
|
AtomMost = Yap_LookupAtom("most");
|
||||||
AtomMultiFile = Yap_FullLookupAtom("$mf");
|
AtomMultiFile = Yap_FullLookupAtom("$mf");
|
||||||
AtomMutable = Yap_LookupAtom("mutable");
|
AtomMutable = Yap_LookupAtom("mutable");
|
||||||
AtomMutableVariable = Yap_FullLookupAtom("$mutable_variable");
|
AtomMutableVariable = Yap_FullLookupAtom("$mutable_variable");
|
||||||
|
@ -227,6 +227,7 @@ static void InitWorker(int wid) {
|
|||||||
REMOTE_FunctorVar(wid) = FunctorVar;
|
REMOTE_FunctorVar(wid) = FunctorVar;
|
||||||
|
|
||||||
|
|
||||||
|
REMOTE_exo_it(wid) = NULL;
|
||||||
REMOTE_exo_base(wid) = NULL;
|
REMOTE_exo_base(wid) = NULL;
|
||||||
REMOTE_exo_arity(wid) = 0;
|
REMOTE_exo_arity(wid) = 0;
|
||||||
REMOTE_exo_arg(wid) = 0;
|
REMOTE_exo_arg(wid) = 0;
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
AtomArrayType = AtomAdjust(AtomArrayType);
|
AtomArrayType = AtomAdjust(AtomArrayType);
|
||||||
AtomArrow = AtomAdjust(AtomArrow);
|
AtomArrow = AtomAdjust(AtomArrow);
|
||||||
AtomAssert = AtomAdjust(AtomAssert);
|
AtomAssert = AtomAdjust(AtomAssert);
|
||||||
|
AtomEmptyBrackets = AtomAdjust(AtomEmptyBrackets);
|
||||||
|
AtomEmptySquareBrackets = AtomAdjust(AtomEmptySquareBrackets);
|
||||||
|
AtomEmptyCurlyBrackets = AtomAdjust(AtomEmptyCurlyBrackets);
|
||||||
AtomAt = AtomAdjust(AtomAt);
|
AtomAt = AtomAdjust(AtomAt);
|
||||||
AtomAtom = AtomAdjust(AtomAtom);
|
AtomAtom = AtomAdjust(AtomAtom);
|
||||||
AtomAtomic = AtomAdjust(AtomAtomic);
|
AtomAtomic = AtomAdjust(AtomAtomic);
|
||||||
@ -156,6 +159,7 @@
|
|||||||
AtomLT = AtomAdjust(AtomLT);
|
AtomLT = AtomAdjust(AtomLT);
|
||||||
AtomLastExecuteWithin = AtomAdjust(AtomLastExecuteWithin);
|
AtomLastExecuteWithin = AtomAdjust(AtomLastExecuteWithin);
|
||||||
AtomLeash = AtomAdjust(AtomLeash);
|
AtomLeash = AtomAdjust(AtomLeash);
|
||||||
|
AtomLeast = AtomAdjust(AtomLeast);
|
||||||
AtomLength = AtomAdjust(AtomLength);
|
AtomLength = AtomAdjust(AtomLength);
|
||||||
AtomList = AtomAdjust(AtomList);
|
AtomList = AtomAdjust(AtomList);
|
||||||
AtomLive = AtomAdjust(AtomLive);
|
AtomLive = AtomAdjust(AtomLive);
|
||||||
@ -164,14 +168,17 @@
|
|||||||
AtomLocalSp = AtomAdjust(AtomLocalSp);
|
AtomLocalSp = AtomAdjust(AtomLocalSp);
|
||||||
AtomLocalTrie = AtomAdjust(AtomLocalTrie);
|
AtomLocalTrie = AtomAdjust(AtomLocalTrie);
|
||||||
AtomMax = AtomAdjust(AtomMax);
|
AtomMax = AtomAdjust(AtomMax);
|
||||||
|
AtomMaximum = AtomAdjust(AtomMaximum);
|
||||||
AtomMaxArity = AtomAdjust(AtomMaxArity);
|
AtomMaxArity = AtomAdjust(AtomMaxArity);
|
||||||
AtomMaxFiles = AtomAdjust(AtomMaxFiles);
|
AtomMaxFiles = AtomAdjust(AtomMaxFiles);
|
||||||
AtomMegaClause = AtomAdjust(AtomMegaClause);
|
AtomMegaClause = AtomAdjust(AtomMegaClause);
|
||||||
AtomMetaCall = AtomAdjust(AtomMetaCall);
|
AtomMetaCall = AtomAdjust(AtomMetaCall);
|
||||||
AtomMfClause = AtomAdjust(AtomMfClause);
|
AtomMfClause = AtomAdjust(AtomMfClause);
|
||||||
AtomMin = AtomAdjust(AtomMin);
|
AtomMin = AtomAdjust(AtomMin);
|
||||||
|
AtomMinimum = AtomAdjust(AtomMinimum);
|
||||||
AtomMinus = AtomAdjust(AtomMinus);
|
AtomMinus = AtomAdjust(AtomMinus);
|
||||||
AtomModify = AtomAdjust(AtomModify);
|
AtomModify = AtomAdjust(AtomModify);
|
||||||
|
AtomMost = AtomAdjust(AtomMost);
|
||||||
AtomMultiFile = AtomAdjust(AtomMultiFile);
|
AtomMultiFile = AtomAdjust(AtomMultiFile);
|
||||||
AtomMutable = AtomAdjust(AtomMutable);
|
AtomMutable = AtomAdjust(AtomMutable);
|
||||||
AtomMutableVariable = AtomAdjust(AtomMutableVariable);
|
AtomMutableVariable = AtomAdjust(AtomMutableVariable);
|
||||||
|
@ -230,6 +230,7 @@ static void RestoreWorker(int wid USES_REGS) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
14
H/tatoms.h
14
H/tatoms.h
@ -38,6 +38,12 @@
|
|||||||
#define AtomArrow Yap_heap_regs->AtomArrow_
|
#define AtomArrow Yap_heap_regs->AtomArrow_
|
||||||
Atom AtomAssert_;
|
Atom AtomAssert_;
|
||||||
#define AtomAssert Yap_heap_regs->AtomAssert_
|
#define AtomAssert Yap_heap_regs->AtomAssert_
|
||||||
|
Atom AtomEmptyBrackets_;
|
||||||
|
#define AtomEmptyBrackets Yap_heap_regs->AtomEmptyBrackets_
|
||||||
|
Atom AtomEmptySquareBrackets_;
|
||||||
|
#define AtomEmptySquareBrackets Yap_heap_regs->AtomEmptySquareBrackets_
|
||||||
|
Atom AtomEmptyCurlyBrackets_;
|
||||||
|
#define AtomEmptyCurlyBrackets Yap_heap_regs->AtomEmptyCurlyBrackets_
|
||||||
Atom AtomAt_;
|
Atom AtomAt_;
|
||||||
#define AtomAt Yap_heap_regs->AtomAt_
|
#define AtomAt Yap_heap_regs->AtomAt_
|
||||||
Atom AtomAtom_;
|
Atom AtomAtom_;
|
||||||
@ -310,6 +316,8 @@
|
|||||||
#define AtomLastExecuteWithin Yap_heap_regs->AtomLastExecuteWithin_
|
#define AtomLastExecuteWithin Yap_heap_regs->AtomLastExecuteWithin_
|
||||||
Atom AtomLeash_;
|
Atom AtomLeash_;
|
||||||
#define AtomLeash Yap_heap_regs->AtomLeash_
|
#define AtomLeash Yap_heap_regs->AtomLeash_
|
||||||
|
Atom AtomLeast_;
|
||||||
|
#define AtomLeast Yap_heap_regs->AtomLeast_
|
||||||
Atom AtomLength_;
|
Atom AtomLength_;
|
||||||
#define AtomLength Yap_heap_regs->AtomLength_
|
#define AtomLength Yap_heap_regs->AtomLength_
|
||||||
Atom AtomList_;
|
Atom AtomList_;
|
||||||
@ -326,6 +334,8 @@
|
|||||||
#define AtomLocalTrie Yap_heap_regs->AtomLocalTrie_
|
#define AtomLocalTrie Yap_heap_regs->AtomLocalTrie_
|
||||||
Atom AtomMax_;
|
Atom AtomMax_;
|
||||||
#define AtomMax Yap_heap_regs->AtomMax_
|
#define AtomMax Yap_heap_regs->AtomMax_
|
||||||
|
Atom AtomMaximum_;
|
||||||
|
#define AtomMaximum Yap_heap_regs->AtomMaximum_
|
||||||
Atom AtomMaxArity_;
|
Atom AtomMaxArity_;
|
||||||
#define AtomMaxArity Yap_heap_regs->AtomMaxArity_
|
#define AtomMaxArity Yap_heap_regs->AtomMaxArity_
|
||||||
Atom AtomMaxFiles_;
|
Atom AtomMaxFiles_;
|
||||||
@ -338,10 +348,14 @@
|
|||||||
#define AtomMfClause Yap_heap_regs->AtomMfClause_
|
#define AtomMfClause Yap_heap_regs->AtomMfClause_
|
||||||
Atom AtomMin_;
|
Atom AtomMin_;
|
||||||
#define AtomMin Yap_heap_regs->AtomMin_
|
#define AtomMin Yap_heap_regs->AtomMin_
|
||||||
|
Atom AtomMinimum_;
|
||||||
|
#define AtomMinimum Yap_heap_regs->AtomMinimum_
|
||||||
Atom AtomMinus_;
|
Atom AtomMinus_;
|
||||||
#define AtomMinus Yap_heap_regs->AtomMinus_
|
#define AtomMinus Yap_heap_regs->AtomMinus_
|
||||||
Atom AtomModify_;
|
Atom AtomModify_;
|
||||||
#define AtomModify Yap_heap_regs->AtomModify_
|
#define AtomModify Yap_heap_regs->AtomModify_
|
||||||
|
Atom AtomMost_;
|
||||||
|
#define AtomMost Yap_heap_regs->AtomMost_
|
||||||
Atom AtomMultiFile_;
|
Atom AtomMultiFile_;
|
||||||
#define AtomMultiFile Yap_heap_regs->AtomMultiFile_
|
#define AtomMultiFile Yap_heap_regs->AtomMultiFile_
|
||||||
Atom AtomMutable_;
|
Atom AtomMutable_;
|
||||||
|
14
docs/yap.tex
14
docs/yap.tex
@ -14400,7 +14400,8 @@ Letter = 'D',
|
|||||||
Number = 123456789 ?
|
Number = 123456789 ?
|
||||||
yes
|
yes
|
||||||
@end example
|
@end example
|
||||||
generates the query @example
|
generates the query
|
||||||
|
@example
|
||||||
SELECT A.Letter , 'John Doe' , A.Number
|
SELECT A.Letter , 'John Doe' , A.Number
|
||||||
FROM 'phonebook' A
|
FROM 'phonebook' A
|
||||||
WHERE A.Name = 'John Doe';
|
WHERE A.Name = 'John Doe';
|
||||||
@ -14464,7 +14465,8 @@ above. Assuming the declaration:
|
|||||||
yes
|
yes
|
||||||
@end example
|
@end example
|
||||||
we
|
we
|
||||||
write:@example
|
write:
|
||||||
|
@example
|
||||||
?- db_view(direct_cycle(A,B),(edge(A,B), edge(B,A))).
|
?- db_view(direct_cycle(A,B),(edge(A,B), edge(B,A))).
|
||||||
yes
|
yes
|
||||||
?- direct_cycle(A,B)).
|
?- direct_cycle(A,B)).
|
||||||
@ -14472,7 +14474,8 @@ A = 10,
|
|||||||
B = 20 ?
|
B = 20 ?
|
||||||
@end example
|
@end example
|
||||||
This call generates the SQL
|
This call generates the SQL
|
||||||
statement: @example
|
statement:
|
||||||
|
@example
|
||||||
SELECT A.attr1 , A.attr2
|
SELECT A.attr1 , A.attr2
|
||||||
FROM Edge A , Edge B
|
FROM Edge A , Edge B
|
||||||
WHERE B.attr1 = A.attr2 AND B.attr2 = A.attr1;
|
WHERE B.attr1 = A.attr2 AND B.attr2 = A.attr1;
|
||||||
@ -14897,7 +14900,8 @@ yes
|
|||||||
The MySQL C API permits two modes for transferring the data generated by
|
The MySQL C API permits two modes for transferring the data generated by
|
||||||
a query to the client, in our case YAP. The first mode, and the default
|
a query to the client, in our case YAP. The first mode, and the default
|
||||||
mode used by the MYDDAS-MySQL, is to store the result. This mode copies all the
|
mode used by the MYDDAS-MySQL, is to store the result. This mode copies all the
|
||||||
information generated to the client side.@example
|
information generated to the client side.
|
||||||
|
@example
|
||||||
?- db_my_result_set(X).
|
?- db_my_result_set(X).
|
||||||
X=store_result
|
X=store_result
|
||||||
yes
|
yes
|
||||||
@ -16182,7 +16186,7 @@ loop(Env) :-
|
|||||||
loop(NewEnv).
|
loop(NewEnv).
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@end table
|
@end itemize
|
||||||
|
|
||||||
@section Deterministic Programs
|
@section Deterministic Programs
|
||||||
|
|
||||||
|
@ -2265,8 +2265,8 @@ PL_discard_foreign_frame(fid_t f)
|
|||||||
LOCAL_execution = env->old;
|
LOCAL_execution = env->old;
|
||||||
ASP = LCL0-CurSlot;
|
ASP = LCL0-CurSlot;
|
||||||
B = B->cp_b;
|
B = B->cp_b;
|
||||||
EX = NULL;
|
//LOCAL_BallTerm = EX;
|
||||||
LOCAL_BallTerm = EX;
|
//EX = NULL;
|
||||||
free(env);
|
free(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2331,7 +2331,7 @@ X_API void PL_close_query(qid_t qi)
|
|||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
EX = NULL;
|
EX = NULL;
|
||||||
if (EX && !(qi->flags & (PL_Q_CATCH_EXCEPTION|PL_Q_PASS_EXCEPTION))) {
|
if (EX && !(qi->flags & (PL_Q_CATCH_EXCEPTION))) {
|
||||||
EX = NULL;
|
EX = NULL;
|
||||||
}
|
}
|
||||||
/* need to implement backtracking here */
|
/* need to implement backtracking here */
|
||||||
|
@ -9,13 +9,12 @@
|
|||||||
:- module(exo_interval,
|
:- module(exo_interval,
|
||||||
[max/2,
|
[max/2,
|
||||||
min/2,
|
min/2,
|
||||||
|
any/2,
|
||||||
max/1,
|
max/1,
|
||||||
min/1,
|
min/1,
|
||||||
any/2,
|
maximum/1,
|
||||||
|
minimum/1,
|
||||||
any/1,
|
any/1,
|
||||||
max/3,
|
|
||||||
min/3,
|
|
||||||
any/3,
|
|
||||||
(#<)/2,
|
(#<)/2,
|
||||||
(#>)/2,
|
(#>)/2,
|
||||||
(#=<)/2,
|
(#=<)/2,
|
||||||
@ -27,31 +26,33 @@
|
|||||||
op(700, xfx, (#=<)),
|
op(700, xfx, (#=<)),
|
||||||
op(700, xfx, (#=))]).
|
op(700, xfx, (#=))]).
|
||||||
|
|
||||||
:- meta_predicate max(?,0,?), min(?,0,?), any(?,0,?).
|
:- meta_predicate max(?,0), min(?,0), any(?,0).
|
||||||
|
|
||||||
max(X, G, X) :-
|
max(X, G) :-
|
||||||
insert_atts(X, i(_,_,max)),
|
insert_atts(X, i(_,_,max)),
|
||||||
call(G).
|
call(G).
|
||||||
|
|
||||||
min(X, G, X) :-
|
min(X, G) :-
|
||||||
insert_atts(X, i(_,_,min)),
|
insert_atts(X, i(_,_,min)),
|
||||||
call(G).
|
call(G).
|
||||||
|
|
||||||
max(X, X) :-
|
|
||||||
insert_atts(X, i(_,_,max)).
|
|
||||||
|
|
||||||
min(X, X) :-
|
|
||||||
insert_atts(X, i(_,_,min)).
|
|
||||||
|
|
||||||
max(X) :-
|
max(X) :-
|
||||||
insert_atts(X, i(_,_,max)).
|
insert_atts(X, i(_,_,max)).
|
||||||
|
|
||||||
|
maximum(X) :-
|
||||||
|
insert_atts(X, i(_,_,maximum)).
|
||||||
|
|
||||||
any(X) :-
|
any(X) :-
|
||||||
insert_atts(X, i(_,_,any)).
|
insert_atts(X, i(_,_,any)).
|
||||||
|
|
||||||
min(X) :-
|
min(X) :-
|
||||||
insert_atts(X, i(_,_,min)).
|
insert_atts(X, i(_,_,min)).
|
||||||
|
|
||||||
|
minimum(X) :-
|
||||||
|
insert_atts(X, i(_,_,minimum)).
|
||||||
|
|
||||||
|
least(X) :-
|
||||||
|
insert_atts(X, i(_,_,least)).
|
||||||
|
|
||||||
X #> Y :-
|
X #> Y :-
|
||||||
( var(X) -> insert_atts(X, i(Y,_,_))
|
( var(X) -> insert_atts(X, i(Y,_,_))
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
:- module(nb, [
|
:- module(nb, [
|
||||||
|
nb_create_accumulator/2,
|
||||||
|
nb_add_to_accumulator/2,
|
||||||
|
nb_accumulator_value/2,
|
||||||
nb_queue/1,
|
nb_queue/1,
|
||||||
nb_queue/2,
|
nb_queue/2,
|
||||||
nb_queue_close/3,
|
nb_queue_close/3,
|
||||||
|
@ -25,6 +25,9 @@ A ArrayOverflow N "array_overflow"
|
|||||||
A ArrayType N "array_type"
|
A ArrayType N "array_type"
|
||||||
A Arrow N "->"
|
A Arrow N "->"
|
||||||
A Assert N ":-"
|
A Assert N ":-"
|
||||||
|
A EmptyBrackets N "()"
|
||||||
|
A EmptySquareBrackets N "[]"
|
||||||
|
A EmptyCurlyBrackets N "{}"
|
||||||
A At N "at"
|
A At N "at"
|
||||||
A Atom N "atom"
|
A Atom N "atom"
|
||||||
A Atomic N "atomic"
|
A Atomic N "atomic"
|
||||||
@ -161,6 +164,7 @@ A LOOP N "_LOOP_"
|
|||||||
A LT N "<"
|
A LT N "<"
|
||||||
A LastExecuteWithin F "$last_execute_within"
|
A LastExecuteWithin F "$last_execute_within"
|
||||||
A Leash F "$leash"
|
A Leash F "$leash"
|
||||||
|
A Least N "least"
|
||||||
A Length F "length"
|
A Length F "length"
|
||||||
A List N "list"
|
A List N "list"
|
||||||
A Live F "$live"
|
A Live F "$live"
|
||||||
@ -169,14 +173,17 @@ A Local N "local"
|
|||||||
A LocalSp N "local_sp"
|
A LocalSp N "local_sp"
|
||||||
A LocalTrie N "local_trie"
|
A LocalTrie N "local_trie"
|
||||||
A Max N "max"
|
A Max N "max"
|
||||||
|
A Maximum N "maximum"
|
||||||
A MaxArity N "max_arity"
|
A MaxArity N "max_arity"
|
||||||
A MaxFiles N "max_files"
|
A MaxFiles N "max_files"
|
||||||
A MegaClause F "$mega_clause"
|
A MegaClause F "$mega_clause"
|
||||||
A MetaCall F "$call"
|
A MetaCall F "$call"
|
||||||
A MfClause F "$mf_clause"
|
A MfClause F "$mf_clause"
|
||||||
A Min N "min"
|
A Min N "min"
|
||||||
|
A Minimum N "minimum"
|
||||||
A Minus N "-"
|
A Minus N "-"
|
||||||
A Modify N "modify"
|
A Modify N "modify"
|
||||||
|
A Most N "most"
|
||||||
A MultiFile F "$mf"
|
A MultiFile F "$mf"
|
||||||
A Mutable N "mutable"
|
A Mutable N "mutable"
|
||||||
A MutableVariable F "$mutable_variable"
|
A MutableVariable F "$mutable_variable"
|
||||||
|
@ -255,10 +255,11 @@ yamop *ImportFAILCODE =NULL
|
|||||||
|
|
||||||
Functor FunctorVar =FunctorVar
|
Functor FunctorVar =FunctorVar
|
||||||
|
|
||||||
// exo indexingxb
|
// exo indexing
|
||||||
|
|
||||||
UInt ibnds[256] void
|
UInt ibnds[256] void
|
||||||
BITS32* exo_base =NULL
|
struct index_t* exo_it =NULL
|
||||||
|
CELL* exo_base =NULL
|
||||||
UInt exo_arity =0
|
UInt exo_arity =0
|
||||||
UInt exo_arg =0
|
UInt exo_arg =0
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ process_arg(Sk, Id, _I) -->
|
|||||||
% if :: been used before for this skolem
|
% if :: been used before for this skolem
|
||||||
% just keep on using it,
|
% just keep on using it,
|
||||||
% otherwise, assume it is t,f
|
% otherwise, assume it is t,f
|
||||||
( \+ \+ skolem(Sk,_D) -> true ; new_skolem(Sk,[t,f]) ),
|
( \+ \+ skolem(Sk,_D) -> true ; new_skolem(Sk,[f,t]) ),
|
||||||
assert(skolem_in(Sk, Id))
|
assert(skolem_in(Sk, Id))
|
||||||
},
|
},
|
||||||
[Sk].
|
[Sk].
|
||||||
|
@ -1,123 +1,123 @@
|
|||||||
|
|
||||||
/* start css.sty */
|
/* start css.sty */
|
||||||
.cmr-7{font-size:70%;}
|
.cmr-7{font-size:70%;}
|
||||||
.cmmi-7{font-size:70%;font-style: italic;}
|
.cmmi-7{font-size:70%;font-style: italic;}
|
||||||
.cmmi-10{font-style: italic;}
|
.cmmi-10{font-style: italic;}
|
||||||
.cmr-17{font-size:170%;}
|
.cmr-17{font-size:170%;}
|
||||||
.cmtt-12x-x-144{font-size:172%;font-family: monospace;}
|
.cmtt-12x-x-144{font-size:172%;font-family: monospace;}
|
||||||
.cmtt-12x-x-144{font-family: monospace;}
|
.cmtt-12x-x-144{font-family: monospace;}
|
||||||
.cmr-12{font-size:120%;}
|
.cmr-12{font-size:120%;}
|
||||||
.cmtt-10{font-family: monospace;}
|
.cmtt-10{font-family: monospace;}
|
||||||
.cmtt-10{font-family: monospace;}
|
.cmtt-10{font-family: monospace;}
|
||||||
.cmbx-10{ font-weight: bold;}
|
.cmbx-10{ font-weight: bold;}
|
||||||
.cmti-10{ font-style: italic;}
|
.cmti-10{ font-style: italic;}
|
||||||
p.noindent { text-indent: 0em }
|
p.noindent { text-indent: 0em }
|
||||||
td p.noindent { text-indent: 0em; margin-top:0em; }
|
td p.noindent { text-indent: 0em; margin-top:0em; }
|
||||||
p.nopar { text-indent: 0em; }
|
p.nopar { text-indent: 0em; }
|
||||||
p.indent{ text-indent: 1.5em }
|
p.indent{ text-indent: 1.5em }
|
||||||
@media print {div.crosslinks {visibility:hidden;}}
|
@media print {div.crosslinks {visibility:hidden;}}
|
||||||
a img { border-top: 0; border-left: 0; border-right: 0; }
|
a img { border-top: 0; border-left: 0; border-right: 0; }
|
||||||
center { margin-top:1em; margin-bottom:1em; }
|
center { margin-top:1em; margin-bottom:1em; }
|
||||||
td center { margin-top:0em; margin-bottom:0em; }
|
td center { margin-top:0em; margin-bottom:0em; }
|
||||||
.Canvas { position:relative; }
|
.Canvas { position:relative; }
|
||||||
img.math{vertical-align:middle;}
|
img.math{vertical-align:middle;}
|
||||||
li p.indent { text-indent: 0em }
|
li p.indent { text-indent: 0em }
|
||||||
li p:first-child{ margin-top:0em; }
|
li p:first-child{ margin-top:0em; }
|
||||||
li p:last-child, li div:last-child { margin-bottom:0.5em; }
|
li p:last-child, li div:last-child { margin-bottom:0.5em; }
|
||||||
li p~ul:last-child, li p~ol:last-child{ margin-bottom:0.5em; }
|
li p~ul:last-child, li p~ol:last-child{ margin-bottom:0.5em; }
|
||||||
.enumerate1 {list-style-type:decimal;}
|
.enumerate1 {list-style-type:decimal;}
|
||||||
.enumerate2 {list-style-type:lower-alpha;}
|
.enumerate2 {list-style-type:lower-alpha;}
|
||||||
.enumerate3 {list-style-type:lower-roman;}
|
.enumerate3 {list-style-type:lower-roman;}
|
||||||
.enumerate4 {list-style-type:upper-alpha;}
|
.enumerate4 {list-style-type:upper-alpha;}
|
||||||
div.newtheorem { margin-bottom: 2em; margin-top: 2em;}
|
div.newtheorem { margin-bottom: 2em; margin-top: 2em;}
|
||||||
.obeylines-h,.obeylines-v {white-space: nowrap; }
|
.obeylines-h,.obeylines-v {white-space: nowrap; }
|
||||||
div.obeylines-v p { margin-top:0; margin-bottom:0; }
|
div.obeylines-v p { margin-top:0; margin-bottom:0; }
|
||||||
.overline{ text-decoration:overline; }
|
.overline{ text-decoration:overline; }
|
||||||
.overline img{ border-top: 1px solid black; }
|
.overline img{ border-top: 1px solid black; }
|
||||||
td.displaylines {text-align:center; white-space:nowrap;}
|
td.displaylines {text-align:center; white-space:nowrap;}
|
||||||
.centerline {text-align:center;}
|
.centerline {text-align:center;}
|
||||||
.rightline {text-align:right;}
|
.rightline {text-align:right;}
|
||||||
div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; }
|
div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; }
|
||||||
.fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
.fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
||||||
div.fbox {display:table}
|
div.fbox {display:table}
|
||||||
div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
||||||
div.minipage{width:100%;}
|
div.minipage{width:100%;}
|
||||||
div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;}
|
div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;}
|
||||||
div.center div {text-align: left;}
|
div.center div {text-align: left;}
|
||||||
div.flushright, div.flushright div.flushright {text-align: right;}
|
div.flushright, div.flushright div.flushright {text-align: right;}
|
||||||
div.flushright div {text-align: left;}
|
div.flushright div {text-align: left;}
|
||||||
div.flushleft {text-align: left;}
|
div.flushleft {text-align: left;}
|
||||||
.underline{ text-decoration:underline; }
|
.underline{ text-decoration:underline; }
|
||||||
.underline img{ border-bottom: 1px solid black; margin-bottom:1pt; }
|
.underline img{ border-bottom: 1px solid black; margin-bottom:1pt; }
|
||||||
.framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
.framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
|
||||||
.framebox-c {text-align:center;}
|
.framebox-c {text-align:center;}
|
||||||
.framebox-l {text-align:left;}
|
.framebox-l {text-align:left;}
|
||||||
.framebox-r {text-align:right;}
|
.framebox-r {text-align:right;}
|
||||||
span.thank-mark{ vertical-align: super }
|
span.thank-mark{ vertical-align: super }
|
||||||
span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; }
|
span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; }
|
||||||
div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; }
|
div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; }
|
||||||
table.tabular td p{margin-top:0em;}
|
table.tabular td p{margin-top:0em;}
|
||||||
table.tabular {margin-left: auto; margin-right: auto;}
|
table.tabular {margin-left: auto; margin-right: auto;}
|
||||||
td p:first-child{ margin-top:0em; }
|
td p:first-child{ margin-top:0em; }
|
||||||
td p:last-child{ margin-bottom:0em; }
|
td p:last-child{ margin-bottom:0em; }
|
||||||
div.td00{ margin-left:0pt; margin-right:0pt; }
|
div.td00{ margin-left:0pt; margin-right:0pt; }
|
||||||
div.td01{ margin-left:0pt; margin-right:5pt; }
|
div.td01{ margin-left:0pt; margin-right:5pt; }
|
||||||
div.td10{ margin-left:5pt; margin-right:0pt; }
|
div.td10{ margin-left:5pt; margin-right:0pt; }
|
||||||
div.td11{ margin-left:5pt; margin-right:5pt; }
|
div.td11{ margin-left:5pt; margin-right:5pt; }
|
||||||
table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
|
table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
|
||||||
td.td00{ padding-left:0pt; padding-right:0pt; }
|
td.td00{ padding-left:0pt; padding-right:0pt; }
|
||||||
td.td01{ padding-left:0pt; padding-right:5pt; }
|
td.td01{ padding-left:0pt; padding-right:5pt; }
|
||||||
td.td10{ padding-left:5pt; padding-right:0pt; }
|
td.td10{ padding-left:5pt; padding-right:0pt; }
|
||||||
td.td11{ padding-left:5pt; padding-right:5pt; }
|
td.td11{ padding-left:5pt; padding-right:5pt; }
|
||||||
table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
|
table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
|
||||||
.hline hr, .cline hr{ height : 1px; margin:0px; }
|
.hline hr, .cline hr{ height : 1px; margin:0px; }
|
||||||
.tabbing-right {text-align:right;}
|
.tabbing-right {text-align:right;}
|
||||||
span.TEX {letter-spacing: -0.125em; }
|
span.TEX {letter-spacing: -0.125em; }
|
||||||
span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;}
|
span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;}
|
||||||
a span.TEX span.E {text-decoration: none; }
|
a span.TEX span.E {text-decoration: none; }
|
||||||
span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;}
|
span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;}
|
||||||
span.LATEX span.TEX{ position:relative; left: -0.4em; }
|
span.LATEX span.TEX{ position:relative; left: -0.4em; }
|
||||||
div.float, div.figure {margin-left: auto; margin-right: auto;}
|
div.float, div.figure {margin-left: auto; margin-right: auto;}
|
||||||
div.float img {text-align:center;}
|
div.float img {text-align:center;}
|
||||||
div.figure img {text-align:center;}
|
div.figure img {text-align:center;}
|
||||||
.marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;}
|
.marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;}
|
||||||
.marginpar p{margin-top:0.4em; margin-bottom:0.4em;}
|
.marginpar p{margin-top:0.4em; margin-bottom:0.4em;}
|
||||||
table.equation {width:100%;}
|
table.equation {width:100%;}
|
||||||
.equation td{text-align:center; }
|
.equation td{text-align:center; }
|
||||||
td.equation { margin-top:1em; margin-bottom:1em; }
|
td.equation { margin-top:1em; margin-bottom:1em; }
|
||||||
td.equation-label { width:5%; text-align:center; }
|
td.equation-label { width:5%; text-align:center; }
|
||||||
td.eqnarray4 { width:5%; white-space: normal; }
|
td.eqnarray4 { width:5%; white-space: normal; }
|
||||||
td.eqnarray2 { width:5%; }
|
td.eqnarray2 { width:5%; }
|
||||||
table.eqnarray-star, table.eqnarray {width:100%;}
|
table.eqnarray-star, table.eqnarray {width:100%;}
|
||||||
div.eqnarray{text-align:center;}
|
div.eqnarray{text-align:center;}
|
||||||
div.array {text-align:center;}
|
div.array {text-align:center;}
|
||||||
div.pmatrix {text-align:center;}
|
div.pmatrix {text-align:center;}
|
||||||
table.pmatrix {width:100%;}
|
table.pmatrix {width:100%;}
|
||||||
span.pmatrix img{vertical-align:middle;}
|
span.pmatrix img{vertical-align:middle;}
|
||||||
div.pmatrix {text-align:center;}
|
div.pmatrix {text-align:center;}
|
||||||
table.pmatrix {width:100%;}
|
table.pmatrix {width:100%;}
|
||||||
span.bar-css {text-decoration:overline;}
|
span.bar-css {text-decoration:overline;}
|
||||||
img.cdots{vertical-align:middle;}
|
img.cdots{vertical-align:middle;}
|
||||||
.partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;}
|
.partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;}
|
||||||
.index-item, .index-subitem, .index-subsubitem {display:block}
|
.index-item, .index-subitem, .index-subsubitem {display:block}
|
||||||
div.caption {text-indent:-2em; margin-left:3em; margin-right:1em; text-align:left;}
|
div.caption {text-indent:-2em; margin-left:3em; margin-right:1em; text-align:left;}
|
||||||
div.caption span.id{font-weight: bold; white-space: nowrap; }
|
div.caption span.id{font-weight: bold; white-space: nowrap; }
|
||||||
h1.partHead{text-align: center}
|
h1.partHead{text-align: center}
|
||||||
p.bibitem { text-indent: -2em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
|
p.bibitem { text-indent: -2em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
|
||||||
p.bibitem-p { text-indent: 0em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
|
p.bibitem-p { text-indent: 0em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
|
||||||
.paragraphHead, .likeparagraphHead { margin-top:2em; font-weight: bold;}
|
.paragraphHead, .likeparagraphHead { margin-top:2em; font-weight: bold;}
|
||||||
.subparagraphHead, .likesubparagraphHead { font-weight: bold;}
|
.subparagraphHead, .likesubparagraphHead { font-weight: bold;}
|
||||||
.quote {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; margin-right:1em; text-align:justify;}
|
.quote {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; margin-right:1em; text-align:justify;}
|
||||||
.verse{white-space:nowrap; margin-left:2em}
|
.verse{white-space:nowrap; margin-left:2em}
|
||||||
div.maketitle {text-align:center;}
|
div.maketitle {text-align:center;}
|
||||||
h2.titleHead{text-align:center;}
|
h2.titleHead{text-align:center;}
|
||||||
div.maketitle{ margin-bottom: 2em; }
|
div.maketitle{ margin-bottom: 2em; }
|
||||||
div.author, div.date {text-align:center;}
|
div.author, div.date {text-align:center;}
|
||||||
div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; }
|
div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; }
|
||||||
div.author{white-space: nowrap;}
|
div.author{white-space: nowrap;}
|
||||||
.quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; }
|
.quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; }
|
||||||
.abstract p {margin-left:5%; margin-right:5%;}
|
.abstract p {margin-left:5%; margin-right:5%;}
|
||||||
div.abstract {width:100%;}
|
div.abstract {width:100%;}
|
||||||
.figure img.graphics {margin-left:10%;}
|
.figure img.graphics {margin-left:10%;}
|
||||||
/* end css.sty */
|
/* end css.sty */
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -31,10 +31,10 @@ fabrizio.riguzzi@unife.it}
|
|||||||
\texttt{cplint} is a suite of programs for reasoning with ICL \cite{DBLP:journals/ai/Poole97}, LPADs \cite{VenVer03-TR,VenVer04-ICLP04-IC} and CP-logic programs \cite{VenDenBru-JELIA06,DBLP:journals/tplp/VennekensDB09}. It contains programs both for inference and learning.
|
\texttt{cplint} is a suite of programs for reasoning with ICL \cite{DBLP:journals/ai/Poole97}, LPADs \cite{VenVer03-TR,VenVer04-ICLP04-IC} and CP-logic programs \cite{VenDenBru-JELIA06,DBLP:journals/tplp/VennekensDB09}. It contains programs both for inference and learning.
|
||||||
|
|
||||||
\section{Installation}
|
\section{Installation}
|
||||||
\texttt{cplint} is distributed in source code in the source code development tree of Yap. It includes Prolog and C files. Download it by following the instruction in \url{http://www.ncc.up.pt/~vsc/Yap/downloads.html}.
|
\texttt{cplint} is distributed in source code in the source code development tree of Yap. It includes Prolog and C files. Download it by following the instruction in \url{http://www.dcc.fc.up.pt/\string ~vsc/Yap/downloads.html}.
|
||||||
|
|
||||||
\texttt{cplint} requires \href{http://vlsi.colorado.edu/~fabio/CUDD/}{CUDD}.
|
\texttt{cplint} requires \href{http://vlsi.colorado.edu/\string ~fabio/CUDD/}{CUDD}.
|
||||||
You can download CUDD from \url{ftp://vlsi.colorado.edu/pub/cudd-2.4.2.tar.gz}.
|
You can download CUDD from \url{ftp://vlsi.colorado.edu/pub/cudd-2.5.0.tar.gz}.
|
||||||
|
|
||||||
Compile CUDD:
|
Compile CUDD:
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
@ -48,7 +48,7 @@ when compiling Yap following the instruction of the \texttt{INSTALL} file in the
|
|||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
configure --enable-cplint=DIR
|
configure --enable-cplint=DIR
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
where \verb|DIR| is the directory where CUDD is, i.e., the directory ending with \texttt{cudd-2.4.2}.
|
where \verb|DIR| is the directory where CUDD is, i.e., the directory ending with \texttt{cudd-2.5.0}.
|
||||||
Under Windows, you have to use Cygwin (CUDD does not compile under MinGW), so\\
|
Under Windows, you have to use Cygwin (CUDD does not compile under MinGW), so\\
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
configure --enable-cplint=DIR --enable-cygwin
|
configure --enable-cplint=DIR --enable-cygwin
|
||||||
@ -114,7 +114,7 @@ average/2
|
|||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
that, given a list of numbers, computes its arithmetic mean.
|
that, given a list of numbers, computes its arithmetic mean.
|
||||||
|
|
||||||
The syntax of ICL program is the one used by the \href{http://www.cs.ubc.ca/~poole/aibook/code/ailog/ailog2.html}{AILog 2} system.
|
The syntax of ICL program is the one used by the \href{http://www.cs.ubc.ca/\string ~poole/aibook/code/ailog/ailog2.html}{AILog 2} system.
|
||||||
\section{Inference}
|
\section{Inference}
|
||||||
\texttt{cplint} contains various modules for answering queries.
|
\texttt{cplint} contains various modules for answering queries.
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ It is also able to deal with extensions of LPADs and CP-logic: the clause bodies
|
|||||||
\item \texttt{montecarlo.pl} performs Monte Carlo \cite{BraRig10-ILP10-IC}
|
\item \texttt{montecarlo.pl} performs Monte Carlo \cite{BraRig10-ILP10-IC}
|
||||||
\item \texttt{mcintyre.pl}: implements the algorithm MCINTYRE (Monte Carlo INference wiTh Yap REcord) \cite{Rig11-CILC11-NC}
|
\item \texttt{mcintyre.pl}: implements the algorithm MCINTYRE (Monte Carlo INference wiTh Yap REcord) \cite{Rig11-CILC11-NC}
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\item \texttt{approx/exact.pl} as \texttt{lpadsld.pl} but uses SimplecuddLPADs, a modification of the \href{www.cs.kuleuven.be/~theo/tools/simplecudd.html}{Simplecudd} instead of the \texttt{cplint} library for building BDDs and computing the probability.
|
\item \texttt{approx/exact.pl} as \texttt{lpadsld.pl} but uses SimplecuddLPADs, a modification of the \href{http://dtai.cs.kuleuven.be/problog/download.html}{Simplecudd} instead of the \texttt{cplint} library for building BDDs and computing the probability.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
These modules answer queries using the definition of the semantics of LPADs and CP-logic:
|
These modules answer queries using the definition of the semantics of LPADs and CP-logic:
|
||||||
@ -268,7 +268,7 @@ Variables: [(2,[X=2,X1=1]),(2,[X=1,X1=0]),(1,[])]
|
|||||||
In the example above variable \texttt{X0} corresponds to clause \texttt{2} with the substitutions \texttt{X=2,X1=1},
|
In the example above variable \texttt{X0} corresponds to clause \texttt{2} with the substitutions \texttt{X=2,X1=1},
|
||||||
variable \texttt{X1} corresponds to clause \texttt{2} with the substitutions \texttt{X=1,X1=0} and
|
variable \texttt{X1} corresponds to clause \texttt{2} with the substitutions \texttt{X=1,X1=0} and
|
||||||
variable \texttt{X2} corresponds to clause \texttt{1} with the empty substitution.
|
variable \texttt{X2} corresponds to clause \texttt{1} with the empty substitution.
|
||||||
You can view the graph with \href{www.graphviz.org}{\texttt{graphviz}} using the
|
You can view the graph with \href{http://www.graphviz.org}{\texttt{graphviz}} using the
|
||||||
command
|
command
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
dotty cpl.dot &
|
dotty cpl.dot &
|
||||||
@ -504,7 +504,7 @@ unseen(<predicate>/<arity>).
|
|||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
For SLIPCASE, you have to specify the language bias by means of mode declarations in the style of
|
For SLIPCASE, you have to specify the language bias by means of mode declarations in the style of
|
||||||
\href{http://www.doc.ic.ac.uk/~shm/progol.html}{Progol}.
|
\href{http://www.doc.ic.ac.uk/\string ~shm/progol.html}{Progol}.
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
modeh(<recall>,<predicate>(<arg1>,...).
|
modeh(<recall>,<predicate>(<arg1>,...).
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
@ -529,6 +529,25 @@ for specifying an output variable of type \texttt{<type>}. or
|
|||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
for specifying a constant.
|
for specifying a constant.
|
||||||
|
|
||||||
|
An example of language bias for the UWCSE domain is
|
||||||
|
\begin{verbatim}
|
||||||
|
output(advisedby/2).
|
||||||
|
|
||||||
|
input(student/1).
|
||||||
|
input(professor/1).
|
||||||
|
....
|
||||||
|
|
||||||
|
modeh(*,advisedby(+person,+person)).
|
||||||
|
|
||||||
|
modeb(*,professor(+person)).
|
||||||
|
modeb(*,student(+person)).
|
||||||
|
modeb(*,sameperson(+person, -person)).
|
||||||
|
modeb(*,sameperson(-person, +person)).
|
||||||
|
modeb(*,samecourse(+course, -course)).
|
||||||
|
modeb(*,samecourse(-course, +course)).
|
||||||
|
....
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
\subsection{Parameters}
|
\subsection{Parameters}
|
||||||
In order to set the algorithms' parameters, you have to insert in \texttt{<stem>.l} commands of the form
|
In order to set the algorithms' parameters, you have to insert in \texttt{<stem>.l} commands of the form
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
@ -601,6 +620,9 @@ and call
|
|||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
?:- sl(stem).
|
?:- sl(stem).
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
\subsection{Learning Examples}
|
||||||
|
The subfolders \verb|em|, \verb|rib| and \verb|slipcase| of the \verb|packages/cplint| folder in Yap git distribution
|
||||||
|
contain examples of input and output files for the learning algorithms.
|
||||||
|
|
||||||
\section{License}
|
\section{License}
|
||||||
\label{license}
|
\label{license}
|
||||||
@ -610,10 +632,10 @@ and call
|
|||||||
\texttt{cplint}, as Yap, follows the Artistic License 2.0 that you can find in Yap CVS root dir. The copyright is by Fabrizio Riguzzi.
|
\texttt{cplint}, as Yap, follows the Artistic License 2.0 that you can find in Yap CVS root dir. The copyright is by Fabrizio Riguzzi.
|
||||||
\vspace{3mm}
|
\vspace{3mm}
|
||||||
|
|
||||||
The modules in the approx subdirectory use SimplecuddLPADs, a modification of the \href{www.cs.kuleuven.be/~theo/tools/simplecudd.html}{Simplecudd} library whose copyright is by Katholieke Universiteit Leuven and that follows the Artistic License 2.0.
|
The modules in the approx subdirectory use SimplecuddLPADs, a modification of the \href{http://dtai.cs.kuleuven.be/problog/download.html}{Simplecudd} library whose copyright is by Katholieke Universiteit Leuven and that follows the Artistic License 2.0.
|
||||||
\vspace{3mm}
|
\vspace{3mm}
|
||||||
|
|
||||||
Some modules use the library \href{http://vlsi.colorado.edu/~fabio/}{CUDD} for manipulating BDDs that is included in glu.
|
Some modules use the library \href{http://vlsi.colorado.edu/\string ~fabio/}{CUDD} for manipulating BDDs that is included in glu.
|
||||||
For the use of CUDD, the following license must be accepted:
|
For the use of CUDD, the following license must be accepted:
|
||||||
|
|
||||||
\vspace{3mm}
|
\vspace{3mm}
|
||||||
@ -654,7 +676,7 @@ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|||||||
POSSIBILITY OF SUCH DAMAGE.
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
\texttt{lpad.pl}, \texttt{semlpad.pl} and \texttt{cpl.pl} are based on the SLG system
|
\texttt{lpad.pl}, \texttt{semlpad.pl} and \texttt{cpl.pl} are based on the SLG system
|
||||||
by \href{http://engr.smu.edu/~wchen/}{Weidong Chen} and \href{http://www.cs.sunysb.edu/~warren/}{David Scott Warren},
|
by Weidong Chen and \href{http://www.cs.sunysb.edu/\string ~warren/}{David Scott Warren},
|
||||||
Copyright (C) 1993 Southern Methodist University, 1993 SUNY at Stony Brook, see the file COYPRIGHT\_SLG for detailed information on this copyright.
|
Copyright (C) 1993 Southern Methodist University, 1993 SUNY at Stony Brook, see the file COYPRIGHT\_SLG for detailed information on this copyright.
|
||||||
|
|
||||||
\bibliographystyle{plain}
|
\bibliographystyle{plain}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 724 B After Width: | Height: | Size: 3.3 KiB |
2
packages/cplint/slipcase/ai_train.cpl
Normal file
2
packages/cplint/slipcase/ai_train.cpl
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
advisedby(X,Y):0.5.
|
||||||
|
advisedby(X,Y):0.5.
|
4264
packages/cplint/slipcase/ai_train.kb
Normal file
4264
packages/cplint/slipcase/ai_train.kb
Normal file
File diff suppressed because it is too large
Load Diff
157
packages/cplint/slipcase/ai_train.l
Normal file
157
packages/cplint/slipcase/ai_train.l
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
|
||||||
|
output(advisedby/2).
|
||||||
|
|
||||||
|
input(student/1).
|
||||||
|
|
||||||
|
input(professor/1).
|
||||||
|
|
||||||
|
input(inphase/2).
|
||||||
|
|
||||||
|
input(hasposition/2).
|
||||||
|
|
||||||
|
input(publication/2).
|
||||||
|
|
||||||
|
input(yearsinprogram/2).
|
||||||
|
|
||||||
|
input(taughtby/3).
|
||||||
|
|
||||||
|
input(ta/3).
|
||||||
|
|
||||||
|
input(courselevel/2).
|
||||||
|
|
||||||
|
input(tempadvisedby/2).
|
||||||
|
|
||||||
|
input(projectmember/2).
|
||||||
|
|
||||||
|
input(sameperson/2).
|
||||||
|
input(samecourse/2).
|
||||||
|
input(sameproject/2).
|
||||||
|
|
||||||
|
|
||||||
|
modeh(*,advisedby(+person,+person)).
|
||||||
|
|
||||||
|
modeb(*,professor(+person)).
|
||||||
|
modeb(*,student(+person)).
|
||||||
|
|
||||||
|
modeb(*,sameperson(+person, -person)).
|
||||||
|
modeb(*,sameperson(-person, +person)).
|
||||||
|
modeb(*,samecourse(+course, -course)).
|
||||||
|
modeb(*,samecourse(-course, +course)).
|
||||||
|
modeb(*,sameproject(-project, +project)).
|
||||||
|
modeb(*,sameproject(+project, -project)).
|
||||||
|
|
||||||
|
modeb(*,publication(+title, -person)).
|
||||||
|
modeb(*,courselevel(+course, -level)).
|
||||||
|
modeb(*,hasposition(+person, -position)).
|
||||||
|
%modeb(*,projectmember(+project, -person)).
|
||||||
|
modeb(*,projectmember(project119, +person)).
|
||||||
|
modeb(*,projectmember(project130, +person)).
|
||||||
|
modeb(*,projectmember(project152, +person)).
|
||||||
|
modeb(*,projectmember(project62, +person)).
|
||||||
|
modeb(*,projectmember(project94, +person)).
|
||||||
|
modeb(*,inphase(+person, -phase)).
|
||||||
|
modeb(*,tempadvisedby(+person, -person)).
|
||||||
|
modeb(*,yearsinprogram(+person, -integer)).
|
||||||
|
|
||||||
|
modeb(*,publication(-title, +person)).
|
||||||
|
%modeb(*,courselevel(-course, +level)).
|
||||||
|
modeb(*,courselevel(+course, level_500)).
|
||||||
|
modeb(*,courselevel(+course, level_400)).
|
||||||
|
modeb(*,courselevel(+course, level_300)).
|
||||||
|
%modeb(*,hasposition(-person, +position)).
|
||||||
|
modeb(*,hasposition(+person, faculty)).
|
||||||
|
modeb(*,hasposition(+person, faculty_affiliate)).
|
||||||
|
modeb(*,hasposition(+person, faculty_adjunct)).
|
||||||
|
modeb(*,hasposition(+person, faculty_visiting)).
|
||||||
|
modeb(*,hasposition(+person, faculty_emeritus)).
|
||||||
|
modeb(*,projectmember(-project, +person)).
|
||||||
|
%modeb(*,inphase(-person, +phase)).
|
||||||
|
modeb(*,inphase(+person, post_quals)).
|
||||||
|
modeb(*,inphase(+person, post_generals)).
|
||||||
|
modeb(*,inphase(+person, pre_quals)).
|
||||||
|
modeb(*,tempadvisedby(-person, +person)).
|
||||||
|
%modeb(*,yearsinprogram(-person, +integer)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_1)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_2)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_3)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_4)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_5)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_6)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_7)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_8)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_9)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_10)).
|
||||||
|
modeb(*,yearsinprogram(+person, year_12)).
|
||||||
|
|
||||||
|
modeb(*,taughtby(+course, -person, -quarter)).
|
||||||
|
modeb(*,ta(+course, -person, -quarter)).
|
||||||
|
modeb(*,taughtby(-course, +person, -quarter)).
|
||||||
|
modeb(*,ta(-course, +person, -quarter)).
|
||||||
|
|
||||||
|
%modeb(*,taughtby(-course, -person, +quarter)).
|
||||||
|
%modeb(*,ta(-course, -person, +quarter)).
|
||||||
|
|
||||||
|
modeb(*,taughtby(+course, +person, -quarter)).
|
||||||
|
modeb(*,ta(+course, +person, -quarter)).
|
||||||
|
|
||||||
|
%modeb(*,taughtby(+course, -person, +quarter)).
|
||||||
|
%modeb(*,ta(+course, -person, +quarter)).
|
||||||
|
modeb(*,taughtby(+course, -person, autumn_0001)).
|
||||||
|
modeb(*,ta(+course, -person, autumn_0001)).
|
||||||
|
modeb(*,taughtby(+course, -person, autumn_0102)).
|
||||||
|
modeb(*,ta(+course, -person, autumn_0102)).
|
||||||
|
modeb(*,taughtby(+course, -person, autumn_0203)).
|
||||||
|
modeb(*,ta(+course, -person, autumn_0203)).
|
||||||
|
modeb(*,taughtby(+course, -person, autumn_0304)).
|
||||||
|
modeb(*,ta(+course, -person, autumn_0304)).
|
||||||
|
modeb(*,taughtby(+course, -person, spring_0001)).
|
||||||
|
modeb(*,ta(+course, -person, spring_0001)).
|
||||||
|
modeb(*,taughtby(+course, -person, spring_0102)).
|
||||||
|
modeb(*,ta(+course, -person, spring_0102)).
|
||||||
|
modeb(*,taughtby(+course, -person, spring_0203)).
|
||||||
|
modeb(*,ta(+course, -person, spring_0203)).
|
||||||
|
modeb(*,taughtby(+course, -person, spring_0304)).
|
||||||
|
modeb(*,ta(+course, -person, spring_0304)).
|
||||||
|
modeb(*,taughtby(+course, -person, summer_0102)).
|
||||||
|
modeb(*,ta(+course, -person, summer_0102)).
|
||||||
|
modeb(*,taughtby(+course, -person, summer_0203)).
|
||||||
|
modeb(*,ta(+course, -person, summer_0203)).
|
||||||
|
modeb(*,taughtby(+course, -person, winter_0001)).
|
||||||
|
modeb(*,ta(+course, -person, winter_0001)).
|
||||||
|
modeb(*,taughtby(+course, -person, winter_0102)).
|
||||||
|
modeb(*,ta(+course, -person, winter_0102)).
|
||||||
|
modeb(*,taughtby(+course, -person, winter_0203)).
|
||||||
|
modeb(*,ta(+course, -person, winter_0203)).
|
||||||
|
modeb(*,taughtby(+course, -person, winter_0304)).
|
||||||
|
modeb(*,ta(+course, -person, winter_0304)).
|
||||||
|
|
||||||
|
%modeb(*,taughtby(-course, +person, +quarter)).
|
||||||
|
%modeb(*,ta(-course, +person, +quarter)).
|
||||||
|
modeb(*,taughtby(-course, +person, autumn_0001)).
|
||||||
|
modeb(*,ta(-course, +person, autumn_0001)).
|
||||||
|
modeb(*,taughtby(-course, +person, autumn_0102)).
|
||||||
|
modeb(*,ta(-course, +person, autumn_0102)).
|
||||||
|
modeb(*,taughtby(-course, +person, autumn_0203)).
|
||||||
|
modeb(*,ta(-course, +person, autumn_0203)).
|
||||||
|
modeb(*,taughtby(-course, +person, autumn_0304)).
|
||||||
|
modeb(*,ta(-course, +person, autumn_0304)).
|
||||||
|
modeb(*,taughtby(-course, +person, spring_0001)).
|
||||||
|
modeb(*,ta(-course, +person, spring_0001)).
|
||||||
|
modeb(*,taughtby(-course, +person, spring_0102)).
|
||||||
|
modeb(*,ta(-course, +person, spring_0102)).
|
||||||
|
modeb(*,taughtby(-course, +person, spring_0203)).
|
||||||
|
modeb(*,ta(-course, +person, spring_0203)).
|
||||||
|
modeb(*,taughtby(-course, +person, spring_0304)).
|
||||||
|
modeb(*,ta(-course, +person, spring_0304)).
|
||||||
|
modeb(*,taughtby(-course, +person, summer_0102)).
|
||||||
|
modeb(*,ta(-course, +person, summer_0102)).
|
||||||
|
modeb(*,taughtby(-course, +person, summer_0203)).
|
||||||
|
modeb(*,ta(-course, +person, summer_0203)).
|
||||||
|
modeb(*,taughtby(-course, +person, winter_0001)).
|
||||||
|
modeb(*,ta(-course, +person, winter_0001)).
|
||||||
|
modeb(*,taughtby(-course, +person, winter_0102)).
|
||||||
|
modeb(*,ta(-course, +person, winter_0102)).
|
||||||
|
modeb(*,taughtby(-course, +person, winter_0203)).
|
||||||
|
modeb(*,ta(-course, +person, winter_0203)).
|
||||||
|
modeb(*,taughtby(-course, +person, winter_0304)).
|
||||||
|
modeb(*,ta(-course, +person, winter_0304)).
|
34
packages/cplint/slipcase/ai_train.rules
Normal file
34
packages/cplint/slipcase/ai_train.rules
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* SLIPCASE Final CLL -0.461865
|
||||||
|
Execution time 100.887000
|
||||||
|
setting(epsilon_em,0.0001).
|
||||||
|
setting(epsilon_em_fraction,1.0e-5).
|
||||||
|
setting(eps,0.0001).
|
||||||
|
setting(eps_f,1.0e-5).
|
||||||
|
setting(epsilon_sem,2).
|
||||||
|
setting(random_restarts_REFnumber,1).
|
||||||
|
setting(random_restarts_number,1).
|
||||||
|
setting(iterREF,-1).
|
||||||
|
setting(iter,-1).
|
||||||
|
setting(examples,atoms).
|
||||||
|
setting(group,1).
|
||||||
|
setting(d,1).
|
||||||
|
setting(verbosity,1).
|
||||||
|
setting(logzero,log(1.0e-6)).
|
||||||
|
setting(initial_clauses_modeh,1).
|
||||||
|
setting(max_iter,10).
|
||||||
|
setting(max_var,5).
|
||||||
|
setting(max_rules,10).
|
||||||
|
setting(beamsize,20).
|
||||||
|
setting(epsilon_parsing,1.0e-10).
|
||||||
|
setting(tabling,off).
|
||||||
|
setting(bagof,false).
|
||||||
|
setting(depth_bound,false).
|
||||||
|
setting(depth,2).
|
||||||
|
setting(single_var,false).
|
||||||
|
setting(compiling,off).
|
||||||
|
*/
|
||||||
|
|
||||||
|
advisedby(A,B):0.264403 :-
|
||||||
|
professor(B),
|
||||||
|
student(A).
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
EMBLEM and SLIPCASE
|
EMBLEM and SLIPCASE
|
||||||
|
|
||||||
Copyright (c) 2011, Fabrizio Riguzzi and Elena Bellodi
|
Copyright (c) 2013, Fabrizio Riguzzi and Elena Bellodi
|
||||||
|
|
||||||
This package uses the library cudd, see http://vlsi.colorado.edu/~fabio/CUDD/
|
This package uses the library cudd, see http://vlsi.colorado.edu/~fabio/CUDD/
|
||||||
for the relative license.
|
for the relative license.
|
||||||
@ -41,24 +41,18 @@ typedef struct
|
|||||||
|
|
||||||
tablerow * table;
|
tablerow * table;
|
||||||
|
|
||||||
static variable * vars;
|
|
||||||
static variable ** vars_ex;
|
static variable ** vars_ex;
|
||||||
static int * bVar2mVar;
|
|
||||||
static int ** bVar2mVar_ex;
|
static int ** bVar2mVar_ex;
|
||||||
static double * sigma;
|
static double * sigma;
|
||||||
static double ***eta;
|
static double ***eta;
|
||||||
static double ***eta_temp;
|
static double ***eta_temp;
|
||||||
static double **arrayprob;
|
static double **arrayprob;
|
||||||
static int *rules;
|
static int *rules;
|
||||||
static DdManager *mgr;
|
|
||||||
static DdManager **mgr_ex;
|
static DdManager **mgr_ex;
|
||||||
static int *nVars;
|
|
||||||
static int *nVars_ex;
|
static int *nVars_ex;
|
||||||
static int nRules;
|
static int nRules;
|
||||||
double * probs;
|
|
||||||
double * nodes_probs_ex;
|
double * nodes_probs_ex;
|
||||||
double ** probs_ex;
|
double ** probs_ex;
|
||||||
static int * boolVars;
|
|
||||||
static int * boolVars_ex;
|
static int * boolVars_ex;
|
||||||
tablerow * nodesB;
|
tablerow * nodesB;
|
||||||
tablerow * nodesF;
|
tablerow * nodesF;
|
||||||
@ -75,13 +69,13 @@ static int init(void);
|
|||||||
static int end(void);
|
static int end(void);
|
||||||
static int EM(void);
|
static int EM(void);
|
||||||
static int Q(void);
|
static int Q(void);
|
||||||
double ProbPath(DdNode *node, int comp_par);
|
double ProbPath(DdNode *node, int comp_par, int nex);
|
||||||
static int rec_deref(void);
|
static int rec_deref(void);
|
||||||
int indexMvar(DdNode *node);
|
int indexMvar(DdNode *node);
|
||||||
void Forward(DdNode *node);
|
void Forward(DdNode *node, int nex);
|
||||||
void GetForward(DdNode *node, double ForwProbPath);
|
void GetForward(DdNode *node, double ForwProbPath);
|
||||||
void UpdateForward(DdNode * node);
|
void UpdateForward(DdNode * node, int nex);
|
||||||
double GetOutsideExpe(DdNode *root,double ex_prob);
|
double GetOutsideExpe(DdNode *root,double ex_prob, int nex);
|
||||||
void Maximization(void);
|
void Maximization(void);
|
||||||
static double Expectation(DdNode **nodes_ex, int lenNodes);
|
static double Expectation(DdNode **nodes_ex, int lenNodes);
|
||||||
void init_my_predicates(void);
|
void init_my_predicates(void);
|
||||||
@ -133,33 +127,27 @@ static int init(void)
|
|||||||
|
|
||||||
static int init_bdd(void)
|
static int init_bdd(void)
|
||||||
{
|
{
|
||||||
mgr=Cudd_Init(0,0,UNIQUE_SLOTS,CACHE_SLOTS,5120);
|
|
||||||
Cudd_AutodynEnable(mgr, CUDD_REORDER_GROUP_SIFT);
|
|
||||||
Cudd_SetMaxCacheHard(mgr, 0);
|
|
||||||
Cudd_SetLooseUpTo(mgr, 0);
|
|
||||||
Cudd_SetMinHit(mgr, 15);
|
|
||||||
mgr_ex=(DdManager **) realloc(mgr_ex, (ex+1)* sizeof(DdManager *));
|
mgr_ex=(DdManager **) realloc(mgr_ex, (ex+1)* sizeof(DdManager *));
|
||||||
mgr_ex[ex]=mgr;
|
mgr_ex[ex]=Cudd_Init(0,0,UNIQUE_SLOTS,CACHE_SLOTS,5120);
|
||||||
|
Cudd_AutodynEnable(mgr_ex[ex], CUDD_REORDER_GROUP_SIFT);
|
||||||
|
Cudd_SetMaxCacheHard(mgr_ex[ex], 0);
|
||||||
|
Cudd_SetLooseUpTo(mgr_ex[ex], 0);
|
||||||
|
Cudd_SetMinHit(mgr_ex[ex], 15);
|
||||||
|
|
||||||
bVar2mVar_ex=(int **) realloc(bVar2mVar_ex, (ex+1)* sizeof(int *));
|
bVar2mVar_ex=(int **) realloc(bVar2mVar_ex, (ex+1)* sizeof(int *));
|
||||||
bVar2mVar_ex[ex]=NULL;
|
bVar2mVar_ex[ex]=NULL;
|
||||||
bVar2mVar=bVar2mVar_ex[ex];
|
|
||||||
|
|
||||||
vars_ex=(variable **) realloc(vars_ex, (ex+1)* sizeof(variable *));
|
vars_ex=(variable **) realloc(vars_ex, (ex+1)* sizeof(variable *));
|
||||||
vars_ex[ex]=NULL;
|
vars_ex[ex]=NULL;
|
||||||
vars=vars_ex[ex];
|
|
||||||
|
|
||||||
nVars_ex=(int *) realloc(nVars_ex, (ex+1)* sizeof(int ));
|
nVars_ex=(int *) realloc(nVars_ex, (ex+1)* sizeof(int ));
|
||||||
nVars=nVars_ex+ex;
|
nVars_ex[ex]=0;
|
||||||
*nVars=0;
|
|
||||||
|
|
||||||
probs_ex=(double **) realloc(probs_ex, (ex+1)* sizeof(double *));
|
probs_ex=(double **) realloc(probs_ex, (ex+1)* sizeof(double *));
|
||||||
probs_ex[ex]=NULL;
|
probs_ex[ex]=NULL;
|
||||||
probs=probs_ex[ex];
|
|
||||||
|
|
||||||
boolVars_ex=(int *) realloc(boolVars_ex, (ex+1)* sizeof(int ));
|
boolVars_ex=(int *) realloc(boolVars_ex, (ex+1)* sizeof(int ));
|
||||||
boolVars=boolVars_ex+ex;
|
boolVars_ex[ex]=0;
|
||||||
*boolVars=0;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -167,9 +155,6 @@ static int init_bdd(void)
|
|||||||
static int end_bdd(void)
|
static int end_bdd(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
bVar2mVar_ex[ex]=bVar2mVar;
|
|
||||||
probs_ex[ex]=probs;
|
|
||||||
vars_ex[ex]=vars;
|
|
||||||
ex=ex+1;
|
ex=ex+1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -184,33 +169,31 @@ static int init_test(void)
|
|||||||
nRules=YAP_IntOfTerm(arg1);
|
nRules=YAP_IntOfTerm(arg1);
|
||||||
|
|
||||||
|
|
||||||
mgr=Cudd_Init(0,0,UNIQUE_SLOTS,CACHE_SLOTS,0);
|
mgr_ex[ex]=Cudd_Init(0,0,UNIQUE_SLOTS,CACHE_SLOTS,0);
|
||||||
Cudd_AutodynEnable(mgr, CUDD_REORDER_GROUP_SIFT);
|
Cudd_AutodynEnable(mgr_ex[ex], CUDD_REORDER_GROUP_SIFT);
|
||||||
Cudd_SetMaxCacheHard(mgr, 1024*1024*1024);
|
Cudd_SetMaxCacheHard(mgr_ex[ex], 1024*1024*1024);
|
||||||
Cudd_SetLooseUpTo(mgr, 1024*1024*512);
|
Cudd_SetLooseUpTo(mgr_ex[ex], 1024*1024*512);
|
||||||
rules= (int *) malloc(nRules * sizeof(int));
|
rules= (int *) malloc(nRules * sizeof(int));
|
||||||
|
|
||||||
bVar2mVar=NULL;
|
bVar2mVar_ex[ex]=NULL;
|
||||||
probs=NULL;
|
probs_ex[ex]=NULL;
|
||||||
vars=NULL;
|
vars_ex[ex]=NULL;
|
||||||
|
|
||||||
nVars=(int *) malloc(sizeof(int ));
|
nVars_ex[ex]=0;
|
||||||
*nVars=0;
|
|
||||||
|
|
||||||
boolVars=(int *) malloc(sizeof(int ));
|
boolVars_ex[ex]=0;
|
||||||
*boolVars=0;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int end_test(void)
|
static int end_test(void)
|
||||||
{
|
{
|
||||||
free(bVar2mVar);
|
free(bVar2mVar_ex[ex]);
|
||||||
free(vars);
|
free(vars_ex[ex]);
|
||||||
free(nVars);
|
free(nVars_ex+ex);
|
||||||
free(boolVars);
|
free(boolVars_ex+ex);
|
||||||
Cudd_Quit(mgr);
|
Cudd_Quit(mgr_ex[ex]);
|
||||||
free(probs);
|
free(probs_ex[ex]);
|
||||||
free(rules);
|
free(rules);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -221,21 +204,16 @@ static double Expectation(DdNode **nodes_ex,int lenNodes)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double rootProb,CLL=0;
|
double rootProb,CLL=0;
|
||||||
|
|
||||||
for(i=0;i<lenNodes;i++)
|
for(i=0;i<lenNodes;i++)
|
||||||
{
|
{
|
||||||
if (!Cudd_IsConstant(nodes_ex[i]))
|
if (!Cudd_IsConstant(nodes_ex[i]))
|
||||||
{
|
{
|
||||||
mgr=mgr_ex[i];
|
nodesB=init_table(boolVars_ex[i]);
|
||||||
probs=probs_ex[i];
|
nodesF=init_table(boolVars_ex[i]);
|
||||||
boolVars=boolVars_ex+i;
|
|
||||||
nodesB=init_table(*boolVars);
|
|
||||||
nodesF=init_table(*boolVars);
|
|
||||||
bVar2mVar=bVar2mVar_ex[i];
|
|
||||||
vars=vars_ex[i];
|
|
||||||
|
|
||||||
Forward(nodes_ex[i]);
|
Forward(nodes_ex[i],i);
|
||||||
rootProb=GetOutsideExpe(nodes_ex[i],example_prob[i]);
|
rootProb=GetOutsideExpe(nodes_ex[i],example_prob[i],i);
|
||||||
|
|
||||||
if (rootProb<=0.0)
|
if (rootProb<=0.0)
|
||||||
CLL = CLL + LOGZERO*example_prob[i];
|
CLL = CLL + LOGZERO*example_prob[i];
|
||||||
@ -243,8 +221,8 @@ static double Expectation(DdNode **nodes_ex,int lenNodes)
|
|||||||
CLL = CLL + log(rootProb)*example_prob[i];
|
CLL = CLL + log(rootProb)*example_prob[i];
|
||||||
|
|
||||||
nodes_probs_ex[i]=rootProb;
|
nodes_probs_ex[i]=rootProb;
|
||||||
destroy_table(nodesB,*boolVars);
|
destroy_table(nodesB,boolVars_ex[i]);
|
||||||
destroy_table(nodesF,*boolVars);
|
destroy_table(nodesF,boolVars_ex[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (nodes_ex[i]==Cudd_ReadLogicZero(mgr_ex[i]))
|
if (nodes_ex[i]==Cudd_ReadLogicZero(mgr_ex[i]))
|
||||||
@ -307,13 +285,13 @@ static int ret_prob(void)
|
|||||||
|
|
||||||
if (!Cudd_IsConstant(node))
|
if (!Cudd_IsConstant(node))
|
||||||
{
|
{
|
||||||
table=init_table(*boolVars);
|
table=init_table(boolVars_ex[ex]);
|
||||||
out=YAP_MkFloatTerm(Prob(node,0));
|
out=YAP_MkFloatTerm(Prob(node,0));
|
||||||
destroy_table(table,*boolVars);
|
destroy_table(table,boolVars_ex[ex]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (node==Cudd_ReadOne(mgr))
|
if (node==Cudd_ReadOne(mgr_ex[ex]))
|
||||||
out=YAP_MkFloatTerm(1.0);
|
out=YAP_MkFloatTerm(1.0);
|
||||||
else
|
else
|
||||||
out=YAP_MkFloatTerm(0.0);
|
out=YAP_MkFloatTerm(0.0);
|
||||||
@ -347,10 +325,6 @@ so that it is not recomputed
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
nodekey=Cudd_Regular(node);
|
nodekey=Cudd_Regular(node);
|
||||||
/* if (comp)
|
|
||||||
nodekey=Cudd_Complement(nodefw);
|
|
||||||
else
|
|
||||||
nodekey=nodefw;*/
|
|
||||||
value_p=get_value(table,nodekey);
|
value_p=get_value(table,nodekey);
|
||||||
if (value_p!=NULL)
|
if (value_p!=NULL)
|
||||||
return *value_p;
|
return *value_p;
|
||||||
@ -358,15 +332,15 @@ so that it is not recomputed
|
|||||||
{
|
{
|
||||||
index=Cudd_NodeReadIndex(node); //Returns the index of the node. The node pointer can be either regular or complemented.
|
index=Cudd_NodeReadIndex(node); //Returns the index of the node. The node pointer can be either regular or complemented.
|
||||||
//The index field holds the name of the variable that labels the node. The index of a variable is a permanent attribute that reflects the order of creation.
|
//The index field holds the name of the variable that labels the node. The index of a variable is a permanent attribute that reflects the order of creation.
|
||||||
p=probs[index];
|
p=probs_ex[ex][index];
|
||||||
T = Cudd_T(node);
|
T = Cudd_T(node);
|
||||||
F = Cudd_E(node);
|
F = Cudd_E(node);
|
||||||
pf=Prob(F,comp);
|
pf=Prob(F,comp);
|
||||||
pt=Prob(T,comp);
|
pt=Prob(T,comp);
|
||||||
BChild0=pf*(1-p);
|
BChild0=pf*(1-p);
|
||||||
BChild1=pt*p;
|
BChild1=pt*p;
|
||||||
mVarIndex=bVar2mVar[index];
|
mVarIndex=bVar2mVar_ex[ex][index];
|
||||||
v=vars[mVarIndex];
|
v=vars_ex[ex][mVarIndex];
|
||||||
pos=index-v.firstBoolVar;
|
pos=index-v.firstBoolVar;
|
||||||
res=BChild0+BChild1;
|
res=BChild0+BChild1;
|
||||||
add_node(table,nodekey,res);
|
add_node(table,nodekey,res);
|
||||||
@ -390,29 +364,30 @@ static int add_var(void)
|
|||||||
arg2=YAP_ARG2;
|
arg2=YAP_ARG2;
|
||||||
arg3=YAP_ARG3;
|
arg3=YAP_ARG3;
|
||||||
arg4=YAP_ARG4;
|
arg4=YAP_ARG4;
|
||||||
*nVars=*nVars+1;
|
nVars_ex[ex]=nVars_ex[ex]+1;
|
||||||
vars=(variable *) realloc(vars,*nVars * sizeof(variable));
|
vars_ex[ex]=(variable *) realloc(vars_ex[ex],nVars_ex[ex] * sizeof(variable));
|
||||||
v=&vars[*nVars-1];
|
|
||||||
|
v=&vars_ex[ex][nVars_ex[ex]-1];
|
||||||
v->nVal=YAP_IntOfTerm(arg1);
|
v->nVal=YAP_IntOfTerm(arg1);
|
||||||
v->nRule=YAP_IntOfTerm(arg3);
|
v->nRule=YAP_IntOfTerm(arg3);
|
||||||
v->firstBoolVar=*boolVars;
|
v->firstBoolVar=boolVars_ex[ex];
|
||||||
probs=(double *) realloc(probs,(((*boolVars+v->nVal-1)* sizeof(double))));
|
probs_ex[ex]=(double *) realloc(probs_ex[ex],(((boolVars_ex[ex]+v->nVal-1)* sizeof(double))));
|
||||||
bVar2mVar=(int *) realloc(bVar2mVar,((*boolVars+v->nVal-1)* sizeof(int)));
|
bVar2mVar_ex[ex]=(int *) realloc(bVar2mVar_ex[ex],((boolVars_ex[ex]+v->nVal-1)* sizeof(int)));
|
||||||
probTerm=arg2;
|
probTerm=arg2;
|
||||||
p0=1;
|
p0=1;
|
||||||
for (i=0;i<v->nVal-1;i++)
|
for (i=0;i<v->nVal-1;i++)
|
||||||
{
|
{
|
||||||
node=Cudd_bddIthVar(mgr,*boolVars+i);
|
node=Cudd_bddIthVar(mgr_ex[ex],boolVars_ex[ex]+i);
|
||||||
p=YAP_FloatOfTerm(YAP_HeadOfTerm(probTerm));
|
p=YAP_FloatOfTerm(YAP_HeadOfTerm(probTerm));
|
||||||
bVar2mVar[*boolVars+i]=*nVars-1;
|
bVar2mVar_ex[ex][boolVars_ex[ex]+i]=nVars_ex[ex]-1;
|
||||||
probs[*boolVars+i]=p/p0;
|
probs_ex[ex][boolVars_ex[ex]+i]=p/p0;
|
||||||
probTerm_temp=YAP_TailOfTerm(probTerm);
|
probTerm_temp=YAP_TailOfTerm(probTerm);
|
||||||
probTerm=probTerm_temp;
|
probTerm=probTerm_temp;
|
||||||
p0=p0*(1-p/p0);
|
p0=p0*(1-p/p0);
|
||||||
}
|
}
|
||||||
*boolVars=*boolVars+v->nVal-1;
|
boolVars_ex[ex]=boolVars_ex[ex]+v->nVal-1;
|
||||||
rules[v->nRule]= v->nVal;
|
rules[v->nRule]= v->nVal;
|
||||||
out=YAP_MkIntTerm((YAP_Int)* nVars-1);
|
out=YAP_MkIntTerm((YAP_Int) nVars_ex[ex]-1);
|
||||||
return YAP_Unify(out,arg4);
|
return YAP_Unify(out,arg4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,30 +400,30 @@ static int equality(void)
|
|||||||
variable v;
|
variable v;
|
||||||
DdNode * node, * tmp,*var;
|
DdNode * node, * tmp,*var;
|
||||||
|
|
||||||
arg1=YAP_ARG1; //var
|
arg1=YAP_ARG1;
|
||||||
arg2=YAP_ARG2; //value
|
arg2=YAP_ARG2;
|
||||||
arg3=YAP_ARG3; //node
|
arg3=YAP_ARG3;
|
||||||
varIndex=YAP_IntOfTerm(arg1);
|
varIndex=YAP_IntOfTerm(arg1);
|
||||||
value=YAP_IntOfTerm(arg2);
|
value=YAP_IntOfTerm(arg2);
|
||||||
v=vars[varIndex];
|
v=vars_ex[ex][varIndex];
|
||||||
i=v.firstBoolVar;
|
i=v.firstBoolVar;
|
||||||
tmp=Cudd_ReadOne(mgr);
|
tmp=Cudd_ReadOne(mgr_ex[ex]);
|
||||||
Cudd_Ref(tmp);
|
Cudd_Ref(tmp);
|
||||||
node=NULL;
|
node=NULL;
|
||||||
for (i=v.firstBoolVar;i<v.firstBoolVar+value;i++)
|
for (i=v.firstBoolVar;i<v.firstBoolVar+value;i++)
|
||||||
{
|
{
|
||||||
var=Cudd_bddIthVar(mgr,i);
|
var=Cudd_bddIthVar(mgr_ex[ex],i);
|
||||||
node=Cudd_bddAnd(mgr,tmp,Cudd_Not(var));
|
node=Cudd_bddAnd(mgr_ex[ex],tmp,Cudd_Not(var));
|
||||||
Cudd_Ref(node);
|
Cudd_Ref(node);
|
||||||
Cudd_RecursiveDeref(mgr,tmp);
|
Cudd_RecursiveDeref(mgr_ex[ex],tmp);
|
||||||
tmp=node;
|
tmp=node;
|
||||||
}
|
}
|
||||||
if (!(value==v.nVal-1))
|
if (!(value==v.nVal-1))
|
||||||
{
|
{
|
||||||
var=Cudd_bddIthVar(mgr,v.firstBoolVar+value);
|
var=Cudd_bddIthVar(mgr_ex[ex],v.firstBoolVar+value);
|
||||||
node=Cudd_bddAnd(mgr,tmp,var);
|
node=Cudd_bddAnd(mgr_ex[ex],tmp,var);
|
||||||
Cudd_Ref(node);
|
Cudd_Ref(node);
|
||||||
Cudd_RecursiveDeref(mgr,tmp);
|
Cudd_RecursiveDeref(mgr_ex[ex],tmp);
|
||||||
}
|
}
|
||||||
out=YAP_MkIntTerm((YAP_Int) node);
|
out=YAP_MkIntTerm((YAP_Int) node);
|
||||||
return(YAP_Unify(out,arg3));
|
return(YAP_Unify(out,arg3));
|
||||||
@ -460,7 +435,7 @@ static int one(void)
|
|||||||
DdNode * node;
|
DdNode * node;
|
||||||
|
|
||||||
arg=YAP_ARG1;
|
arg=YAP_ARG1;
|
||||||
node = Cudd_ReadOne(mgr);
|
node = Cudd_ReadOne(mgr_ex[ex]);
|
||||||
Cudd_Ref(node);
|
Cudd_Ref(node);
|
||||||
out=YAP_MkIntTerm((YAP_Int) node);
|
out=YAP_MkIntTerm((YAP_Int) node);
|
||||||
return(YAP_Unify(out,arg));
|
return(YAP_Unify(out,arg));
|
||||||
@ -472,7 +447,7 @@ static int zero(void)
|
|||||||
DdNode * node;
|
DdNode * node;
|
||||||
|
|
||||||
arg=YAP_ARG1;
|
arg=YAP_ARG1;
|
||||||
node = Cudd_ReadLogicZero(mgr);
|
node = Cudd_ReadLogicZero(mgr_ex[ex]);
|
||||||
Cudd_Ref(node);
|
Cudd_Ref(node);
|
||||||
out=YAP_MkIntTerm((YAP_Int) node);
|
out=YAP_MkIntTerm((YAP_Int) node);
|
||||||
return(YAP_Unify(out,arg));
|
return(YAP_Unify(out,arg));
|
||||||
@ -501,7 +476,7 @@ static int and(void)
|
|||||||
arg3=YAP_ARG3;
|
arg3=YAP_ARG3;
|
||||||
node1=(DdNode *)YAP_IntOfTerm(arg1);
|
node1=(DdNode *)YAP_IntOfTerm(arg1);
|
||||||
node2=(DdNode *)YAP_IntOfTerm(arg2);
|
node2=(DdNode *)YAP_IntOfTerm(arg2);
|
||||||
nodeout=Cudd_bddAnd(mgr,node1,node2);
|
nodeout=Cudd_bddAnd(mgr_ex[ex],node1,node2);
|
||||||
Cudd_Ref(nodeout);
|
Cudd_Ref(nodeout);
|
||||||
out=YAP_MkIntTerm((YAP_Int) nodeout);
|
out=YAP_MkIntTerm((YAP_Int) nodeout);
|
||||||
return(YAP_Unify(out,arg3));
|
return(YAP_Unify(out,arg3));
|
||||||
@ -517,7 +492,7 @@ static int or(void)
|
|||||||
arg3=YAP_ARG3;
|
arg3=YAP_ARG3;
|
||||||
node1=(DdNode *)YAP_IntOfTerm(arg1);
|
node1=(DdNode *)YAP_IntOfTerm(arg1);
|
||||||
node2=(DdNode *)YAP_IntOfTerm(arg2);
|
node2=(DdNode *)YAP_IntOfTerm(arg2);
|
||||||
nodeout=Cudd_bddOr(mgr,node1,node2);
|
nodeout=Cudd_bddOr(mgr_ex[ex],node1,node2);
|
||||||
Cudd_Ref(nodeout);
|
Cudd_Ref(nodeout);
|
||||||
out=YAP_MkIntTerm((YAP_Int) nodeout);
|
out=YAP_MkIntTerm((YAP_Int) nodeout);
|
||||||
return(YAP_Unify(out,arg3));
|
return(YAP_Unify(out,arg3));
|
||||||
@ -531,7 +506,7 @@ static int garbage_collect(void)
|
|||||||
arg1=YAP_ARG1;
|
arg1=YAP_ARG1;
|
||||||
arg2=YAP_ARG2;
|
arg2=YAP_ARG2;
|
||||||
clearCache=YAP_IntOfTerm(arg1);
|
clearCache=YAP_IntOfTerm(arg1);
|
||||||
nodes=(YAP_Int)cuddGarbageCollect(mgr,clearCache);
|
nodes=(YAP_Int)cuddGarbageCollect(mgr_ex[ex],clearCache);
|
||||||
out=YAP_MkIntTerm(nodes);
|
out=YAP_MkIntTerm(nodes);
|
||||||
return(YAP_Unify(out,arg2));
|
return(YAP_Unify(out,arg2));
|
||||||
}
|
}
|
||||||
@ -544,7 +519,7 @@ static int bdd_to_add(void)
|
|||||||
arg1=YAP_ARG1;
|
arg1=YAP_ARG1;
|
||||||
arg2=YAP_ARG2;
|
arg2=YAP_ARG2;
|
||||||
node1=(DdNode *)YAP_IntOfTerm(arg1);
|
node1=(DdNode *)YAP_IntOfTerm(arg1);
|
||||||
node2= Cudd_BddToAdd(mgr,node1);
|
node2= Cudd_BddToAdd(mgr_ex[ex],node1);
|
||||||
out=YAP_MkIntTerm((YAP_Int) node2);
|
out=YAP_MkIntTerm((YAP_Int) node2);
|
||||||
return(YAP_Unify(out,arg2));
|
return(YAP_Unify(out,arg2));
|
||||||
}
|
}
|
||||||
@ -564,11 +539,11 @@ static int create_dot(void)
|
|||||||
arg2=YAP_ARG2;
|
arg2=YAP_ARG2;
|
||||||
|
|
||||||
YAP_StringToBuffer(arg2,filename,1000);
|
YAP_StringToBuffer(arg2,filename,1000);
|
||||||
inames= (char **) malloc(sizeof(char *)*(*boolVars));
|
inames= (char **) malloc(sizeof(char *)*(boolVars_ex[ex]));
|
||||||
index=0;
|
index=0;
|
||||||
for (i=0;i<*nVars;i++)
|
for (i=0;i<nVars_ex[ex];i++)
|
||||||
{
|
{
|
||||||
v=vars[i];
|
v=vars_ex[ex][i];
|
||||||
for (b=0;b<v.nVal-1;b++)
|
for (b=0;b<v.nVal-1;b++)
|
||||||
{
|
{
|
||||||
inames[b+index]=(char *) malloc(sizeof(char)*20);
|
inames[b+index]=(char *) malloc(sizeof(char)*20);
|
||||||
@ -583,12 +558,12 @@ static int create_dot(void)
|
|||||||
}
|
}
|
||||||
array[0]=(DdNode *)YAP_IntOfTerm(arg1);
|
array[0]=(DdNode *)YAP_IntOfTerm(arg1);
|
||||||
file = open_file(filename, "w");
|
file = open_file(filename, "w");
|
||||||
Cudd_DumpDot(mgr,1,array,inames,onames,file);
|
Cudd_DumpDot(mgr_ex[ex],1,array,inames,onames,file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
index=0;
|
index=0;
|
||||||
for (i=0;i<*nVars;i++)
|
for (i=0;i<nVars_ex[ex];i++)
|
||||||
{
|
{
|
||||||
v=vars[i];
|
v=vars_ex[ex][i];
|
||||||
for (b=0;b<v.nVal-1;b++)
|
for (b=0;b<v.nVal-1;b++)
|
||||||
{
|
{
|
||||||
free(inames[b+index]);
|
free(inames[b+index]);
|
||||||
@ -607,13 +582,13 @@ static int rec_deref(void)
|
|||||||
|
|
||||||
arg1=YAP_ARG1;
|
arg1=YAP_ARG1;
|
||||||
node=(DdNode *) YAP_IntOfTerm(arg1);
|
node=(DdNode *) YAP_IntOfTerm(arg1);
|
||||||
Cudd_RecursiveDeref(mgr, node);
|
Cudd_RecursiveDeref(mgr_ex[ex], node);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double ProbPath(DdNode *node,int comp_par)
|
double ProbPath(DdNode *node,int comp_par, int nex)
|
||||||
{
|
{
|
||||||
int index,mVarIndex,comp,pos,position,boolVarIndex;
|
int index,mVarIndex,comp,pos,position,boolVarIndex;
|
||||||
variable v;
|
variable v;
|
||||||
@ -622,7 +597,7 @@ double ProbPath(DdNode *node,int comp_par)
|
|||||||
double * value_p,** eta_rule;
|
double * value_p,** eta_rule;
|
||||||
DdNode *nodekey,*T,*F;
|
DdNode *nodekey,*T,*F;
|
||||||
|
|
||||||
comp=Cudd_IsComplement(node);
|
comp=Cudd_IsComplement(node);
|
||||||
comp=(comp && !comp_par) ||(!comp && comp_par);
|
comp=(comp && !comp_par) ||(!comp && comp_par);
|
||||||
if (Cudd_IsConstant(node))
|
if (Cudd_IsConstant(node))
|
||||||
{
|
{
|
||||||
@ -647,42 +622,42 @@ double ProbPath(DdNode *node,int comp_par)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
index=Cudd_NodeReadIndex(node);
|
index=Cudd_NodeReadIndex(node);
|
||||||
p=probs[index];
|
p=probs_ex[nex][index];
|
||||||
T = Cudd_T(node);
|
T = Cudd_T(node);
|
||||||
F = Cudd_E(node);
|
F = Cudd_E(node);
|
||||||
pf=ProbPath(F,comp);
|
pf=ProbPath(F,comp,nex);
|
||||||
pt=ProbPath(T,comp);
|
pt=ProbPath(T,comp,nex);
|
||||||
BChild0=pf*(1-p);
|
BChild0=pf*(1-p);
|
||||||
BChild1=pt*p;
|
BChild1=pt*p;
|
||||||
value_p=get_value(nodesF,nodekey);
|
value_p=get_value(nodesF,nodekey);
|
||||||
e0 = (*value_p)*BChild0;
|
e0 = (*value_p)*BChild0;
|
||||||
e1 = (*value_p)*BChild1;
|
e1 = (*value_p)*BChild1;
|
||||||
mVarIndex=bVar2mVar[index];
|
mVarIndex=bVar2mVar_ex[nex][index];
|
||||||
v=vars[mVarIndex];
|
v=vars_ex[nex][mVarIndex];
|
||||||
pos=index-v.firstBoolVar;
|
pos=index-v.firstBoolVar;
|
||||||
eta_rule=eta_temp[v.nRule];
|
eta_rule=eta_temp[v.nRule];
|
||||||
eta_rule[pos][0]=eta_rule[pos][0]+e0;
|
eta_rule[pos][0]=eta_rule[pos][0]+e0;
|
||||||
eta_rule[pos][1]=eta_rule[pos][1]+e1;
|
eta_rule[pos][1]=eta_rule[pos][1]+e1;
|
||||||
res=BChild0+BChild1;
|
res=BChild0+BChild1;
|
||||||
add_node(nodesB,nodekey,res);
|
add_node(nodesB,nodekey,res);
|
||||||
position=Cudd_ReadPerm(mgr,index);
|
position=Cudd_ReadPerm(mgr_ex[nex],index);
|
||||||
position=position+1;
|
position=position+1;
|
||||||
boolVarIndex=Cudd_ReadInvPerm(mgr,position); //Returns the index of the variable currently in the i-th position of the order.
|
boolVarIndex=Cudd_ReadInvPerm(mgr_ex[nex],position);//Returns the index of the variable currently in the i-th position of the order.
|
||||||
if (position<*boolVars)
|
if (position<boolVars_ex[nex])
|
||||||
{
|
{
|
||||||
sigma[position]=sigma[position]+e0+e1;
|
sigma[position]=sigma[position]+e0+e1;
|
||||||
}
|
}
|
||||||
if(!Cudd_IsConstant(T))
|
if(!Cudd_IsConstant(T))
|
||||||
{
|
{
|
||||||
index=Cudd_NodeReadIndex(T);
|
index=Cudd_NodeReadIndex(T);
|
||||||
position=Cudd_ReadPerm(mgr,index);
|
position=Cudd_ReadPerm(mgr_ex[nex],index);
|
||||||
sigma[position]=sigma[position]-e1;
|
sigma[position]=sigma[position]-e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Cudd_IsConstant(F))
|
if(!Cudd_IsConstant(F))
|
||||||
{
|
{
|
||||||
index=Cudd_NodeReadIndex(F);
|
index=Cudd_NodeReadIndex(F);
|
||||||
position=Cudd_ReadPerm(mgr,index);
|
position=Cudd_ReadPerm(mgr_ex[nex],index);
|
||||||
sigma[position]=sigma[position]-e0;
|
sigma[position]=sigma[position]-e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,29 +669,29 @@ double ProbPath(DdNode *node,int comp_par)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Forward(DdNode *root)
|
void Forward(DdNode *root, int nex)
|
||||||
{
|
{
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
if (*boolVars)
|
if (boolVars_ex[nex])
|
||||||
{
|
{
|
||||||
nodesToVisit= (DdNode ***)malloc(sizeof(DdNode **)* *boolVars);
|
nodesToVisit= (DdNode ***)malloc(sizeof(DdNode **)* boolVars_ex[nex]);
|
||||||
NnodesToVisit= (int *)malloc(sizeof(int)* *boolVars);
|
NnodesToVisit= (int *)malloc(sizeof(int)* boolVars_ex[nex]);
|
||||||
nodesToVisit[0]=(DdNode **)malloc(sizeof(DdNode *));
|
nodesToVisit[0]=(DdNode **)malloc(sizeof(DdNode *));
|
||||||
nodesToVisit[0][0]=root;
|
nodesToVisit[0][0]=root;
|
||||||
NnodesToVisit[0]=1;
|
NnodesToVisit[0]=1;
|
||||||
for(i=1;i<*boolVars;i++)
|
for(i=1;i<boolVars_ex[nex];i++)
|
||||||
{
|
{
|
||||||
nodesToVisit[i]=NULL;
|
nodesToVisit[i]=NULL;
|
||||||
NnodesToVisit[i]=0;
|
NnodesToVisit[i]=0;
|
||||||
}
|
}
|
||||||
add_node(nodesF,Cudd_Regular(root),1);
|
add_node(nodesF,Cudd_Regular(root),1);
|
||||||
for(i=0;i<*boolVars;i++)
|
for(i=0;i<boolVars_ex[nex];i++)
|
||||||
{
|
{
|
||||||
for(j=0;j<NnodesToVisit[i];j++)
|
for(j=0;j<NnodesToVisit[i];j++)
|
||||||
UpdateForward(nodesToVisit[i][j]);
|
UpdateForward(nodesToVisit[i][j],nex);
|
||||||
}
|
}
|
||||||
for(i=0;i<*boolVars;i++)
|
for(i=0;i<boolVars_ex[nex];i++)
|
||||||
{
|
{
|
||||||
free(nodesToVisit[i]);
|
free(nodesToVisit[i]);
|
||||||
}
|
}
|
||||||
@ -729,7 +704,7 @@ void Forward(DdNode *root)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateForward(DdNode *node)
|
void UpdateForward(DdNode *node, int nex)
|
||||||
{
|
{
|
||||||
int index,position,mVarIndex;
|
int index,position,mVarIndex;
|
||||||
DdNode *T,*E,*nodereg;
|
DdNode *T,*E,*nodereg;
|
||||||
@ -743,9 +718,9 @@ void UpdateForward(DdNode *node)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
index=Cudd_NodeReadIndex(node);
|
index=Cudd_NodeReadIndex(node);
|
||||||
mVarIndex=bVar2mVar[index];
|
mVarIndex=bVar2mVar_ex[nex][index];
|
||||||
v=vars[mVarIndex];
|
v=vars_ex[nex][mVarIndex];
|
||||||
p=probs[index];
|
p=probs_ex[nex][index];
|
||||||
nodereg=Cudd_Regular(node);
|
nodereg=Cudd_Regular(node);
|
||||||
value_p=get_value(nodesF,nodereg);
|
value_p=get_value(nodesF,nodereg);
|
||||||
if (value_p== NULL)
|
if (value_p== NULL)
|
||||||
@ -768,7 +743,7 @@ void UpdateForward(DdNode *node)
|
|||||||
{
|
{
|
||||||
add_or_replace_node(nodesF,Cudd_Regular(T),*value_p*p);
|
add_or_replace_node(nodesF,Cudd_Regular(T),*value_p*p);
|
||||||
index=Cudd_NodeReadIndex(T);
|
index=Cudd_NodeReadIndex(T);
|
||||||
position=Cudd_ReadPerm(mgr,index);
|
position=Cudd_ReadPerm(mgr_ex[nex],index);
|
||||||
nodesToVisit[position]=(DdNode **)realloc(nodesToVisit[position],
|
nodesToVisit[position]=(DdNode **)realloc(nodesToVisit[position],
|
||||||
(NnodesToVisit[position]+1)* sizeof(DdNode *));
|
(NnodesToVisit[position]+1)* sizeof(DdNode *));
|
||||||
nodesToVisit[position][NnodesToVisit[position]]=T;
|
nodesToVisit[position][NnodesToVisit[position]]=T;
|
||||||
@ -787,7 +762,7 @@ void UpdateForward(DdNode *node)
|
|||||||
{
|
{
|
||||||
add_or_replace_node(nodesF,Cudd_Regular(E),*value_p*(1-p));
|
add_or_replace_node(nodesF,Cudd_Regular(E),*value_p*(1-p));
|
||||||
index=Cudd_NodeReadIndex(E);
|
index=Cudd_NodeReadIndex(E);
|
||||||
position=Cudd_ReadPerm(mgr,index);
|
position=Cudd_ReadPerm(mgr_ex[nex],index);
|
||||||
nodesToVisit[position]=(DdNode **)realloc(nodesToVisit[position],
|
nodesToVisit[position]=(DdNode **)realloc(nodesToVisit[position],
|
||||||
(NnodesToVisit[position]+1)* sizeof(DdNode *));
|
(NnodesToVisit[position]+1)* sizeof(DdNode *));
|
||||||
nodesToVisit[position][NnodesToVisit[position]]=E;
|
nodesToVisit[position][NnodesToVisit[position]]=E;
|
||||||
@ -805,22 +780,22 @@ int indexMvar(DdNode * node)
|
|||||||
int index,mVarIndex;
|
int index,mVarIndex;
|
||||||
|
|
||||||
index=Cudd_NodeReadIndex(node);
|
index=Cudd_NodeReadIndex(node);
|
||||||
mVarIndex=bVar2mVar[index];
|
mVarIndex=bVar2mVar_ex[ex][index];
|
||||||
return mVarIndex;
|
return mVarIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double GetOutsideExpe(DdNode *root,double ex_prob)
|
double GetOutsideExpe(DdNode *root,double ex_prob, int nex)
|
||||||
{
|
{
|
||||||
int i,j,mVarIndex,bVarIndex;
|
int i,j,mVarIndex,bVarIndex;
|
||||||
double **eta_rule;
|
double **eta_rule;
|
||||||
double theta,rootProb, T=0;
|
double theta,rootProb, T=0;
|
||||||
|
|
||||||
|
|
||||||
sigma=(double *)malloc(*boolVars * sizeof(double));
|
sigma=(double *)malloc(boolVars_ex[nex] * sizeof(double));
|
||||||
|
|
||||||
for (j=0; j<*boolVars; j++)
|
for (j=0; j<boolVars_ex[nex]; j++)
|
||||||
{
|
{
|
||||||
sigma[j]=0;
|
sigma[j]=0;
|
||||||
}
|
}
|
||||||
@ -832,23 +807,23 @@ double GetOutsideExpe(DdNode *root,double ex_prob)
|
|||||||
eta_temp[j][i][1]=0;
|
eta_temp[j][i][1]=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rootProb=ProbPath(root,0);
|
rootProb=ProbPath(root,0,nex);
|
||||||
if (rootProb>0.0)
|
if (rootProb>0.0)
|
||||||
{
|
{
|
||||||
for (j=0; j<*boolVars; j++)
|
for (j=0; j<boolVars_ex[nex]; j++)
|
||||||
{
|
{
|
||||||
T += sigma[j];
|
T += sigma[j];
|
||||||
bVarIndex=Cudd_ReadInvPerm(mgr,j);
|
bVarIndex=Cudd_ReadInvPerm(mgr_ex[nex],j);
|
||||||
if (bVarIndex==-1)
|
if (bVarIndex==-1)
|
||||||
{
|
{
|
||||||
bVarIndex=j;
|
bVarIndex=j;
|
||||||
}
|
}
|
||||||
|
|
||||||
mVarIndex=bVar2mVar[bVarIndex];
|
mVarIndex=bVar2mVar_ex[nex][bVarIndex];
|
||||||
eta_rule=eta_temp[vars[mVarIndex].nRule];
|
eta_rule=eta_temp[vars_ex[nex][mVarIndex].nRule];
|
||||||
for (i=0; i<vars[mVarIndex].nVal-1;i++)
|
for (i=0; i<vars_ex[nex][mVarIndex].nVal-1;i++)
|
||||||
{
|
{
|
||||||
theta=probs[bVarIndex];
|
theta=probs_ex[nex][bVarIndex];
|
||||||
eta_rule[i][0]=eta_rule[i][0]+T*(1-theta);
|
eta_rule[i][0]=eta_rule[i][0]+T*(1-theta);
|
||||||
eta_rule[i][1]=eta_rule[i][1]+T*theta;
|
eta_rule[i][1]=eta_rule[i][1]+T*theta;
|
||||||
}
|
}
|
||||||
@ -872,7 +847,7 @@ void Maximization(void)
|
|||||||
{
|
{
|
||||||
int r,i,j,e;
|
int r,i,j,e;
|
||||||
double sum=0;
|
double sum=0;
|
||||||
double *probs_rule,**eta_rule;
|
double *probs_rule,**eta_rule;
|
||||||
|
|
||||||
for (r=0;r<nRules;r++)
|
for (r=0;r<nRules;r++)
|
||||||
{
|
{
|
||||||
@ -885,23 +860,19 @@ void Maximization(void)
|
|||||||
arrayprob[r][i]=0;
|
arrayprob[r][i]=0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
arrayprob[r][i]=eta_rule[i][1]/sum;
|
arrayprob[r][i]=eta_rule[i][1]/sum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(e=0;e<ex;e++)
|
for(e=0;e<ex;e++)
|
||||||
{
|
{
|
||||||
nVars=nVars_ex+e;
|
for (j=0;j<nVars_ex[e];j++)
|
||||||
probs=probs_ex[e];
|
|
||||||
vars=vars_ex[e];
|
|
||||||
|
|
||||||
for (j=0;j<*nVars;j++)
|
|
||||||
{
|
{
|
||||||
r=vars[j].nRule;
|
r=vars_ex[e][j].nRule;
|
||||||
probs_rule=arrayprob[r];
|
probs_rule=arrayprob[r];
|
||||||
for(i=0;i<rules[r]-1;i++)
|
for(i=0;i<rules[r]-1;i++)
|
||||||
{
|
{
|
||||||
probs[vars[j].firstBoolVar+i]=probs_rule[i];
|
probs_ex[e][vars_ex[e][j].firstBoolVar+i]=probs_rule[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -935,17 +906,14 @@ static int randomize(void)
|
|||||||
}
|
}
|
||||||
for(e=0;e<ex;e++)
|
for(e=0;e<ex;e++)
|
||||||
{
|
{
|
||||||
nVars=nVars_ex+e;
|
for (j=0; j<nVars_ex[e]; j++)
|
||||||
probs=probs_ex[e];
|
|
||||||
vars=vars_ex[e];
|
|
||||||
for (j=0; j<*nVars; j++)
|
|
||||||
{
|
{
|
||||||
rule=vars[j].nRule;
|
rule=vars_ex[e][j].nRule;
|
||||||
theta=Theta_rules[rule];
|
theta=Theta_rules[rule];
|
||||||
p0=1;
|
p0=1;
|
||||||
for (i=0; i<vars[j].nVal-1;i++)
|
for (i=0; i<vars_ex[e][j].nVal-1;i++)
|
||||||
{
|
{
|
||||||
probs[vars[j].firstBoolVar+i]=theta[i]/p0;
|
probs_ex[e][vars_ex[e][j].firstBoolVar+i]=theta[i]/p0;
|
||||||
p0=p0*(1-theta[i]/p0);
|
p0=p0*(1-theta[i]/p0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1009,7 +977,7 @@ static int EM(void)
|
|||||||
cycle++;
|
cycle++;
|
||||||
for (r=0;r<nRules;r++)
|
for (r=0;r<nRules;r++)
|
||||||
{
|
{
|
||||||
for (i=0;i<rules[r]-1;i++)
|
for (i=0;i<rules[r]-1;i++)
|
||||||
{
|
{
|
||||||
eta_rule=eta[r];
|
eta_rule=eta[r];
|
||||||
eta_rule[i][0]=0;
|
eta_rule[i][0]=0;
|
||||||
@ -1027,13 +995,13 @@ static int EM(void)
|
|||||||
{
|
{
|
||||||
tail=YAP_TermNil();
|
tail=YAP_TermNil();
|
||||||
p0=1;
|
p0=1;
|
||||||
for (i=0;i<rules[r]-1;i++)
|
for (i=0;i<rules[r]-1;i++)
|
||||||
{
|
{
|
||||||
p=arrayprob[r][i]*p0;
|
p=arrayprob[r][i]*p0;
|
||||||
tail=YAP_MkPairTerm(YAP_MkFloatTerm(p),tail);
|
tail=YAP_MkPairTerm(YAP_MkFloatTerm(p),tail);
|
||||||
p0=p0*(1-arrayprob[r][i]);
|
p0=p0*(1-arrayprob[r][i]);
|
||||||
}
|
}
|
||||||
tail=YAP_MkPairTerm(YAP_MkFloatTerm(p0),tail);
|
tail=YAP_MkPairTerm(YAP_MkFloatTerm(p0),tail);
|
||||||
ruleTerm=YAP_MkIntTerm(r);
|
ruleTerm=YAP_MkIntTerm(r);
|
||||||
compoundTerm=YAP_MkPairTerm(ruleTerm,YAP_MkPairTerm(tail,YAP_TermNil()));
|
compoundTerm=YAP_MkPairTerm(ruleTerm,YAP_MkPairTerm(tail,YAP_TermNil()));
|
||||||
out2=YAP_MkPairTerm(compoundTerm,out2);
|
out2=YAP_MkPairTerm(compoundTerm,out2);
|
||||||
@ -1047,6 +1015,7 @@ static int EM(void)
|
|||||||
return (YAP_Unify(out2,arg7));
|
return (YAP_Unify(out2,arg7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int Q(void)
|
static int Q(void)
|
||||||
{
|
{
|
||||||
YAP_Term arg1,arg2,arg3,arg4,out,out1,
|
YAP_Term arg1,arg2,arg3,arg4,out,out1,
|
||||||
@ -1091,14 +1060,14 @@ static int Q(void)
|
|||||||
for (r=0; r<nRules; r++)
|
for (r=0; r<nRules; r++)
|
||||||
{
|
{
|
||||||
tail=YAP_TermNil();
|
tail=YAP_TermNil();
|
||||||
eta_rule=eta[r];
|
eta_rule=eta[r];
|
||||||
for (i=0;i<rules[r]-1;i++)
|
for (i=0;i<rules[r]-1;i++)
|
||||||
{
|
{
|
||||||
p0=eta_rule[i][0];
|
p0=eta_rule[i][0];
|
||||||
p1=eta_rule[i][1];
|
p1=eta_rule[i][1];
|
||||||
term=YAP_MkPairTerm(YAP_MkFloatTerm(p0),
|
term=YAP_MkPairTerm(YAP_MkFloatTerm(p0),
|
||||||
YAP_MkPairTerm(YAP_MkFloatTerm(p1),YAP_TermNil()));
|
YAP_MkPairTerm(YAP_MkFloatTerm(p1),YAP_TermNil()));
|
||||||
tail=YAP_MkPairTerm(term,tail);
|
tail=YAP_MkPairTerm(term,tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
ruleTerm=YAP_MkIntTerm(r);
|
ruleTerm=YAP_MkIntTerm(r);
|
||||||
|
4
packages/cplint/slipcase/hep1.cpl
Normal file
4
packages/cplint/slipcase/hep1.cpl
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
type(_A,type_b):0.5.
|
||||||
|
|
||||||
|
type(_A,type_c):0.5.
|
||||||
|
|
259520
packages/cplint/slipcase/hep1.kb
Normal file
259520
packages/cplint/slipcase/hep1.kb
Normal file
File diff suppressed because it is too large
Load Diff
151
packages/cplint/slipcase/hep1.l
Normal file
151
packages/cplint/slipcase/hep1.l
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
output(type/2).
|
||||||
|
|
||||||
|
input(fibros/2).
|
||||||
|
input(activity/2).
|
||||||
|
input(sex/2).
|
||||||
|
input(action/2).
|
||||||
|
input(age/2).
|
||||||
|
input(type/2).
|
||||||
|
input(got/2).
|
||||||
|
input(gpt/2).
|
||||||
|
input(tbil/2).
|
||||||
|
input(dbil/2).
|
||||||
|
input(che/2).
|
||||||
|
input(ttt/2).
|
||||||
|
input(ztt/2).
|
||||||
|
input(tcho/2).
|
||||||
|
input(tp/2).
|
||||||
|
input(dur/2).
|
||||||
|
input(b_rel11/2).
|
||||||
|
input(b_rel12/2).
|
||||||
|
input(b_rel13/2).
|
||||||
|
|
||||||
|
|
||||||
|
modeh(*,type(+m,type_b)).
|
||||||
|
modeh(*,type(+m,type_c)).
|
||||||
|
|
||||||
|
determination(type/2,sex/2).
|
||||||
|
determination(type/2,age/2).
|
||||||
|
|
||||||
|
determination(type/2,b_rel11/2).
|
||||||
|
determination(type/2,b_rel12/2).
|
||||||
|
determination(type/2,b_rel13/2).
|
||||||
|
|
||||||
|
determination(type/2,fibros/2).
|
||||||
|
determination(type/2,activity/2).
|
||||||
|
determination(type/2,got/2).
|
||||||
|
determination(type/2,gpt/2).
|
||||||
|
determination(type/2,tbil/2).
|
||||||
|
determination(type/2,dbil/2).
|
||||||
|
determination(type/2,che/2).
|
||||||
|
determination(type/2,ttt/2).
|
||||||
|
determination(type/2,ztt/2).
|
||||||
|
determination(type/2,tcho/2).
|
||||||
|
determination(type/2,tp/2).
|
||||||
|
determination(type/2,dur/2).
|
||||||
|
|
||||||
|
modeb(*,b_rel11(-b,+m)).
|
||||||
|
modeb(*,b_rel12(-i,+m)).
|
||||||
|
modeb(*,b_rel13(-a,+m)).
|
||||||
|
|
||||||
|
modeb(*,b_rel11(+b,-m)).
|
||||||
|
modeb(*,b_rel12(+i,-m)).
|
||||||
|
modeb(*,b_rel13(+a,-m)).
|
||||||
|
|
||||||
|
|
||||||
|
modeb(*,fibros(+b,fibros_0)).
|
||||||
|
modeb(*,fibros(+b,fibros_1)).
|
||||||
|
modeb(*,fibros(+b,fibros_2)).
|
||||||
|
modeb(*,fibros(+b,fibros_3)).
|
||||||
|
modeb(*,fibros(+b,fibros_4)).
|
||||||
|
modeb(*,activity(+b,activity_0)).
|
||||||
|
modeb(*,activity(+b,activity_1)).
|
||||||
|
modeb(*,activity(+b,activity_2)).
|
||||||
|
modeb(*,activity(+b,activity_3)).
|
||||||
|
modeb(*,activity(+b,activity_false)).
|
||||||
|
modeb(*,sex(+m,sex_f)).
|
||||||
|
modeb(*,sex(+m,sex_m)).
|
||||||
|
modeb(*,age(+m,age_0)).
|
||||||
|
modeb(*,age(+m,age_1)).
|
||||||
|
modeb(*,age(+m,age_2)).
|
||||||
|
modeb(*,age(+m,age_3)).
|
||||||
|
modeb(*,age(+m,age_4)).
|
||||||
|
modeb(*,age(+m,age_5)).
|
||||||
|
modeb(*,age(+m,age_6)).
|
||||||
|
modeb(*,got(+i,got_1)).
|
||||||
|
modeb(*,got(+i,got_2)).
|
||||||
|
modeb(*,got(+i,got_3)).
|
||||||
|
modeb(*,got(+i,got_4)).
|
||||||
|
modeb(*,got(+i,got_5)).
|
||||||
|
modeb(*,gpt(+i,gpt_1)).
|
||||||
|
modeb(*,gpt(+i,gpt_2)).
|
||||||
|
modeb(*,gpt(+i,gpt_3)).
|
||||||
|
modeb(*,gpt(+i,gpt_4)).
|
||||||
|
modeb(*,tbil(+i,tbil_1)).
|
||||||
|
modeb(*,tbil(+i,tbil_2)).
|
||||||
|
modeb(*,dbil(+i,dbil_1)).
|
||||||
|
modeb(*,dbil(+i,dbil_2)).
|
||||||
|
modeb(*,che(+i,che_1)).
|
||||||
|
modeb(*,che(+i,che_2)).
|
||||||
|
modeb(*,che(+i,che_3)).
|
||||||
|
modeb(*,che(+i,che_4)).
|
||||||
|
modeb(*,che(+i,che_5)).
|
||||||
|
modeb(*,che(+i,che_6)).
|
||||||
|
modeb(*,che(+i,che_7)).
|
||||||
|
modeb(*,che(+i,che_8)).
|
||||||
|
modeb(*,che(+i,che_9)).
|
||||||
|
modeb(*,che(+i,che_10)).
|
||||||
|
modeb(*,ttt(+i,ttt_1)).
|
||||||
|
modeb(*,ttt(+i,ttt_2)).
|
||||||
|
modeb(*,ttt(+i,ttt_3)).
|
||||||
|
modeb(*,ttt(+i,ttt_4)).
|
||||||
|
modeb(*,ttt(+i,ttt_5)).
|
||||||
|
modeb(*,ttt(+i,ttt_6)).
|
||||||
|
modeb(*,ztt(+i,ztt_1)).
|
||||||
|
modeb(*,ztt(+i,ztt_2)).
|
||||||
|
modeb(*,ztt(+i,ztt_3)).
|
||||||
|
modeb(*,ztt(+i,ztt_4)).
|
||||||
|
modeb(*,ztt(+i,ztt_5)).
|
||||||
|
modeb(*,ztt(+i,ztt_6)).
|
||||||
|
modeb(*,tcho(+i,tcho_1)).
|
||||||
|
modeb(*,tcho(+i,tcho_2)).
|
||||||
|
modeb(*,tcho(+i,tcho_3)).
|
||||||
|
modeb(*,tcho(+i,tcho_4)).
|
||||||
|
modeb(*,tp(+i,tp_1)).
|
||||||
|
modeb(*,tp(+i,tp_2)).
|
||||||
|
modeb(*,tp(+i,tp_3)).
|
||||||
|
modeb(*,tp(+i,tp_4)).
|
||||||
|
modeb(*,dur(+a,dur_0)).
|
||||||
|
modeb(*,dur(+a,dur_1)).
|
||||||
|
modeb(*,dur(+a,dur_2)).
|
||||||
|
modeb(*,dur(+a,dur_3)).
|
||||||
|
modeb(*,dur(+a,dur_4)).
|
||||||
|
modeb(*,fibros(+b,-f)).
|
||||||
|
modeb(*,activity(+b,-a)).
|
||||||
|
modeb(*,sex(+m,-sex)).
|
||||||
|
modeb(*,age(+m,-age)).
|
||||||
|
modeb(*,got(+i,-got)).
|
||||||
|
modeb(*,gpt(+i,-gpt)).
|
||||||
|
modeb(*,tbil(+i,-tbil)).
|
||||||
|
modeb(*,dbil(+i,-dbil)).
|
||||||
|
modeb(*,che(+i,-che)).
|
||||||
|
modeb(*,ttt(+i,-ttt)).
|
||||||
|
modeb(*,ztt(+i,-ztt)).
|
||||||
|
modeb(*,tcho(+i,-tcho)).
|
||||||
|
modeb(*,tp(+i,-tp)).
|
||||||
|
modeb(*,dur(+a,dur)).
|
||||||
|
|
||||||
|
lookahead(b_rel11(A,_),[fibros(A,_)]).
|
||||||
|
lookahead(b_rel11(A,_),[activity(A,_)]).
|
||||||
|
|
||||||
|
lookahead(b_rel12(A,_),[got(A,_)]).
|
||||||
|
lookahead(b_rel11(A,_B),[gpt(A,_)]).
|
||||||
|
lookahead(b_rel11(A,_B),[tbil(A,_)]).
|
||||||
|
lookahead(b_rel11(A,_B),[dbil(A,_)]).
|
||||||
|
lookahead(b_rel11(A,_B),[che(A,_)]).
|
||||||
|
lookahead(b_rel11(A,_B),[ttt(A,_)]).
|
||||||
|
lookahead(b_rel11(A,_B),[ztt(A,_)]).
|
||||||
|
lookahead(b_rel11(A,_B),[tcho(A,_)]).
|
||||||
|
lookahead(b_rel11(A,_B),[tp(A,_)]).
|
||||||
|
lookahead(b_rel13(A,_B),[dur(A,_)]).
|
||||||
|
|
40
packages/cplint/slipcase/hep1.rules
Normal file
40
packages/cplint/slipcase/hep1.rules
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* SLIPCASE Final CLL -2.525186
|
||||||
|
Execution time 45.693000
|
||||||
|
setting(epsilon_em,0.0001).
|
||||||
|
setting(epsilon_em_fraction,1.0e-5).
|
||||||
|
setting(eps,0.0001).
|
||||||
|
setting(eps_f,1.0e-5).
|
||||||
|
setting(epsilon_sem,2).
|
||||||
|
setting(random_restarts_REFnumber,1).
|
||||||
|
setting(random_restarts_number,1).
|
||||||
|
setting(iterREF,-1).
|
||||||
|
setting(iter,-1).
|
||||||
|
setting(examples,atoms).
|
||||||
|
setting(group,1).
|
||||||
|
setting(d,1).
|
||||||
|
setting(verbosity,1).
|
||||||
|
setting(logzero,log(1.0e-6)).
|
||||||
|
setting(initial_clauses_modeh,1).
|
||||||
|
setting(max_iter,10).
|
||||||
|
setting(max_var,5).
|
||||||
|
setting(max_rules,10).
|
||||||
|
setting(beamsize,20).
|
||||||
|
setting(epsilon_parsing,1.0e-10).
|
||||||
|
setting(tabling,off).
|
||||||
|
setting(bagof,false).
|
||||||
|
setting(depth_bound,false).
|
||||||
|
setting(depth,2).
|
||||||
|
setting(single_var,false).
|
||||||
|
setting(compiling,off).
|
||||||
|
*/
|
||||||
|
|
||||||
|
type(A,type_b):0.215232.
|
||||||
|
|
||||||
|
type(A,type_c):0.513334 :-
|
||||||
|
b_rel11(B,A),
|
||||||
|
fibros(B,C),
|
||||||
|
b_rel11(D,A),
|
||||||
|
fibros(B,E).
|
||||||
|
|
||||||
|
type(A,type_b):0.257763.
|
||||||
|
|
@ -92,11 +92,11 @@
|
|||||||
'$do_error'(instantiation_error,G).
|
'$do_error'(instantiation_error,G).
|
||||||
'$check_op_name'(_,_,',',G) :- !,
|
'$check_op_name'(_,_,',',G) :- !,
|
||||||
'$do_error'(permission_error(modify,operator,','),G).
|
'$do_error'(permission_error(modify,operator,','),G).
|
||||||
'$check_op_name'(_,_,'[]',G) :- !,
|
'$check_op_name'(_,_,'[]',G) :- T \= yf, T\= xf, !,
|
||||||
'$do_error'(permission_error(create,operator,'[]'),G).
|
'$do_error'(permission_error(create,operator,'[]'),G).
|
||||||
'$check_op_name'(_,_,'{}',G) :- !,
|
'$check_op_name'(_,_,'{}',G) :- T \= yf, T\= xf, !,
|
||||||
'$do_error'(permission_error(create,operator,'{}'),G).
|
'$do_error'(permission_error(create,operator,'{}'),G).
|
||||||
'$check_op_name'(P,T,'|',G) :-
|
'$check_op_name'(P,T,'|',G) :-
|
||||||
(
|
(
|
||||||
integer(P),
|
integer(P),
|
||||||
P < 1001, P > 0
|
P < 1001, P > 0
|
||||||
|
Reference in New Issue
Block a user