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-05-17 12:00:33 +01:00
|
|
|
#include "CptEntry.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&);
|
|
|
|
Factor (VarId, unsigned, const ParamSet&);
|
|
|
|
Factor (VarNodes&, Distribution*);
|
|
|
|
Factor (const VarNodes&, const ParamSet&);
|
|
|
|
Factor (const VarIdSet&, const Ranges&, const ParamSet&);
|
|
|
|
|
|
|
|
void setParameters (const ParamSet&);
|
|
|
|
void copyFromFactor (const Factor& f);
|
|
|
|
void multiplyByFactor (const Factor&, const vector<CptEntry>* = 0);
|
|
|
|
void insertVariable (VarId, unsigned);
|
|
|
|
void removeAllVariablesExcept (VarId);
|
|
|
|
void removeVariable (VarId);
|
|
|
|
void removeFirstVariable (void);
|
|
|
|
void removeLastVariable (void);
|
|
|
|
void orderVariables (void);
|
|
|
|
void orderVariables (const VarIdSet&);
|
|
|
|
void removeInconsistentEntries (VarId, unsigned);
|
2011-07-22 21:33:30 +01:00
|
|
|
string getLabel (void) const;
|
2011-12-12 15:29:51 +00:00
|
|
|
void printFactor (void) const;
|
|
|
|
int getPositionOf (VarId) const;
|
|
|
|
const vector<CptEntry>& getCptEntries (void) const;
|
|
|
|
|
|
|
|
const VarIdSet& getVarIds (void) const { return varids_; }
|
|
|
|
const Ranges& getRanges (void) const { return ranges_; }
|
|
|
|
const ParamSet& getParameters (void) const { return dist_->params; }
|
|
|
|
Distribution* getDistribution (void) const { return dist_; }
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
void freeDistribution (void)
|
|
|
|
{
|
|
|
|
delete dist_;
|
|
|
|
dist_ = 0;
|
|
|
|
}
|
2011-05-17 12:00:33 +01:00
|
|
|
|
|
|
|
private:
|
2011-12-12 15:29:51 +00:00
|
|
|
|
|
|
|
VarIdSet varids_;
|
|
|
|
Ranges ranges_;
|
|
|
|
Distribution* dist_;
|
2011-05-17 12:00:33 +01:00
|
|
|
};
|
|
|
|
|
2011-12-12 15:29:51 +00:00
|
|
|
#endif // HORUS_FACTOR_H
|
|
|
|
|