dlvhex  2.5.0
EncodingBasedUnfoundedSetChecker Class Reference

#include <include/dlvhex2/UnfoundedSetChecker.h>

Inheritance diagram for EncodingBasedUnfoundedSetChecker:
Collaboration diagram for EncodingBasedUnfoundedSetChecker:

Public Member Functions

 EncodingBasedUnfoundedSetChecker (ProgramCtx &ctx, const OrdinaryASPProgram &groundProgram, InterpretationConstPtr componentAtoms=InterpretationConstPtr(), SimpleNogoodContainerPtr ngc=SimpleNogoodContainerPtr())
 Initializes the UFS checker without support for external atoms (they are considered as ordinary ones).
 EncodingBasedUnfoundedSetChecker (BaseModelGenerator &mg, ProgramCtx &ctx, const OrdinaryASPProgram &groundProgram, const AnnotatedGroundProgram &agp, InterpretationConstPtr componentAtoms=InterpretationConstPtr(), SimpleNogoodContainerPtr ngc=SimpleNogoodContainerPtr())
 Initializes the UFS checker with support for external atoms.
void learnNogoodsFromMainSearch (bool reset)
 Forces all unfounded set checker in this manager to learn nogoods from main search now.
std::vector< IDAddressgetUnfoundedSet (InterpretationConstPtr compatibleSet, const std::set< ID > &skipProgram)
 Transforms a nogood from the main search to the UFS search.

Private Member Functions

void constructUFSDetectionProblem (NogoodSet &ufsDetectionProblem, InterpretationConstPtr compatibleSet, InterpretationConstPtr compatibleSetWithoutAux, const std::set< ID > &skipProgram, std::vector< ID > &ufsProgram)
 Constructs the nogood set used for unfounded set detection.
void constructUFSDetectionProblemNecessaryPart (NogoodSet &ufsDetectionProblem, int &auxatomcnt, InterpretationConstPtr compatibleSet, InterpretationConstPtr compatibleSetWithoutAux, const std::set< ID > &skipProgram, std::vector< ID > &ufsProgram)
 Constructs the necessary part of the nogood set used for unfounded set detection.
void constructUFSDetectionProblemOptimizationPart (NogoodSet &ufsDetectionProblem, int &auxatomcnt, InterpretationConstPtr compatibleSet, InterpretationConstPtr compatibleSetWithoutAux, const std::set< ID > &skipProgram, std::vector< ID > &ufsProgram)
 Constructs the optional optimization part of the nogood set used for unfounded set detection.
void constructUFSDetectionProblemOptimizationPartRestrictToCompatibleSet (NogoodSet &ufsDetectionProblem, int &auxatomcnt, InterpretationConstPtr compatibleSet, InterpretationConstPtr compatibleSetWithoutAux, const std::set< ID > &skipProgram, std::vector< ID > &ufsProgram)
 Constructs the optional optimization part of the nogood set used for unfounded set detection such that the search is restricted to atoms which are true in the compatible set.
void constructUFSDetectionProblemOptimizationPartBasicEAKnowledge (NogoodSet &ufsDetectionProblem, int &auxatomcnt, InterpretationConstPtr compatibleSet, InterpretationConstPtr compatibleSetWithoutAux, const std::set< ID > &skipProgram, std::vector< ID > &ufsProgram)
 Constructs the optional optimization part of the nogood set used for unfounded set detection, exploiting the fact that the truth value of external atoms cannot change if no input atom is unfounded.
void constructUFSDetectionProblemOptimizationPartLearnedFromMainSearch (NogoodSet &ufsDetectionProblem, int &auxatomcnt, InterpretationConstPtr compatibleSet, InterpretationConstPtr compatibleSetWithoutAux, const std::set< ID > &skipProgram, std::vector< ID > &ufsProgram)
 Constructs the optional optimization part of the nogood set used for unfounded set detection using learned nogoods from the main search.
void constructUFSDetectionProblemOptimizationPartEAEnforement (NogoodSet &ufsDetectionProblem, int &auxatomcnt, InterpretationConstPtr compatibleSet, InterpretationConstPtr compatibleSetWithoutAux, const std::set< ID > &skipProgram, std::vector< ID > &ufsProgram)
 Constructs the optional optimization part of the nogood set used for unfounded set detection which tries to keep the truth values of external atoms unchanged.
