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/horus/Parfactor.h

126 lines
2.7 KiB
C
Raw Normal View History

2012-05-23 14:56:01 +01: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"
#include "Factor.h"
class Parfactor : public TFactor<ProbFormula>
{
public:
Parfactor (
const ProbFormulas&,
const Params&,
const Tuples&,
2012-05-24 23:38:44 +01:00
unsigned distId);
2012-05-23 14:56:01 +01:00
Parfactor (const Parfactor*, const Tuple&);
Parfactor (const Parfactor*, ConstraintTree*);
Parfactor (const Parfactor&);
~Parfactor (void);
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;
2012-05-24 22:55:20 +01:00
LogVarSet exclusiveLogVars (size_t fIdx) const;
2012-05-24 23:39:38 +01:00
2012-05-25 20:15:05 +01:00
void sumOutIndex (size_t fIdx);
2012-05-23 14:56:01 +01:00
void multiply (Parfactor&);
bool canCountConvert (LogVar X);
void countConvert (LogVar);
void expand (LogVar, LogVar, LogVar);
void fullExpand (LogVar);
void reorderAccordingGrounds (const Grounds&);
void absorveEvidence (const ProbFormula&, unsigned);
void setNewGroups (void);
void applySubstitution (const Substitution&);
2012-06-14 11:57:00 +01:00
size_t indexOfGround (const Ground&) const;
2012-05-24 23:38:44 +01:00
PrvGroup findGroup (const Ground&) const;
2012-05-23 14:56:01 +01:00
bool containsGround (const Ground&) const;
2012-06-14 11:57:00 +01:00
bool containsGrounds (const Grounds&) const;
2012-05-24 23:38:44 +01:00
bool containsGroup (PrvGroup) const;
2012-06-14 11:57:00 +01:00
bool containsGroups (vector<PrvGroup>) const;
2012-05-23 14:56:01 +01:00
unsigned nrFormulas (LogVar) const;
int indexOfLogVar (LogVar) const;
2012-05-24 23:38:44 +01:00
int indexOfGroup (PrvGroup) const;
2012-05-23 14:56:01 +01:00
2012-05-24 23:38:44 +01:00
unsigned nrFormulasWithGroup (PrvGroup) const;
2012-05-23 14:56:01 +01:00
2012-05-24 23:38:44 +01:00
vector<PrvGroup> getAllGroups (void) const;
2012-05-23 14:56:01 +01:00
void print (bool = false) const;
void printParameters (void) const;
void printProjections (void) const;
string getLabel (void) const;
void simplifyGrounds (void);
static bool canMultiply (Parfactor*, Parfactor*);
private:
2012-05-24 22:55:20 +01:00
void simplifyCountingFormulas (size_t fIdx);
2012-05-23 14:56:01 +01:00
2012-05-24 22:55:20 +01:00
void simplifyParfactor (size_t fIdx1, size_t fIdx2);
2012-05-23 14:56:01 +01:00
static std::pair<LogVars, LogVars> getAlignLogVars (
Parfactor* g1, Parfactor* g2);
2012-05-24 22:55:20 +01:00
void expandPotential (size_t fIdx, unsigned newRange,
2012-05-23 14:56:01 +01:00
const vector<unsigned>& sumIndexes);
static void alignAndExponentiate (Parfactor*, Parfactor*);
static void alignLogicalVars (Parfactor*, Parfactor*);
ConstraintTree* constr_;
};
typedef vector<Parfactor*> Parfactors;
#endif // HORUS_PARFACTOR_H