This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/CLPBN/clpbn/bp/Parfactor.h

102 lines
2.1 KiB
C
Raw Normal View History

2012-03-22 11:33:24 +00:00
#ifndef HORUS_PARFACTOR_H
#define HORUS_PARFACTOR_H
#include <list>
#include <unordered_map>
#include "ProbFormula.h"
#include "ConstraintTree.h"
#include "LiftedUtils.h"
#include "Horus.h"
2012-03-31 23:27:37 +01:00
#include "Factor.h"
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
class Parfactor : public TFactor<ProbFormula>
2012-03-22 11:33:24 +00:00
{
public:
Parfactor (
const ProbFormulas&,
const Params&,
const Tuples&,
unsigned);
2012-03-31 23:27:37 +01:00
Parfactor (const Parfactor*, const Tuple&);
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
Parfactor (const Parfactor*, ConstraintTree*);
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
Parfactor (const Parfactor&);
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
~Parfactor (void);
2012-03-22 11:33:24 +00:00
ConstraintTree* constr (void) { return constr_; }
const ConstraintTree* constr (void) const { return constr_; }
const LogVars& logVars (void) const { return constr_->logVars(); }
const LogVarSet& logVarSet (void) const { return constr_->logVarSet(); }
LogVarSet countedLogVars (void) const;
LogVarSet uncountedLogVars (void) const;
LogVarSet elimLogVars (void) const;
LogVarSet exclusiveLogVars (unsigned) const;
void setConstraintTree (ConstraintTree*);
2012-03-31 23:27:37 +01:00
void sumOut (unsigned fIdx);
2012-03-22 11:33:24 +00:00
void multiply (Parfactor&);
void countConvert (LogVar);
2012-03-31 23:27:37 +01:00
void expand (LogVar, LogVar, LogVar);
2012-03-22 11:33:24 +00:00
void fullExpand (LogVar);
void reorderAccordingGrounds (const Grounds&);
2012-03-31 23:27:37 +01:00
void absorveEvidence (const ProbFormula&, unsigned);
2012-03-22 11:33:24 +00:00
void setNewGroups (void);
void applySubstitution (const Substitution&);
2012-04-03 11:58:21 +01:00
int findGroup (const Ground&) const;
2012-03-31 23:27:37 +01:00
2012-03-22 11:33:24 +00:00
bool containsGround (const Ground&) const;
bool containsGroup (unsigned) const;
2012-03-31 23:27:37 +01:00
2012-03-22 11:33:24 +00:00
unsigned nrFormulas (LogVar) const;
2012-03-31 23:27:37 +01:00
int indexOfLogVar (LogVar) const;
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
int indexOfGroup (unsigned) const;
2012-03-22 11:33:24 +00:00
vector<unsigned> getAllGroups (void) const;
void print (bool = false) const;
2012-03-31 23:27:37 +01:00
string getLabel (void) const;
2012-03-22 11:33:24 +00:00
private:
2012-03-31 23:27:37 +01:00
void expandPotential (int fIdx, unsigned newRange,
const vector<unsigned>& sumIndexes);
2012-03-22 11:33:24 +00:00
static void alignAndExponentiate (Parfactor*, Parfactor*);
2012-03-31 23:27:37 +01:00
2012-03-22 11:33:24 +00:00
static void align (
Parfactor*, const LogVars&, Parfactor*, const LogVars&);
2012-03-31 23:27:37 +01:00
ConstraintTree* constr_;
2012-03-22 11:33:24 +00:00
};
typedef vector<Parfactor*> Parfactors;
#endif // HORUS_PARFACTOR_H