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

123 lines
2.6 KiB
C
Raw Normal View History

2012-05-23 14:56:01 +01:00
#ifndef HORUS_PARFACTOR_H
#define HORUS_PARFACTOR_H
2012-12-27 12:54:58 +00:00
#include "Factor.h"
2012-05-23 14:56:01 +01:00
#include "ProbFormula.h"
#include "ConstraintTree.h"
#include "LiftedUtils.h"
#include "Horus.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(); }
2012-12-17 18:39:42 +00:00
2012-05-23 14:56:01 +01:00
const LogVarSet& logVarSet (void) const { return constr_->logVarSet(); }
LogVarSet countedLogVars (void) const;
LogVarSet uncountedLogVars (void) const;
2012-12-17 18:39:42 +00:00
2012-05-23 14:56:01 +01:00
LogVarSet elimLogVars (void) const;
2012-12-17 18:39:42 +00:00
2012-05-24 22:55:20 +01:00
LogVarSet exclusiveLogVars (size_t fIdx) const;
2012-12-17 18:39:42 +00: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&);
2012-12-17 18:39:42 +00:00
2012-05-23 14:56:01 +01:00
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-12-17 18:39:42 +00:00
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-12-17 18:39:42 +00:00
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*);
2012-12-17 18:39:42 +00:00
2012-05-23 14:56:01 +01:00
ConstraintTree* constr_;
2012-12-20 23:19:10 +00:00
2012-05-23 14:56:01 +01:00
};
typedef vector<Parfactor*> Parfactors;
#endif // HORUS_PARFACTOR_H