| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef KONCLUDE_REASONER_KERNEL_ALGORITHM_CSATISFIABLEEXPANDERCACHEHANDLER_H |
| 22 |
#define KONCLUDE_REASONER_KERNEL_ALGORITHM_CSATISFIABLEEXPANDERCACHEHANDLER_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
|
| 26 |
|
| 27 |
// Namespace includes |
| 28 |
#include "AlgorithmSettings.h" |
| 29 |
#include "CCalculationAlgorithmContext.h" |
| 30 |
#include "CClashDescriptorFactory.h" |
| 31 |
#include "CTrackedClashedDescriptor.h" |
| 32 |
|
| 33 |
// Other includes |
| 34 |
#include "Reasoner/Kernel/Process/CIndividualProcessNode.h" |
| 35 |
#include "Reasoner/Kernel/Process/CClashedDependencyDescriptor.h" |
| 36 |
#include "Reasoner/Kernel/Process/CIndividualNodeSatisfiableExpandingCacheStoringData.h" |
| 37 |
|
| 38 |
#include "Reasoner/Kernel/Process/Dependency/CDependencyTrackPoint.h" |
| 39 |
|
| 40 |
#include "Reasoner/Kernel/Cache/CSignatureSatisfiableExpanderCacheReader.h" |
| 41 |
#include "Reasoner/Kernel/Cache/CSignatureSatisfiableExpanderCacheWriter.h" |
| 42 |
#include "Reasoner/Kernel/Cache/CSignatureSatisfiableExpanderCacheEntry.h" |
| 43 |
#include "Reasoner/Kernel/Cache/CSignatureSatisfiableExpanderCacheEntryWriteData.h" |
| 44 |
#include "Reasoner/Kernel/Cache/CSignatureSatisfiableExpanderCacheEntryExpandWriteData.h" |
| 45 |
#include "Reasoner/Kernel/Cache/CSignatureSatisfiableExpanderCacheEntrySatisfiableBranchWriteData.h" |
| 46 |
|
| 47 |
#include "Context/CContextBase.h" |
| 48 |
|
| 49 |
// Logger includes |
| 50 |
#include "Logger/CLogger.h" |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
namespace Konclude { |
| 55 |
|
| 56 |
using namespace Context; |
| 57 |
|
| 58 |
namespace Reasoner { |
| 59 |
|
| 60 |
namespace Kernel { |
| 61 |
|
| 62 |
using namespace Process; |
| 63 |
using namespace Dependency; |
| 64 |
using namespace Cache; |
| 65 |
|
| 66 |
namespace Algorithm { |
| 67 |
|
| 68 |
/*! |
| 69 |
* |
| 70 |
* \class CSatisfiableExpanderCacheHandler |
| 71 |
* \author Andreas Steigmiller |
| 72 |
* \version 0.1 |
| 73 |
* \brief TODO |
| 74 |
* |
| 75 |
*/ |
| 76 |
class CSatisfiableExpanderCacheHandler { |
| 77 |
// public methods |
| 78 |
public: |
| 79 |
//! Constructor |
| 80 |
CSatisfiableExpanderCacheHandler(CSignatureSatisfiableExpanderCacheReader* satCacheReader, CSignatureSatisfiableExpanderCacheWriter* satCacheWriter); |
| 81 |
|
| 82 |
//! Destructor |
| 83 |
virtual ~CSatisfiableExpanderCacheHandler(); |
| 84 |
|
| 85 |
typedef QPair<cint64,CDependencyTrackPoint*> CDepthDependencyPair; |
| 86 |
|
| 87 |
|
| 88 |
bool isIndividualNodeExpandCached(CIndividualProcessNode* individualNode, bool* satisfiable, CSignatureSatisfiableExpanderCacheEntry** entry, CCalculationAlgorithmContext* calcAlgContext); |
| 89 |
bool compareIndividualNodeCompatibility(CIndividualProcessNode* individualNode, CSignatureSatisfiableExpanderCacheEntry* cachedEntry, CCalculationAlgorithmContext* calcAlgContext); |
| 90 |
|
| 91 |
bool cacheIndividualNodeExpansion(CIndividualProcessNode* individualNode, CCalculationAlgorithmContext* calcAlgContext); |
| 92 |
bool cacheIndividualNodeExpansion(CIndividualProcessNode* individualNode, CIndividualNodeSatisfiableExpandingCacheStoringData* satStorData, CConceptDescriptor* lastAddedConDes, CConceptDescriptor* lastCachedConceptDes, cint64 lastSignature, cint64 lastCachedSignature, CCalculationAlgorithmContext* calcAlgContext); |
| 93 |
|
| 94 |
|
| 95 |
bool hasDependencyToAncestor(CIndividualProcessNode* individualNode, CDependencyTrackPoint* depTrackPoint, bool* branchedFlag, CCalculationAlgorithmContext* calcAlgContext); |
| 96 |
bool simpleDependencyTracking(CIndividualProcessNode* individualNode, cint64 conTag, CDependencyTrackPoint* depTrackPoint, CCACHINGHASH<cint64,cint64>* depHash, CPROCESSINGSET<cint64>* notBranchConceptsSet, bool* branchedFlag, CCalculationAlgorithmContext* calcAlgContext); |
| 97 |
bool complexDependencyTracking(CIndividualProcessNode* individualNode, cint64 conTag, CPROCESSINGSET<CDepthDependencyPair>* depSet, CPROCESSINGLIST<CDepthDependencyPair>* depList, CCACHINGHASH<cint64,cint64>* depHash, CPROCESSINGSET<cint64>* notBranchConceptsSet, bool* branchedFlag, CCalculationAlgorithmContext* calcAlgContext); |
| 98 |
|
| 99 |
bool cacheIndividualNodeSatisfiable(CIndividualProcessNode* individualNode, CCalculationAlgorithmContext* calcAlgContext); |
| 100 |
|
| 101 |
bool isConceptRelevantForSatisfiableBranch(CIndividualProcessNode* individualNode, CConceptDescriptor* conDes, CCalculationAlgorithmContext* calcAlgContext); |
| 102 |
bool isAutomatConceptRelevantForSatisfiableBranch(CIndividualProcessNode* individualNode, CConcept* concept, bool conNegation, CCalculationAlgorithmContext* calcAlgContext); |
| 103 |
|
| 104 |
bool isCardinalityRestrictionCriticalForSatisfiable(CIndividualProcessNode* individualNode, CConceptDescriptor* conDes, CCalculationAlgorithmContext* calcAlgContext); |
| 105 |
bool hasInverseSubRole(CRole* role, CCalculationAlgorithmContext* calcAlgContext); |
| 106 |
bool hasInverseSuperRole(CRole* role, CCalculationAlgorithmContext* calcAlgContext); |
| 107 |
|
| 108 |
bool commitCacheMessages(CCalculationAlgorithmContext* calcAlgContext); |
| 109 |
|
| 110 |
// protected methods |
| 111 |
protected: |
| 112 |
bool prepareCacheMessages(CCalculationAlgorithmContext* calcAlgContext); |
| 113 |
bool addCacheMessages(CSignatureSatisfiableExpanderCacheEntryWriteData* expandWriteData, CCalculationAlgorithmContext* calcAlgContext); |
| 114 |
|
| 115 |
// protected variables |
| 116 |
protected: |
| 117 |
CSignatureSatisfiableExpanderCacheReader* mSatCacheReader; |
| 118 |
CSignatureSatisfiableExpanderCacheWriter* mSatCacheWriter; |
| 119 |
|
| 120 |
CReapplyConceptLabelSet* mTestConSet; |
| 121 |
|
| 122 |
CSignatureSatisfiableExpanderCacheEntryWriteData* mWriteData; |
| 123 |
CTaskMemoryPoolAllocationManager* mMemAllocMan; |
| 124 |
CMemoryPoolContainer mMemPoolCon; |
| 125 |
CContextBase* mTmpContext; |
| 126 |
|
| 127 |
|
| 128 |
// private methods |
| 129 |
private: |
| 130 |
|
| 131 |
// private variables |
| 132 |
private: |
| 133 |
|
| 134 |
}; |
| 135 |
|
| 136 |
}; // end namespace Algorithm |
| 137 |
|
| 138 |
}; // end namespace Kernel |
| 139 |
|
| 140 |
}; // end namespace Reasoner |
| 141 |
|
| 142 |
}; // end namespace Konclude |
| 143 |
|
| 144 |
#endif // KONCLUDE_REASONER_KERNEL_ALGORITHM_CSATISFIABLEEXPANDERCACHEHANDLER_H |