std::pair< bool, NogoodnogoodTransformation (Nogood ng, InterpretationConstPtr compatibleSet)
 Transforms a nogood (valid input-output relationship of some external atom) learned in the main search for being used in the UFS search.

Detailed Description

Definition at line 263 of file UnfoundedSetChecker.h.


Constructor & Destructor Documentation

Initializes the UFS checker without support for external atoms (they are considered as ordinary ones).

Parameters:
ctxProgramCtx
groundProgramGround program used for UFS checking.
componentAtomsAtoms in the component the UFS checker is initialized for.
ngcPointer to a container with valid input-output relationships (EANogoods)

Definition at line 557 of file UnfoundedSetChecker.cpp.

Initializes the UFS checker with support for external atoms.

Parameters:
mgReference to a model generator (used to evaluate the external atoms).
ctxProgramCtx.
groundProgramGround program used for UFS checking.
agpGround program with meta information used for optimized UFS checking.
choiceRuleCompatibleThis parameter is necessary for the clasp backend, which implements non-head cycle free disjunctive rules using choice rules. However, this transformation must be regarded in the optimization of UFS checking. More specifically, the UFS check MUST NOT BE SKIPPED for HFC-free components if they contain such choice rules. For more information, see examples/trickyufs.hex.
ngcPointer to a container with valid input-output relationships (EANogoods)

Definition at line 567 of file UnfoundedSetChecker.cpp.


Member Function Documentation

void EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblem ( NogoodSet ufsDetectionProblem,
InterpretationConstPtr  compatibleSet,
InterpretationConstPtr  compatibleSetWithoutAux,
const std::set< ID > &  skipProgram,
std::vector< ID > &  ufsProgram 
) [private]

Constructs the nogood set used for unfounded set detection.

The construction depends on the interpretation (encoding-based UFS detection). The constructed UFS detection problem is written to ufsDetectionProblem

Parameters:
compatibleSetThe compatible set to create the UFS check for.
compatibleSetWithoutAuxThe compatible set without external atom auxiliaries.
skipProgramThe set of rules considered in the UFS search.
ufsProgramthe set of rules in the program but ignored in the UFS search.

Definition at line 579 of file UnfoundedSetChecker.cpp.

References constructUFSDetectionProblemNecessaryPart(), and constructUFSDetectionProblemOptimizationPart().

Referenced by getUnfoundedSet().

void EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemNecessaryPart ( NogoodSet ufsDetectionProblem,
int &  auxatomcnt,
InterpretationConstPtr  compatibleSet,
InterpretationConstPtr  compatibleSetWithoutAux,
const std::set< ID > &  skipProgram,
std::vector< ID > &  ufsProgram 
) [private]

Constructs the necessary part of the nogood set used for unfounded set detection.

The construction depends on the interpretation (encoding-based UFS detection). The constructed UFS detection problem is written to ufsDetectionProblem

Parameters:
compatibleSetThe compatible set to create the UFS check for.
compatibleSetWithoutAuxThe compatible set without external atom auxiliaries.
skipProgramThe set of rules considered in the UFS search.
ufsProgramthe set of rules in the program but ignored in the UFS search.

Definition at line 593 of file UnfoundedSetChecker.cpp.

References NogoodSet::addNogood(), ID::address, UnfoundedSetChecker::agp, UnfoundedSetChecker::componentAtoms, ProgramCtx::config, NogoodContainer::createLiteral(), UnfoundedSetChecker::ctx, DBGLOG, UnfoundedSetChecker::domain, OrdinaryASPProgram::edb, AnnotatedGroundProgram::getAuxToEA(), Configuration::getOption(), UnfoundedSetChecker::groundProgram, Rule::head, Nogood::insert(), ID::isExternalAuxiliary(), ID::isNaf(), ID::isWeightRule(), LOG, ID::MAINKIND_ATOM, AnnotatedGroundProgram::mapsAux(), UnfoundedSetChecker::mode, UnfoundedSetChecker::Ordinary, RawPrinter::print(), ID::PROPERTY_ATOM_HIDDEN, ID::PROPERTY_AUX, UnfoundedSetChecker::reg, ID::SUBKIND_ATOM_ORDINARYG, Atom::tuple, WARNING(), and UnfoundedSetChecker::WithExt.

