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

68 lines
1.9 KiB
C
Raw Normal View History

2011-12-12 15:29:51 +00:00
#ifndef HORUS_FACTOR_H
#define HORUS_FACTOR_H
#include <vector>
#include "Distribution.h"
2011-12-12 15:29:51 +00:00
#include "VarNode.h"
using namespace std;
class Distribution;
2011-12-12 15:29:51 +00:00
class Factor
{
public:
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;
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-12-12 15:29:51 +00:00
void setDistribution (Distribution* dist)
{
dist_ = dist;
}
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-12-12 15:29:51 +00:00
#endif // HORUS_FACTOR_H