Debian Codegraph @

Source/Reasoner/Kernel/Algorithm/CSaturationNodeExpansionCacheHandler.h

raw
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_CSATURATIONNODEEXPANSIONCACHEHANDLER_H
22 #define KONCLUDE_REASONER_KERNEL_ALGORITHM_CSATURATIONNODEEXPANSIONCACHEHANDLER_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 #include "Reasoner/Kernel/Process/CIndividualNodeSatisfiableExpandingCacheStoringData.h"
38
39 #include "Reasoner/Ontology/CConceptProcessData.h"
40 #include "Reasoner/Ontology/CConceptReferenceLinking.h"
41 #include "Reasoner/Ontology/CConceptSaturationReferenceLinkingData.h"
42
43 #include "Reasoner/Consistiser/CSaturationConceptDataItem.h"
44
45 #include "Reasoner/Kernel/Process/Dependency/CDependencyTrackPoint.h"
46
47 #include "Reasoner/Kernel/Cache/CSaturationNodeAssociatedExpansionCacheReader.h"
48 #include "Reasoner/Kernel/Cache/CSaturationNodeAssociatedExpansionCacheWriter.h"
49 #include "Reasoner/Kernel/Cache/CSaturationNodeAssociatedExpansionCacheEntry.h"
50 #include "Reasoner/Kernel/Cache/CSaturationNodeAssociatedExpansionCacheWriteData.h"
51 #include "Reasoner/Kernel/Cache/CSaturationNodeAssociatedExpansionCacheUnsatisfiabilityWriteData.h"
52 #include "Reasoner/Kernel/Cache/CSaturationNodeAssociatedExpansionCacheExpansionWriteData.h"
53
54 #include "Context/CContextBase.h"
55
56 // Logger includes
57 #include "Logger/CLogger.h"
58
59
60
61 namespace Konclude {
62
63 using namespace Context;
64
65 namespace Reasoner {
66
67 using namespace Ontology;
68 using namespace Consistiser;
69
70 namespace Kernel {
71
72 using namespace Process;
73 using namespace Dependency;
74 using namespace Cache;
75
76 namespace Algorithm {
77
78 /*!
79 *
80 * \class CSaturationNodeExpansionCacheHandler
81 * \author Andreas Steigmiller
82 * \version 0.1
83 * \brief TODO
84 *
85 */
86 class CSaturationNodeExpansionCacheHandler {
87 // public methods
88 public:
89 //! Constructor
90 CSaturationNodeExpansionCacheHandler(CSaturationNodeAssociatedExpansionCacheReader* satCacheReader, CSaturationNodeAssociatedExpansionCacheWriter* satCacheWriter);
91
92 CIndividualSaturationProcessNode* getSaturationIndividualNodeForConcept(CConcept* concept, bool negation, CCalculationAlgorithmContext* calcAlgContext);
93
94 bool cacheUnsatisfiableConcept(CConcept* concept, CCalculationAlgorithmContext* calcAlgContext);
95 bool isConceptUnsatisfiableCached(CConcept* concept, bool negation, CCalculationAlgorithmContext* calcAlgContext);
96
97
98 bool isNodeSatisfiableCached(CIndividualProcessNode* individualProcessNode, CSaturationNodeAssociatedConceptExpansion*& expansion, CCalculationAlgorithmContext* calcAlgContext);
99
100 bool tryNodeSatisfiableCaching(CIndividualProcessNode* individualProcessNode, CCalculationAlgorithmContext* calcAlgContext);
101
102 bool getCachedDeterministicExpansion(CIndividualSaturationProcessNode* saturationNode, CSaturationNodeAssociatedDeterministicConceptExpansion*& expansion, CCalculationAlgorithmContext* calcAlgContext);
103
104 bool commitCacheMessages(CCalculationAlgorithmContext* calcAlgContext);
105
106 // protected methods
107 protected:
108 bool prepareCacheMessages(CCalculationAlgorithmContext* calcAlgContext);
109 bool addCacheMessages(CSaturationNodeAssociatedExpansionCacheWriteData* expandWriteData, CCalculationAlgorithmContext* calcAlgContext);
110
111 CCacheValue getCacheValueForConcept(CConcept* concept, bool negation, CCalculationAlgorithmContext* calcAlgContext);
112 CCacheValue getCacheValueForConcept(CConceptDescriptor* conDes, CCalculationAlgorithmContext* calcAlgContext);
113
114 bool testNodeMatchingExpansion(CSaturationNodeAssociatedConceptExpansion* expansion, CSaturationNodeAssociatedConceptExpansion* alternativeExpansion, CReapplyConceptLabelSet* conSet, CIndividualNodeSaturationBlockingData* satBlockData, CCalculationAlgorithmContext* calcAlgContext);
115
116
117 bool isDeterministicallyDependingOnSaturationConcept(CIndividualProcessNode* individualNode, CDependencyTrackPoint* depTrackPoint, CConceptDescriptor* saturationConceptDescriptor, CCalculationAlgorithmContext* calcAlgContext);
118
119 bool testNodeCachingPossible(CIndividualProcessNode* individualProcessNode, bool& onlyIfCompletelyDeterministic, bool& onlyAllNondeterministic, CSaturationNodeAssociatedExpansionCacheEntry*& cacheEntry, CCalculationAlgorithmContext* calcAlgContext);
120
121
122 // protected variables
123 protected:
124 CSaturationNodeAssociatedExpansionCacheReader* mSatCacheReader;
125 CSaturationNodeAssociatedExpansionCacheWriter* mSatCacheWriter;
126
127 CSaturationNodeAssociatedExpansionCacheWriteData* mWriteData;
128 CTaskMemoryPoolAllocationManager* mMemAllocMan;
129 CMemoryPoolContainer mMemPoolCon;
130 CContextBase* mTmpContext;
131
132
133 // private methods
134 private:
135
136 // private variables
137 private:
138
139 };
140
141 }; // end namespace Algorithm
142
143 }; // end namespace Kernel
144
145 }; // end namespace Reasoner
146
147 }; // end namespace Konclude
148
149 #endif // KONCLUDE_REASONER_KERNEL_ALGORITHM_CSATURATIONNODEEXPANSIONCACHEHANDLER_H