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

125 lines
2.7 KiB
C
Raw Normal View History

2013-02-07 17:50:02 +00:00
#ifndef YAP_PACKAGES_CLPBN_HORUS_PARFACTOR_H_
#define YAP_PACKAGES_CLPBN_HORUS_PARFACTOR_H_
2012-05-23 14:56:01 +01:00
2013-02-07 20:09:10 +00:00
#include <vector>
#include <string>
#include "GenericFactor.h"
2012-05-23 14:56:01 +01:00
#include "ProbFormula.h"
#include "ConstraintTree.h"
#include "LiftedUtils.h"
#include "Horus.h"
namespace Horus {
2013-02-07 23:53:13 +00:00
class Parfactor : public GenericFactor<ProbFormula> {
2012-05-23 14:56:01 +01:00
public:
2013-02-13 15:25:55 +00:00
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();
2012-05-23 14:56:01 +01:00
ConstraintTree* constr() { return constr_; }
2012-05-23 14:56:01 +01:00
const ConstraintTree* constr() const { return constr_; }
2012-05-23 14:56:01 +01:00
const LogVars& logVars() const { return constr_->logVars(); }
2012-12-17 18:39:42 +00:00
const LogVarSet& logVarSet() const { return constr_->logVarSet(); }
2012-05-23 14:56:01 +01:00
LogVarSet countedLogVars() const;
2012-05-23 14:56:01 +01:00
LogVarSet uncountedLogVars() const;
2012-12-17 18:39:42 +00:00
LogVarSet elimLogVars() 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();
2012-05-23 14:56:01 +01:00
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
2013-02-07 13:37:15 +00:00
bool containsGroups (std::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
std::vector<PrvGroup> getAllGroups() const;
2012-05-23 14:56:01 +01:00
void print (bool = false) const;
void printParameters() const;
2012-05-23 14:56:01 +01:00
void printProjections() const;
2012-05-23 14:56:01 +01:00
std::string getLabel() const;
2012-05-23 14:56:01 +01:00
void simplifyGrounds();
2012-05-23 14:56:01 +01:00
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,
2013-02-07 13:37:15 +00:00
const std::vector<unsigned>& sumIndexes);
2012-05-23 14:56:01 +01:00
static void alignAndExponentiate (Parfactor*, Parfactor*);
static void alignLogicalVars (Parfactor*, Parfactor*);
2012-12-17 18:39:42 +00:00
ConstraintTree* constr_;
2012-12-20 23:19:10 +00:00
2012-12-27 22:25:45 +00:00
DISALLOW_ASSIGN (Parfactor);
2012-05-23 14:56:01 +01:00
};
2013-02-07 13:37:15 +00:00
typedef std::vector<Parfactor*> Parfactors;
2012-05-23 14:56:01 +01:00
} // namespace Horus
2013-02-07 23:53:13 +00:00
2013-02-08 00:20:01 +00:00
#endif // YAP_PACKAGES_CLPBN_HORUS_PARFACTOR_H_
2012-05-23 14:56:01 +01:00