2013-02-07 17:50:02 +00:00
|
|
|
#ifndef YAP_PACKAGES_CLPBN_HORUS_PROBFORMULA_H_
|
|
|
|
#define YAP_PACKAGES_CLPBN_HORUS_PROBFORMULA_H_
|
2012-05-23 14:56:01 +01:00
|
|
|
|
2013-02-07 20:09:10 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <ostream>
|
2012-05-23 14:56:01 +01:00
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
#include "ConstraintTree.h"
|
|
|
|
#include "LiftedUtils.h"
|
|
|
|
#include "Horus.h"
|
|
|
|
|
2013-02-07 23:53:13 +00:00
|
|
|
|
2013-02-08 21:12:46 +00:00
|
|
|
namespace Horus {
|
2013-02-07 23:53:13 +00:00
|
|
|
|
2012-05-24 23:38:44 +01:00
|
|
|
typedef unsigned long PrvGroup;
|
2012-05-23 14:56:01 +01:00
|
|
|
|
2013-02-13 14:26:47 +00:00
|
|
|
class ProbFormula {
|
2012-05-23 14:56:01 +01:00
|
|
|
public:
|
2012-12-20 23:19:10 +00:00
|
|
|
ProbFormula (Symbol f, const LogVars& lvs, unsigned range)
|
2012-05-23 14:56:01 +01:00
|
|
|
: functor_(f), logVars_(lvs), range_(range),
|
2012-12-27 12:54:58 +00:00
|
|
|
countedLogVar_(), group_(std::numeric_limits<PrvGroup>::max()) { }
|
2012-05-23 14:56:01 +01:00
|
|
|
|
2012-12-20 23:19:10 +00:00
|
|
|
ProbFormula (Symbol f, unsigned r)
|
2012-12-27 12:54:58 +00:00
|
|
|
: functor_(f), range_(r),
|
|
|
|
group_(std::numeric_limits<PrvGroup>::max()) { }
|
2012-05-23 14:56:01 +01:00
|
|
|
|
|
|
|
Symbol functor (void) const { return functor_; }
|
|
|
|
|
|
|
|
unsigned arity (void) const { return logVars_.size(); }
|
|
|
|
|
|
|
|
unsigned range (void) const { return range_; }
|
|
|
|
|
|
|
|
LogVars& logVars (void) { return logVars_; }
|
|
|
|
|
|
|
|
const LogVars& logVars (void) const { return logVars_; }
|
|
|
|
|
|
|
|
LogVarSet logVarSet (void) const { return LogVarSet (logVars_); }
|
2012-12-17 18:39:42 +00:00
|
|
|
|
2012-05-24 23:38:44 +01:00
|
|
|
PrvGroup group (void) const { return group_; }
|
2012-05-23 14:56:01 +01:00
|
|
|
|
2012-05-24 23:38:44 +01:00
|
|
|
void setGroup (PrvGroup g) { group_ = g; }
|
2012-12-17 18:39:42 +00:00
|
|
|
|
2012-05-23 14:56:01 +01:00
|
|
|
bool sameSkeletonAs (const ProbFormula&) const;
|
|
|
|
|
|
|
|
bool contains (LogVar) const;
|
|
|
|
|
|
|
|
bool contains (LogVarSet) const;
|
|
|
|
|
2012-05-24 22:55:20 +01:00
|
|
|
size_t indexOf (LogVar) const;
|
2012-05-23 14:56:01 +01:00
|
|
|
|
|
|
|
bool isAtom (void) const;
|
|
|
|
|
|
|
|
bool isCounting (void) const;
|
|
|
|
|
|
|
|
LogVar countedLogVar (void) const;
|
2012-12-17 18:39:42 +00:00
|
|
|
|
2012-05-23 14:56:01 +01:00
|
|
|
void setCountedLogVar (LogVar);
|
|
|
|
|
|
|
|
void clearCountedLogVar (void);
|
2012-12-17 18:39:42 +00:00
|
|
|
|
2012-05-23 14:56:01 +01:00
|
|
|
void rename (LogVar, LogVar);
|
2012-12-17 18:39:42 +00:00
|
|
|
|
2012-05-24 23:38:44 +01:00
|
|
|
static PrvGroup getNewGroup (void);
|
2012-05-23 14:56:01 +01:00
|
|
|
|
2013-02-07 22:37:45 +00:00
|
|
|
private:
|
2013-02-07 13:37:15 +00:00
|
|
|
friend bool operator== (
|
|
|
|
const ProbFormula& f1, const ProbFormula& f2);
|
2012-05-23 14:56:01 +01:00
|
|
|
|
2013-02-07 13:37:15 +00:00
|
|
|
friend std::ostream& operator<< (
|
2013-02-07 22:37:45 +00:00
|
|
|
std::ostream&, const ProbFormula&);
|
2013-02-06 00:24:02 +00:00
|
|
|
|
2012-05-23 14:56:01 +01:00
|
|
|
Symbol functor_;
|
|
|
|
LogVars logVars_;
|
|
|
|
unsigned range_;
|
|
|
|
LogVar countedLogVar_;
|
2012-05-24 23:38:44 +01:00
|
|
|
PrvGroup group_;
|
|
|
|
static PrvGroup freeGroup_;
|
2012-05-23 14:56:01 +01:00
|
|
|
};
|
|
|
|
|
2013-02-07 13:37:15 +00:00
|
|
|
typedef std::vector<ProbFormula> ProbFormulas;
|
2012-05-23 14:56:01 +01:00
|
|
|
|
|
|
|
|
2013-02-13 14:26:47 +00:00
|
|
|
class ObservedFormula {
|
2012-05-23 14:56:01 +01:00
|
|
|
public:
|
2013-02-06 00:24:02 +00:00
|
|
|
ObservedFormula (Symbol f, unsigned a, unsigned ev);
|
2012-05-23 14:56:01 +01:00
|
|
|
|
2013-02-06 00:24:02 +00:00
|
|
|
ObservedFormula (Symbol f, unsigned ev, const Tuple& tuple);
|
2012-05-23 14:56:01 +01:00
|
|
|
|
|
|
|
Symbol functor (void) const { return functor_; }
|
|
|
|
|
|
|
|
unsigned arity (void) const { return arity_; }
|
|
|
|
|
|
|
|
unsigned evidence (void) const { return evidence_; }
|
|
|
|
|
2012-06-14 11:57:00 +01:00
|
|
|
void setEvidence (unsigned ev) { evidence_ = ev; }
|
|
|
|
|
2012-05-23 14:56:01 +01:00
|
|
|
ConstraintTree& constr (void) { return constr_; }
|
|
|
|
|
|
|
|
bool isAtom (void) const { return arity_ == 0; }
|
|
|
|
|
|
|
|
void addTuple (const Tuple& tuple) { constr_.addTuple (tuple); }
|
|
|
|
|
|
|
|
private:
|
2013-02-07 22:37:45 +00:00
|
|
|
friend std::ostream& operator<< (
|
|
|
|
std::ostream&, const ObservedFormula&);
|
|
|
|
|
2012-05-23 14:56:01 +01:00
|
|
|
Symbol functor_;
|
|
|
|
unsigned arity_;
|
|
|
|
unsigned evidence_;
|
|
|
|
ConstraintTree constr_;
|
|
|
|
};
|
|
|
|
|
2013-02-07 13:37:15 +00:00
|
|
|
typedef std::vector<ObservedFormula> ObservedFormulas;
|
2012-05-23 14:56:01 +01:00
|
|
|
|
2013-02-08 21:12:46 +00:00
|
|
|
} // namespace Horus
|
2013-02-07 23:53:13 +00:00
|
|
|
|
2013-02-08 00:20:01 +00:00
|
|
|
#endif // YAP_PACKAGES_CLPBN_HORUS_PROBFORMULA_H_
|
2012-05-23 14:56:01 +01:00
|
|
|
|