#include <groundclause.h>
Public Member Functions | |
GroundClause (const Clause *const &c, GroundPredicateHashArray *const &gndPredHashArray) | |
~GroundClause () | |
void | deleteFoClauseFrequencies () |
void | addWt (const double &wt) |
void | setWt (const double &wt) |
double | getWt () const |
void | setWtToHardWt () |
bool | isHardClause () const |
int | getNumGroundPredicates () const |
const GroundPredicate * | getGroundPredicate (const int &i, GroundPredicateHashArray *const &gndPredHashArray) const |
void | appendToGndPreds (GroundPredicateHashArray *const &gndPredHashArray) |
Appends this GroundClause to all GroundPredicates in it. | |
bool | getGroundPredicateSense (const int &i) const |
void | setGroundPredicateSense (const int &i, const bool &sense) |
void | setGroundPredicateIndex (const int &i, const int &gndPredIdx) |
int | getGroundPredicateIndex (const int &i) const |
const Array< int > * | getGndPredIndexes () const |
void | setWtToSumOfParentWts (const MLN *const &mln) |
The weight of this ground clause is set to the sum of its parent weights. | |
IntBoolPair * | getClauseFrequencies () |
int | getClauseFrequency (int clauseno) |
void | incrementClauseFrequency (int clauseno, int increment, bool invertWt) |
void | removeGndPred (const int &gndPred) |
Removes a ground predicate from this ground clause. | |
void | changeGndPredIndex (const int &oldIdx, const int &newIdx) |
Changes the index of a ground predicate in this ground clause. | |
size_t | hashCode () |
bool | same (const GroundClause *const &gc) |
void | printWithoutWt (ostream &out) const |
void | print (ostream &out) const |
ostream & | print (ostream &out, const Domain *const &domain, const bool &withWt, const bool &asInt, const bool &withStrVar, const GroundPredicateHashArray *const &predHashArray) const |
ostream & | printWithoutWt (ostream &out, const Domain *const &domain, const GroundPredicateHashArray *const &predHashArray) const |
ostream & | printWithoutWtWithStrVar (ostream &out, const Domain *const &domain, const GroundPredicateHashArray *const &predHashArray) const |
ostream & | printWithWtAndStrVar (ostream &out, const Domain *const &domain, const GroundPredicateHashArray *const &predHashArray) const |
ostream & | print (ostream &out, const Domain *const &domain, const GroundPredicateHashArray *const &predHashArray) const |
ostream & | printWithoutWtWithStrVarAndPeriod (ostream &out, const Domain *const &domain, const GroundPredicateHashArray *const &predHashArray) const |
double | sizeKB () |
Computes and returns the size of this ground clause. |
Definition at line 104 of file groundclause.h.
void GroundClause::appendToGndPreds | ( | GroundPredicateHashArray *const & | gndPredHashArray | ) |
Appends this GroundClause to all GroundPredicates in it.
gndPredHashArray | Reference HashArray containing the GroundPredicates indexed in the GroundClause. |
Definition at line 153 of file groundclause.cpp.
References Array< Type >::size().
Referenced by MRF::addUnknownGndClause().
00155 { 00156 // For each ground pred in this clause 00157 for (int i = 0; i < gndPredIndexes_->size(); i++) 00158 { 00159 bool sense = ((*gndPredIndexes_)[i] > 0); 00160 int index = abs((*gndPredIndexes_)[i]) - 1; 00161 // Tell the ground pred that it occurs in this ground clause 00162 (*gndPredHashArray)[index]->appendGndClause(this, sense); 00163 //assert(ok); ok = true; // avoid compilation warning 00164 } 00165 }
void GroundClause::setWtToSumOfParentWts | ( | const MLN *const & | mln | ) |
The weight of this ground clause is set to the sum of its parent weights.
If the weight has been inverted from the parent, this is taken into account.
mln | Reference MLN to which the clause indices in foClauseFrequencies_ correspond. |
Definition at line 174 of file groundclause.cpp.
References MLN::getClause(), and Clause::getWt().
00175 { 00176 wt_ = 0; 00177 00178 IntBoolPairItr itr; 00179 for (itr = foClauseFrequencies_->begin(); 00180 itr != foClauseFrequencies_->end(); itr++) 00181 { 00182 int clauseno = itr->first; 00183 int frequency = itr->second.first; 00184 bool invertWt = itr->second.second; 00185 double parentWeight = mln->getClause(clauseno)->getWt(); 00186 if (invertWt) wt_ -= parentWeight*frequency; 00187 else wt_ += parentWeight*frequency; 00188 } 00189 }
void GroundClause::removeGndPred | ( | const int & | gndPred | ) | [inline] |
Removes a ground predicate from this ground clause.
The ground predicate at the given index is removed and the new hash code is stored.
gndPred | The ground predicate to be removed. |
Definition at line 216 of file groundclause.h.
References Array< Type >::compress(), Array< Type >::removeItem(), and Array< Type >::size().
00217 { 00218 for (int i = 0; i < gndPredIndexes_->size(); i++) 00219 { 00220 if (gndPred == (*gndPredIndexes_)[i]) 00221 { 00222 gndPredIndexes_->removeItem(i); 00223 gndPredIndexes_->compress(); 00224 rehash(); 00225 break; 00226 } 00227 } 00228 }
void GroundClause::changeGndPredIndex | ( | const int & | oldIdx, | |
const int & | newIdx | |||
) | [inline] |
Changes the index of a ground predicate in this ground clause.
The new hash code is stored.
oldIdx | Index of the ground predicate to be changed. | |
newIdx | New index of the ground predicate. |
Definition at line 237 of file groundclause.h.
References Array< Type >::size().
00238 { 00239 for (int i = 0; i < gndPredIndexes_->size(); i++) 00240 { 00241 if (oldIdx == (*gndPredIndexes_)[i]) 00242 { 00243 (*gndPredIndexes_)[i] = newIdx; 00244 rehash(); 00245 break; 00246 } 00247 } 00248 }