dlvhex
2.5.0
|
Decides when to do an unfounded set check (over partial interpretations) More...
#include <include/dlvhex2/UnfoundedSetCheckHeuristicsInterface.h>
Public Member Functions | |
UnfoundedSetCheckHeuristics (const AnnotatedGroundProgram &groundProgram, RegistryPtr reg) | |
virtual bool | doUFSCheck (InterpretationConstPtr verifiedAuxes, InterpretationConstPtr partialAssignment, InterpretationConstPtr assigned, InterpretationConstPtr changed)=0 |
Decides if the reasoner shall do an unfounded set check at this point. | |
virtual void | notify (InterpretationConstPtr verifiedAuxes, InterpretationConstPtr partialAssignment, InterpretationConstPtr assigned, InterpretationConstPtr changed) |
Notifies the heuristic about changes in the assignment, although the caller is not going to perform an UFS check at this point. | |
void | updateSkipProgram (InterpretationConstPtr verifiedAuxes, InterpretationConstPtr partialAssignment, InterpretationConstPtr assigned, InterpretationConstPtr changed) |
Updates the skip program according to a new partial assignment. | |
const std::set< ID > & | getSkipProgram () const |
Returns a reference to the current skip program. | |
Protected Attributes | |
RegistryPtr | reg |
Pointer to the registry. | |
const AnnotatedGroundProgram & | groundProgram |
Reference to the ground program for which the initation of unfounded set checks shall be decided. | |
InterpretationPtr | previouslyAssignedAndVerifiedAtoms |
stores the atoms which were assigned and verified when the skipProgram was updated last time. | |
InterpretationPtr | notYetVerifiedExternalAtoms |
Remembers external atom replacement atoms which have already been assigned but could not be verified yet. | |
std::map< IDAddress, std::set < int > > | rulesOfAtom |
Stores for each atom in which rule (identified by its index in the ground program) it occurs (positively or negatively). | |
std::vector< int > | atomsInRule |
Stores for each rule (address) the number of total and of currently assigned and verified atoms. | |
std::vector< int > | assignedAndVerifiedAtomsInRule |
std::set< ID > | skipProgram |
See UnfoundedSetCheckHeuristics::updateSkipProgram and UnfoundedSetCheckHeuristics::getSkipProgram. |
Decides when to do an unfounded set check (over partial interpretations)
The implementers of this interface decide for a given (partial) assignment if a minimality check shall be performed at this point. Note that this is only for optimization purposes as the reasoner will automatically do such a check whenever it is necessary. However, heuristics may initiate additional checks to possibly detect unfounded atoms earlier. Base class for all unfounded set check heuristics.
Definition at line 63 of file UnfoundedSetCheckHeuristicsInterface.h.
DLVHEX_NAMESPACE_BEGIN UnfoundedSetCheckHeuristics::UnfoundedSetCheckHeuristics | ( | const AnnotatedGroundProgram & | groundProgram, |
RegistryPtr | reg | ||
) |
Definition at line 45 of file UnfoundedSetCheckHeuristicsInterface.cpp.
References ID::address, assignedAndVerifiedAtomsInRule, atomsInRule, Rule::body, DBGLOG, AnnotatedGroundProgram::getGroundProgram(), Rule::head, OrdinaryASPProgram::idb, Rule::isEAGuessingRule(), ID::isExternalAuxiliary(), notYetVerifiedExternalAtoms, previouslyAssignedAndVerifiedAtoms, rulesOfAtom, skipProgram, and toString().
virtual bool UnfoundedSetCheckHeuristics::doUFSCheck | ( | InterpretationConstPtr | verifiedAuxes, |
InterpretationConstPtr | partialAssignment, | ||
InterpretationConstPtr | assigned, | ||
InterpretationConstPtr | changed | ||
) | [pure virtual] |
Decides if the reasoner shall do an unfounded set check at this point.
verifiedAuxes | The set of verified external atom auxiliaries wrt. the current partial interpretation |
partialAssignment | The current (partial) interpretation |
assigned | The current set of assigned atoms; if NULL, then the interpretation is complete |
changed | The set of atoms with a (possibly) modified truth value since the last call of this method; if NULL, then all atoms have changed |
Implemented in UnfoundedSetCheckHeuristicsPeriodic, UnfoundedSetCheckHeuristicsMax, and UnfoundedSetCheckHeuristicsPost.
const std::set<ID>& UnfoundedSetCheckHeuristics::getSkipProgram | ( | ) | const [inline] |
Returns a reference to the current skip program.
The method UnfoundedSetCheckHeuristics::updateSkipProgram should be called before this method is used.
Definition at line 129 of file UnfoundedSetCheckHeuristicsInterface.h.
void UnfoundedSetCheckHeuristics::notify | ( | InterpretationConstPtr | verifiedAuxes, |
InterpretationConstPtr | partialAssignment, | ||
InterpretationConstPtr | assigned, | ||
InterpretationConstPtr | changed | ||
) | [virtual] |
Notifies the heuristic about changes in the assignment, although the caller is not going to perform an UFS check at this point.
This allows the heuristic to update internal data structures.
partialAssignment | The current (partial) interpretation |
assigned | The current set of assigned atoms; if NULL, then the interpretation is complete |
changed | The set of atoms with a (possibly) modified truth value since the last call of this method; if NULL, then all atoms have changed |
Definition at line 102 of file UnfoundedSetCheckHeuristicsInterface.cpp.
void UnfoundedSetCheckHeuristics::updateSkipProgram | ( | InterpretationConstPtr | verifiedAuxes, |
InterpretationConstPtr | partialAssignment, | ||
InterpretationConstPtr | assigned, | ||
InterpretationConstPtr | changed | ||
) |
Updates the skip program according to a new partial assignment.
The skip program is the set of rules which are currently not (fully) assignment and thus have to be excluded from UFS checks.
partialAssignment | The current (partial) interpretation |
assigned | The current set of assigned atoms; if NULL, then the interpretation is complete |
changed | The set of atoms with a (possibly) modified truth value since the last call of this method; if NULL, then all atoms have changed |
Definition at line 107 of file UnfoundedSetCheckHeuristicsInterface.cpp.
References ID::address, assignedAndVerifiedAtomsInRule, atomsInRule, Rule::body, DBGLOG, AnnotatedGroundProgram::getGroundProgram(), groundProgram, Rule::head, OrdinaryASPProgram::idb, Rule::isEAGuessingRule(), ID::isExternalAuxiliary(), notYetVerifiedExternalAtoms, previouslyAssignedAndVerifiedAtoms, RawPrinter::print(), reg, rulesOfAtom, skipProgram, and RawPrinter::toString().
std::vector<int> UnfoundedSetCheckHeuristics::assignedAndVerifiedAtomsInRule [protected] |
Definition at line 84 of file UnfoundedSetCheckHeuristicsInterface.h.
Referenced by UnfoundedSetCheckHeuristics(), and updateSkipProgram().
std::vector<int> UnfoundedSetCheckHeuristics::atomsInRule [protected] |
Stores for each rule (address) the number of total and of currently assigned and verified atoms.
Definition at line 84 of file UnfoundedSetCheckHeuristicsInterface.h.
Referenced by UnfoundedSetCheckHeuristics(), and updateSkipProgram().
const AnnotatedGroundProgram& UnfoundedSetCheckHeuristics::groundProgram [protected] |
Reference to the ground program for which the initation of unfounded set checks shall be decided.
Definition at line 72 of file UnfoundedSetCheckHeuristicsInterface.h.
Referenced by updateSkipProgram().
Remembers external atom replacement atoms which have already been assigned but could not be verified yet.
Definition at line 78 of file UnfoundedSetCheckHeuristicsInterface.h.
Referenced by UnfoundedSetCheckHeuristics(), and updateSkipProgram().
stores the atoms which were assigned and verified when the skipProgram was updated last time.
Definition at line 75 of file UnfoundedSetCheckHeuristicsInterface.h.
Referenced by UnfoundedSetCheckHeuristics(), and updateSkipProgram().
RegistryPtr UnfoundedSetCheckHeuristics::reg [protected] |
Pointer to the registry.
Definition at line 69 of file UnfoundedSetCheckHeuristicsInterface.h.
Referenced by updateSkipProgram().
std::map<IDAddress, std::set<int> > UnfoundedSetCheckHeuristics::rulesOfAtom [protected] |
Stores for each atom in which rule (identified by its index in the ground program) it occurs (positively or negatively).
Definition at line 81 of file UnfoundedSetCheckHeuristicsInterface.h.
Referenced by UnfoundedSetCheckHeuristics(), and updateSkipProgram().
std::set<ID> UnfoundedSetCheckHeuristics::skipProgram [protected] |
See UnfoundedSetCheckHeuristics::updateSkipProgram and UnfoundedSetCheckHeuristics::getSkipProgram.
Definition at line 87 of file UnfoundedSetCheckHeuristicsInterface.h.
Referenced by UnfoundedSetCheckHeuristics(), and updateSkipProgram().