Referenced by constructUFSDetectionProblem().

void EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemOptimizationPart ( NogoodSet ufsDetectionProblem,
int &  auxatomcnt,
InterpretationConstPtr  compatibleSet,
InterpretationConstPtr  compatibleSetWithoutAux,
const std::set< ID > &  skipProgram,
std::vector< ID > &  ufsProgram 
) [private]

Constructs the optional optimization part of the nogood set used for unfounded set detection.

The construction depends on the interpretation (encoding-based UFS detection). The constructed UFS detection problem is written to ufsDetectionProblem

Parameters:
compatibleSetThe compatible set to create the UFS check for.
compatibleSetWithoutAuxThe compatible set without external atom auxiliaries.
skipProgramThe set of rules considered in the UFS search.
ufsProgramthe set of rules in the program but ignored in the UFS search.

Definition at line 776 of file UnfoundedSetChecker.cpp.

References constructUFSDetectionProblemOptimizationPartBasicEAKnowledge(), constructUFSDetectionProblemOptimizationPartEAEnforement(), constructUFSDetectionProblemOptimizationPartLearnedFromMainSearch(), constructUFSDetectionProblemOptimizationPartRestrictToCompatibleSet(), DBGLOG, UnfoundedSetChecker::mode, UnfoundedSetChecker::ngc, and UnfoundedSetChecker::WithExt.

Referenced by constructUFSDetectionProblem().

void EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemOptimizationPartBasicEAKnowledge ( NogoodSet ufsDetectionProblem,
int &  auxatomcnt,
InterpretationConstPtr  compatibleSet,
InterpretationConstPtr  compatibleSetWithoutAux,
const std::set< ID > &  skipProgram,
std::vector< ID > &  ufsProgram 
) [private]

Constructs the optional optimization part of the nogood set used for unfounded set detection, exploiting the fact that the truth value of external atoms cannot change if no input atom is unfounded.

The construction depends on the interpretation (encoding-based UFS detection). The constructed UFS detection problem is written to ufsDetectionProblem

Parameters:
compatibleSetThe compatible set to create the UFS check for.
compatibleSetWithoutAuxThe compatible set without external atom auxiliaries.
skipProgramThe set of rules considered in the UFS search.
ufsProgramthe set of rules in the program but ignored in the UFS search.

Definition at line 828 of file UnfoundedSetChecker.cpp.

References NogoodSet::addNogood(), UnfoundedSetChecker::agp, NogoodContainer::createLiteral(), DBGLOG, UnfoundedSetChecker::domain, AnnotatedGroundProgram::getEAMask(), AnnotatedGroundProgram::getIndexedEAtom(), AnnotatedGroundProgram::getIndexedEAtoms(), ExternalAtom::getPredicateInputMask(), Nogood::insert(), UnfoundedSetChecker::reg, and ExternalAtom::updatePredicateInputMask().

Referenced by constructUFSDetectionProblemOptimizationPart().

void EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemOptimizationPartEAEnforement ( NogoodSet ufsDetectionProblem,
int &  auxatomcnt,
InterpretationConstPtr  compatibleSet,
InterpretationConstPtr  compatibleSetWithoutAux,
const std::set< ID > &  skipProgram,
std::vector< ID > &  ufsProgram 
) [private]

Constructs the optional optimization part of the nogood set used for unfounded set detection which tries to keep the truth values of external atoms unchanged.

The construction depends on the interpretation (encoding-based UFS detection). The constructed UFS detection problem is written to ufsDetectionProblem

Parameters:
compatibleSetThe compatible set to create the UFS check for.
compatibleSetWithoutAuxThe compatible set without external atom auxiliaries.
skipProgramThe set of rules considered in the UFS search.
ufsProgramthe set of rules in the program but ignored in the UFS search.

Definition at line 914 of file UnfoundedSetChecker.cpp.

References NogoodSet::addNogood(), ID::address, Rule::body, NogoodContainer::createLiteral(), DBGLOG, Rule::head, Nogood::insert(), ID::isExternalAuxiliary(), ID::isNaf(), ID::MAINKIND_ATOM, ID::PROPERTY_ATOM_HIDDEN, ID::PROPERTY_AUX, UnfoundedSetChecker::reg, ID::SUBKIND_ATOM_ORDINARYG, and Atom::tuple.

