dlvhex
2.5.0
|
Stores a set of nogoods. More...
#include <include/dlvhex2/Nogood.h>
Public Member Functions | |
void | defragment () |
Reorders the nogoods such that there are no free indices in the range 0-(getNogoodCount()-1). | |
const NogoodSet & | operator= (const NogoodSet &other) |
Sets this NogoodSet to another one (overwrites the contents). | |
int | addNogood (Nogood ng) |
Adds a new nogood to the set. | |
void | removeNogood (int nogoodIndex) |
Removes a nogood from the set if contained. | |
void | removeNogood (Nogood ng) |
Removes a nogood if it is contained. | |
Nogood & | getNogood (int index) |
Returns a nogood from the set. | |
const Nogood & | getNogood (int index) const |
Returns a nogood from the set. | |
int | getNogoodCount () const |
Returns the current number of nogoods in the set. | |
void | forgetLeastFrequentlyAdded () |
Applies a heuristics to remove the lease frequently added nogoods from the set. | |
std::ostream & | print (std::ostream &o) const |
Prints the nogood set in numeric format. | |
std::string | getStringRepresentation (RegistryPtr reg) const |
Prints the nogood set in string format. | |
Private Attributes | |
std::vector< Nogood > | nogoods |
Internal nogood vector. | |
std::vector< int > | addCount |
Stores for each nogood how often it was added although it is actually stored only once since this is a set (used for deletion strategies). | |
Set< int > | freeIndices |
Indices between 0 and nogoods.size() which are currently unused. | |
boost::unordered_map< size_t, Set< int > > | nogoodsWithHash |
Stores for each hash the indices of nogoods with this hash (used in the unlikely case that there is a clash of hashes). |
int NogoodSet::addNogood | ( | Nogood | ng | ) |
Adds a new nogood to the set.
ng | The nogood to add. |
Definition at line 434 of file Nogood.cpp.
References addCount, Set< T >::begin(), DBGLOG, Set< T >::erase(), freeIndices, Nogood::getHash(), nogoods, nogoodsWithHash, Nogood::recomputeHash(), and Set< T >::size().
Referenced by SimpleNogoodContainer::addNogood(), CDNLSolver::addNogoodAndUpdateWatchingStructures(), AssumptionBasedUnfoundedSetChecker::constructUFSDetectionProblemBasicEABehavior(), AssumptionBasedUnfoundedSetChecker::constructUFSDetectionProblemDefineAuxiliaries(), AssumptionBasedUnfoundedSetChecker::constructUFSDetectionProblemFacts(), EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemNecessaryPart(), AssumptionBasedUnfoundedSetChecker::constructUFSDetectionProblemNonempty(), EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemOptimizationPartBasicEAKnowledge(), EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemOptimizationPartEAEnforement(), EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemOptimizationPartLearnedFromMainSearch(), EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemOptimizationPartRestrictToCompatibleSet(), AssumptionBasedUnfoundedSetChecker::constructUFSDetectionProblemRestrictToSCC(), AssumptionBasedUnfoundedSetChecker::constructUFSDetectionProblemRule(), InternalGroundASPSolver::createNogoodsForRule(), InternalGroundASPSolver::createNogoodsForRuleBody(), and InternalGroundASPSolver::createSingularLoopNogoods().
void NogoodSet::defragment | ( | ) |
Reorders the nogoods such that there are no free indices in the range 0-(getNogoodCount()-1).
Definition at line 392 of file Nogood.cpp.
References addCount, Set< T >::clear(), Set< T >::count(), Set< T >::erase(), freeIndices, nogoods, nogoodsWithHash, and Set< T >::size().
Referenced by SimpleNogoodContainer::defragment(), and SimpleNogoodContainer::forgetLeastFrequentlyAdded().
Applies a heuristics to remove the lease frequently added nogoods from the set.
Definition at line 513 of file Nogood.cpp.
References addCount, DBGLOG, nogoods, and removeNogood().
Referenced by SimpleNogoodContainer::forgetLeastFrequentlyAdded().
Nogood & NogoodSet::getNogood | ( | int | index | ) |
Returns a nogood from the set.
index | Index of the nogood to retrieve. |
Definition at line 469 of file Nogood.cpp.
References nogoods.
Referenced by CDNLSolver::analysis(), CDNLSolver::getCause(), CDNLSolver::getContradictoryNogoods(), CDNLSolver::getGuess(), InternalGroundASPSolver::getImplicationGraphAsDotString(), InternalGroundASPSolver::getInconsistencyCause(), SimpleNogoodContainer::getNogood(), CDNLSolver::initListOfAllAtoms(), CDNLSolver::setFact(), CDNLSolver::unitPropagation(), CDNLSolver::updateWatchingStructuresAfterAddNogood(), CDNLSolver::updateWatchingStructuresAfterClearFact(), CDNLSolver::updateWatchingStructuresAfterRemoveNogood(), and CDNLSolver::updateWatchingStructuresAfterSetFact().
const Nogood & NogoodSet::getNogood | ( | int | index | ) | const |
Returns a nogood from the set.
index | Index of the nogood to retrieve. |
Definition at line 475 of file Nogood.cpp.
References nogoods.
int NogoodSet::getNogoodCount | ( | ) | const |
Returns the current number of nogoods in the set.
Number | of nogoods in the set. |
Definition at line 507 of file Nogood.cpp.
References freeIndices, nogoods, and Set< T >::size().
Referenced by SimpleNogoodContainer::forgetLeastFrequentlyAdded(), InternalGroundASPSolver::getNextModel(), CDNLSolver::getNextModel(), SimpleNogoodContainer::getNogoodCount(), CDNLSolver::handlePreviousModel(), CDNLSolver::initListOfAllAtoms(), and CDNLSolver::initWatchingStructures().
std::string NogoodSet::getStringRepresentation | ( | RegistryPtr | reg | ) | const |
Prints the nogood set in string format.
reg | The registry used for resolving literal IDs. |
Definition at line 530 of file Nogood.cpp.
References Nogood::getStringRepresentation(), and nogoods.
Sets this NogoodSet to another one (overwrites the contents).
other | The new NogoodSet. |
Reference | to this object. |
Definition at line 381 of file Nogood.cpp.
References freeIndices, nogoods, and nogoodsWithHash.
std::ostream & NogoodSet::print | ( | std::ostream & | o | ) | const |
Prints the nogood set in numeric format.
o | The stream to print the output. |
o
. Definition at line 546 of file Nogood.cpp.
References nogoods.
void NogoodSet::removeNogood | ( | int | nogoodIndex | ) |
Removes a nogood from the set if contained.
nogoodIndex | The index of the nogood to remove. |
Definition at line 481 of file Nogood.cpp.
References addCount, freeIndices, Set< T >::insert(), nogoods, and nogoodsWithHash.
Referenced by forgetLeastFrequentlyAdded(), removeNogood(), and SimpleNogoodContainer::removeNogood().
void NogoodSet::removeNogood | ( | Nogood | ng | ) |
Removes a nogood if it is contained.
ng | Nogood to remove. |
Definition at line 490 of file Nogood.cpp.
References DBGLOG, Nogood::getHash(), nogoods, nogoodsWithHash, Nogood::recomputeHash(), and removeNogood().
std::vector<int> NogoodSet::addCount [private] |
Stores for each nogood how often it was added although it is actually stored only once since this is a set (used for deletion strategies).
Definition at line 215 of file Nogood.h.
Referenced by addNogood(), defragment(), forgetLeastFrequentlyAdded(), and removeNogood().
Set<int> NogoodSet::freeIndices [private] |
Indices between 0 and nogoods.size() which are currently unused.
Definition at line 217 of file Nogood.h.
Referenced by addNogood(), defragment(), getNogoodCount(), operator=(), and removeNogood().
std::vector<Nogood> NogoodSet::nogoods [private] |
Internal nogood vector.
Definition at line 213 of file Nogood.h.
Referenced by addNogood(), defragment(), forgetLeastFrequentlyAdded(), getNogood(), getNogoodCount(), getStringRepresentation(), operator=(), print(), and removeNogood().
boost::unordered_map<size_t, Set<int> > NogoodSet::nogoodsWithHash [private] |
Stores for each hash the indices of nogoods with this hash (used in the unlikely case that there is a clash of hashes).
Definition at line 219 of file Nogood.h.
Referenced by addNogood(), defragment(), operator=(), and removeNogood().