2011-12-12 15:29:51 +00:00
|
|
|
#ifndef HORUS_FACTOR_H
|
|
|
|
#define HORUS_FACTOR_H
|
2011-05-17 12:00:33 +01:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2011-07-22 21:33:30 +01:00
|
|
|
#include "Distribution.h"
|
2011-12-12 15:29:51 +00:00
|
|
|
#include "VarNode.h"
|
|
|
|
|
2011-05-17 12:00:33 +01:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2011-07-22 21:33:30 +01:00
|
|
|
class Distribution;
|
2011-05-17 12:00:33 +01:00
|
|
|
|
2011-12-12 15:29:51 +00:00
|
|
|
|
2011-05-17 12:00:33 +01:00
|
|
|
class Factor
|
|
|
|
{
|
|
|
|
public:
|
2011-07-22 21:33:30 +01:00
|
|
|
Factor (void) { }
|
|
|
|
Factor (const Factor&);
|
2011-12-12 15:29:51 +00:00
|
|
|
Factor (VarId, unsigned);
|
|
|
|
Factor (const VarNodes&);
|
2012-03-22 11:33:24 +00:00
|
|
|
Factor (VarId, unsigned, const Params&);
|
2011-12-12 15:29:51 +00:00
|
|
|
Factor (VarNodes&, Distribution*);
|
2012-03-22 11:33:24 +00:00
|
|
|
Factor (const VarNodes&, const Params&);
|
|
|
|
Factor (const VarIds&, const Ranges&, const Params&);
|
|
|
|
~Factor (void);
|
2011-12-12 15:29:51 +00:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
void setParameters (const Params&);
|
2011-12-12 15:29:51 +00:00
|
|
|
void copyFromFactor (const Factor& f);
|
2012-03-22 11:33:24 +00:00
|
|
|
void multiply (const Factor&);
|
2011-12-12 15:29:51 +00:00
|
|
|
void insertVariable (VarId, unsigned);
|
2012-03-22 11:33:24 +00:00
|
|
|
void insertVariables (const VarIds&, const Ranges&);
|
|
|
|
void sumOutAllExcept (VarId);
|
|
|
|
void sumOutAllExcept (const VarIds&);
|
|
|
|
void sumOut (VarId);
|
|
|
|
void sumOutFirstVariable (void);
|
|
|
|
void sumOutLastVariable (void);
|
2011-12-12 15:29:51 +00:00
|
|
|
void orderVariables (void);
|
2012-03-22 11:33:24 +00:00
|
|
|
void reorderVariables (const VarIds&);
|
|
|
|
void absorveEvidence (VarId, unsigned);
|
|
|
|
void normalize (void);
|
|
|
|
bool contains (const VarIds&) const;
|
|
|
|
int indexOf (VarId) const;
|
2011-07-22 21:33:30 +01:00
|
|
|
string getLabel (void) const;
|
2012-03-22 11:33:24 +00:00
|
|
|
void print (void) const;
|
2011-12-12 15:29:51 +00:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
const VarIds& getVarIds (void) const { return varids_; }
|
2011-12-12 15:29:51 +00:00
|
|
|
const Ranges& getRanges (void) const { return ranges_; }
|
2012-03-22 11:33:24 +00:00
|
|
|
const Params& getParameters (void) const { return dist_->params; }
|
2011-12-12 15:29:51 +00:00
|
|
|
Distribution* getDistribution (void) const { return dist_; }
|
2012-03-22 11:33:24 +00:00
|
|
|
unsigned nrVariables (void) const { return varids_.size(); }
|
|
|
|
unsigned nrParameters() const { return dist_->params.size(); }
|
2011-07-22 21:33:30 +01:00
|
|
|
|
2011-12-12 15:29:51 +00:00
|
|
|
void setDistribution (Distribution* dist)
|
|
|
|
{
|
|
|
|
dist_ = dist;
|
|
|
|
}
|
2011-05-17 12:00:33 +01:00
|
|
|
|
|
|
|
private:
|
2011-12-12 15:29:51 +00:00
|
|
|
|
2012-03-22 11:33:24 +00:00
|
|
|
VarIds varids_;
|
2011-12-12 15:29:51 +00:00
|
|
|
Ranges ranges_;
|
|
|
|
Distribution* dist_;
|
2011-05-17 12:00:33 +01:00
|
|
|
};
|
|
|
|
|
2011-12-12 15:29:51 +00:00
|
|
|
#endif // HORUS_FACTOR_H
|
|
|
|
|