| 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 |
#include "CSaturationNodeBackendAssociationCacheHandler.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Algorithm { |
| 31 |
|
| 32 |
CSaturationNodeBackendAssociationCacheHandler::CSaturationNodeBackendAssociationCacheHandler(CBackendRepresentativeMemoryCacheReader* backAssCacheReader, CBackendRepresentativeMemoryCacheWriter* backAssCacheWriter, COccurrenceStatisticsCacheWriter* occStatsCacheWriter) : CBackendAssociationCacheHandler(backAssCacheReader, backAssCacheWriter) { |
| 33 |
mOccStatsCacheWriter = occStatsCacheWriter; |
| 34 |
mConfDirectCardinalityInsufficient = false; |
| 35 |
mConfOccurrenceStatisticsCounting = true; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
void CSaturationNodeBackendAssociationCacheHandler::readCalculationConfig(CCalculationConfigurationExtension* config) { |
| 43 |
if (config) { |
| 44 |
mConfOccurrenceStatisticsCounting = config->isOccurrenceStatisticsCollectionActivated(); |
| 45 |
} else { |
| 46 |
mConfOccurrenceStatisticsCounting = true; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
bool CSaturationNodeBackendAssociationCacheHandler::determineCardinalityAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 58 |
|
| 59 |
if (mConfDirectCardinalityInsufficient) { |
| 60 |
tmpAssWriteDataLinker->setCompletelyHandled(false); |
| 61 |
tmpAssWriteDataLinker->setCompletelySaturated(false); |
| 62 |
tmpAssWriteDataLinker->setCompletelyPropagated(false); |
| 63 |
return false; |
| 64 |
} else { |
| 65 |
function<void(CPROCESSHASH<cint64, CRoleCardinalityCountData>* superRoleTagUsedCardCountHash)> initFunc = [&](CPROCESSHASH<cint64, CRoleCardinalityCountData>* superRoleTagUsedCardCountHash)->void { |
| 66 |
CReapplyConceptSaturationLabelSet* conSet = satNode->getReapplyConceptSaturationLabelSet(false); |
| 67 |
if (conSet) { |
| 68 |
for (CConceptSaturationDescriptor* conSatDesIt = conSet->getConceptSaturationDescriptionLinker(); conSatDesIt; conSatDesIt = conSatDesIt->getNext()) { |
| 69 |
CConcept* concept = conSatDesIt->getConcept(); |
| 70 |
bool negation = conSatDesIt->isNegated(); |
| 71 |
cint64 conOpCode = concept->getOperatorCode(); |
| 72 |
if (!negation && conOpCode == CCATMOST || negation && conOpCode == CCATLEAST) { |
| 73 |
CRole* role = concept->getRole(); |
| 74 |
cint64 cardinality = concept->getParameter(); |
| 75 |
if (negation && conOpCode == CCATLEAST) { |
| 76 |
cardinality = cardinality - 1; |
| 77 |
} |
| 78 |
CRoleCardinalityCountData& cardCountData = (*superRoleTagUsedCardCountHash)[role->getRoleTag()]; |
| 79 |
if (!cardCountData.mHasRestrictingCardinality) { |
| 80 |
cardCountData.mHasRestrictingCardinality = true; |
| 81 |
cardCountData.mRestrictingCardinality = cardinality; |
| 82 |
} else { |
| 83 |
cardCountData.mRestrictingCardinality = qMin(cardCountData.mRestrictingCardinality, cardinality); |
| 84 |
} |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
}; |
| 89 |
return CBackendAssociationCacheHandler::determineCardinalityAssociationBackendItem(initFunc, roleUsedCardHash, true, tmpAssWriteDataLinker, calcAlgContext); |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
bool CSaturationNodeBackendAssociationCacheHandler::collectConceptOccurrenceStatistics(CIndividualSaturationProcessNode* indiNode, CCalculationAlgorithmContext* calcAlgContext) { |
| 102 |
CReapplyConceptSaturationLabelSet* conSet = indiNode->getReapplyConceptSaturationLabelSet(false); |
| 103 |
CConcreteOntology* ontology = calcAlgContext->getProcessingDataBox()->getOntology(); |
| 104 |
for (CConceptSaturationDescriptor* conSatDesLinkerIt = conSet->getConceptSaturationDescriptionLinker(); conSatDesLinkerIt; conSatDesLinkerIt = conSatDesLinkerIt->getNext()) { |
| 105 |
CConcept* concept = conSatDesLinkerIt->getConcept(); |
| 106 |
mOccStatsCacheWriter->incConceptInstanceOccurrencceStatistics(ontology, concept->getConceptTag(), 1, 0, 1, 0); |
| 107 |
} |
| 108 |
return true; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
bool CSaturationNodeBackendAssociationCacheHandler::determineFullConceptSetLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, cint64 labelType, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 118 |
CReapplyConceptSaturationLabelSet* conSet = satNode->getReapplyConceptSaturationLabelSet(false); |
| 119 |
if (!conSet) { |
| 120 |
return false; |
| 121 |
} |
| 122 |
CIndividualSaturationProcessNode* copiedNode = satNode->getCopyIndividualNode(); |
| 123 |
if (copiedNode && copiedNode->getReapplyConceptSaturationLabelSet(false) && copiedNode->getReapplyConceptSaturationLabelSet(false)->getConceptSaturationDescriptionLinker() == conSet->getConceptSaturationDescriptionLinker()) { |
| 124 |
return determineFullConceptSetLabelAssociationBackendItem(copiedNode, labelType,tmpAssWriteDataLinker,calcAlgContext); |
| 125 |
} |
| 126 |
|
| 127 |
QPair<CBackendRepresentativeMemoryLabelCacheItem*,CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>* hashedRefPair = nullptr; |
| 128 |
if (satNode->getNominalIndividual() == nullptr) { |
| 129 |
QPair<CBackendRepresentativeMemoryLabelCacheItem*,CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>& refPair = (*mIndiNodeRefDetConceptSetLabelHash)[satNode]; |
| 130 |
if (refPair.first) { |
| 131 |
tmpAssWriteDataLinker->setReferredLabelData(labelType, refPair.first); |
| 132 |
++mStatReusedHashedIndiLabels; |
| 133 |
return true; |
| 134 |
} else if (refPair.second) { |
| 135 |
tmpAssWriteDataLinker->setReferredTemporaryLabelData(labelType, refPair.second); |
| 136 |
++mStatReusedHashedIndiLabels; |
| 137 |
return true; |
| 138 |
} |
| 139 |
hashedRefPair = &refPair; |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
cint64 conCount = conSet->getConceptCount(); |
| 144 |
cint64 conSetSigValue = CBackendRepresentativeMemoryCacheUtilities::getConceptDescriptorSignature(conSet->getConceptSaturationDescriptionLinker(), conCount, nullptr); |
| 145 |
|
| 146 |
|
| 147 |
CBackendRepresentativeMemoryLabelCacheItem* cachedLabelItem = mAssBackCacheReader->getConceptSetLabelCacheEntry(labelType, conSetSigValue,conSet->getConceptCount(),conSet->getConceptSaturationDescriptionLinker()); |
| 148 |
if (cachedLabelItem) { |
| 149 |
++mStatReusedCachedLabels; |
| 150 |
if (hashedRefPair) { |
| 151 |
hashedRefPair->first = cachedLabelItem; |
| 152 |
} |
| 153 |
tmpAssWriteDataLinker->setReferredLabelData(labelType, cachedLabelItem); |
| 154 |
return true; |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*& prevTempRefLabels = (*mSignatureTmpRefDetConceptSetLabelHash)[conSetSigValue]; |
| 159 |
if (prevTempRefLabels) { |
| 160 |
for (CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* prevTempRefLabelIt = prevTempRefLabels; prevTempRefLabelIt; prevTempRefLabelIt = prevTempRefLabelIt->getNext()) { |
| 161 |
if (prevTempRefLabelIt->getCacheValueCount() == conSet->getConceptCount()) { |
| 162 |
bool compatibleConcepts = true; |
| 163 |
for (CBackendRepresentativeMemoryLabelValueLinker* labelValueLinkerIt = prevTempRefLabelIt->getCacheValueLinker(); labelValueLinkerIt && compatibleConcepts; labelValueLinkerIt = labelValueLinkerIt->getNext()) { |
| 164 |
CCacheValue& cacheValue = labelValueLinkerIt->getCacheValue(); |
| 165 |
CConcept* concept = (CConcept*)cacheValue.getIdentification(); |
| 166 |
bool negation = cacheValue.getCacheValueIdentifier() == CCacheValue::CACHEVALTAGANDNEGATEDCONCEPT; |
| 167 |
if (!conSet->hasConcept(concept,negation)) { |
| 168 |
compatibleConcepts = false; |
| 169 |
} |
| 170 |
} |
| 171 |
if (compatibleConcepts) { |
| 172 |
++mStatReusedHashedSignatureLabels; |
| 173 |
++mStatReusedTempLabels; |
| 174 |
if (hashedRefPair) { |
| 175 |
hashedRefPair->second = prevTempRefLabelIt; |
| 176 |
} |
| 177 |
tmpAssWriteDataLinker->setReferredTemporaryLabelData(labelType, prevTempRefLabelIt); |
| 178 |
return true; |
| 179 |
} |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTempRefLabel = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 186 |
newTempRefLabel->initLabelWriteData(conSetSigValue, labelType); |
| 187 |
CIndividualSaturationProcessNodeStatusFlags* indFlags = satNode->getIndirectStatusFlags(); |
| 188 |
CIndividualSaturationProcessNodeStatusFlags* dirFlags = satNode->getDirectStatusFlags(); |
| 189 |
bool insufficient = indFlags->hasInsufficientFlag() || !indFlags->hasCompletedFlag() || !dirFlags->hasCompletedFlag(); |
| 190 |
if (!insufficient) { |
| 191 |
newTempRefLabel->setCompletelySaturated(true); |
| 192 |
newTempRefLabel->setCompletelyHandled(true); |
| 193 |
newTempRefLabel->setCompletelyPropagated(true); |
| 194 |
} |
| 195 |
for (CConceptSaturationDescriptor* conSatDesIt = conSet->getConceptSaturationDescriptionLinker(); conSatDesIt; conSatDesIt = conSatDesIt->getNext()) { |
| 196 |
CConcept* concept = conSatDesIt->getConcept(); |
| 197 |
bool negation = conSatDesIt->isNegated(); |
| 198 |
CBackendRepresentativeMemoryLabelValueLinker* labelValueLinker = CObjectAllocator< CBackendRepresentativeMemoryLabelValueLinker >::allocateAndConstruct(mMemAllocMan); |
| 199 |
labelValueLinker->initLabelValueLinker(getCacheValue(concept,negation)); |
| 200 |
newTempRefLabel->appendCacheValueLinker(labelValueLinker); |
| 201 |
} |
| 202 |
mNewTmpLabelList->append(newTempRefLabel); |
| 203 |
++mStatCreatedTempLabels; |
| 204 |
|
| 205 |
if (hashedRefPair) { |
| 206 |
hashedRefPair->second = newTempRefLabel; |
| 207 |
} |
| 208 |
tmpAssWriteDataLinker->setReferredTemporaryLabelData(labelType, newTempRefLabel); |
| 209 |
prevTempRefLabels = newTempRefLabel->append(prevTempRefLabels); |
| 210 |
return true; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
bool CSaturationNodeBackendAssociationCacheHandler::collectSelfRestrictionRoles(CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>*& roleInstantiatedSet, CSortedNegLinker<CRole*>*& roleInstantiatedLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 241 |
|
| 242 |
bool hasSelf = false; |
| 243 |
CRole* topRole = calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole(); |
| 244 |
CReapplyConceptSaturationLabelSet* conSet = satNode->getReapplyConceptSaturationLabelSet(false); |
| 245 |
for (CConceptSaturationDescriptor* conSatDesIt = conSet->getConceptSaturationDescriptionLinker(); conSatDesIt; conSatDesIt = conSatDesIt->getNext()) { |
| 246 |
CConcept* concept = conSatDesIt->getConcept(); |
| 247 |
bool conNegation = conSatDesIt->isNegated(); |
| 248 |
cint64 conCode = concept->getOperatorCode(); |
| 249 |
CRole* role = concept->getRole(); |
| 250 |
bool existentialSuccessorCand = false; |
| 251 |
if (role != topRole) { |
| 252 |
if (!conNegation && conCode == CCSELF) { |
| 253 |
if (!roleInstantiatedSet->contains(TRoleInversionPair(role, false))) { |
| 254 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 255 |
roleInstantiatedLinker = roleLinker->init(role, false, roleInstantiatedLinker); |
| 256 |
roleInstantiatedSet->insert(TRoleInversionPair(role, false)); |
| 257 |
} |
| 258 |
if (!roleInstantiatedSet->contains(TRoleInversionPair(role, true))) { |
| 259 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 260 |
roleInstantiatedLinker = roleLinker->init(role, true, roleInstantiatedLinker); |
| 261 |
roleInstantiatedSet->insert(TRoleInversionPair(role, true)); |
| 262 |
} |
| 263 |
hasSelf = true; |
| 264 |
} |
| 265 |
} |
| 266 |
} |
| 267 |
return hasSelf; |
| 268 |
} |
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
bool CSaturationNodeBackendAssociationCacheHandler::determineSaturationNodeIndividualCombinedNeighbourRoleInstantiatedSetLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 277 |
|
| 278 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnDataLinker = mNominalIndiIdRoleConnectionDataHash->value(satNode->getNominalIndividual()->getIndividualID()); |
| 279 |
|
| 280 |
CIndividualSaturationProcessNodeExtensionData* extensionData = satNode->getIndividualExtensionData(false); |
| 281 |
if (!extensionData && !nominalConnDataLinker) { |
| 282 |
return false; |
| 283 |
} |
| 284 |
|
| 285 |
CPROCESSSET<TRoleInversionPair>* combinedNeigbourRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 286 |
|
| 287 |
CSortedNegLinker<CRole*>* combinedNeigbourRoleInstantiatedLinker = nullptr; |
| 288 |
|
| 289 |
bool selfRestrictions = collectSelfRestrictionRoles(satNode, combinedNeigbourRoleInstantiatedSet, combinedNeigbourRoleInstantiatedLinker, calcAlgContext); |
| 290 |
|
| 291 |
CLinkedNeighbourRoleAssertionSaturationHash* linkedNeighbourRoleAssHash = extensionData->getLinkedNeighbourRoleAssertionHash(false); |
| 292 |
if (!selfRestrictions && !linkedNeighbourRoleAssHash && !nominalConnDataLinker) { |
| 293 |
return false; |
| 294 |
} |
| 295 |
|
| 296 |
|
| 297 |
CRole* topRole = calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole(); |
| 298 |
CPROCESSHASH<cint64, CLinkedNeighbourRoleAssertionSaturationData*>* neighbourRoleAssertionDataHash = nullptr; |
| 299 |
if (linkedNeighbourRoleAssHash) { |
| 300 |
neighbourRoleAssertionDataHash = linkedNeighbourRoleAssHash->getNeighbourRoleAssertionDataHash(); |
| 301 |
} |
| 302 |
if (neighbourRoleAssertionDataHash) { |
| 303 |
for (CPROCESSHASH<cint64, CLinkedNeighbourRoleAssertionSaturationData*>::const_iterator it = neighbourRoleAssertionDataHash->constBegin(), itEnd = neighbourRoleAssertionDataHash->constEnd(); it != itEnd; ++it) { |
| 304 |
cint64 neighbourIndiId = it.key(); |
| 305 |
CLinkedNeighbourRoleAssertionSaturationData* data = it.value(); |
| 306 |
for (CLinkedNeighbourRoleAssertionLinker* linkedRoleAssertedLinkerIt = data->getLinkedRoleAssertedLinker(); linkedRoleAssertedLinkerIt; linkedRoleAssertedLinkerIt = linkedRoleAssertedLinkerIt->getNext()) { |
| 307 |
CRole* role = linkedRoleAssertedLinkerIt->getAssertedRole(); |
| 308 |
bool inversed = linkedRoleAssertedLinkerIt->isAssertedRoleInversed(); |
| 309 |
|
| 310 |
if (role != topRole && !combinedNeigbourRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) { |
| 311 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 312 |
combinedNeigbourRoleInstantiatedLinker = roleLinker->init(role, inversed, combinedNeigbourRoleInstantiatedLinker); |
| 313 |
combinedNeigbourRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed)); |
| 314 |
} |
| 315 |
} |
| 316 |
} |
| 317 |
} |
| 318 |
|
| 319 |
for (CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnData = nominalConnDataLinker; nominalConnData; nominalConnData = nominalConnData->getNext()) { |
| 320 |
CRole* role = nominalConnData->getConnectionRole(); |
| 321 |
bool inversed = nominalConnData->isInversedConnection(); |
| 322 |
|
| 323 |
if (role != topRole && !combinedNeigbourRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) { |
| 324 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 325 |
combinedNeigbourRoleInstantiatedLinker = roleLinker->init(role, inversed, combinedNeigbourRoleInstantiatedLinker); |
| 326 |
combinedNeigbourRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed)); |
| 327 |
} |
| 328 |
} |
| 329 |
|
| 330 |
if (combinedNeigbourRoleInstantiatedLinker) { |
| 331 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, combinedNeigbourRoleInstantiatedLinker, combinedNeigbourRoleInstantiatedSet, true, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext); |
| 332 |
tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, labelRef); |
| 333 |
|
| 334 |
if (mConfOccurrenceStatisticsCounting) { |
| 335 |
CConcreteOntology* ontology = calcAlgContext->getProcessingDataBox()->getOntology(); |
| 336 |
visitRolesOfAssociatedCompinationRoleSetLabel(labelRef, [&](CRole* role, bool inversed)->bool { |
| 337 |
if (!inversed) { |
| 338 |
mOccStatsCacheWriter->incRoleInstanceOccurrencceStatistics(ontology, role->getRoleTag(), 1, 0, 1, 0, 0, 0); |
| 339 |
} |
| 340 |
return true; |
| 341 |
}, calcAlgContext); |
| 342 |
} |
| 343 |
|
| 344 |
return true; |
| 345 |
} |
| 346 |
else { |
| 347 |
return false; |
| 348 |
} |
| 349 |
|
| 350 |
|
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
CIndividualSaturationProcessNode* CSaturationNodeBackendAssociationCacheHandler::getSuccessorSaturationNode(CConceptSaturationDescriptor* conDes, CIndividualSaturationProcessNode* satNode, CCalculationAlgorithmContext* calcAlgContext) { |
| 365 |
CConcept* concept = conDes->getConcept(); |
| 366 |
bool conNegation = conDes->isNegated(); |
| 367 |
CRole* role = concept->getRole(); |
| 368 |
CConceptData* conceptData = concept->getConceptData(); |
| 369 |
if (conceptData) { |
| 370 |
CConceptProcessData* conProcData = (CConceptProcessData*)conceptData; |
| 371 |
CConceptReferenceLinking* conRefLinking = conProcData->getConceptReferenceLinking(); |
| 372 |
if (conRefLinking) { |
| 373 |
CConceptSaturationReferenceLinkingData* confSatRefLinkingData = (CConceptSaturationReferenceLinkingData*)conRefLinking; |
| 374 |
CSaturationConceptReferenceLinking* extSatCalcRefLinkData = confSatRefLinkingData->getExistentialSuccessorConceptSaturationReferenceLinkingData(); |
| 375 |
if (extSatCalcRefLinkData) { |
| 376 |
CIndividualSaturationProcessNode* existIndiNode = (CIndividualSaturationProcessNode*)extSatCalcRefLinkData->getIndividualProcessNodeForConcept(); |
| 377 |
if (existIndiNode) { |
| 378 |
return existIndiNode; |
| 379 |
} |
| 380 |
} |
| 381 |
} |
| 382 |
} |
| 383 |
CSortedNegLinker<CConcept*>* conceptOpLinkerIt = concept->getOperandList(); |
| 384 |
while (conceptOpLinkerIt) { |
| 385 |
CConcept* opConcept = conceptOpLinkerIt->getData(); |
| 386 |
bool opConNegation = conceptOpLinkerIt->isNegated() ^ conNegation; |
| 387 |
CConceptData* opConceptData = opConcept->getConceptData(); |
| 388 |
if (opConceptData) { |
| 389 |
CConceptProcessData* conProcData = (CConceptProcessData*)opConceptData; |
| 390 |
CConceptReferenceLinking* conRefLinking = conProcData->getConceptReferenceLinking(); |
| 391 |
if (conRefLinking) { |
| 392 |
CConceptSaturationReferenceLinkingData* confSatRefLinkingData = (CConceptSaturationReferenceLinkingData*)conRefLinking; |
| 393 |
CSaturationConceptReferenceLinking* satCalcRefLinkData = confSatRefLinkingData->getConceptSaturationReferenceLinkingData(opConNegation); |
| 394 |
if (satCalcRefLinkData) { |
| 395 |
CIndividualSaturationProcessNode* existIndiNode = (CIndividualSaturationProcessNode*)satCalcRefLinkData->getIndividualProcessNodeForConcept(); |
| 396 |
if (existIndiNode) { |
| 397 |
return existIndiNode; |
| 398 |
} |
| 399 |
} |
| 400 |
} |
| 401 |
} |
| 402 |
conceptOpLinkerIt = conceptOpLinkerIt->getNext(); |
| 403 |
} |
| 404 |
CConcept* baseTopConcept = nullptr; |
| 405 |
if (!role->isDataRole()) { |
| 406 |
baseTopConcept = calcAlgContext->getUsedProcessingDataBox()->getOntologyTopConcept(); |
| 407 |
} else { |
| 408 |
baseTopConcept = calcAlgContext->getUsedProcessingDataBox()->getOntologyTopDataRangeConcept(); |
| 409 |
} |
| 410 |
CConcept* opConcept = baseTopConcept; |
| 411 |
bool opConNegation = false; |
| 412 |
CConceptData* opConceptData = opConcept->getConceptData(); |
| 413 |
if (opConceptData) { |
| 414 |
CConceptProcessData* conProcData = (CConceptProcessData*)opConceptData; |
| 415 |
CConceptReferenceLinking* conRefLinking = conProcData->getConceptReferenceLinking(); |
| 416 |
if (conRefLinking) { |
| 417 |
CConceptSaturationReferenceLinkingData* confSatRefLinkingData = (CConceptSaturationReferenceLinkingData*)conRefLinking; |
| 418 |
CSaturationConceptReferenceLinking* satCalcRefLinkData = confSatRefLinkingData->getConceptSaturationReferenceLinkingData(opConNegation); |
| 419 |
if (satCalcRefLinkData) { |
| 420 |
CIndividualSaturationProcessNode* existIndiNode = (CIndividualSaturationProcessNode*)satCalcRefLinkData->getIndividualProcessNodeForConcept(); |
| 421 |
if (existIndiNode) { |
| 422 |
return existIndiNode; |
| 423 |
} |
| 424 |
} |
| 425 |
} |
| 426 |
} |
| 427 |
return nullptr; |
| 428 |
} |
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
bool CSaturationNodeBackendAssociationCacheHandler::collectSaturationNodeSuccessorRelatedRoles(cint64 satIndiId, CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, |
| 435 |
CRole* role, CIndividualSaturationProcessNode* succSatNode, CSaturationSuccessorData* succData, |
| 436 |
CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >* nominalIndiIdRoleConnectionDataHash, CPROCESSSET<cint64>** existentialIndirectlyConnectedNominalIndividualSet, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, CCalculationAlgorithmContext* calcAlgContext) { |
| 437 |
|
| 438 |
bool collected = false; |
| 439 |
if (roleSet && !(*roleSet)->contains(TRoleInversionPair(role, false))) { |
| 440 |
(*roleSet)->insert(TRoleInversionPair(role, false)); |
| 441 |
collected = true; |
| 442 |
|
| 443 |
CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 444 |
*roleLinker = newRoleLinker->init(role, false, *roleLinker); |
| 445 |
|
| 446 |
if (roleUsedCardHash) { |
| 447 |
cint64 cardCount = 1; |
| 448 |
if (succData) { |
| 449 |
cardCount = succData->mSuccCount; |
| 450 |
} |
| 451 |
(*roleUsedCardHash)[role] += cardCount; |
| 452 |
} |
| 453 |
} |
| 454 |
|
| 455 |
if (mConfOccurrenceStatisticsCounting && succSatNode && !succSatNode->isSeparated()) { |
| 456 |
succSatNode->setOccurrenceStatisticsCollectingRequired(true); |
| 457 |
} |
| 458 |
|
| 459 |
if (succSatNode && succSatNode->getIndirectStatusFlags()->hasNominalConnectionFlag()) { |
| 460 |
CSuccessorConnectedNominalSet* succConnNomSet = succSatNode->getSuccessorConnectedNominalSet(false); |
| 461 |
if (succConnNomSet && existentialIndirectlyConnectedNominalIndividualSet) { |
| 462 |
for (CSuccessorConnectedNominalSet::const_iterator it = succConnNomSet->constBegin(), itEnd = succConnNomSet->constEnd(); it != itEnd; ++it) { |
| 463 |
cint64 nomIndiId = *it; |
| 464 |
if (!*existentialIndirectlyConnectedNominalIndividualSet) { |
| 465 |
*existentialIndirectlyConnectedNominalIndividualSet = CObjectParameterizingAllocator< CPROCESSSET<cint64>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 466 |
} |
| 467 |
(*existentialIndirectlyConnectedNominalIndividualSet)->insert(nomIndiId); |
| 468 |
} |
| 469 |
} |
| 470 |
} |
| 471 |
|
| 472 |
|
| 473 |
if (nominalIndiIdRoleConnectionDataHash && (succSatNode && succSatNode->getIntegratedNominalIndividual() || succData && succData->mVALUENominalConnection)) { |
| 474 |
cint64 nominalId = -1; |
| 475 |
if (succSatNode && succSatNode->getIntegratedNominalIndividual()) { |
| 476 |
nominalId = succSatNode->getIntegratedNominalIndividual()->getIndividualID(); |
| 477 |
} else if (succData && succData->mVALUENominalConnection) { |
| 478 |
nominalId = succData->mVALUENominalID; |
| 479 |
} |
| 480 |
collected = true; |
| 481 |
|
| 482 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData*& prevNominalConnectionData = (*nominalIndiIdRoleConnectionDataHash)[nominalId]; |
| 483 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* newNominalConnectionData = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 484 |
newNominalConnectionData->initNominalRoleConnectionData(role, true, CIndividualReference(satIndiId)); |
| 485 |
newNominalConnectionData->setNext(prevNominalConnectionData); |
| 486 |
prevNominalConnectionData = newNominalConnectionData; |
| 487 |
|
| 488 |
|
| 489 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData*& prevSaturationNodeConnectionData = (*nominalIndiIdRoleConnectionDataHash)[satIndiId]; |
| 490 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* newSaturationNodeConnectionData = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 491 |
newSaturationNodeConnectionData->initNominalRoleConnectionData(role, false, CIndividualReference(nominalId)); |
| 492 |
newSaturationNodeConnectionData->setNext(prevSaturationNodeConnectionData); |
| 493 |
prevSaturationNodeConnectionData = newSaturationNodeConnectionData; |
| 494 |
} |
| 495 |
return collected; |
| 496 |
} |
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
bool CSaturationNodeBackendAssociationCacheHandler::collectSaturationNodeSuccessorRelatedRoles(cint64 satIndiId, CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, |
| 501 |
bool collectExistentialConnectionRoles, bool collectNominalConnectionRoles, bool collectDataConnectionRoles, bool analyseConcepts, bool analyseSuccessorLinks, |
| 502 |
CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >* nominalIndiIdRoleConnectionDataHash, CPROCESSSET<cint64>** existentialIndirectlyConnectedNominalIndividualSet, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, |
| 503 |
CPROCESSHASH<TRoleInversionPair, CSuccessorRelatedNodesAlternativeCheckingData>* successorRelatedNodesAlternativeCheckingHash, CCalculationAlgorithmContext* calcAlgContext) { |
| 504 |
|
| 505 |
CReapplyConceptSaturationLabelSet* conSet = satNode->getReapplyConceptSaturationLabelSet(false); |
| 506 |
if (!conSet) { |
| 507 |
return false; |
| 508 |
} |
| 509 |
|
| 510 |
CLinkedRoleSaturationSuccessorHash* linkedSuccHash = satNode->getLinkedRoleSuccessorHash(false); |
| 511 |
|
| 512 |
CIndividualSaturationProcessNode* copiedNode = satNode->getCopyIndividualNode(); |
| 513 |
if (copiedNode && copiedNode->getReapplyConceptSaturationLabelSet(false) && copiedNode->getReapplyConceptSaturationLabelSet(false)->getConceptSaturationDescriptionLinker() == conSet->getConceptSaturationDescriptionLinker() && (!linkedSuccHash || copiedNode->getLinkedRoleSuccessorHash(false))) { |
| 514 |
return collectSaturationNodeSuccessorRelatedRoles(satIndiId, copiedNode, roleSet, roleLinker, collectExistentialConnectionRoles, collectNominalConnectionRoles, collectDataConnectionRoles, analyseConcepts, analyseSuccessorLinks, nominalIndiIdRoleConnectionDataHash, existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, successorRelatedNodesAlternativeCheckingHash, calcAlgContext); |
| 515 |
} |
| 516 |
|
| 517 |
bool collected = false; |
| 518 |
|
| 519 |
CRole* topRole = calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole(); |
| 520 |
if (analyseSuccessorLinks && linkedSuccHash) { |
| 521 |
CPROCESSHASH<CRole*, CLinkedRoleSaturationSuccessorData*>* linkSuccDatahash = linkedSuccHash->getLinkedRoleSuccessorHash(); |
| 522 |
for (CPROCESSHASH<CRole*, CLinkedRoleSaturationSuccessorData*>::const_iterator it = linkSuccDatahash->constBegin(), itEnd = linkSuccDatahash->constEnd(); it != itEnd; ++it) { |
| 523 |
CRole* role = it.key(); |
| 524 |
CLinkedRoleSaturationSuccessorData* linkSuccData = it.value(); |
| 525 |
if (role != topRole && linkSuccData->mSuccCount > 0) { |
| 526 |
CPROCESSMAP<cint64, CSaturationSuccessorData*>* succNodeMap = linkSuccData->getSuccessorNodeDataMap(false); |
| 527 |
for (CPROCESSMAP<cint64, CSaturationSuccessorData*>::const_iterator succIt = succNodeMap->constBegin(), succItEnd = succNodeMap->constEnd(); succIt != succItEnd; ++succIt) { |
| 528 |
CSaturationSuccessorData* succData = succIt.value(); |
| 529 |
if (succData->mActiveCount > 0) { |
| 530 |
CIndividualSaturationProcessNode* succSatNode = succData->mSuccIndiNode; |
| 531 |
bool collectSuccessorNode = true; |
| 532 |
if (succSatNode && succSatNode->isABoxIndividualRepresentationNode()) { |
| 533 |
collectSuccessorNode = false; |
| 534 |
} |
| 535 |
if (succSatNode && succSatNode->getIntegratedNominalIndividual() || succData->mVALUENominalConnection) { |
| 536 |
if (!collectNominalConnectionRoles) { |
| 537 |
collectSuccessorNode = false; |
| 538 |
} |
| 539 |
} else { |
| 540 |
if (role->isDataRole()) { |
| 541 |
if (!collectDataConnectionRoles) { |
| 542 |
collectSuccessorNode = false; |
| 543 |
} |
| 544 |
} else { |
| 545 |
if (!collectExistentialConnectionRoles) { |
| 546 |
collectSuccessorNode = false; |
| 547 |
} |
| 548 |
} |
| 549 |
} |
| 550 |
if (collectSuccessorNode) { |
| 551 |
collected |= collectSaturationNodeSuccessorRelatedRoles(satIndiId, satNode, roleSet, roleLinker, role, succSatNode, succData, nominalIndiIdRoleConnectionDataHash, existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, calcAlgContext); |
| 552 |
} |
| 553 |
} |
| 554 |
} |
| 555 |
} |
| 556 |
} |
| 557 |
|
| 558 |
} else if (analyseConcepts) { |
| 559 |
for (CConceptSaturationDescriptor* conSatDesIt = conSet->getConceptSaturationDescriptionLinker(); conSatDesIt; conSatDesIt = conSatDesIt->getNext()) { |
| 560 |
CConcept* concept = conSatDesIt->getConcept(); |
| 561 |
bool conNegation = conSatDesIt->isNegated(); |
| 562 |
cint64 conCode = concept->getOperatorCode(); |
| 563 |
CRole* role = concept->getRole(); |
| 564 |
bool existentialSuccessorCand = false; |
| 565 |
if (role != topRole) { |
| 566 |
if (!conNegation && conCode == CCVALUE && collectNominalConnectionRoles) { |
| 567 |
CSaturationSuccessorData succData; |
| 568 |
succData.mVALUENominalConnection = true; |
| 569 |
succData.mVALUENominalID = concept->getNominalIndividual()->getIndividualID(); |
| 570 |
collected |= collectSaturationNodeSuccessorRelatedRoles(satIndiId, satNode, roleSet, roleLinker, role, nullptr, &succData, nominalIndiIdRoleConnectionDataHash, existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, calcAlgContext); |
| 571 |
} |
| 572 |
if (!conNegation && conCode == CCATLEAST || conNegation && conCode == CCATMOST) { |
| 573 |
CIndividualSaturationProcessNode* succSatNode = getSuccessorSaturationNode(conSatDesIt, satNode, calcAlgContext); |
| 574 |
CSaturationSuccessorData succData; |
| 575 |
succData.mSuccCount = concept->getParameter(); |
| 576 |
if (conNegation) { |
| 577 |
succData.mSuccCount--; |
| 578 |
} |
| 579 |
bool collectSuccessorNode = true; |
| 580 |
if (successorRelatedNodesAlternativeCheckingHash) { |
| 581 |
CSuccessorRelatedNodesAlternativeCheckingData alternativeCheckingData = successorRelatedNodesAlternativeCheckingHash->value(TRoleInversionPair(role, false)); |
| 582 |
for (CXLinker<CIndividualSaturationProcessNode*>* alternativeNodeLinkerIt = alternativeCheckingData.mCheckingNodeLinker; alternativeNodeLinkerIt && collectSuccessorNode; alternativeNodeLinkerIt = alternativeNodeLinkerIt->getNext()) { |
| 583 |
CIndividualSaturationProcessNode* alternativeCheckingNode = alternativeNodeLinkerIt->getData(); |
| 584 |
if (alternativeCheckingNode && succData.mSuccCount == 1) { |
| 585 |
bool containsExistentiallyRestrictedConcept = true; |
| 586 |
if (concept->getOperandList()) { |
| 587 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && containsExistentiallyRestrictedConcept; opConLinkerIt = opConLinkerIt->getNext()) { |
| 588 |
CConcept* opCon = opConLinkerIt->getData(); |
| 589 |
bool opConNeg = opConLinkerIt->isNegated(); |
| 590 |
if (!alternativeCheckingNode->getReapplyConceptSaturationLabelSet(false) || !alternativeCheckingNode->getReapplyConceptSaturationLabelSet(false)->containsConcept(opCon, opConNeg)) { |
| 591 |
containsExistentiallyRestrictedConcept = false; |
| 592 |
} |
| 593 |
} |
| 594 |
} |
| 595 |
if (containsExistentiallyRestrictedConcept) { |
| 596 |
collectSuccessorNode = false; |
| 597 |
} |
| 598 |
} |
| 599 |
} |
| 600 |
} |
| 601 |
|
| 602 |
if (collectSuccessorNode) { |
| 603 |
collected |= collectSaturationNodeSuccessorRelatedRoles(satIndiId, satNode, roleSet, roleLinker, role, succSatNode, &succData, nominalIndiIdRoleConnectionDataHash, existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, calcAlgContext); |
| 604 |
} |
| 605 |
} |
| 606 |
|
| 607 |
if (!conNegation && (conCode == CCSOME || conCode == CCAQSOME) || conNegation && (conCode == CCALL)) { |
| 608 |
existentialSuccessorCand = true; |
| 609 |
} |
| 610 |
if (role && existentialSuccessorCand) { |
| 611 |
CIndividualSaturationProcessNode* succSatNode = getSuccessorSaturationNode(conSatDesIt, satNode, calcAlgContext); |
| 612 |
if (succSatNode) { |
| 613 |
bool collectSuccessorNode = true; |
| 614 |
if (succSatNode->getIntegratedNominalIndividual()) { |
| 615 |
if (!collectNominalConnectionRoles) { |
| 616 |
collectSuccessorNode = false; |
| 617 |
} |
| 618 |
} else { |
| 619 |
if (role->isDataRole()) { |
| 620 |
if (!collectDataConnectionRoles) { |
| 621 |
collectSuccessorNode = false; |
| 622 |
} |
| 623 |
} else { |
| 624 |
if (!collectExistentialConnectionRoles) { |
| 625 |
collectSuccessorNode = false; |
| 626 |
} |
| 627 |
} |
| 628 |
} |
| 629 |
|
| 630 |
if (collectSuccessorNode && successorRelatedNodesAlternativeCheckingHash) { |
| 631 |
CSuccessorRelatedNodesAlternativeCheckingData alternativeCheckingData = successorRelatedNodesAlternativeCheckingHash->value(TRoleInversionPair(role, false)); |
| 632 |
for (CXLinker<CIndividualSaturationProcessNode*>* alternativeNodeLinkerIt = alternativeCheckingData.mCheckingNodeLinker; alternativeNodeLinkerIt && collectSuccessorNode; alternativeNodeLinkerIt = alternativeNodeLinkerIt->getNext()) { |
| 633 |
CIndividualSaturationProcessNode* alternativeCheckingNode = alternativeNodeLinkerIt->getData(); |
| 634 |
if (alternativeCheckingNode) { |
| 635 |
bool containsExistentiallyRestrictedConcept = true; |
| 636 |
if (concept->getOperandList()) { |
| 637 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && containsExistentiallyRestrictedConcept; opConLinkerIt = opConLinkerIt->getNext()) { |
| 638 |
CConcept* opCon = opConLinkerIt->getData(); |
| 639 |
bool opConNeg = opConLinkerIt->isNegated() ^ conNegation; |
| 640 |
if (!alternativeCheckingNode->getReapplyConceptSaturationLabelSet(false) || !alternativeCheckingNode->getReapplyConceptSaturationLabelSet(false)->containsConcept(opCon, opConNeg)) { |
| 641 |
containsExistentiallyRestrictedConcept = false; |
| 642 |
} |
| 643 |
} |
| 644 |
} |
| 645 |
if (containsExistentiallyRestrictedConcept) { |
| 646 |
collectSuccessorNode = false; |
| 647 |
} |
| 648 |
} |
| 649 |
} |
| 650 |
} |
| 651 |
|
| 652 |
if (collectSuccessorNode) { |
| 653 |
collected |= collectSaturationNodeSuccessorRelatedRoles(satIndiId, satNode, roleSet, roleLinker, role, succSatNode, nullptr, nominalIndiIdRoleConnectionDataHash, existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, calcAlgContext); |
| 654 |
} |
| 655 |
} |
| 656 |
} |
| 657 |
} |
| 658 |
|
| 659 |
} |
| 660 |
} |
| 661 |
|
| 662 |
return collected; |
| 663 |
} |
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
bool CSaturationNodeBackendAssociationCacheHandler::determineCombinedExistentialRoleInstantiatedSetLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CPROCESSSET<cint64>** existentialIndirectlyConnectedNominalIndividualSet, CPROCESSHASH<CRole*, cint64>* roleUsedCardHash, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 669 |
|
| 670 |
|
| 671 |
CPROCESSHASH<TRoleInversionPair, CSuccessorRelatedNodesAlternativeCheckingData>* successorRelatedNodesAlternativeCheckingHash = nullptr; |
| 672 |
|
| 673 |
CIndividualSaturationProcessNodeExtensionData* extensionData = satNode->getIndividualExtensionData(false); |
| 674 |
// don't use it at the moment since it causes errors |
| 675 |
// TODO: fix |
| 676 |
CRole* topRole = calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole(); |
| 677 |
if (extensionData) { |
| 678 |
CLinkedNeighbourRoleAssertionSaturationHash* linkedNeighbourRoleAssHash = extensionData->getLinkedNeighbourRoleAssertionHash(false); |
| 679 |
CPROCESSHASH<cint64, CLinkedNeighbourRoleAssertionSaturationData*>* neighbourRoleAssertionDataHash = nullptr; |
| 680 |
if (linkedNeighbourRoleAssHash) { |
| 681 |
neighbourRoleAssertionDataHash = linkedNeighbourRoleAssHash->getNeighbourRoleAssertionDataHash(); |
| 682 |
} |
| 683 |
if (neighbourRoleAssertionDataHash) { |
| 684 |
successorRelatedNodesAlternativeCheckingHash = CObjectParameterizingAllocator< CPROCESSHASH<TRoleInversionPair, CSuccessorRelatedNodesAlternativeCheckingData>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 685 |
CRole* lastRole = nullptr; |
| 686 |
bool lastRoleInversion = false; |
| 687 |
cint64 lastRoleUsedCount = 0; |
| 688 |
for (CPROCESSHASH<cint64, CLinkedNeighbourRoleAssertionSaturationData*>::const_iterator it = neighbourRoleAssertionDataHash->constBegin(), itEnd = neighbourRoleAssertionDataHash->constEnd(); it != itEnd; ++it) { |
| 689 |
cint64 neighbourIndiId = it.key(); |
| 690 |
CLinkedNeighbourRoleAssertionSaturationData* data = it.value(); |
| 691 |
for (CLinkedNeighbourRoleAssertionSaturationNodeLinker* linkedRoleAssertedLinkerIt = data->getLinkedRoleAssertedLinker(); linkedRoleAssertedLinkerIt; linkedRoleAssertedLinkerIt = (CLinkedNeighbourRoleAssertionSaturationNodeLinker*)linkedRoleAssertedLinkerIt->getNext()) { |
| 692 |
CRole* role = linkedRoleAssertedLinkerIt->getAssertedRole(); |
| 693 |
bool inversed = linkedRoleAssertedLinkerIt->isAssertedRoleInversed(); |
| 694 |
|
| 695 |
if ((role == lastRole && lastRoleInversion == inversed && lastRoleUsedCount < 3) || role != lastRole || lastRoleInversion != inversed) { |
| 696 |
if (role == lastRole && lastRoleInversion == inversed) { |
| 697 |
++lastRoleUsedCount; |
| 698 |
} else { |
| 699 |
lastRole = role; |
| 700 |
lastRoleInversion = inversed; |
| 701 |
lastRoleUsedCount = 0; |
| 702 |
} |
| 703 |
|
| 704 |
CIndividualSaturationProcessNode* connectedSatNode = linkedRoleAssertedLinkerIt->getConnectedSaturationNode(); |
| 705 |
|
| 706 |
for (CSortedNegLinker<CRole*>* superRoleLinkerIt = role->getIndirectSuperRoleList(); superRoleLinkerIt; superRoleLinkerIt = superRoleLinkerIt->getNext()) { |
| 707 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 708 |
bool superRoleInversion = inversed ^ superRoleLinkerIt->isNegated(); |
| 709 |
|
| 710 |
if (superRole != topRole && !superRoleInversion) { |
| 711 |
CSuccessorRelatedNodesAlternativeCheckingData& checkingData = (*successorRelatedNodesAlternativeCheckingHash)[TRoleInversionPair(superRole, superRoleInversion)]; |
| 712 |
if (!checkingData.mRole) { |
| 713 |
checkingData.mRole = superRole; |
| 714 |
checkingData.mInversed = superRoleInversion; |
| 715 |
} |
| 716 |
if (checkingData.mCheckingNodeCount < 3) { |
| 717 |
CXLinker<CIndividualSaturationProcessNode*>* checkingNodeLinker = CObjectAllocator< CXLinker<CIndividualSaturationProcessNode*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 718 |
checkingNodeLinker->initLinker(connectedSatNode); |
| 719 |
checkingData.mCheckingNodeLinker = checkingNodeLinker->append(checkingData.mCheckingNodeLinker); |
| 720 |
} |
| 721 |
} |
| 722 |
} |
| 723 |
|
| 724 |
} |
| 725 |
} |
| 726 |
} |
| 727 |
} |
| 728 |
} |
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
CPROCESSSET<TRoleInversionPair>* combinedExistentialRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 734 |
CSortedNegLinker<CRole*>* combinedExistentialRoleInstantiatedLinker = nullptr; |
| 735 |
|
| 736 |
collectSaturationNodeSuccessorRelatedRoles(satNode->getIndividualID(), satNode, &combinedExistentialRoleInstantiatedSet, &combinedExistentialRoleInstantiatedLinker, true, false, false, true, true, nullptr, existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, successorRelatedNodesAlternativeCheckingHash, calcAlgContext); |
| 737 |
|
| 738 |
if (combinedExistentialRoleInstantiatedLinker) { |
| 739 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, combinedExistentialRoleInstantiatedLinker, combinedExistentialRoleInstantiatedSet, true, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext); |
| 740 |
tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, labelRef); |
| 741 |
|
| 742 |
if (mConfOccurrenceStatisticsCounting) { |
| 743 |
CConcreteOntology* ontology = calcAlgContext->getProcessingDataBox()->getOntology(); |
| 744 |
visitRolesOfAssociatedCompinationRoleSetLabel(labelRef, [&](CRole* role, bool inversed)->bool { |
| 745 |
if (!inversed) { |
| 746 |
mOccStatsCacheWriter->incRoleInstanceOccurrencceStatistics(ontology, role->getRoleTag(), 1, 0, 1, 0, 0, 0); |
| 747 |
} else if (role->getInverseRole()) { |
| 748 |
mOccStatsCacheWriter->incRoleInstanceOccurrencceStatistics(ontology, role->getInverseRole()->getRoleTag(), 1, 0, 0, 1, 0, 0); |
| 749 |
} |
| 750 |
return true; |
| 751 |
}, calcAlgContext); |
| 752 |
} |
| 753 |
|
| 754 |
return true; |
| 755 |
} else { |
| 756 |
return false; |
| 757 |
} |
| 758 |
|
| 759 |
} |
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
bool CSaturationNodeBackendAssociationCacheHandler::determineCombinedDataRoleInstantiatedSetLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 766 |
|
| 767 |
CPROCESSSET<TRoleInversionPair>* combinedDataRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 768 |
CSortedNegLinker<CRole*>* combinedDataRoleInstantiatedLinker = nullptr; |
| 769 |
|
| 770 |
// TODO: only do this, if there are data value concepts, i.e., set flag if data value concepts are used |
| 771 |
collectSaturationNodeSuccessorRelatedRoles(satNode->getIndividualID(), satNode, &combinedDataRoleInstantiatedSet, &combinedDataRoleInstantiatedLinker, false, false, true, true, true, nullptr, nullptr, nullptr, nullptr, calcAlgContext); |
| 772 |
|
| 773 |
CLinkedDataValueAssertionSaturationData* dataValueAssertionsData = satNode->getLinkedDataValueAssertionData(false); |
| 774 |
if (dataValueAssertionsData) { |
| 775 |
for (CXLinker<CRole*>* dataRoleIt = dataValueAssertionsData->getDataValueRoleAssertionLinker(); dataRoleIt; dataRoleIt = dataRoleIt->getNext()) { |
| 776 |
CRole* dataRole = dataRoleIt->getData(); |
| 777 |
if (!combinedDataRoleInstantiatedSet->contains(TRoleInversionPair(dataRole, false))) { |
| 778 |
combinedDataRoleInstantiatedSet->insert(TRoleInversionPair(dataRole, false)); |
| 779 |
|
| 780 |
CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 781 |
combinedDataRoleInstantiatedLinker = newRoleLinker->init(dataRole, false, combinedDataRoleInstantiatedLinker); |
| 782 |
} |
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
|
| 787 |
if (combinedDataRoleInstantiatedLinker) { |
| 788 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, combinedDataRoleInstantiatedLinker, combinedDataRoleInstantiatedSet, true, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext); |
| 789 |
tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, labelRef); |
| 790 |
return true; |
| 791 |
} else { |
| 792 |
return false; |
| 793 |
} |
| 794 |
|
| 795 |
} |
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
bool CSaturationNodeBackendAssociationCacheHandler::determineSaturationNodeIndividualNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(CIndividualSaturationProcessNode* satNode, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 827 |
|
| 828 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnection = mNominalIndiIdRoleConnectionDataHash->value(satNode->getNominalIndividual()->getIndividualID()); |
| 829 |
|
| 830 |
CIndividualSaturationProcessNodeExtensionData* extensionData = satNode->getIndividualExtensionData(false); |
| 831 |
if (!extensionData && !nominalConnection) { |
| 832 |
return false; |
| 833 |
} |
| 834 |
|
| 835 |
CPROCESSSET<TRoleInversionPair>* selfRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 836 |
CSortedNegLinker<CRole*>* selfRoleInstantiatedLinker = nullptr; |
| 837 |
|
| 838 |
bool selfRestrictions = collectSelfRestrictionRoles(satNode, selfRoleInstantiatedSet, selfRoleInstantiatedLinker, calcAlgContext); |
| 839 |
|
| 840 |
CLinkedNeighbourRoleAssertionSaturationHash* linkedNeighbourRoleAssHash = extensionData->getLinkedNeighbourRoleAssertionHash(false); |
| 841 |
if (!selfRestrictions && !linkedNeighbourRoleAssHash && !nominalConnection) { |
| 842 |
return false; |
| 843 |
} |
| 844 |
|
| 845 |
CPROCESSSET<CBackendRepresentativeMemoryCacheTemporaryLabelReference>* neigbourRoleInstantiatedSetCompination = CObjectParameterizingAllocator< CPROCESSSET<CBackendRepresentativeMemoryCacheTemporaryLabelReference>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 846 |
|
| 847 |
CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >* mNominalNeighbourIndiIdRoleConnectionDataHash = nullptr; |
| 848 |
|
| 849 |
if (nominalConnection) { |
| 850 |
mNominalIndiIdRoleConnectionDataHash->remove(satNode->getNominalIndividual()->getIndividualID()); |
| 851 |
mNominalNeighbourIndiIdRoleConnectionDataHash = CObjectParameterizingAllocator< CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 852 |
|
| 853 |
for (CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnectionIt = nominalConnection; nominalConnectionIt; nominalConnectionIt = nominalConnectionIt->getNext()) { |
| 854 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData*& neigbbourNominalConnectionDataLinker = (*mNominalNeighbourIndiIdRoleConnectionDataHash)[nominalConnectionIt->getConnectedIndividual().getIndividualID()]; |
| 855 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* newNeigbbourNominalConnectionDataLinker = CObjectAllocator<CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData>::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 856 |
newNeigbbourNominalConnectionDataLinker->initNominalRoleConnectionData(nominalConnectionIt->getConnectionRole(), nominalConnectionIt->isInversedConnection(), nominalConnectionIt->getConnectedIndividual()); |
| 857 |
neigbbourNominalConnectionDataLinker = newNeigbbourNominalConnectionDataLinker->append(neigbbourNominalConnectionDataLinker); |
| 858 |
} |
| 859 |
} |
| 860 |
|
| 861 |
|
| 862 |
CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker* roleSetNeighbourUpdateLinker = nullptr; |
| 863 |
|
| 864 |
if (selfRoleInstantiatedLinker) { |
| 865 |
|
| 866 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker* superRoleAssertionLinker = nullptr; |
| 867 |
CPROCESSHASH<TRoleInversionPair, CBackendRepresentativeMemoryCacheRoleAssertionLinker*>* superRoleInversionLinkerHash = CObjectParameterizingAllocator< CPROCESSHASH<TRoleInversionPair, CBackendRepresentativeMemoryCacheRoleAssertionLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 868 |
|
| 869 |
|
| 870 |
CRole* topRole = calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole(); |
| 871 |
for (CSortedNegLinker<CRole*>* selfRoleInstantiatedLinkerIt = selfRoleInstantiatedLinker; selfRoleInstantiatedLinkerIt; selfRoleInstantiatedLinkerIt = selfRoleInstantiatedLinkerIt->getNext()) { |
| 872 |
|
| 873 |
CRole* role = selfRoleInstantiatedLinkerIt->getData(); |
| 874 |
bool inversed = selfRoleInstantiatedLinkerIt->isNegated(); |
| 875 |
for (CSortedNegLinker<CRole*>* superRoleLinkerIt = role->getIndirectSuperRoleList(); superRoleLinkerIt; superRoleLinkerIt = superRoleLinkerIt->getNext()) { |
| 876 |
CRole* superRole = superRoleLinkerIt->getData(); |
| 877 |
bool superRoleNegation = superRoleLinkerIt->isNegated() ^ inversed; |
| 878 |
if (superRole != topRole && superRoleInversionLinkerHash->value(TRoleInversionPair(superRole, superRoleNegation)) == nullptr) { |
| 879 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker* newRoleLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheRoleAssertionLinker >::allocateAndConstruct(calcAlgContext->getMemoryAllocationManager()); |
| 880 |
newRoleLinker->initRoleAssertionLinker(superRole, superRoleNegation, false, true, false); |
| 881 |
superRoleInversionLinkerHash->insert(TRoleInversionPair(superRole, superRoleNegation), newRoleLinker); |
| 882 |
superRoleAssertionLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)newRoleLinker->append(superRoleAssertionLinker); |
| 883 |
} |
| 884 |
} |
| 885 |
} |
| 886 |
|
| 887 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference neighbourRoleSetLabelRef = getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(nullptr, superRoleAssertionLinker, nullptr, calcAlgContext); |
| 888 |
neigbourRoleInstantiatedSetCompination->insert(neighbourRoleSetLabelRef); |
| 889 |
|
| 890 |
CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker* newRoleSetNeighbourUpdateLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 891 |
newRoleSetNeighbourUpdateLinker->initRoleSetNeighbourUpdateDataLinker(neighbourRoleSetLabelRef, satNode->getNominalIndividual()->getIndividualID()); |
| 892 |
roleSetNeighbourUpdateLinker = newRoleSetNeighbourUpdateLinker->append(roleSetNeighbourUpdateLinker); |
| 893 |
} |
| 894 |
|
| 895 |
|
| 896 |
CPROCESSHASH<cint64, CLinkedNeighbourRoleAssertionSaturationData*>* neighbourRoleAssertionDataHash = nullptr; |
| 897 |
if (linkedNeighbourRoleAssHash) { |
| 898 |
neighbourRoleAssertionDataHash = linkedNeighbourRoleAssHash->getNeighbourRoleAssertionDataHash(); |
| 899 |
} |
| 900 |
if (neighbourRoleAssertionDataHash) { |
| 901 |
for (CPROCESSHASH<cint64, CLinkedNeighbourRoleAssertionSaturationData*>::const_iterator it = neighbourRoleAssertionDataHash->constBegin(), itEnd = neighbourRoleAssertionDataHash->constEnd(); it != itEnd; ++it) { |
| 902 |
cint64 neighbourIndiId = it.key(); |
| 903 |
CLinkedNeighbourRoleAssertionSaturationData* data = it.value(); |
| 904 |
|
| 905 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalNeighbourConnection = nullptr; |
| 906 |
if (mNominalNeighbourIndiIdRoleConnectionDataHash) { |
| 907 |
nominalNeighbourConnection = mNominalNeighbourIndiIdRoleConnectionDataHash->value(neighbourIndiId); |
| 908 |
mNominalNeighbourIndiIdRoleConnectionDataHash->remove(neighbourIndiId); |
| 909 |
} |
| 910 |
|
| 911 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference neighbourRoleSetLabelRef; |
| 912 |
CLinkedNeighbourRoleAssertionLinker* linkedRoleAssertedLinker = data->getLinkedRoleAssertedLinker(); |
| 913 |
if (linkedRoleAssertedLinker && !linkedRoleAssertedLinker->hasNext() && !nominalNeighbourConnection) { |
| 914 |
CRole* role = linkedRoleAssertedLinker->getAssertedRole(); |
| 915 |
bool inversed = linkedRoleAssertedLinker->isAssertedRoleInversed(); |
| 916 |
neighbourRoleSetLabelRef = getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(role, inversed, calcAlgContext); |
| 917 |
neigbourRoleInstantiatedSetCompination->insert(neighbourRoleSetLabelRef); |
| 918 |
} else { |
| 919 |
neighbourRoleSetLabelRef = getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(linkedRoleAssertedLinker, nullptr, nominalNeighbourConnection, calcAlgContext); |
| 920 |
neigbourRoleInstantiatedSetCompination->insert(neighbourRoleSetLabelRef); |
| 921 |
} |
| 922 |
|
| 923 |
CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker* newRoleSetNeighbourUpdateLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 924 |
newRoleSetNeighbourUpdateLinker->initRoleSetNeighbourUpdateDataLinker(neighbourRoleSetLabelRef, neighbourIndiId); |
| 925 |
roleSetNeighbourUpdateLinker = newRoleSetNeighbourUpdateLinker->append(roleSetNeighbourUpdateLinker); |
| 926 |
} |
| 927 |
} |
| 928 |
if (mNominalNeighbourIndiIdRoleConnectionDataHash && !mNominalNeighbourIndiIdRoleConnectionDataHash->isEmpty()) { |
| 929 |
for (CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >::const_iterator it = mNominalNeighbourIndiIdRoleConnectionDataHash->constBegin(), itEnd = mNominalNeighbourIndiIdRoleConnectionDataHash->constEnd(); it != itEnd; ++it) { |
| 930 |
cint64 neighbourIndiId = it.key(); |
| 931 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalNeighbourConnection = it.value(); |
| 932 |
|
| 933 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference neighbourRoleSetLabelRef = getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(nullptr, nullptr, nominalNeighbourConnection, calcAlgContext); |
| 934 |
neigbourRoleInstantiatedSetCompination->insert(neighbourRoleSetLabelRef); |
| 935 |
|
| 936 |
CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker* newRoleSetNeighbourUpdateLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 937 |
newRoleSetNeighbourUpdateLinker->initRoleSetNeighbourUpdateDataLinker(neighbourRoleSetLabelRef, neighbourIndiId); |
| 938 |
roleSetNeighbourUpdateLinker = newRoleSetNeighbourUpdateLinker->append(roleSetNeighbourUpdateLinker); |
| 939 |
} |
| 940 |
} |
| 941 |
|
| 942 |
tmpAssWriteDataLinker->setRoleSetNeighbourUpdateDataLinker(roleSetNeighbourUpdateLinker); |
| 943 |
return determineNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(neigbourRoleInstantiatedSetCompination, tmpAssWriteDataLinker, calcAlgContext); |
| 944 |
} |
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
bool CSaturationNodeBackendAssociationCacheHandler::determineNominalIndividualIdNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(cint64 nominalId, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnection, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 957 |
CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker* roleSetNeighbourUpdateLinker = nullptr; |
| 958 |
|
| 959 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = mAssBackCacheReader->getIndividualAssociationData(nominalId); |
| 960 |
CBackendRepresentativeMemoryLabelCacheItem* existingNeighbourRoleInstantiatedSetCompinationLabel = nullptr; |
| 961 |
if (indiAssData) { |
| 962 |
existingNeighbourRoleInstantiatedSetCompinationLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 963 |
} |
| 964 |
CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* existingNeighbourRoleSetHash = nullptr; |
| 965 |
if (indiAssData) { |
| 966 |
existingNeighbourRoleSetHash = indiAssData->getNeighbourRoleSetHash(); |
| 967 |
} |
| 968 |
|
| 969 |
|
| 970 |
bool updated = false; |
| 971 |
|
| 972 |
|
| 973 |
CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >* mNominalNeighbourIndiIdRoleConnectionDataHash = nullptr; |
| 974 |
if (nominalConnection) { |
| 975 |
mNominalNeighbourIndiIdRoleConnectionDataHash = CObjectParameterizingAllocator< CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 976 |
|
| 977 |
for (CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnectionIt = nominalConnection; nominalConnectionIt; nominalConnectionIt = nominalConnectionIt->getNext()) { |
| 978 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData*& neigbbourNominalConnectionDataLinker = (*mNominalNeighbourIndiIdRoleConnectionDataHash)[nominalConnectionIt->getConnectedIndividual().getIndividualID()]; |
| 979 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* newNeigbbourNominalConnectionDataLinker = CObjectAllocator<CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData>::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 980 |
newNeigbbourNominalConnectionDataLinker->initNominalRoleConnectionData(nominalConnectionIt->getConnectionRole(), nominalConnectionIt->isInversedConnection(), nominalConnectionIt->getConnectedIndividual()); |
| 981 |
neigbbourNominalConnectionDataLinker = newNeigbbourNominalConnectionDataLinker->append(neigbbourNominalConnectionDataLinker); |
| 982 |
} |
| 983 |
} |
| 984 |
|
| 985 |
|
| 986 |
CPROCESSSET<CBackendRepresentativeMemoryCacheTemporaryLabelReference>* neigbourRoleInstantiatedSetCompination = nullptr; |
| 987 |
for (CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >::const_iterator it = mNominalNeighbourIndiIdRoleConnectionDataHash->constBegin(), itEnd = mNominalNeighbourIndiIdRoleConnectionDataHash->constEnd(); it != itEnd; ++it) { |
| 988 |
cint64 neighbourIndiId = it.key(); |
| 989 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnectionData = it.value(); |
| 990 |
CBackendRepresentativeMemoryLabelCacheItem* prevNeighbourRoleSetLabel = nullptr; |
| 991 |
if (existingNeighbourRoleSetHash) { |
| 992 |
prevNeighbourRoleSetLabel = existingNeighbourRoleSetHash->getNeighbourRoleSetLabel(neighbourIndiId); |
| 993 |
} |
| 994 |
|
| 995 |
|
| 996 |
bool updateRequired = false; |
| 997 |
if (!prevNeighbourRoleSetLabel) { |
| 998 |
updateRequired = true; |
| 999 |
} else { |
| 1000 |
for (CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnectionIt = nominalConnectionData; !updateRequired && nominalConnectionIt; nominalConnectionIt = nominalConnectionIt->getNext()) { |
| 1001 |
if (!mAssBackCacheReader->hasRoleInAssociatedNeigbourRoleSetLabel(indiAssData, prevNeighbourRoleSetLabel, nominalConnectionIt->getConnectionRole(), nominalConnectionIt->isInversedConnection(), false, true, false)) { |
| 1002 |
updateRequired = true; |
| 1003 |
} |
| 1004 |
} |
| 1005 |
} |
| 1006 |
|
| 1007 |
if (updateRequired) { |
| 1008 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker* linkedRoleAssertedLinker = nullptr; |
| 1009 |
if (prevNeighbourRoleSetLabel) { |
| 1010 |
mAssBackCacheReader->visitRolesOfAssociatedNeigbourRoleSetLabel(indiAssData, prevNeighbourRoleSetLabel, [&](CRole* role, bool inversed, bool aboxAsserted, bool nominalConnection, bool nondeterministic)->bool { |
| 1011 |
CBackendRepresentativeMemoryCacheRoleAssertionLinker* newLinkedRoleAssertedLinker = CObjectAllocator<CBackendRepresentativeMemoryCacheRoleAssertionLinker>::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 1012 |
newLinkedRoleAssertedLinker->initRoleAssertionLinker(role, inversed, aboxAsserted, nominalConnection, nondeterministic); |
| 1013 |
linkedRoleAssertedLinker = (CBackendRepresentativeMemoryCacheRoleAssertionLinker*)newLinkedRoleAssertedLinker->append(linkedRoleAssertedLinker); |
| 1014 |
return true; |
| 1015 |
}); |
| 1016 |
} |
| 1017 |
|
| 1018 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference neighbourRoleSetLabelRef = getNeighbourRoleInstantiatedSetLabelAssociationBackendItem(nullptr, linkedRoleAssertedLinker, nominalConnectionData, calcAlgContext); |
| 1019 |
CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker* newRoleSetNeighbourUpdateLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryIndividualRoleSetNeighbourUpdateDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 1020 |
newRoleSetNeighbourUpdateLinker->initRoleSetNeighbourUpdateDataLinker(neighbourRoleSetLabelRef, neighbourIndiId); |
| 1021 |
roleSetNeighbourUpdateLinker = newRoleSetNeighbourUpdateLinker->append(roleSetNeighbourUpdateLinker); |
| 1022 |
|
| 1023 |
|
| 1024 |
if (neighbourRoleSetLabelRef.getReferredTemporaryLabelData() || !checkNeighbourRoleInstantiatedSetCompinationLabelContainsNeighbourRoleInstantiatedSet(existingNeighbourRoleInstantiatedSetCompinationLabel, neighbourRoleSetLabelRef, calcAlgContext)) { |
| 1025 |
if (!neigbourRoleInstantiatedSetCompination) { |
| 1026 |
neigbourRoleInstantiatedSetCompination = CObjectParameterizingAllocator< CPROCESSSET<CBackendRepresentativeMemoryCacheTemporaryLabelReference>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1027 |
} |
| 1028 |
neigbourRoleInstantiatedSetCompination->insert(neighbourRoleSetLabelRef); |
| 1029 |
} |
| 1030 |
|
| 1031 |
updated = true; |
| 1032 |
} |
| 1033 |
} |
| 1034 |
tmpAssWriteDataLinker->setRoleSetNeighbourUpdateDataLinker(roleSetNeighbourUpdateLinker); |
| 1035 |
|
| 1036 |
if (neigbourRoleInstantiatedSetCompination) { |
| 1037 |
if (indiAssData) { |
| 1038 |
mAssBackCacheReader->visitLabelsOfAssociatedNeigbourRoleSetCombinationLabel(indiAssData, existingNeighbourRoleInstantiatedSetCompinationLabel, [&](CBackendRepresentativeMemoryLabelCacheItem* label)->bool { |
| 1039 |
neigbourRoleInstantiatedSetCompination->insert(CBackendRepresentativeMemoryCacheTemporaryLabelReference(label)); |
| 1040 |
return true; |
| 1041 |
}); |
| 1042 |
} |
| 1043 |
updated |= determineNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(neigbourRoleInstantiatedSetCompination, tmpAssWriteDataLinker, calcAlgContext); |
| 1044 |
} |
| 1045 |
|
| 1046 |
return updated; |
| 1047 |
} |
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
bool CSaturationNodeBackendAssociationCacheHandler::determineNominalIndividualIdCombinedNeighbourRoleInstantiatedSetLabelAssociationBackendItem(cint64 nominalId, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnDataLinker, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 1059 |
|
| 1060 |
bool updateRequired = false; |
| 1061 |
bool updated = false; |
| 1062 |
|
| 1063 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = mAssBackCacheReader->getIndividualAssociationData(nominalId); |
| 1064 |
CBackendRepresentativeMemoryLabelCacheItem* existingDeterministicCombinedNeighbourRoleInstantiatedSetLabel = nullptr; |
| 1065 |
if (indiAssData) { |
| 1066 |
existingDeterministicCombinedNeighbourRoleInstantiatedSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL); |
| 1067 |
} |
| 1068 |
|
| 1069 |
for (CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnData = nominalConnDataLinker; !updateRequired && nominalConnData; nominalConnData = nominalConnData->getNext()) { |
| 1070 |
if (!mAssBackCacheReader->hasRoleInAssociatedNeigbourRoleSetLabel(indiAssData, existingDeterministicCombinedNeighbourRoleInstantiatedSetLabel, nominalConnData->getConnectionRole(), nominalConnData->isInversedConnection(), false, true, false)) { |
| 1071 |
updateRequired = true; |
| 1072 |
} |
| 1073 |
} |
| 1074 |
|
| 1075 |
|
| 1076 |
if (updateRequired) { |
| 1077 |
|
| 1078 |
CPROCESSSET<TRoleInversionPair>* combinedNeigbourRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1079 |
CSortedNegLinker<CRole*>* combinedNeigbourRoleInstantiatedLinker = nullptr; |
| 1080 |
|
| 1081 |
|
| 1082 |
if (existingDeterministicCombinedNeighbourRoleInstantiatedSetLabel) { |
| 1083 |
mAssBackCacheReader->visitRolesOfAssociatedNeigbourRoleSetLabel(indiAssData, existingDeterministicCombinedNeighbourRoleInstantiatedSetLabel, [&](CRole* role, bool inversed, bool aboxAsserted, bool nominalConnection, bool nondeterministic)->bool { |
| 1084 |
if (!combinedNeigbourRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) { |
| 1085 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 1086 |
combinedNeigbourRoleInstantiatedLinker = roleLinker->init(role, inversed, combinedNeigbourRoleInstantiatedLinker); |
| 1087 |
combinedNeigbourRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed)); |
| 1088 |
} |
| 1089 |
return true; |
| 1090 |
}); |
| 1091 |
} |
| 1092 |
|
| 1093 |
for (CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnData = nominalConnDataLinker; nominalConnData; nominalConnData = nominalConnData->getNext()) { |
| 1094 |
CRole* role = nominalConnData->getConnectionRole(); |
| 1095 |
bool inversed = nominalConnData->isInversedConnection(); |
| 1096 |
|
| 1097 |
if (!combinedNeigbourRoleInstantiatedSet->contains(TRoleInversionPair(role, inversed))) { |
| 1098 |
CSortedNegLinker<CRole*>* roleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 1099 |
combinedNeigbourRoleInstantiatedLinker = roleLinker->init(role, inversed, combinedNeigbourRoleInstantiatedLinker); |
| 1100 |
combinedNeigbourRoleInstantiatedSet->insert(TRoleInversionPair(role, inversed)); |
| 1101 |
} |
| 1102 |
} |
| 1103 |
|
| 1104 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, combinedNeigbourRoleInstantiatedLinker, combinedNeigbourRoleInstantiatedSet, true, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext); |
| 1105 |
tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_NEIGHBOUR_INSTANTIATED_ROLE_SET_LABEL, labelRef); |
| 1106 |
|
| 1107 |
if (mConfOccurrenceStatisticsCounting) { |
| 1108 |
CConcreteOntology* ontology = calcAlgContext->getProcessingDataBox()->getOntology(); |
| 1109 |
visitRolesOfAssociatedCompinationRoleSetLabel(labelRef, [&](CRole* role, bool inversed)->bool { |
| 1110 |
if (!inversed) { |
| 1111 |
mOccStatsCacheWriter->incRoleInstanceOccurrencceStatistics(ontology, role->getRoleTag(), 1, 0, 1, 0, 0, 0); |
| 1112 |
} |
| 1113 |
return true; |
| 1114 |
}, calcAlgContext); |
| 1115 |
} |
| 1116 |
|
| 1117 |
|
| 1118 |
updated = true; |
| 1119 |
} |
| 1120 |
return updated; |
| 1121 |
|
| 1122 |
} |
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
bool CSaturationNodeBackendAssociationCacheHandler::collectNominalRelatedRoles(cint64 satIndiId, cint64 nominalId, CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, |
| 1164 |
CRole* role, CCalculationAlgorithmContext* calcAlgContext) { |
| 1165 |
|
| 1166 |
bool collected = false; |
| 1167 |
// collect inversed since we are interested in the roles from the perspective of the nominal |
| 1168 |
if (roleSet && !(*roleSet)->contains(TRoleInversionPair(role, true))) { |
| 1169 |
(*roleSet)->insert(TRoleInversionPair(role, true)); |
| 1170 |
collected = true; |
| 1171 |
|
| 1172 |
CSortedNegLinker<CRole*>* newRoleLinker = CObjectAllocator< CSortedNegLinker<CRole*> >::allocateAndConstruct(calcAlgContext->getUsedTemporaryMemoryAllocationManager()); |
| 1173 |
*roleLinker = newRoleLinker->init(role, true, *roleLinker); |
| 1174 |
} |
| 1175 |
|
| 1176 |
return collected; |
| 1177 |
} |
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
bool CSaturationNodeBackendAssociationCacheHandler::collectNominalRelatedRoles(cint64 satIndiId, cint64 nominalId, CIndividualSaturationProcessNode* satNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 1182 |
|
| 1183 |
CReapplyConceptSaturationLabelSet* conSet = satNode->getReapplyConceptSaturationLabelSet(false); |
| 1184 |
if (!conSet) { |
| 1185 |
return false; |
| 1186 |
} |
| 1187 |
|
| 1188 |
CLinkedRoleSaturationSuccessorHash* linkedSuccHash = satNode->getLinkedRoleSuccessorHash(false); |
| 1189 |
|
| 1190 |
CIndividualSaturationProcessNode* copiedNode = satNode->getCopyIndividualNode(); |
| 1191 |
if (copiedNode && copiedNode->getReapplyConceptSaturationLabelSet(false) && copiedNode->getReapplyConceptSaturationLabelSet(false)->getConceptSaturationDescriptionLinker() == conSet->getConceptSaturationDescriptionLinker() && (!linkedSuccHash || copiedNode->getLinkedRoleSuccessorHash(false))) { |
| 1192 |
return collectNominalRelatedRoles(satIndiId, nominalId, copiedNode, roleSet, roleLinker, calcAlgContext); |
| 1193 |
} |
| 1194 |
|
| 1195 |
bool collected = false; |
| 1196 |
|
| 1197 |
CRole* topRole = calcAlgContext->getProcessingDataBox()->getOntology()->getRBox()->getTopObjectRole(); |
| 1198 |
if (linkedSuccHash) { |
| 1199 |
CPROCESSHASH<CRole*, CLinkedRoleSaturationSuccessorData*>* linkSuccDatahash = linkedSuccHash->getLinkedRoleSuccessorHash(); |
| 1200 |
for (CPROCESSHASH<CRole*, CLinkedRoleSaturationSuccessorData*>::const_iterator it = linkSuccDatahash->constBegin(), itEnd = linkSuccDatahash->constEnd(); it != itEnd; ++it) { |
| 1201 |
CRole* role = it.key(); |
| 1202 |
CLinkedRoleSaturationSuccessorData* linkSuccData = it.value(); |
| 1203 |
if (role != topRole && linkSuccData->mSuccCount > 0) { |
| 1204 |
CPROCESSMAP<cint64, CSaturationSuccessorData*>* succNodeMap = linkSuccData->getSuccessorNodeDataMap(false); |
| 1205 |
for (CPROCESSMAP<cint64, CSaturationSuccessorData*>::const_iterator succIt = succNodeMap->constBegin(), succItEnd = succNodeMap->constEnd(); succIt != succItEnd; ++succIt) { |
| 1206 |
CSaturationSuccessorData* succData = succIt.value(); |
| 1207 |
if (succData->mActiveCount > 0) { |
| 1208 |
CIndividualSaturationProcessNode* succSatNode = succData->mSuccIndiNode; |
| 1209 |
bool collectSuccessorNode = false; |
| 1210 |
if (succData->mVALUENominalConnection && succData->mVALUENominalID == nominalId) { |
| 1211 |
collectSuccessorNode = true; |
| 1212 |
} |
| 1213 |
|
| 1214 |
if (succSatNode && succSatNode->getIntegratedNominalIndividual() && succSatNode->getIntegratedNominalIndividual()->getIndividualID() == nominalId) { |
| 1215 |
collectSuccessorNode = true; |
| 1216 |
} |
| 1217 |
if (collectSuccessorNode) { |
| 1218 |
collected |= collectNominalRelatedRoles(satIndiId, nominalId, satNode, roleSet, roleLinker, role, calcAlgContext); |
| 1219 |
} |
| 1220 |
} |
| 1221 |
} |
| 1222 |
} |
| 1223 |
} |
| 1224 |
} else { |
| 1225 |
for (CConceptSaturationDescriptor* conSatDesIt = conSet->getConceptSaturationDescriptionLinker(); conSatDesIt; conSatDesIt = conSatDesIt->getNext()) { |
| 1226 |
CConcept* concept = conSatDesIt->getConcept(); |
| 1227 |
bool conNegation = conSatDesIt->isNegated(); |
| 1228 |
cint64 conCode = concept->getOperatorCode(); |
| 1229 |
CRole* role = concept->getRole(); |
| 1230 |
bool collectSuccessorNode = false; |
| 1231 |
bool existentialSuccessorCand = false; |
| 1232 |
if (!conNegation && (conCode == CCSOME || conCode == CCAQSOME) || conNegation && (conCode == CCALL)) { |
| 1233 |
existentialSuccessorCand = true; |
| 1234 |
} |
| 1235 |
if (!conNegation && conCode == CCATLEAST || conNegation && conCode == CCATMOST) { |
| 1236 |
existentialSuccessorCand = true; |
| 1237 |
} |
| 1238 |
if (!conNegation && conCode == CCVALUE) { |
| 1239 |
collectSuccessorNode = true; |
| 1240 |
} |
| 1241 |
if (role && existentialSuccessorCand) { |
| 1242 |
CIndividualSaturationProcessNode* succSatNode = getSuccessorSaturationNode(conSatDesIt, satNode, calcAlgContext); |
| 1243 |
if (succSatNode && succSatNode->getIntegratedNominalIndividual() && succSatNode->getIntegratedNominalIndividual()->getIndividualID() == nominalId) { |
| 1244 |
collectSuccessorNode = true; |
| 1245 |
} |
| 1246 |
} |
| 1247 |
if (role != topRole && collectSuccessorNode) { |
| 1248 |
collected |= collectNominalRelatedRoles(satIndiId, nominalId, satNode, roleSet, roleLinker, role, calcAlgContext); |
| 1249 |
} |
| 1250 |
} |
| 1251 |
} |
| 1252 |
|
| 1253 |
return collected; |
| 1254 |
} |
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
bool CSaturationNodeBackendAssociationCacheHandler::collectNominalRelatedRolesFromPredecessors(cint64 satIndiId, cint64 nominalId, CIndividualSaturationProcessNode* satIndiNode, CPROCESSSET<TRoleInversionPair>** roleSet, CSortedNegLinker<CRole*>** roleLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 1259 |
|
| 1260 |
bool collected = false; |
| 1261 |
CPROCESSSET< CIndividualSaturationProcessNode* >* handledSatNodeSet = CObjectParameterizingAllocator< CPROCESSSET< CIndividualSaturationProcessNode* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1262 |
CRoleBackwardSaturationPropagationHash* backwardPropHash = satIndiNode->getRoleBackwardPropagationHash(false); |
| 1263 |
if (backwardPropHash) { |
| 1264 |
CPROCESSHASH<CRole*, CRoleBackwardSaturationPropagationHashData>* backPropHash = backwardPropHash->getRoleBackwardPropagationDataHash(); |
| 1265 |
for (CPROCESSHASH<CRole*, CRoleBackwardSaturationPropagationHashData>::const_iterator it = backPropHash->constBegin(), itEnd = backPropHash->constEnd(); it != itEnd; ++it) { |
| 1266 |
const CRoleBackwardSaturationPropagationHashData& backwardPropData = it.value(); |
| 1267 |
for (CBackwardSaturationPropagationLink* linkIt = backwardPropData.mLinkLinker; linkIt; linkIt = linkIt->getNext()) { |
| 1268 |
CIndividualSaturationProcessNode* sourceIndividual = linkIt->getSourceIndividual(); |
| 1269 |
if (!handledSatNodeSet->contains(sourceIndividual)) { |
| 1270 |
handledSatNodeSet->insert(sourceIndividual); |
| 1271 |
collected |= collectNominalRelatedRoles(satIndiId, nominalId, sourceIndividual, roleSet, roleLinker, calcAlgContext); |
| 1272 |
} |
| 1273 |
} |
| 1274 |
} |
| 1275 |
} |
| 1276 |
|
| 1277 |
for (CXLinker<CIndividualSaturationProcessNode*>* nonInvConnIndiLinkerIt = satIndiNode->getNonInverseConnectedIndividualNodeLinker(); nonInvConnIndiLinkerIt; nonInvConnIndiLinkerIt = nonInvConnIndiLinkerIt->getNext()) { |
| 1278 |
CIndividualSaturationProcessNode* sourceIndividual = nonInvConnIndiLinkerIt->getData(); |
| 1279 |
if (!handledSatNodeSet->contains(sourceIndividual)) { |
| 1280 |
handledSatNodeSet->insert(sourceIndividual); |
| 1281 |
collected |= collectNominalRelatedRoles(satIndiId, nominalId, sourceIndividual, roleSet, roleLinker, calcAlgContext); |
| 1282 |
} |
| 1283 |
} |
| 1284 |
return collected; |
| 1285 |
} |
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
bool CSaturationNodeBackendAssociationCacheHandler::determineNominalIndividualIdPossiblyExistentialRoleInstantiatedSetLabelAssociationBackendItem(cint64 nominalId, CSaturationNominalDependentNodeData* nomDepNodeData, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker, CCalculationAlgorithmContext* calcAlgContext) { |
| 1291 |
bool updated = false; |
| 1292 |
|
| 1293 |
CPROCESSSET<TRoleInversionPair>* combinedNeigbourRoleInstantiatedSet = CObjectParameterizingAllocator< CPROCESSSET<TRoleInversionPair>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1294 |
CSortedNegLinker<CRole*>* combinedNeigbourRoleInstantiatedLinker = nullptr; |
| 1295 |
|
| 1296 |
for (CSaturationNominalDependentNodeData* nominalDepData = nomDepNodeData; nominalDepData; nominalDepData = nominalDepData->getNext()) { |
| 1297 |
|
| 1298 |
CIndividualSaturationProcessNode* depNode = nominalDepData->getDependentIndividualSaturationNode(); |
| 1299 |
if (nominalDepData->getNominalConnectionType() == CSaturationNominalDependentNodeData::VALUECONNECTION) { |
| 1300 |
collectNominalRelatedRoles(depNode->getIndividualID(), nominalId, depNode, &combinedNeigbourRoleInstantiatedSet, &combinedNeigbourRoleInstantiatedLinker, calcAlgContext); |
| 1301 |
} else if (nominalDepData->getNominalConnectionType() == CSaturationNominalDependentNodeData::NOMINALCONNECTION) { |
| 1302 |
collectNominalRelatedRolesFromPredecessors(depNode->getIndividualID(), nominalId, depNode, &combinedNeigbourRoleInstantiatedSet, &combinedNeigbourRoleInstantiatedLinker, calcAlgContext); |
| 1303 |
} |
| 1304 |
} |
| 1305 |
|
| 1306 |
if (combinedNeigbourRoleInstantiatedLinker) { |
| 1307 |
CBackendRepresentativeMemoryCacheTemporaryLabelReference labelRef = getRoleInstantiatedSetLabelAssociationBackendItem(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, combinedNeigbourRoleInstantiatedLinker, combinedNeigbourRoleInstantiatedSet, true, mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL], calcAlgContext); |
| 1308 |
tmpAssWriteDataLinker->setReferredLabel(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, labelRef); |
| 1309 |
updated = true; |
| 1310 |
|
| 1311 |
if (mConfOccurrenceStatisticsCounting) { |
| 1312 |
CConcreteOntology* ontology = calcAlgContext->getProcessingDataBox()->getOntology(); |
| 1313 |
visitRolesOfAssociatedCompinationRoleSetLabel(labelRef, [&](CRole* role, bool inversed)->bool { |
| 1314 |
if (!inversed) { |
| 1315 |
mOccStatsCacheWriter->incRoleInstanceOccurrencceStatistics(ontology, role->getRoleTag(), 0, 1, 1, 0, 0, 0); |
| 1316 |
} else if (role->getInverseRole()) { |
| 1317 |
mOccStatsCacheWriter->incRoleInstanceOccurrencceStatistics(ontology, role->getInverseRole()->getRoleTag(), 0, 1, 0, 1, 0, 0); |
| 1318 |
} |
| 1319 |
return true; |
| 1320 |
}, calcAlgContext); |
| 1321 |
} |
| 1322 |
|
| 1323 |
} |
| 1324 |
return updated; |
| 1325 |
|
| 1326 |
} |
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
bool CSaturationNodeBackendAssociationCacheHandler::tryAssociateNodesWithBackendCache(CIndividualSaturationProcessNodeLinker* indiSaturationAnalysingNodeLinker, CSatisfiableTaskRepresentativeBackendUpdatingAdapter* repbackUpdAdapter, CCalculationAlgorithmContext* calcAlgContext) { |
| 1364 |
calcAlgContext->mUsedTempMemMan = nullptr; |
| 1365 |
|
| 1366 |
mIndiNodeRefDetConceptSetLabelHash = CObjectParameterizingAllocator< CPROCESSHASH< CIndividualSaturationProcessNode*,QPair<CBackendRepresentativeMemoryLabelCacheItem*,CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*> >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(),calcAlgContext->getUsedTaskProcessorContext()); |
| 1367 |
mSignatureTmpRefDetConceptSetLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64,CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(),calcAlgContext->getUsedTaskProcessorContext()); |
| 1368 |
|
| 1369 |
mTmpConceptLabelTmpCardDataHash = CObjectParameterizingAllocator< CPROCESSHASH< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*, CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(),calcAlgContext->getUsedTaskProcessorContext()); |
| 1370 |
|
| 1371 |
mSignatureTmpRefNeigbourRoleInstantiatedSetCombinationLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1372 |
mRoleInversionTmpRefNeighbourInstantiatedRoleSetLabelHash = CObjectParameterizingAllocator< CPROCESSHASH< TRoleInversionPair, CBackendRepresentativeMemoryCacheTemporaryLabelReference* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1373 |
|
| 1374 |
mSuperRoleSignatureCacheValueTmpRefNeighbourInstantiatedRoleSetLabelPairHash = CObjectParameterizingAllocator< CPROCESSHASH< cint64, CCacheValueTmpLabelReferenceData* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1375 |
|
| 1376 |
for (cint64 i = 0; i < CBackendRepresentativeMemoryLabelCacheItem::LABEL_CACHE_ITEM_TYPE_COUNT; ++i) { |
| 1377 |
mRoleInversionSetTmpRefRoleInstantiatedSetLabelHashTypeArray[i] = CObjectParameterizingAllocator< CPROCESSHASH< CProcessSetHasher<TRoleInversionPair>, CBackendRepresentativeMemoryCacheTemporaryLabelReference* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1378 |
} |
| 1379 |
|
| 1380 |
mNominalIndiIdRoleConnectionDataHash = CObjectParameterizingAllocator< CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1381 |
|
| 1382 |
mNewTmpLabelList = CObjectParameterizingAllocator< CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1383 |
mNewTmpCardList = CObjectParameterizingAllocator< CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1384 |
|
| 1385 |
mSignatureTmpIndiConnIndiSetRefLabelHash = CObjectParameterizingAllocator< CPROCESSHASH<cint64, CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker*>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1386 |
CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* >* nominalIndirectConnectionUpdateDataLinkerHash = CObjectParameterizingAllocator< CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* >, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1387 |
|
| 1388 |
prepareCacheMessages(calcAlgContext); |
| 1389 |
|
| 1390 |
CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinker = nullptr; |
| 1391 |
CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* lastTmpAssWriteDataLinker = nullptr; |
| 1392 |
|
| 1393 |
|
| 1394 |
CBackendRepresentativeMemoryCacheTemporaryAssociationUseDataLinker* tmpAssUseDataLinker = nullptr; |
| 1395 |
CIndividualRepresentativeBackendCacheLoadedAssociationHash* indiLoadedAssocHash = calcAlgContext->getUsedProcessingDataBox()->getBackendCacheLoadedAssociationHash(true); |
| 1396 |
indiLoadedAssocHash->unshareAll(); |
| 1397 |
|
| 1398 |
CSaturationNominalDependentNodeHash* nominalDependentNodeHash = calcAlgContext->getUsedProcessingDataBox()->getSaturationNominalDependentNodeHash(false); |
| 1399 |
|
| 1400 |
for (CIndividualSaturationProcessNodeLinker* indiSaturationAnalysingNodeLinkerIt = indiSaturationAnalysingNodeLinker; indiSaturationAnalysingNodeLinkerIt; indiSaturationAnalysingNodeLinkerIt = indiSaturationAnalysingNodeLinkerIt->getNext()) { |
| 1401 |
CIndividualSaturationProcessNode* satNode = indiSaturationAnalysingNodeLinkerIt->getProcessingIndividual(); |
| 1402 |
CIndividual* nominalIndividual = satNode->getNominalIndividual(); |
| 1403 |
|
| 1404 |
if (nominalIndividual) { |
| 1405 |
|
| 1406 |
CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* newAssWriteDataLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 1407 |
if (!nominalIndividual->isTemporaryIndividual()) { |
| 1408 |
newAssWriteDataLinker->initAccociationWriteData(nominalIndividual, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::ADDITION, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::ADDITION); |
| 1409 |
} else { |
| 1410 |
newAssWriteDataLinker->initAccociationWriteData(nominalIndividual->getIndividualID(), CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::ADDITION, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::ADDITION); |
| 1411 |
} |
| 1412 |
|
| 1413 |
if (mConfOccurrenceStatisticsCounting) { |
| 1414 |
collectConceptOccurrenceStatistics(satNode, calcAlgContext); |
| 1415 |
} |
| 1416 |
determineFullConceptSetLabelAssociationBackendItem(satNode, CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL, newAssWriteDataLinker,calcAlgContext); |
| 1417 |
|
| 1418 |
CPROCESSSET<cint64>* existentialIndirectlyConnectedNominalIndividualSet = nullptr; |
| 1419 |
|
| 1420 |
CPROCESSHASH<CRole*, cint64>* roleUsedCardHash = nullptr; |
| 1421 |
if (satNode->getReapplyConceptSaturationLabelSet(false)->getConceptFlags()->containsATMOSTCardinalityFlags()) { |
| 1422 |
roleUsedCardHash = CObjectParameterizingAllocator< CPROCESSHASH<CRole*, cint64>, CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getUsedTemporaryMemoryAllocationManager(), calcAlgContext->getUsedTaskProcessorContext()); |
| 1423 |
} |
| 1424 |
|
| 1425 |
determineCombinedExistentialRoleInstantiatedSetLabelAssociationBackendItem(satNode, &existentialIndirectlyConnectedNominalIndividualSet, roleUsedCardHash, newAssWriteDataLinker, calcAlgContext); |
| 1426 |
determineCombinedDataRoleInstantiatedSetLabelAssociationBackendItem(satNode, newAssWriteDataLinker, calcAlgContext); |
| 1427 |
|
| 1428 |
if (roleUsedCardHash) { |
| 1429 |
determineCardinalityAssociationBackendItem(satNode, roleUsedCardHash, newAssWriteDataLinker, calcAlgContext); |
| 1430 |
} |
| 1431 |
|
| 1432 |
if (existentialIndirectlyConnectedNominalIndividualSet) { |
| 1433 |
determineIndirectlyConnectedNominalIndividualSetLabelAssociationBackendItem(existentialIndirectlyConnectedNominalIndividualSet, newAssWriteDataLinker, calcAlgContext); |
| 1434 |
|
| 1435 |
for (CPROCESSSET<cint64>::const_iterator it = existentialIndirectlyConnectedNominalIndividualSet->constBegin(), itEnd = existentialIndirectlyConnectedNominalIndividualSet->constEnd(); it != itEnd; ++it) { |
| 1436 |
cint64 nomIndiId = *it; |
| 1437 |
|
| 1438 |
//TODO: only add linker if the individual was not already connected to the nominal (based on the previous indirectly connected nominal individual set label) |
| 1439 |
CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker*& nomIndiConnDataLinker = (*nominalIndirectConnectionUpdateDataLinkerHash)[nomIndiId]; |
| 1440 |
if (!nomIndiConnDataLinker) { |
| 1441 |
nomIndiConnDataLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 1442 |
nomIndiConnDataLinker->initNominalIndirectConnectionData(nomIndiId); |
| 1443 |
if (indiLoadedAssocHash && indiLoadedAssocHash->contains(satNode->getIndividualID())) { |
| 1444 |
CIndividualRepresentativeBackendCacheLoadedAssociationData& assoLoadingData = (*indiLoadedAssocHash)[satNode->getIndividualID()]; |
| 1445 |
if (assoLoadingData.getLoadedIndividualAssociationData()) { |
| 1446 |
nomIndiConnDataLinker->setLastChangeIntegrationId(assoLoadingData.getLoadedIndividualAssociationData()->getLastIntegratedIndirectlyConnectedIndividualsChangeId()); |
| 1447 |
} |
| 1448 |
} |
| 1449 |
} |
| 1450 |
CXLinker<cint64>* indiIdLinker = CObjectAllocator< CXLinker<cint64> >::allocateAndConstruct(mMemAllocMan); |
| 1451 |
indiIdLinker->initLinker(nominalIndividual->getIndividualID()); |
| 1452 |
nomIndiConnDataLinker->addIndirectlyConnectedIndividualIdLinker(indiIdLinker); |
| 1453 |
} |
| 1454 |
} |
| 1455 |
|
| 1456 |
if (nominalDependentNodeHash && nominalDependentNodeHash->getNominalDependentNodeData(nominalIndividual->getIndividualID())) { |
| 1457 |
CSaturationNominalDependentNodeData* nomDepNodeData = nominalDependentNodeHash->getNominalDependentNodeData(nominalIndividual->getIndividualID()); |
| 1458 |
if (nomDepNodeData) { |
| 1459 |
// identify connections and save them as possibly/non-deterministic (existentially) instantiated roles |
| 1460 |
newAssWriteDataLinker->setIndirectlyConnectedNominalIndividual(true); |
| 1461 |
determineNominalIndividualIdPossiblyExistentialRoleInstantiatedSetLabelAssociationBackendItem(nominalIndividual->getIndividualID(), nomDepNodeData, newAssWriteDataLinker, calcAlgContext); |
| 1462 |
} |
| 1463 |
} |
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
collectSaturationNodeSuccessorRelatedRoles(satNode->getIndividualID(), satNode, nullptr, nullptr, false, true, false, true, true, mNominalIndiIdRoleConnectionDataHash, nullptr, nullptr, nullptr, calcAlgContext); |
| 1468 |
|
| 1469 |
CIndividualSaturationProcessNodeStatusFlags* indFlags = satNode->getIndirectStatusFlags(); |
| 1470 |
CIndividualSaturationProcessNodeStatusFlags* dirFlags = satNode->getDirectStatusFlags(); |
| 1471 |
bool insufficient = indFlags->hasInsufficientFlag() || !indFlags->hasCompletedFlag() || !dirFlags->hasCompletedFlag(); |
| 1472 |
if (insufficient) { |
| 1473 |
newAssWriteDataLinker->setCompletelySaturated(false); |
| 1474 |
newAssWriteDataLinker->setCompletelyHandled(false); |
| 1475 |
} |
| 1476 |
|
| 1477 |
newAssWriteDataLinker->setCompletelyPropagated(!dirFlags->hasPropagationIncompleteFlag()); |
| 1478 |
|
| 1479 |
|
| 1480 |
if (indiLoadedAssocHash && indiLoadedAssocHash->contains(satNode->getIndividualID())) { |
| 1481 |
CIndividualRepresentativeBackendCacheLoadedAssociationData& assoLoadingData = (*indiLoadedAssocHash)[satNode->getIndividualID()]; |
| 1482 |
assoLoadingData.setIndividualIntegrated(true); |
| 1483 |
} |
| 1484 |
|
| 1485 |
if (!lastTmpAssWriteDataLinker) { |
| 1486 |
tmpAssWriteDataLinker = newAssWriteDataLinker; |
| 1487 |
lastTmpAssWriteDataLinker = tmpAssWriteDataLinker; |
| 1488 |
} else { |
| 1489 |
lastTmpAssWriteDataLinker->setNext(newAssWriteDataLinker); |
| 1490 |
lastTmpAssWriteDataLinker = newAssWriteDataLinker; |
| 1491 |
} |
| 1492 |
} |
| 1493 |
} |
| 1494 |
|
| 1495 |
CIndividualSaturationProcessNodeLinker* nextIndiSaturationAnalysingNodeLinkerIt = indiSaturationAnalysingNodeLinker; |
| 1496 |
for (CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* newAssWriteDataLinker = tmpAssWriteDataLinker; newAssWriteDataLinker; newAssWriteDataLinker = newAssWriteDataLinker->getNext()) { |
| 1497 |
|
| 1498 |
CIndividual* nominalIndividual = nullptr; |
| 1499 |
CIndividualSaturationProcessNode* satNode = nullptr; |
| 1500 |
while (!nominalIndividual) { |
| 1501 |
satNode = nextIndiSaturationAnalysingNodeLinkerIt->getProcessingIndividual(); |
| 1502 |
nominalIndividual = satNode->getNominalIndividual(); |
| 1503 |
nextIndiSaturationAnalysingNodeLinkerIt = nextIndiSaturationAnalysingNodeLinkerIt->getNext(); |
| 1504 |
} |
| 1505 |
|
| 1506 |
determineSaturationNodeIndividualCombinedNeighbourRoleInstantiatedSetLabelAssociationBackendItem(satNode, newAssWriteDataLinker, calcAlgContext); |
| 1507 |
determineSaturationNodeIndividualNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(satNode, newAssWriteDataLinker, calcAlgContext); |
| 1508 |
} |
| 1509 |
|
| 1510 |
if (mNominalIndiIdRoleConnectionDataHash && !mNominalIndiIdRoleConnectionDataHash->isEmpty()) { |
| 1511 |
for (CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* >::const_iterator it = mNominalIndiIdRoleConnectionDataHash->constBegin(), itEnd = mNominalIndiIdRoleConnectionDataHash->constEnd(); it != itEnd; ++it) { |
| 1512 |
cint64 indiId = it.key(); |
| 1513 |
CBackendRepresentativeMemoryCacheTemporaryNominalRoleConnectionData* nominalConnectionData = it.value(); |
| 1514 |
|
| 1515 |
CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* newAssWriteDataLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 1516 |
newAssWriteDataLinker->initAccociationWriteData(indiId, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::ADDITION, CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker::ADDITION); |
| 1517 |
|
| 1518 |
determineNominalIndividualIdCombinedNeighbourRoleInstantiatedSetLabelAssociationBackendItem(indiId, nominalConnectionData, newAssWriteDataLinker, calcAlgContext); |
| 1519 |
determineNominalIndividualIdNeighbourRoleInstantiatedSetCompinationLabelAssociationBackendItem(indiId, nominalConnectionData, newAssWriteDataLinker, calcAlgContext); |
| 1520 |
|
| 1521 |
|
| 1522 |
if (indiLoadedAssocHash && indiLoadedAssocHash->contains(indiId)) { |
| 1523 |
CIndividualRepresentativeBackendCacheLoadedAssociationData& assoLoadingData = (*indiLoadedAssocHash)[indiId]; |
| 1524 |
assoLoadingData.setIndividualIntegrated(true); |
| 1525 |
} |
| 1526 |
|
| 1527 |
|
| 1528 |
if (!lastTmpAssWriteDataLinker) { |
| 1529 |
tmpAssWriteDataLinker = newAssWriteDataLinker; |
| 1530 |
lastTmpAssWriteDataLinker = tmpAssWriteDataLinker; |
| 1531 |
} else { |
| 1532 |
lastTmpAssWriteDataLinker->setNext(newAssWriteDataLinker); |
| 1533 |
lastTmpAssWriteDataLinker = newAssWriteDataLinker; |
| 1534 |
} |
| 1535 |
} |
| 1536 |
} |
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* tempNomIndirectConnDataLinker = nullptr; |
| 1543 |
CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* lastTempNomIndirectConnDataLinker = nullptr; |
| 1544 |
|
| 1545 |
for (CBackendRepresentativeMemoryCacheTemporaryAssociationWriteDataLinker* tmpAssWriteDataLinkerIt = tmpAssWriteDataLinker; tmpAssWriteDataLinkerIt; tmpAssWriteDataLinkerIt = tmpAssWriteDataLinkerIt->getNext()) { |
| 1546 |
cint64 indiId = tmpAssWriteDataLinkerIt->getData()->getIndividualID(); |
| 1547 |
CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* nomIndiConnDataLinker = nominalIndirectConnectionUpdateDataLinkerHash->value(indiId); |
| 1548 |
if (nomIndiConnDataLinker) { |
| 1549 |
tmpAssWriteDataLinkerIt->setIndirectlyConnectedNominalIndividual(true); |
| 1550 |
if (tempNomIndirectConnDataLinker) { |
| 1551 |
lastTempNomIndirectConnDataLinker->setNext(nomIndiConnDataLinker); |
| 1552 |
lastTempNomIndirectConnDataLinker = nomIndiConnDataLinker; |
| 1553 |
} else { |
| 1554 |
tempNomIndirectConnDataLinker = nomIndiConnDataLinker; |
| 1555 |
lastTempNomIndirectConnDataLinker = nomIndiConnDataLinker; |
| 1556 |
} |
| 1557 |
nominalIndirectConnectionUpdateDataLinkerHash->remove(indiId); |
| 1558 |
} |
| 1559 |
} |
| 1560 |
for (CPROCESSHASH< cint64, CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* >::const_iterator it = nominalIndirectConnectionUpdateDataLinkerHash->constBegin(), itEnd = nominalIndirectConnectionUpdateDataLinkerHash->constEnd(); it != itEnd; ++it) { |
| 1561 |
cint64 nomIndiId = it.key(); |
| 1562 |
CBackendRepresentativeMemoryCacheTemporaryNominalIndirectConnectionDataLinker* nomIndiConnDataLinker = it.value(); |
| 1563 |
if (nomIndiConnDataLinker) { |
| 1564 |
if (tempNomIndirectConnDataLinker) { |
| 1565 |
lastTempNomIndirectConnDataLinker->setNext(nomIndiConnDataLinker); |
| 1566 |
lastTempNomIndirectConnDataLinker = nomIndiConnDataLinker; |
| 1567 |
} else { |
| 1568 |
tempNomIndirectConnDataLinker = nomIndiConnDataLinker; |
| 1569 |
lastTempNomIndirectConnDataLinker = nomIndiConnDataLinker; |
| 1570 |
} |
| 1571 |
} |
| 1572 |
} |
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
if (indiLoadedAssocHash) { |
| 1578 |
for (CIndividualRepresentativeBackendCacheLoadedAssociationHash::const_iterator it = indiLoadedAssocHash->constBegin(), itEnd = indiLoadedAssocHash->constEnd(); it != itEnd; ++it) { |
| 1579 |
cint64 indiAssoId = it.key(); |
| 1580 |
CIndividualRepresentativeBackendCacheLoadedAssociationData indiAssoLoadingData = it.value(); |
| 1581 |
if (!indiAssoLoadingData.isIndividualIntegrated()) { |
| 1582 |
|
| 1583 |
CBackendRepresentativeMemoryCacheTemporaryAssociationUseDataLinker* newTmpAssUseDataLinker = CObjectAllocator< CBackendRepresentativeMemoryCacheTemporaryAssociationUseDataLinker >::allocateAndConstruct(mMemAllocMan); |
| 1584 |
newTmpAssUseDataLinker->initAccociationUseData(indiAssoId); |
| 1585 |
newTmpAssUseDataLinker->setUsedAssociationUpdateId(indiAssoLoadingData.getLoadedIndividualAssociationData()->getAssociationDataUpdateId()); |
| 1586 |
|
| 1587 |
tmpAssUseDataLinker = newTmpAssUseDataLinker->append(tmpAssUseDataLinker); |
| 1588 |
} |
| 1589 |
} |
| 1590 |
} |
| 1591 |
|
| 1592 |
|
| 1593 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* tempLabelWriteDataLinker = nullptr; |
| 1594 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* lastTempLabelWriteDataLinker = nullptr; |
| 1595 |
for (CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* >::const_iterator it = mNewTmpLabelList->constBegin(), itEnd = mNewTmpLabelList->constEnd(); it != itEnd; ++it) { |
| 1596 |
CBackendRepresentativeMemoryCacheTemporaryLabelWriteDataLinker* newTmpLabelLinker = (*it); |
| 1597 |
newTmpLabelLinker->clearNext(); |
| 1598 |
if (!lastTempLabelWriteDataLinker) { |
| 1599 |
tempLabelWriteDataLinker = newTmpLabelLinker; |
| 1600 |
lastTempLabelWriteDataLinker = tempLabelWriteDataLinker; |
| 1601 |
} else { |
| 1602 |
lastTempLabelWriteDataLinker->setNext(newTmpLabelLinker); |
| 1603 |
lastTempLabelWriteDataLinker = newTmpLabelLinker; |
| 1604 |
} |
| 1605 |
|
| 1606 |
} |
| 1607 |
CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* tempCardWriteDataLinker = nullptr; |
| 1608 |
for (CPROCESSLIST< CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* >::const_iterator it = mNewTmpCardList->constBegin(), itEnd = mNewTmpCardList->constEnd(); it != itEnd; ++it) { |
| 1609 |
CBackendRepresentativeMemoryCacheTemporaryCardinalityWriteDataLinker* newTmpCardLinker = (*it); |
| 1610 |
newTmpCardLinker->clearNext(); |
| 1611 |
tempCardWriteDataLinker = newTmpCardLinker->append(tempCardWriteDataLinker); |
| 1612 |
} |
| 1613 |
|
| 1614 |
cint64 ontologyIdentifier = calcAlgContext->getProcessingDataBox()->getOntology()->getOntologyID(); |
| 1615 |
cint64 repCompId = -1; |
| 1616 |
if (repbackUpdAdapter) { |
| 1617 |
repCompId = repbackUpdAdapter->getRepresentativeCacheRecomputationId(); |
| 1618 |
} |
| 1619 |
CBackendRepresentativeMemoryCacheLabelAssociationWriteData* writeData = CObjectAllocator< CBackendRepresentativeMemoryCacheLabelAssociationWriteData >::allocateAndConstruct(mMemAllocMan); |
| 1620 |
writeData->initWriteData(ontologyIdentifier, tmpAssWriteDataLinker, tempNomIndirectConnDataLinker, tmpAssUseDataLinker, tempLabelWriteDataLinker,tempCardWriteDataLinker, nullptr, nullptr, repCompId); |
| 1621 |
addCacheMessages(writeData,calcAlgContext); |
| 1622 |
commitCacheMessages(calcAlgContext); |
| 1623 |
|
| 1624 |
return false; |
| 1625 |
} |
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
}; // end namespace Algorithm |
| 1637 |
|
| 1638 |
}; // end namespace Kernel |
| 1639 |
|
| 1640 |
}; // end namespace Reasoner |
| 1641 |
|
| 1642 |
}; // end namespace Konclude |