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/CptEntry.h
2011-05-17 12:00:33 +01:00

72 lines
1.2 KiB
C++

#ifndef BP_CPTENTRY_H
#define BP_CPTENTRY_H
#include <vector>
#include "Shared.h"
using namespace std;
class CptEntry
{
public:
CptEntry (unsigned, const vector<unsigned>&);
unsigned getParameterIndex (void) const;
const vector<unsigned>& getParentConfigurations (void) const;
bool matchConstraints (const DomainConstr&) const;
bool matchConstraints (const vector<DomainConstr>&) const;
private:
unsigned index_;
vector<unsigned> confs_;
};
inline
CptEntry::CptEntry (unsigned index, const vector<unsigned>& confs)
{
index_ = index;
confs_ = confs;
}
inline unsigned
CptEntry::getParameterIndex (void) const
{
return index_;
}
inline const vector<unsigned>&
CptEntry::getParentConfigurations (void) const
{
return confs_;
}
inline bool
CptEntry::matchConstraints (const DomainConstr& constr) const
{
return confs_[constr.first] == constr.second;
}
inline bool
CptEntry::matchConstraints (const vector<DomainConstr>& constrs) const
{
for (unsigned j = 0; j < constrs.size(); j++) {
if (confs_[constrs[j].first] != constrs[j].second) {
return false;
}
}
return true;
}
#endif