Debian Codegraph @

Source/Reasoner/Classifier/COptimizedSubClassSubsumptionClassifierThread.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_CLASSIFIER_COPTIMIZEDSUBCLASSSUBSUMPTIONCLASSIFIERTHREAD_H
22 #define KONCLUDE_REASONER_CLASSIFIER_COPTIMIZEDSUBCLASSSUBSUMPTIONCLASSIFIERTHREAD_H
23
24 // Libraries includes
25 #include <QLinkedList>
26
27 // Namespace includes
28 #include "ClassifierSettings.h"
29 #include "CSubsumptionClassifier.h"
30 #include "CSubsumptionClassifierThread.h"
31 #include "CPartialPruningTaxonomy.h"
32 #include "CClassClassificationComputationItem.h"
33 #include "COptimizedSubClassOntologyClassificationItem.h"
34 #include "CClassificationClassSubsumptionMessageData.h"
35 #include "CPrecomputedSaturationSubsumerExtractor.h"
36
37 // Other includes
38 #include "Reasoner/Revision/COntologyRevision.h"
39
40 #include "Reasoner/Ontology/CConceptProcessData.h"
41 #include "Reasoner/Ontology/CConceptSatisfiableReferenceLinkingData.h"
42 #include "Reasoner/Ontology/CConceptSaturationReferenceLinkingData.h"
43
44 #include "Reasoner/Generator/CSatisfiableCalculationJobGenerator.h"
45
46 #include "Reasoner/Kernel/Cache/CSaturationNodeAssociatedExpansionCache.h"
47 #include "Reasoner/Kernel/Cache/CSaturationNodeAssociatedExpansionCacheReader.h"
48
49 #include "KoncludeSettings.h"
50
51 // Logger includes
52 #include "Logger/CLogger.h"
53 #include "Logger/CLogIdentifier.h"
54
55 #include <iostream>
56
57 using namespace std;
58
59
60 namespace Konclude {
61
62
63 namespace Reasoner {
64
65 using namespace Revision;
66 using namespace Ontology;
67 using namespace Generator;
68
69 using namespace Kernel;
70 using namespace Task;
71 using namespace Cache;
72
73 namespace Classifier {
74
75 #ifndef KONCLUDE_FORCE_ALL_DEBUG_DEACTIVATED
76
77 //#define OPTIMIZEDSUBCLASSCLASSIFIERDEBUGCOUTOUTPUT
78 //#define OPTIMIZEDSUBCLASSCLASSIFIERDEBUGTAXONOMYCOUTOUTPUT
79 //#define OPTIMIZEDSUBCLASSCLASSIFIERDEBUGLOGOUTPUT
80 //#define OPTIMIZEDSUBCLASSCLASSIFIERDEBUGBOXDESCRIPTION
81 #define OPTIMIZEDSUBCLASSCLASSIFIERDEBUGSTATUSDESCRIPTION
82
83 #endif
84
85
86 /*!
87 *
88 * \class COptimizedSubClassSubsumptionClassifierThread
89 * \author Andreas Steigmiller
90 * \version 0.1
91 * \brief TODO
92 *
93 */
94 class COptimizedSubClassSubsumptionClassifierThread : public CSubsumptionClassifierThread, public CLogIdentifier {
95 // public methods
96 public:
97 //! Constructor
98 COptimizedSubClassSubsumptionClassifierThread(CReasonerManager *reasonerManager);
99
100 //! Destructor
101 virtual ~COptimizedSubClassSubsumptionClassifierThread();
102
103 virtual QString getStatusString();
104 virtual CClassificationProgress* getClassificationProgress();
105
106 // protected methods
107 protected:
108 virtual bool finishOntologyClassification(COntologyClassClassificationItem *ontClassItem);
109 virtual CSubsumptionClassifierThread *scheduleOntologyClassification(CConcreteOntology *ontology, CClassificationCalculationSupport *classificationSupport, CConfigurationBase *config);
110
111 virtual CSubsumptionClassifierThread *processCalculationJob(CSatisfiableCalculationJob* job, COntologyClassClassificationItem *ontClassItem, CClassClassificationComputationItem* workItem);
112
113 virtual void readCalculationConfig(CCalculationConfigurationExtension *config);
114
115 virtual bool interpreteSubsumptionResult(COntologyClassClassificationItem *ontClassItem, CConcept *subsumerConcept, CConcept *subsumedConcept, bool isSubsumption);
116 virtual bool interpreteSatisfiableResult(COntologyClassClassificationItem *ontClassItem, CConcept *satisfiableConcept, bool isSatis);
117
118 virtual bool interpreteTestResults(CTestCalculatedCallbackEvent *testResult);
119
120 virtual bool createNextSubsumtionTest();
121 virtual CTaxonomy *createEmptyTaxonomyForOntology(CConcreteOntology *ontology, CConfigurationBase *config);
122
123 virtual bool interpreteToldSubsumptionResult(COntologyClassClassificationItem *ontClassItem, const QList<QPair<CConcept *,CConcept *> > &subSumRelList, bool isSubSum);
124
125 void createObviousSubsumptionSatisfiableTestingOrder(COptimizedSubClassOntologyClassificationItem* ontClassItem);
126
127 void createObviousSubsumptionSatisfiableTestingOrderFromBuildData(COptimizedSubClassOntologyClassificationItem* ontClassItem);
128 void createObviousSubsumptionSatisfiableTestingOrderFromSaturationData(COptimizedSubClassOntologyClassificationItem* ontClassItem);
129
130 bool calculateSatisfiable(COptimizedSubClassOntologyClassificationItem *optSubClassItem, COptimizedSubClassSatisfiableTestingItem* nextSatTestItem);
131 bool fastSatisfiableOnlySubClassPrecheckTest(COptimizedSubClassOntologyClassificationItem *optSubClassItem, COptimizedSubClassSatisfiableTestingItem* nextSatTestItem, bool* isSatisfiableFlag);
132
133 virtual bool processToldClassificationMessage(COntologyClassificationItem *ontClassItem, CClassificationMessageData* messageData, CMemoryPool* memoryPools);
134
135 CIndividualSaturationProcessNode* getSaturationIndividualNodeForConcept(CConcept* concept, bool negated);
136 bool hasCachedSaturationIndividualNodeAssociatedExpansionProplematicConcept(CCacheEntry* cacheEntry, CConcept* testingConcept);
137 CCacheEntry* getAssociatedSaturationCacheEntry(COptimizedSubClassSatisfiableTestingItem* classConItem);
138
139
140 // protected variables
141 protected:
142 QHash<CClassClassificationComputationItem *, COntologyClassClassificationItem *> workOntItemHash;
143
144 QStringList satTestedConList;
145 QString statusString;
146 QMutex statUpdateMutex;
147
148 CClassificationProgress mClassifyProgess;
149 cint64 satTestedCount;
150 cint64 totalToTestCount;
151 QTime classStartTime;
152
153 QSet<QPair<CConcept *, CConcept *> > subsumCalcedSet;
154
155 CSaturationNodeAssociatedExpansionCache* mSatNodeExpCache;
156 CSaturationNodeAssociatedExpansionCacheReader* mSatNodeExpCacheReader;
157
158 cint64 mStatFastSubClassCheckCacheTryCount;
159 cint64 mStatFastSubClassCheckCacheSuccCount;
160
161
162 // private methods
163 private:
164
165 // private variables
166 private:
167
168 };
169
170 }; // end namespace Classifier
171
172 }; // end namespace Reasoner
173
174 }; // end namespace Konclude
175
176 #endif // KONCLUDE_REASONER_CLASSIFIER_COPTIMIZEDSUBCLASSSUBSUMPTIONCLASSIFIERTHREAD_H