2012-03-22 11:33:24 +00:00
|
|
|
#ifndef HORUS_FOVESOLVER_H
|
|
|
|
#define HORUS_FOVESOLVER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "ParfactorList.h"
|
|
|
|
|
|
|
|
|
|
|
|
class LiftedOperator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual unsigned getCost (void) = 0;
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
virtual void apply (void) = 0;
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
virtual string toString (void) = 0;
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
static vector<LiftedOperator*> getValidOps (
|
|
|
|
ParfactorList&, const Grounds&);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
static void printValidOps (ParfactorList&, const Grounds&);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SumOutOperator : public LiftedOperator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SumOutOperator (unsigned group, ParfactorList& pfList)
|
|
|
|
: group_(group), pfList_(pfList) { }
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
unsigned getCost (void);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
void apply (void);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
static vector<SumOutOperator*> getValidOps (
|
|
|
|
ParfactorList&, const Grounds&);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
string toString (void);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
private:
|
|
|
|
static bool validOp (unsigned, ParfactorList&, const Grounds&);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
static vector<ParfactorList::iterator> parfactorsWithGroup (
|
|
|
|
ParfactorList& pfList, unsigned group);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
static bool isToEliminate (Parfactor*, unsigned, const Grounds&);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
|
|
|
unsigned group_;
|
|
|
|
ParfactorList& pfList_;
|
2012-03-22 11:33:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CountingOperator : public LiftedOperator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CountingOperator (
|
|
|
|
ParfactorList::iterator pfIter,
|
|
|
|
LogVar X,
|
|
|
|
ParfactorList& pfList)
|
|
|
|
: pfIter_(pfIter), X_(X), pfList_(pfList) { }
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
unsigned getCost (void);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
void apply (void);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
static vector<CountingOperator*> getValidOps (ParfactorList&);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
string toString (void);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
private:
|
|
|
|
static bool validOp (Parfactor*, LogVar);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
|
|
|
ParfactorList::iterator pfIter_;
|
|
|
|
LogVar X_;
|
|
|
|
ParfactorList& pfList_;
|
2012-03-22 11:33:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GroundOperator : public LiftedOperator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GroundOperator (
|
|
|
|
ParfactorList::iterator pfIter,
|
|
|
|
LogVar X,
|
|
|
|
ParfactorList& pfList)
|
|
|
|
: pfIter_(pfIter), X_(X), pfList_(pfList) { }
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
unsigned getCost (void);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
void apply (void);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
static vector<GroundOperator*> getValidOps (ParfactorList&);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
string toString (void);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
private:
|
2012-03-31 23:27:37 +01:00
|
|
|
ParfactorList::iterator pfIter_;
|
|
|
|
LogVar X_;
|
|
|
|
ParfactorList& pfList_;
|
2012-03-22 11:33:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FoveSolver
|
|
|
|
{
|
|
|
|
public:
|
2012-03-31 23:27:37 +01:00
|
|
|
FoveSolver (const ParfactorList& pfList) : pfList_(pfList) { }
|
|
|
|
|
|
|
|
Params getPosterioriOf (const Ground&);
|
2012-03-22 11:33:24 +00:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
Params getJointDistributionOf (const Grounds&);
|
2012-03-22 11:33:24 +00:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
static void absorveEvidence (
|
|
|
|
ParfactorList& pfList, ObservedFormulas& obsFormulas);
|
2012-03-22 11:33:24 +00:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
static Parfactors countNormalize (Parfactor*, const LogVarSet&);
|
2012-03-22 11:33:24 +00:00
|
|
|
|
|
|
|
private:
|
2012-03-31 23:27:37 +01:00
|
|
|
void runSolver (const Grounds&);
|
2012-03-22 11:33:24 +00:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
LiftedOperator* getBestOperation (const Grounds&);
|
2012-03-22 11:33:24 +00:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
void runWeakBayesBall (const Grounds&);
|
|
|
|
|
|
|
|
void shatterAgainstQuery (const Grounds&);
|
|
|
|
|
|
|
|
static Parfactors absorve (ObservedFormula&, Parfactor*);
|
2012-03-22 11:33:24 +00:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
ParfactorList pfList_;
|
2012-03-22 11:33:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HORUS_FOVESOLVER_H
|
|
|
|
|