| 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_CSATURATIONNODEBACKENDASSOCIATIONCACHEHANDLER_H |
| 22 |
#define KONCLUDE_REASONER_KERNEL_ALGORITHM_CSATURATIONNODEBACKENDASSOCIATIONCACHEHANDLER_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
|
| 26 |
|
| 27 |
// Namespace includes |
| 28 |
#include "AlgorithmSettings.h" |
| 29 |
#include "CCalculationAlgorithmContext.h" |
| 30 |
#include "CBackendAssociationCacheHandler.h" |
| 31 |
|
| 32 |
// Other includes |
| 33 |
#include "Reasoner/Ontology/CConceptProcessData.h" |
| 34 |
#include "Reasoner/Ontology/CConceptSaturationReferenceLinkingData.h" |
| 35 |
|
| 36 |
#include "Reasoner/Consistiser/CSaturationConceptReferenceLinking.h" |
| 37 |
|
| 38 |
#include "Reasoner/Kernel/Process/CIndividualSaturationProcessNode.h" |
| 39 |
#include "Reasoner/Kernel/Process/CProcessSetHasher.h" |
| 40 |
|
| 41 |
#include "Reasoner/Kernel/Cache/COccurrenceStatisticsCacheWriter.h" |
| 42 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheReader.h" |
| 43 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheWriter.h" |
| 44 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryLabelCacheItem.h" |
| 45 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheLabelAssociationWriteData.h" |
| 46 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker.h" |
| 47 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker.h" |
| 48 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker.h" |
| 49 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker.h" |
| 50 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheUtilities.h" |
| 51 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData.h" |
| 52 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker.h" |
| 53 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheTemporaryAssociationUseDataLinker.h" |
| 54 |
#include "Reasoner/Kernel/Cache/CBackendRepresentativeMemoryLabelCacheItemCardinalityExtensionData.h" |
| 55 |
|
| 56 |
#include "Reasoner/Kernel/Task/CSatisfiableTaskRepresentativeBackendUpdatingAdapter.h" |
| 57 |
|
| 58 |
#include "Context/CContextBase.h" |
| 59 |
|
| 60 |
// Logger includes |
| 61 |
#include "Logger/CLogger.h" |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
namespace Konclude { |
| 66 |
|
| 67 |
using namespace Context; |
| 68 |
|
| 69 |
namespace Reasoner { |
| 70 |
|
| 71 |
using namespace Ontology; |
| 72 |
using namespace Consistiser; |
| 73 |
|
| 74 |
namespace Kernel { |
| 75 |
|
| 76 |
using namespace Process; |
| 77 |
using namespace Cache; |
| 78 |
using namespace Task; |
| 79 |
|
| 80 |
namespace Algorithm { |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
/*! |
| 85 |
* |
| 86 |
* \class CSaturationNodeBackendAssociationCacheHandler |
| 87 |
* \author Andreas Steigmiller |
| 88 |
* \version 0.1 |
| 89 |
* \brief TODO |
| 90 |
* |
| 91 |
*/ |
| 92 |
class CSaturationNodeBackendAssociationCacheHandler : public CBackendAssociationCacheHandler { |
| 93 |
// public methods |
| 94 |
public: |
| 95 |
//! Constructor |
| 96 |
CSaturationNodeBackendAssociationCacheHandler(CBackendRepresentativeMemoryCacheReader* backAssCacheReader, CBackendRepresentativeMemoryCacheWriter* backAssCacheWriter, COccurrenceStatisticsCacheWriter* occStatsCacheWriter); |
| 97 |
|
| 98 |
void readCalculationConfig(CCalculationConfigurationExtension* config); |
| 99 |
|
| 100 |
|
| 101 |
bool tryAssociateNodesWithBackendCache(CIndividualSaturationProcessNodeLinker* indiSaturationAnalysingNodeLinker, CSatisfiableTaskRepresentativeBackendUpdatingAdapter* repbackUpdAdapter, CCalculationAlgorithmContext* calcAlgContext); |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
// protected classes |
| 106 |
protected: |
| 107 |
class CSuccessorRelatedNodesAlternativeCheckingData { |
| 108 |
public: |
| 109 |
CSuccessorRelatedNodesAlternativeCheckingData(CRole* role = nullptr, bool inversed = false) { |
| 110 |
mRole = role; |
| 111 |
mInversed = inversed; |
| 112 |
mCheckingNodeLinker = nullptr; |
| 113 |
mCheckingNodeCount = 0; |
| 114 |
} |
| 115 |
|
| 116 |
CRole* mRole; |
| 117 |
bool mInversed; |
| 118 |
CXLinker<CIndividualSaturationProcessNode*>* mCheckingNodeLinker; |
| 119 |
cint64 mCheckingNodeCount; |
| 120 |
}; |
| 121 |
|
| 122 |
// protected methods |
| 123 |
protected: |
| 124 |
bool determineCardinalityAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 125 |
|
| 126 |
|
| 127 |
bool determineFullConceptSetLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, cint64 labelType, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 128 |
|
| 129 |
bool collectSelfRestrictionRoles(CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>*& roleInstantiatedSet, CSortedNegLinker<CRole*>*& roleInstantiatedLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 130 |
|
| 131 |
bool determineSaturationNodeIndividualCombinedNeighbourRoleInstantiatedSetLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 132 |
bool determineCombinedExistentialRoleInstantiatedSetLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CPROCESSSET<cint64>** existentialIndirectlyConnectedNominalIndividualSet, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 133 |
bool determineCombinedDataRoleInstantiatedSetLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 134 |
|
| 135 |
|
| 136 |
bool determineSaturationNodeIndividualNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 137 |
|
| 138 |
CIndividualSaturationProcessNode* getSuccessorSaturationNode(CConceptSaturationDescriptor* conDes, CIndividualSaturationProcessNode* satNode, CCalculationAlgorithmContext* calcAlgContext); |
| 139 |
bool collectSaturationNodeSuccessorRelatedRoles(cint64 satIndiId, CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, |
| 140 |
bool collectExistentialConnectionRoles, bool collectNominalConnectionRoles, bool collectDataConnectionRoles, bool analyseConcepts, bool analyseSuccessorLinks, |
| 141 |
CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >* nominalIndiIdRoleConnectionDataHash, CPROCESSSET<cint64>** existentialIndirectlyConnectedNominalIndividualSet, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, |
| 142 |
CPROCESSHASH<TRoleInversionPair, CSuccessorRelatedNodesAlternativeCheckingData>* successorRelatedNodesAlternativeCheckingHash, CCalculationAlgorithmContext* calcAlgContext); |
| 143 |
bool collectSaturationNodeSuccessorRelatedRoles(cint64 satIndiId, CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, |
| 144 |
CRole* role, CIndividualSaturationProcessNode* succSatNode, CSaturationSuccessorData* succData, |
| 145 |
CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >* nominalIndiIdRoleConnectionDataHash, CPROCESSSET<cint64>** existentialIndirectlyConnectedNominalIndividualSet, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, CCalculationAlgorithmContext* calcAlgContext); |
| 146 |
|
| 147 |
|
| 148 |
bool determineNominalIndividualIdNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(cint64 nominalId, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnection, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 149 |
|
| 150 |
|
| 151 |
bool determineNominalIndividualIdCombinedNeighbourRoleInstantiatedSetLabelAssociationBackendItem(cint64 nominalId, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnection, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 152 |
|
| 153 |
|
| 154 |
bool determineNominalIndividualIdPossiblyExistentialRoleInstantiatedSetLabelAssociationBackendItem(cint64 nominalId, CSaturationNominalDependentNodeData* nomDepNodeData, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 155 |
|
| 156 |
|
| 157 |
bool collectNominalRelatedRoles(cint64 satIndiId, cint64 nominalId, CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 158 |
bool collectNominalRelatedRoles(cint64 satIndiId, cint64 nominalId, CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, CRole* role, CCalculationAlgorithmContext* calcAlgContext); |
| 159 |
bool collectNominalRelatedRolesFromPredecessors(cint64 satIndiId, cint64 nominalId, CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, CCalculationAlgorithmContext* calcAlgContext); |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
bool collectConceptOccurrenceStatistics(CIndividualSaturationProcessNode* indiNode, CCalculationAlgorithmContext* calcAlgContext); |
| 164 |
|
| 165 |
|
| 166 |
// protected variables |
| 167 |
protected: |
| 168 |
|
| 169 |
CPROCESSHASH< CIndividualSaturationProcessNode*,QPair<CBackendRepresentativeMemoryLabelCacheItem*,CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*> >* mIndiNodeRefDetConceptSetLabelHash; |
| 170 |
CPROCESSHASH< cint64,CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >* mSignatureTmpRefDetConceptSetLabelHash; |
| 171 |
|
| 172 |
|
| 173 |
CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >* mNominalIndiIdRoleConnectionDataHash; |
| 174 |
|
| 175 |
|
| 176 |
bool mConfDirectCardinalityInsufficient; |
| 177 |
bool mConfOccurrenceStatisticsCounting; |
| 178 |
|
| 179 |
COccurrenceStatisticsCacheWriter* mOccStatsCacheWriter; |
| 180 |
|
| 181 |
// private methods |
| 182 |
private: |
| 183 |
|
| 184 |
// private variables |
| 185 |
private: |
| 186 |
|
| 187 |
}; |
| 188 |
|
| 189 |
}; // end namespace Algorithm |
| 190 |
|
| 191 |
}; // end namespace Kernel |
| 192 |
|
| 193 |
}; // end namespace Reasoner |
| 194 |
|
| 195 |
}; // end namespace Konclude |
| 196 |
|
| 197 |
#endif // KONCLUDE_REASONER_KERNEL_ALGORITHM_CSATURATIONNODEBACKENDASSOCIATIONCACHEHANDLER_H |