2009-02-16 12:23:29 +00:00
|
|
|
/*
|
|
|
|
LPAD and CP-Logic interpreter
|
|
|
|
|
|
|
|
Copyright (c) 2007, Fabrizio Riguzzi
|
|
|
|
|
|
|
|
This package uses the library cudd, see http://vlsi.colorado.edu/~fabio/CUDD/
|
|
|
|
for the relative license.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
#include "cuddInt.h"
|
|
|
|
#include "mtr.h"
|
|
|
|
#include "YapInterface.h"
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int var,value;
|
|
|
|
} factor;
|
|
|
|
|
2010-07-27 15:53:47 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int nFact;
|
|
|
|
factor * factors;
|
|
|
|
} term;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int nTerms;
|
|
|
|
term * terms;
|
|
|
|
} expr;
|
|
|
|
|
2009-02-16 12:23:29 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int nVal,nBit;
|
2010-07-27 15:53:47 +01:00
|
|
|
double * probabilities;
|
|
|
|
DdNode * * booleanVars;
|
2009-02-16 12:23:29 +00:00
|
|
|
} variable;
|
|
|
|
|
2010-07-27 15:53:47 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int nVar;
|
|
|
|
int nBVar;
|
|
|
|
variable * varar;
|
|
|
|
int * bVar2mVar;
|
|
|
|
} variables;
|
2009-02-16 12:23:29 +00:00
|
|
|
|
2010-07-27 15:53:47 +01:00
|
|
|
variables createVars(YAP_Term t,DdManager * mgr, int create_dot, char inames[1000][20]);
|
|
|
|
expr createExpression(YAP_Term t);
|
2009-02-16 12:23:29 +00:00
|
|
|
void init_my_predicates(void);
|
|
|
|
int compare(char *a, char *b);
|
|
|
|
gint my_equal(gconstpointer v,gconstpointer v2);
|
|
|
|
guint my_hash(gconstpointer key);
|
|
|
|
void dealloc(gpointer key,gpointer value,gpointer user_data);
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-27 15:53:47 +01:00
|
|
|
DdNode * retFunction(DdManager * mgr, expr expression,variables v);
|
|
|
|
DdNode * retTerm(DdManager * mgr,term t,variables v);
|
|
|
|
DdNode * retFactor(DdManager * mgr, factor f, variables v);
|
2009-02-16 12:23:29 +00:00
|
|
|
|
2010-07-27 15:53:47 +01:00
|
|
|
double Prob(DdNode *node, variables vars,GHashTable * nodes);
|
2009-02-16 12:23:29 +00:00
|
|
|
|
|
|
|
double ProbBool(DdNode *node, int bits, int nBit,int posBVar,variable v,
|
2010-07-27 15:53:47 +01:00
|
|
|
variables vars,GHashTable * nodes);
|