Referenced by constructUFSDetectionProblemOptimizationPart().

void EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemOptimizationPartLearnedFromMainSearch ( NogoodSet ufsDetectionProblem,
int &  auxatomcnt,
InterpretationConstPtr  compatibleSet,
InterpretationConstPtr  compatibleSetWithoutAux,
const std::set< ID > &  skipProgram,
std::vector< ID > &  ufsProgram 
) [private]

Constructs the optional optimization part of the nogood set used for unfounded set detection using learned nogoods from the main search.

The construction depends on the interpretation (encoding-based UFS detection). The constructed UFS detection problem is written to ufsDetectionProblem

Parameters:
compatibleSetThe compatible set to create the UFS check for.
compatibleSetWithoutAuxThe compatible set without external atom auxiliaries.
skipProgramThe set of rules considered in the UFS search.
ufsProgramthe set of rules in the program but ignored in the UFS search.

Definition at line 887 of file UnfoundedSetChecker.cpp.

References NogoodSet::addNogood(), DBGLOG, Nogood::getStringRepresentation(), Nogood::isGround(), UnfoundedSetChecker::ngc, nogoodTransformation(), and UnfoundedSetChecker::reg.

Referenced by constructUFSDetectionProblemOptimizationPart().

void EncodingBasedUnfoundedSetChecker::constructUFSDetectionProblemOptimizationPartRestrictToCompatibleSet ( NogoodSet ufsDetectionProblem,
int &  auxatomcnt,
InterpretationConstPtr  compatibleSet,
InterpretationConstPtr  compatibleSetWithoutAux,
const std::set< ID > &  skipProgram,
std::vector< ID > &  ufsProgram 
) [private]

Constructs the optional optimization part of the nogood set used for unfounded set detection such that the search is restricted to atoms which are true in the compatible set.

The construction depends on the interpretation (encoding-based UFS detection). The constructed UFS detection problem is written to ufsDetectionProblem

Parameters:
compatibleSetThe compatible set to create the UFS check for.
compatibleSetWithoutAuxThe compatible set without external atom auxiliaries.
skipProgramThe set of rules considered in the UFS search.
ufsProgramthe set of rules in the program but ignored in the UFS search.

Definition at line 797 of file UnfoundedSetChecker.cpp.

References NogoodSet::addNogood(), ID::address, Rule::body, NogoodContainer::createLiteral(), DBGLOG, Rule::head, Nogood::insert(), ID::isExternalAuxiliary(), UnfoundedSetChecker::mode, UnfoundedSetChecker::Ordinary, and UnfoundedSetChecker::reg.

Referenced by constructUFSDetectionProblemOptimizationPart().

Forces all unfounded set checker in this manager to learn nogoods from main search now.

Parameters:
resetSpecifies if the nogood container from the main search shall be scanned from the beginning (otherwise only nogoods added at the back will be recognized).

Implements UnfoundedSetChecker.

Definition at line 1094 of file UnfoundedSetChecker.cpp.

std::pair< bool, Nogood > EncodingBasedUnfoundedSetChecker::nogoodTransformation ( Nogood  ng,
InterpretationConstPtr  compatibleSet 
) [private, virtual]

Transforms a nogood (valid input-output relationship of some external atom) learned in the main search for being used in the UFS search.

Parameters:
ngThe nogood from the main search.
compatibleSetThe current compatible set we do the unfounded set search with respect to. Note: For AssumptionBasedUnfoundedSetChecker it is essential that the nogood transformation is independent of the compatible set.
Returns:
A pair of a boolean, which denotes if the transformation yielded a nogood, an the transformed nogood in this case.

Implements UnfoundedSetChecker.

Definition at line 1007 of file UnfoundedSetChecker.cpp.

References ID::address, NogoodContainer::createLiteral(), DBGLOG, DLVHEX_BENCHMARK_REGISTER_AND_SCOPE, UnfoundedSetChecker::domain, Nogood::insert(), ID::isNaf(), ID::kind, ID::NAF_MASK, UnfoundedSetChecker::reg, and Atom::tuple.

Referenced by constructUFSDetectionProblemOptimizationPartLearnedFromMainSearch().


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