Move some things around. No functional changes
This commit is contained in:
parent
2992f9e3cf
commit
3738d0b2c6
|
@ -100,6 +100,14 @@ class BeliefProp : public GroundSolver
|
||||||
static void setMsgSchedule (MsgSchedule sch) { schedule_ = sch; }
|
static void setMsgSchedule (MsgSchedule sch) { schedule_ = sch; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
struct CmpResidual {
|
||||||
|
bool operator() (const BpLink* l1, const BpLink* l2) {
|
||||||
|
return l1->residual() > l2->residual();
|
||||||
|
}};
|
||||||
|
|
||||||
|
typedef std::multiset<BpLink*, CmpResidual> SortedOrder;
|
||||||
|
typedef std::unordered_map<BpLink*, SortedOrder::iterator> BpLinkMap;
|
||||||
|
|
||||||
SPNodeInfo* ninf (const VarNode* var) const;
|
SPNodeInfo* ninf (const VarNode* var) const;
|
||||||
|
|
||||||
SPNodeInfo* ninf (const FacNode* fac) const;
|
SPNodeInfo* ninf (const FacNode* fac) const;
|
||||||
|
@ -110,14 +118,6 @@ class BeliefProp : public GroundSolver
|
||||||
|
|
||||||
void updateMessage (BpLink* link);
|
void updateMessage (BpLink* link);
|
||||||
|
|
||||||
struct CompareResidual
|
|
||||||
{
|
|
||||||
inline bool operator() (const BpLink* link1, const BpLink* link2)
|
|
||||||
{
|
|
||||||
return link1->residual() > link2->residual();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void runSolver (void);
|
void runSolver (void);
|
||||||
|
|
||||||
virtual void createLinks (void);
|
virtual void createLinks (void);
|
||||||
|
@ -135,16 +135,12 @@ class BeliefProp : public GroundSolver
|
||||||
std::vector<SPNodeInfo*> varsI_;
|
std::vector<SPNodeInfo*> varsI_;
|
||||||
std::vector<SPNodeInfo*> facsI_;
|
std::vector<SPNodeInfo*> facsI_;
|
||||||
bool runned_;
|
bool runned_;
|
||||||
|
SortedOrder sortedOrder_;
|
||||||
|
BpLinkMap linkMap_;
|
||||||
|
|
||||||
typedef std::multiset<BpLink*, CompareResidual> SortedOrder;
|
static double accuracy_;
|
||||||
SortedOrder sortedOrder_;
|
static unsigned maxIter_;
|
||||||
|
static MsgSchedule schedule_;
|
||||||
typedef std::unordered_map<BpLink*, SortedOrder::iterator> BpLinkMap;
|
|
||||||
BpLinkMap linkMap_;
|
|
||||||
|
|
||||||
static double accuracy_;
|
|
||||||
static unsigned maxIter_;
|
|
||||||
static MsgSchedule schedule_;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initializeSolver (void);
|
void initializeSolver (void);
|
||||||
|
|
|
@ -145,7 +145,8 @@ CTNode::deleteSubtree (CTNode* n)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &out, const CTNode& n)
|
std::ostream&
|
||||||
|
operator<< (std::ostream& out, const CTNode& n)
|
||||||
{
|
{
|
||||||
out << "(" << n.level() << ") " ;
|
out << "(" << n.level() << ") " ;
|
||||||
out << n.symbol();
|
out << n.symbol();
|
||||||
|
|
|
@ -13,31 +13,28 @@
|
||||||
|
|
||||||
|
|
||||||
class CTNode;
|
class CTNode;
|
||||||
typedef std::vector<CTNode*> CTNodes;
|
|
||||||
|
|
||||||
class ConstraintTree;
|
class ConstraintTree;
|
||||||
|
|
||||||
|
|
||||||
|
typedef std::vector<CTNode*> CTNodes;
|
||||||
typedef std::vector<ConstraintTree*> ConstraintTrees;
|
typedef std::vector<ConstraintTree*> ConstraintTrees;
|
||||||
|
|
||||||
|
|
||||||
class CTNode
|
class CTNode
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
struct CompareSymbol
|
|
||||||
{
|
|
||||||
bool operator() (const CTNode* n1, const CTNode* n2) const
|
|
||||||
{
|
|
||||||
return n1->symbol() < n2->symbol();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef TinySet<CTNode*, CompareSymbol> CTChilds_;
|
struct CmpSymbol {
|
||||||
|
bool operator() (const CTNode* n1, const CTNode* n2) const {
|
||||||
|
return n1->symbol() < n2->symbol();
|
||||||
|
}};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CTNode (const CTNode& n, const CTChilds_& chs = CTChilds_())
|
typedef TinySet<CTNode*, CmpSymbol> CTChilds;
|
||||||
|
|
||||||
|
CTNode (const CTNode& n, const CTChilds& chs = CTChilds())
|
||||||
: symbol_(n.symbol()), childs_(chs), level_(n.level()) { }
|
: symbol_(n.symbol()), childs_(chs), level_(n.level()) { }
|
||||||
|
|
||||||
CTNode (Symbol s, unsigned l, const CTChilds_& chs = CTChilds_())
|
CTNode (Symbol s, unsigned l, const CTChilds& chs = CTChilds())
|
||||||
: symbol_(s), childs_(chs), level_(l) { }
|
: symbol_(s), childs_(chs), level_(l) { }
|
||||||
|
|
||||||
unsigned level (void) const { return level_; }
|
unsigned level (void) const { return level_; }
|
||||||
|
@ -48,9 +45,9 @@ class CTNode
|
||||||
|
|
||||||
void setSymbol (const Symbol s) { symbol_ = s; }
|
void setSymbol (const Symbol s) { symbol_ = s; }
|
||||||
|
|
||||||
CTChilds_& childs (void) { return childs_; }
|
CTChilds& childs (void) { return childs_; }
|
||||||
|
|
||||||
const CTChilds_& childs (void) const { return childs_; }
|
const CTChilds& childs (void) const { return childs_; }
|
||||||
|
|
||||||
size_t nrChilds (void) const { return childs_.size(); }
|
size_t nrChilds (void) const { return childs_.size(); }
|
||||||
|
|
||||||
|
@ -58,7 +55,7 @@ class CTNode
|
||||||
|
|
||||||
bool isLeaf (void) const { return childs_.empty(); }
|
bool isLeaf (void) const { return childs_.empty(); }
|
||||||
|
|
||||||
CTChilds_::iterator findSymbol (Symbol symb);
|
CTChilds::iterator findSymbol (Symbol symb);
|
||||||
|
|
||||||
void mergeSubtree (CTNode*, bool = true);
|
void mergeSubtree (CTNode*, bool = true);
|
||||||
|
|
||||||
|
@ -80,14 +77,14 @@ class CTNode
|
||||||
void updateChildLevels (CTNode*, unsigned);
|
void updateChildLevels (CTNode*, unsigned);
|
||||||
|
|
||||||
Symbol symbol_;
|
Symbol symbol_;
|
||||||
CTChilds_ childs_;
|
CTChilds childs_;
|
||||||
unsigned level_;
|
unsigned level_;
|
||||||
|
|
||||||
DISALLOW_ASSIGN (CTNode);
|
DISALLOW_ASSIGN (CTNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef TinySet<CTNode*, CTNode::CompareSymbol> CTChilds;
|
typedef CTNode::CTChilds CTChilds;
|
||||||
|
|
||||||
|
|
||||||
inline CTChilds::iterator
|
inline CTChilds::iterator
|
||||||
|
@ -98,7 +95,7 @@ CTNode::findSymbol (Symbol symb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &out, const CTNode&);
|
std::ostream& operator<< (std::ostream&, const CTNode&);
|
||||||
|
|
||||||
|
|
||||||
class ConstraintTree
|
class ConstraintTree
|
||||||
|
|
|
@ -135,6 +135,8 @@ class FactorGraph
|
||||||
static void disablePrintFactorGraph (void) { printFg_ = false; }
|
static void disablePrintFactorGraph (void) { printFg_ = false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
typedef std::unordered_map<unsigned, VarNode*> VarMap;
|
||||||
|
|
||||||
void ignoreLines (std::ifstream&) const;
|
void ignoreLines (std::ifstream&) const;
|
||||||
|
|
||||||
bool containsCycle (void) const;
|
bool containsCycle (void) const;
|
||||||
|
@ -145,19 +147,16 @@ class FactorGraph
|
||||||
bool containsCycle (const FacNode*, const VarNode*,
|
bool containsCycle (const FacNode*, const VarNode*,
|
||||||
std::vector<bool>&, std::vector<bool>&) const;
|
std::vector<bool>&, std::vector<bool>&) const;
|
||||||
|
|
||||||
VarNodes varNodes_;
|
VarNodes varNodes_;
|
||||||
FacNodes facNodes_;
|
FacNodes facNodes_;
|
||||||
|
VarMap varMap_;
|
||||||
BayesBallGraph structure_;
|
BayesBallGraph structure_;
|
||||||
bool bayesFactors_;
|
bool bayesFactors_;
|
||||||
|
|
||||||
typedef std::unordered_map<unsigned, VarNode*> VarMap;
|
static bool exportLd_;
|
||||||
VarMap varMap_;
|
static bool exportUai_;
|
||||||
|
static bool exportGv_;
|
||||||
static bool exportLd_;
|
static bool printFg_;
|
||||||
static bool exportUai_;
|
|
||||||
static bool exportGv_;
|
|
||||||
static bool printFg_;
|
|
||||||
|
|
||||||
DISALLOW_ASSIGN (FactorGraph);
|
DISALLOW_ASSIGN (FactorGraph);
|
||||||
};
|
};
|
||||||
|
|
|
@ -138,7 +138,8 @@ HistogramSet::clearAfter (size_t idx)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &os, const HistogramSet& hs)
|
std::ostream&
|
||||||
|
operator<< (std::ostream& os, const HistogramSet& hs)
|
||||||
{
|
{
|
||||||
os << "#" << hs.hist_;
|
os << "#" << hs.hist_;
|
||||||
return os;
|
return os;
|
||||||
|
|
|
@ -36,11 +36,11 @@ class HistogramSet
|
||||||
|
|
||||||
void clearAfter (size_t);
|
void clearAfter (size_t);
|
||||||
|
|
||||||
|
friend std::ostream& operator<< (std::ostream&, const HistogramSet&);
|
||||||
|
|
||||||
unsigned size_;
|
unsigned size_;
|
||||||
Histogram hist_;
|
Histogram hist_;
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream &os, const HistogramSet& hs);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN (HistogramSet);
|
DISALLOW_COPY_AND_ASSIGN (HistogramSet);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,14 @@ class Indexer
|
||||||
private:
|
private:
|
||||||
void calculateOffsets (void);
|
void calculateOffsets (void);
|
||||||
|
|
||||||
|
friend std::ostream& operator<< (std::ostream&, const Indexer&);
|
||||||
|
|
||||||
size_t index_;
|
size_t index_;
|
||||||
Ranges indices_;
|
Ranges indices_;
|
||||||
const Ranges& ranges_;
|
const Ranges& ranges_;
|
||||||
size_t size_;
|
size_t size_;
|
||||||
std::vector<size_t> offsets_;
|
std::vector<size_t> offsets_;
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream&, const Indexer&);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN (Indexer);
|
DISALLOW_COPY_AND_ASSIGN (Indexer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -223,14 +223,14 @@ class MapIndexer
|
||||||
void reset (void);
|
void reset (void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend std::ostream& operator<< (std::ostream&, const MapIndexer&);
|
||||||
|
|
||||||
size_t index_;
|
size_t index_;
|
||||||
Ranges indices_;
|
Ranges indices_;
|
||||||
const Ranges& ranges_;
|
const Ranges& ranges_;
|
||||||
bool valid_;
|
bool valid_;
|
||||||
std::vector<size_t> offsets_;
|
std::vector<size_t> offsets_;
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream&, const MapIndexer&);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN (MapIndexer);
|
DISALLOW_COPY_AND_ASSIGN (MapIndexer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ printSymbolDictionary (void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &os, const Symbol& s)
|
std::ostream&
|
||||||
|
operator<< (std::ostream& os, const Symbol& s)
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, unsigned>::const_iterator it
|
std::unordered_map<std::string, unsigned>::const_iterator it
|
||||||
= LiftedUtils::symbolDict.begin();
|
= LiftedUtils::symbolDict.begin();
|
||||||
|
@ -54,7 +55,8 @@ std::ostream& operator<< (std::ostream &os, const Symbol& s)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &os, const LogVar& X)
|
std::ostream&
|
||||||
|
operator<< (std::ostream& os, const LogVar& X)
|
||||||
{
|
{
|
||||||
const std::string labels[] = {
|
const std::string labels[] = {
|
||||||
"A", "B", "C", "D", "E", "F",
|
"A", "B", "C", "D", "E", "F",
|
||||||
|
@ -65,7 +67,8 @@ std::ostream& operator<< (std::ostream &os, const LogVar& X)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &os, const Tuple& t)
|
std::ostream&
|
||||||
|
operator<< (std::ostream& os, const Tuple& t)
|
||||||
{
|
{
|
||||||
os << "(" ;
|
os << "(" ;
|
||||||
for (size_t i = 0; i < t.size(); i++) {
|
for (size_t i = 0; i < t.size(); i++) {
|
||||||
|
@ -77,7 +80,8 @@ std::ostream& operator<< (std::ostream &os, const Tuple& t)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &os, const Ground& gr)
|
std::ostream&
|
||||||
|
operator<< (std::ostream& os, const Ground& gr)
|
||||||
{
|
{
|
||||||
os << gr.functor();
|
os << gr.functor();
|
||||||
os << "(" ;
|
os << "(" ;
|
||||||
|
@ -111,7 +115,8 @@ Substitution::getDiscardedLogVars (void) const
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &os, const Substitution& theta)
|
std::ostream&
|
||||||
|
operator<< (std::ostream& os, const Substitution& theta)
|
||||||
{
|
{
|
||||||
std::unordered_map<LogVar, LogVar>::const_iterator it;
|
std::unordered_map<LogVar, LogVar>::const_iterator it;
|
||||||
os << "[" ;
|
os << "[" ;
|
||||||
|
|
|
@ -24,9 +24,9 @@ class Symbol
|
||||||
static Symbol invalid (void) { return Symbol(); }
|
static Symbol invalid (void) { return Symbol(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned id_;
|
friend std::ostream& operator<< (std::ostream&, const Symbol&);
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream &os, const Symbol& s);
|
unsigned id_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ class LogVar
|
||||||
bool valid (void) const;
|
bool valid (void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned id_;
|
friend std::ostream& operator<< (std::ostream&, const LogVar&);
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream &os, const LogVar& X);
|
unsigned id_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,16 +86,16 @@ template <> struct hash<LogVar> {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<Symbol> Symbols;
|
typedef std::vector<Symbol> Symbols;
|
||||||
typedef std::vector<Symbol> Tuple;
|
typedef std::vector<Symbol> Tuple;
|
||||||
typedef std::vector<Tuple> Tuples;
|
typedef std::vector<Tuple> Tuples;
|
||||||
typedef std::vector<LogVar> LogVars;
|
typedef std::vector<LogVar> LogVars;
|
||||||
typedef TinySet<Symbol> SymbolSet;
|
typedef TinySet<Symbol> SymbolSet;
|
||||||
typedef TinySet<LogVar> LogVarSet;
|
typedef TinySet<LogVar> LogVarSet;
|
||||||
typedef TinySet<Tuple> TupleSet;
|
typedef TinySet<Tuple> TupleSet;
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &os, const Tuple& t);
|
std::ostream& operator<< (std::ostream&, const Tuple&);
|
||||||
|
|
||||||
|
|
||||||
namespace LiftedUtils {
|
namespace LiftedUtils {
|
||||||
|
@ -113,7 +113,8 @@ class Ground
|
||||||
public:
|
public:
|
||||||
Ground (Symbol f) : functor_(f) { }
|
Ground (Symbol f) : functor_(f) { }
|
||||||
|
|
||||||
Ground (Symbol f, const Symbols& args) : functor_(f), args_(args) { }
|
Ground (Symbol f, const Symbols& args)
|
||||||
|
: functor_(f), args_(args) { }
|
||||||
|
|
||||||
Symbol functor (void) const { return functor_; }
|
Symbol functor (void) const { return functor_; }
|
||||||
|
|
||||||
|
@ -124,10 +125,10 @@ class Ground
|
||||||
bool isAtom (void) const { return args_.empty(); }
|
bool isAtom (void) const { return args_.empty(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend std::ostream& operator<< (std::ostream&, const Ground&);
|
||||||
|
|
||||||
Symbol functor_;
|
Symbol functor_;
|
||||||
Symbols args_;
|
Symbols args_;
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream &os, const Ground& gr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<Ground> Grounds;
|
typedef std::vector<Ground> Grounds;
|
||||||
|
@ -150,11 +151,10 @@ class Substitution
|
||||||
LogVars getDiscardedLogVars (void) const;
|
LogVars getDiscardedLogVars (void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<LogVar, LogVar> subs_;
|
|
||||||
|
|
||||||
friend std::ostream& operator<< (
|
friend std::ostream& operator<< (
|
||||||
std::ostream &os, const Substitution& theta);
|
std::ostream&, const Substitution&);
|
||||||
|
|
||||||
|
std::unordered_map<LogVar, LogVar> subs_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,6 +205,5 @@ Substitution::nrReplacements (void) const
|
||||||
return subs_.size();
|
return subs_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDUTILS_H_
|
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDUTILS_H_
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ Literal::toString (
|
||||||
|
|
||||||
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
operator<< (std::ostream &os, const Literal& lit)
|
operator<< (std::ostream& os, const Literal& lit)
|
||||||
{
|
{
|
||||||
os << lit.toString();
|
os << lit.toString();
|
||||||
return os;
|
return os;
|
||||||
|
@ -342,7 +342,7 @@ Clause::deleteClauses (Clauses& clauses)
|
||||||
|
|
||||||
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
operator<< (std::ostream &os, const Clause& clause)
|
operator<< (std::ostream& os, const Clause& clause)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < clause.literals_.size(); i++) {
|
for (unsigned i = 0; i < clause.literals_.size(); i++) {
|
||||||
if (i != 0) os << " v " ;
|
if (i != 0) os << " v " ;
|
||||||
|
@ -374,7 +374,7 @@ Clause::getLogVarSetExcluding (size_t idx) const
|
||||||
|
|
||||||
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
operator<< (std::ostream &os, const LitLvTypes& lit)
|
operator<< (std::ostream& os, const LitLvTypes& lit)
|
||||||
{
|
{
|
||||||
os << lit.lid_ << "<" ;
|
os << lit.lid_ << "<" ;
|
||||||
for (size_t i = 0; i < lit.lvTypes_.size(); i++) {
|
for (size_t i = 0; i < lit.lvTypes_.size(); i++) {
|
||||||
|
|
|
@ -54,11 +54,11 @@ class Literal
|
||||||
LogVarSet negCountedLvs = LogVarSet()) const;
|
LogVarSet negCountedLvs = LogVarSet()) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend std::ostream& operator<< (std::ostream&, const Literal&);
|
||||||
|
|
||||||
LiteralId lid_;
|
LiteralId lid_;
|
||||||
LogVars logVars_;
|
LogVars logVars_;
|
||||||
bool negated_;
|
bool negated_;
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream &os, const Literal& lit);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<Literal> Literals;
|
typedef std::vector<Literal> Literals;
|
||||||
|
@ -145,14 +145,14 @@ class Clause
|
||||||
private:
|
private:
|
||||||
LogVarSet getLogVarSetExcluding (size_t idx) const;
|
LogVarSet getLogVarSetExcluding (size_t idx) const;
|
||||||
|
|
||||||
|
friend std::ostream& operator<< (std::ostream&, const Clause&);
|
||||||
|
|
||||||
Literals literals_;
|
Literals literals_;
|
||||||
LogVarSet ipgLvs_;
|
LogVarSet ipgLvs_;
|
||||||
LogVarSet posCountedLvs_;
|
LogVarSet posCountedLvs_;
|
||||||
LogVarSet negCountedLvs_;
|
LogVarSet negCountedLvs_;
|
||||||
ConstraintTree constr_;
|
ConstraintTree constr_;
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream &os, const Clause& clause);
|
|
||||||
|
|
||||||
DISALLOW_ASSIGN (Clause);
|
DISALLOW_ASSIGN (Clause);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -163,22 +163,6 @@ typedef std::vector<Clause*> Clauses;
|
||||||
class LitLvTypes
|
class LitLvTypes
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct CompareLitLvTypes
|
|
||||||
{
|
|
||||||
bool operator() (
|
|
||||||
const LitLvTypes& types1,
|
|
||||||
const LitLvTypes& types2) const
|
|
||||||
{
|
|
||||||
if (types1.lid_ < types2.lid_) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (types1.lid_ == types2.lid_) {
|
|
||||||
return types1.lvTypes_ < types2.lvTypes_;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
LitLvTypes (LiteralId lid, const LogVarTypes& lvTypes) :
|
LitLvTypes (LiteralId lid, const LogVarTypes& lvTypes) :
|
||||||
lid_(lid), lvTypes_(lvTypes) { }
|
lid_(lid), lvTypes_(lvTypes) { }
|
||||||
|
|
||||||
|
@ -190,13 +174,29 @@ class LitLvTypes
|
||||||
std::fill (lvTypes_.begin(), lvTypes_.end(), LogVarType::FULL_LV); }
|
std::fill (lvTypes_.begin(), lvTypes_.end(), LogVarType::FULL_LV); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend std::ostream& operator<< (std::ostream&, const LitLvTypes&);
|
||||||
|
|
||||||
LiteralId lid_;
|
LiteralId lid_;
|
||||||
LogVarTypes lvTypes_;
|
LogVarTypes lvTypes_;
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream &os, const LitLvTypes& lit);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef TinySet<LitLvTypes,LitLvTypes::CompareLitLvTypes> LitLvTypesSet;
|
|
||||||
|
|
||||||
|
struct CmpLitLvTypes
|
||||||
|
{
|
||||||
|
bool operator() (const LitLvTypes& types1, const LitLvTypes& types2) const
|
||||||
|
{
|
||||||
|
if (types1.lid() < types2.lid()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (types1.lid() == types2.lid()){
|
||||||
|
return types1.logVarTypes() < types2.logVarTypes();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef TinySet<LitLvTypes, CmpLitLvTypes> LitLvTypesSet;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,8 @@ ProbFormula::rename (LogVar oldName, LogVar newName)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool operator== (const ProbFormula& f1, const ProbFormula& f2)
|
bool
|
||||||
|
operator== (const ProbFormula& f1, const ProbFormula& f2)
|
||||||
{
|
{
|
||||||
return f1.group_ == f2.group_ &&
|
return f1.group_ == f2.group_ &&
|
||||||
f1.logVars_ == f2.logVars_;
|
f1.logVars_ == f2.logVars_;
|
||||||
|
@ -105,7 +106,8 @@ bool operator== (const ProbFormula& f1, const ProbFormula& f2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &os, const ProbFormula& f)
|
std::ostream&
|
||||||
|
operator<< (std::ostream& os, const ProbFormula& f)
|
||||||
{
|
{
|
||||||
os << f.functor_;
|
os << f.functor_;
|
||||||
if (f.isAtom() == false) {
|
if (f.isAtom() == false) {
|
||||||
|
@ -151,7 +153,8 @@ ObservedFormula::ObservedFormula (Symbol f, unsigned ev, const Tuple& tuple)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream &os, const ObservedFormula& of)
|
std::ostream&
|
||||||
|
operator<< (std::ostream& os, const ObservedFormula& of)
|
||||||
{
|
{
|
||||||
os << of.functor_ << "/" << of.arity_;
|
os << of.functor_ << "/" << of.arity_;
|
||||||
os << "|" << of.constr_.tupleSet();
|
os << "|" << of.constr_.tupleSet();
|
||||||
|
|
|
@ -60,13 +60,13 @@ class ProbFormula
|
||||||
|
|
||||||
static PrvGroup getNewGroup (void);
|
static PrvGroup getNewGroup (void);
|
||||||
|
|
||||||
|
private:
|
||||||
friend bool operator== (
|
friend bool operator== (
|
||||||
const ProbFormula& f1, const ProbFormula& f2);
|
const ProbFormula& f1, const ProbFormula& f2);
|
||||||
|
|
||||||
friend std::ostream& operator<< (
|
friend std::ostream& operator<< (
|
||||||
std::ostream &os, const ProbFormula& f);
|
std::ostream&, const ProbFormula&);
|
||||||
|
|
||||||
private:
|
|
||||||
Symbol functor_;
|
Symbol functor_;
|
||||||
LogVars logVars_;
|
LogVars logVars_;
|
||||||
unsigned range_;
|
unsigned range_;
|
||||||
|
@ -100,13 +100,13 @@ class ObservedFormula
|
||||||
void addTuple (const Tuple& tuple) { constr_.addTuple (tuple); }
|
void addTuple (const Tuple& tuple) { constr_.addTuple (tuple); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend std::ostream& operator<< (
|
||||||
|
std::ostream&, const ObservedFormula&);
|
||||||
|
|
||||||
Symbol functor_;
|
Symbol functor_;
|
||||||
unsigned arity_;
|
unsigned arity_;
|
||||||
unsigned evidence_;
|
unsigned evidence_;
|
||||||
ConstraintTree constr_;
|
ConstraintTree constr_;
|
||||||
|
|
||||||
friend std::ostream& operator<< (
|
|
||||||
std::ostream &os, const ObservedFormula& of);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<ObservedFormula> ObservedFormulas;
|
typedef std::vector<ObservedFormula> ObservedFormulas;
|
||||||
|
|
|
@ -10,9 +10,8 @@ template <typename T, typename Compare = std::less<T>>
|
||||||
class TinySet
|
class TinySet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef typename std::vector<T>::iterator iterator;
|
||||||
typedef typename std::vector<T>::iterator iterator;
|
typedef typename std::vector<T>::const_iterator const_iterator;
|
||||||
typedef typename std::vector<T>::const_iterator const_iterator;
|
|
||||||
|
|
||||||
TinySet (const TinySet& s)
|
TinySet (const TinySet& s)
|
||||||
: vec_(s.vec_), cmp_(s.cmp_) { }
|
: vec_(s.vec_), cmp_(s.cmp_) { }
|
||||||
|
@ -90,9 +89,6 @@ class TinySet
|
||||||
|
|
||||||
bool consistent (void) const;
|
bool consistent (void) const;
|
||||||
|
|
||||||
std::vector<T> vec_;
|
|
||||||
Compare cmp_;
|
|
||||||
|
|
||||||
friend bool operator== (const TinySet& s1, const TinySet& s2)
|
friend bool operator== (const TinySet& s1, const TinySet& s2)
|
||||||
{
|
{
|
||||||
return s1.vec_ == s2.vec_;
|
return s1.vec_ == s2.vec_;
|
||||||
|
@ -114,6 +110,8 @@ class TinySet
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<T> vec_;
|
||||||
|
Compare cmp_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue