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/ParfactorList.h

121 lines
2.8 KiB
C
Raw Normal View History

2012-03-22 11:33:24 +00:00
#ifndef HORUS_PARFACTORLIST_H
#define HORUS_PARFACTORLIST_H
#include <list>
2012-03-31 23:27:37 +01:00
#include <queue>
2012-03-22 11:33:24 +00:00
#include "Parfactor.h"
#include "ProbFormula.h"
using namespace std;
class ParfactorList
{
public:
ParfactorList (void) { }
2012-03-31 23:27:37 +01:00
ParfactorList (const ParfactorList&);
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
ParfactorList (const Parfactors&);
~ParfactorList (void);
const list<Parfactor*>& parfactors (void) const { return pfList_; }
void clear (void) { pfList_.clear(); }
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
unsigned size (void) const { return pfList_.size(); }
2012-03-22 11:33:24 +00:00
typedef std::list<Parfactor*>::iterator iterator;
2012-03-31 23:27:37 +01:00
2012-03-22 11:33:24 +00:00
iterator begin (void) { return pfList_.begin(); }
2012-03-31 23:27:37 +01:00
iterator end (void) { return pfList_.end(); }
2012-03-22 11:33:24 +00:00
typedef std::list<Parfactor*>::const_iterator const_iterator;
2012-03-31 23:27:37 +01:00
2012-03-22 11:33:24 +00:00
const_iterator begin (void) const { return pfList_.begin(); }
2012-03-31 23:27:37 +01:00
const_iterator end (void) const { return pfList_.end(); }
void add (Parfactor* pf);
void add (const Parfactors& pfs);
void addShattered (Parfactor* pf);
list<Parfactor*>::iterator insertShattered (
list<Parfactor*>::iterator, Parfactor*);
list<Parfactor*>::iterator remove (list<Parfactor*>::iterator);
list<Parfactor*>::iterator removeAndDelete (list<Parfactor*>::iterator);
bool isAllShattered (void) const;
2012-03-22 11:33:24 +00:00
void print (void) const;
private:
2012-03-31 23:27:37 +01:00
2012-05-15 16:52:21 +01:00
bool isShattered (const Parfactor*) const;
2012-03-31 23:27:37 +01:00
bool isShattered (const Parfactor*, const Parfactor*) const;
void addToShatteredList (Parfactor*);
Parfactors shatterAgainstMySelf (Parfactor* g);
2012-05-15 16:52:21 +01:00
Parfactors shatterAgainstMySelf2 (Parfactor* g);
Parfactors shatterAgainstMySelf (
Parfactor* g, unsigned fIdx1, unsigned fIdx2);
2012-03-31 23:27:37 +01:00
std::pair<Parfactors, Parfactors> shatter (
Parfactor*, Parfactor*);
std::pair<Parfactors, Parfactors> shatter (
2012-04-03 11:58:21 +01:00
unsigned, Parfactor*, unsigned, Parfactor*);
2012-03-31 23:27:37 +01:00
Parfactors shatter (
Parfactor*,
2012-04-03 11:58:21 +01:00
unsigned,
2012-03-31 23:27:37 +01:00
ConstraintTree*,
ConstraintTree*,
unsigned);
2012-03-22 11:33:24 +00:00
2012-04-18 03:04:06 +01:00
void updateGroups (unsigned group1, unsigned group2);
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
bool proper (
const ProbFormula&, ConstraintTree,
const ProbFormula&, ConstraintTree) const;
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
bool identical (
const ProbFormula&, ConstraintTree,
const ProbFormula&, ConstraintTree) const;
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
bool disjoint (
const ProbFormula&, ConstraintTree,
const ProbFormula&, ConstraintTree) const;
2012-03-22 11:33:24 +00:00
struct sortByParams
{
inline bool operator() (const Parfactor* pf1, const Parfactor* pf2)
{
if (pf1->params().size() < pf2->params().size()) {
return true;
} else if (pf1->params().size() == pf2->params().size() &&
pf1->params() < pf2->params()) {
return true;
}
return false;
}
};
2012-03-31 23:27:37 +01:00
list<Parfactor*> pfList_;
2012-03-22 11:33:24 +00:00
};
#endif // HORUS_PARFACTORLIST_H