dlvhex  2.5.0
NogoodSet Class Reference

Stores a set of nogoods. More...

#include <include/dlvhex2/Nogood.h>

Inheritance diagram for NogoodSet:
Collaboration diagram for NogoodSet:

Public Member Functions

void defragment ()
 Reorders the nogoods such that there are no free indices in the range 0-(getNogoodCount()-1).
const NogoodSetoperator= (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.
NogoodgetNogood (int index)
 Returns a nogood from the set.
const NogoodgetNogood (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< Nogoodnogoods
 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).

Detailed Description

Stores a set of nogoods.

Definition at line 209 of file Nogood.h.


Member Function Documentation

Adds a new nogood to the set.

Parameters:
ngThe nogood to add.
Returns:
Index of the new nogood.

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().

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().

const Nogood & NogoodSet::getNogood ( int  index) const

Returns a nogood from the set.

Parameters:
indexIndex of the nogood to retrieve.
Returns:
Constant reference to the requested nogood.

Definition at line 475 of file Nogood.cpp.

References nogoods.

std::string NogoodSet::getStringRepresentation ( RegistryPtr  reg) const

Prints the nogood set in string format.

Parameters:
regThe registry used for resolving literal IDs.
Returns:
String representation of the nogood set.

Definition at line 530 of file Nogood.cpp.

References Nogood::getStringRepresentation(), and nogoods.

const NogoodSet & NogoodSet::operator= ( const NogoodSet other)

Sets this NogoodSet to another one (overwrites the contents).

Parameters:
otherThe new NogoodSet.
Referenceto 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.

Parameters:
oThe stream to print the output.
Returns:
o.

Definition at line 546 of file Nogood.cpp.

References nogoods.

void NogoodSet::removeNogood ( int  nogoodIndex)

Removes a nogood from the set if contained.

Parameters:
nogoodIndexThe 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().

Removes a nogood if it is contained.

Parameters:
ngNogood to remove.

Definition at line 490 of file Nogood.cpp.

References DBGLOG, Nogood::getHash(), nogoods, nogoodsWithHash, Nogood::recomputeHash(), and removeNogood().


Field Documentation

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]
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().


The documentation for this class was generated from the following files: