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

122 lines
2.9 KiB
C
Raw Normal View History

2013-02-07 17:50:02 +00:00
#ifndef YAP_PACKAGES_CLPBN_HORUS_PARFACTORLIST_H_
#define YAP_PACKAGES_CLPBN_HORUS_PARFACTORLIST_H_
2012-05-23 14:56:01 +01:00
#include <list>
#include "Parfactor.h"
#include "ProbFormula.h"
2012-12-27 12:54:58 +00:00
class Parfactor;
2013-02-07 13:37:15 +00:00
2012-05-23 14:56:01 +01:00
class ParfactorList
{
public:
ParfactorList (void) { }
ParfactorList (const ParfactorList&);
ParfactorList (const Parfactors&);
~ParfactorList (void);
2013-02-07 13:37:15 +00:00
const std::list<Parfactor*>& parfactors (void) const { return pfList_; }
2012-05-23 14:56:01 +01:00
void clear (void) { pfList_.clear(); }
2012-05-24 22:55:20 +01:00
size_t size (void) const { return pfList_.size(); }
2012-05-23 14:56:01 +01:00
typedef std::list<Parfactor*>::iterator iterator;
iterator begin (void) { return pfList_.begin(); }
iterator end (void) { return pfList_.end(); }
typedef std::list<Parfactor*>::const_iterator const_iterator;
const_iterator begin (void) const { return pfList_.begin(); }
const_iterator end (void) const { return pfList_.end(); }
void add (Parfactor* pf);
void add (const Parfactors& pfs);
void addShattered (Parfactor* pf);
2013-02-07 13:37:15 +00:00
std::list<Parfactor*>::iterator insertShattered (
std::list<Parfactor*>::iterator, Parfactor*);
2012-05-23 14:56:01 +01:00
2013-02-07 13:37:15 +00:00
std::list<Parfactor*>::iterator remove (
std::list<Parfactor*>::iterator);
2012-05-23 14:56:01 +01:00
2013-02-07 13:37:15 +00:00
std::list<Parfactor*>::iterator removeAndDelete (
std::list<Parfactor*>::iterator);
2012-05-23 14:56:01 +01:00
bool isAllShattered (void) const;
void print (void) const;
2012-12-17 18:39:42 +00:00
ParfactorList& operator= (const ParfactorList& pfList);
2012-05-23 14:56:01 +01:00
private:
bool isShattered (const Parfactor*) const;
bool isShattered (const Parfactor*, const Parfactor*) const;
void addToShatteredList (Parfactor*);
Parfactors shatterAgainstMySelf (Parfactor* g);
Parfactors shatterAgainstMySelf2 (Parfactor* g);
Parfactors shatterAgainstMySelf (
2012-05-24 22:55:20 +01:00
Parfactor* g, size_t fIdx1, size_t fIdx2);
2012-12-17 18:39:42 +00:00
2012-05-23 14:56:01 +01:00
std::pair<Parfactors, Parfactors> shatter (
Parfactor*, Parfactor*);
std::pair<Parfactors, Parfactors> shatter (
2012-05-24 22:55:20 +01:00
size_t, Parfactor*, size_t, Parfactor*);
2012-05-23 14:56:01 +01:00
Parfactors shatter (
Parfactor*,
2012-05-24 23:38:44 +01:00
size_t,
2012-05-23 14:56:01 +01:00
ConstraintTree*,
ConstraintTree*,
2012-05-24 23:38:44 +01:00
PrvGroup);
2012-05-23 14:56:01 +01:00
2012-05-24 23:38:44 +01:00
void updateGroups (PrvGroup group1, PrvGroup group2);
2012-05-23 14:56:01 +01:00
bool proper (
const ProbFormula&, ConstraintTree,
const ProbFormula&, ConstraintTree) const;
bool identical (
const ProbFormula&, ConstraintTree,
const ProbFormula&, ConstraintTree) const;
bool disjoint (
const ProbFormula&, ConstraintTree,
const ProbFormula&, ConstraintTree) const;
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;
}
};
2013-02-07 13:37:15 +00:00
std::list<Parfactor*> pfList_;
2012-05-23 14:56:01 +01:00
};
2013-02-07 17:50:02 +00:00
#endif // YAP_PACKAGES_CLPBN_HORUS_PARFACTORLIST_H_
2012-05-23 14:56:01 +01:00