| 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 "CSatisfiableTaskComplexAnsweringMessageAnalyser.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Algorithm { |
| 31 |
|
| 32 |
|
| 33 |
CSatisfiableTaskComplexAnsweringMessageAnalyser::CSatisfiableTaskComplexAnsweringMessageAnalyser() { |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
bool CSatisfiableTaskComplexAnsweringMessageAnalyser::readCalculationConfig(CCalculationConfigurationExtension *config) { |
| 39 |
if (config) { |
| 40 |
return true; |
| 41 |
} |
| 42 |
return false; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
CIndividualProcessNode* CSatisfiableTaskComplexAnsweringMessageAnalyser::getCorrectedIndividualID(CIndividualProcessNode* baseIndiNode, CIndividualProcessNodeVector* indiNodeVec, bool* nondetMergedFlag) { |
| 47 |
CIndividualProcessNode* indi = indiNodeVec->getData(baseIndiNode->getIndividualNodeID()); |
| 48 |
while (indi->hasMergedIntoIndividualNodeID()) { |
| 49 |
if (nondetMergedFlag && *nondetMergedFlag == false) { |
| 50 |
if (!indi->getMergedDependencyTrackPoint() || indi->getMergedDependencyTrackPoint()->getBranchingTag() > 0) { |
| 51 |
*nondetMergedFlag = true; |
| 52 |
} |
| 53 |
} |
| 54 |
indi = indiNodeVec->getData(indi->getMergedIntoIndividualNodeID()); |
| 55 |
} |
| 56 |
return indi; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
CAnsweringMessageData* CSatisfiableTaskComplexAnsweringMessageAnalyser::extractPossibleSubsumptionInformation(CConcept* testingConcept, bool testingConceptNegation, CIndividualProcessNode* indiNode, CReapplyConceptLabelSet* conSet, CCalculationAlgorithmContext* calcAlgContext) { |
| 62 |
STATINC(ANALYSEPOSSIBLESUBSUMPTIONSCOUNT,calcAlgContext); |
| 63 |
|
| 64 |
CAnsweringMessageData* messageDataLinker = nullptr; |
| 65 |
|
| 66 |
|
| 67 |
// initialize possible subsumption list |
| 68 |
CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CAnsweringMessageDataCalculationPossibleClassSubsumersData*>* possSubsumerList = nullptr; |
| 69 |
|
| 70 |
|
| 71 |
CReapplyConceptLabelSetIterator conSetIt = conSet->getConceptLabelSetIterator(true,true,false); |
| 72 |
|
| 73 |
// create new initialization list for possible subsumers |
| 74 |
while (conSetIt.hasNext()) { |
| 75 |
CConceptDescriptor* conDes = conSetIt.getConceptDescriptor(); |
| 76 |
CConcept* concept = conDes->getConcept(); |
| 77 |
bool negated = conDes->getNegation(); |
| 78 |
|
| 79 |
|
| 80 |
if (!negated && concept->hasClassName()) { |
| 81 |
if (!possSubsumerList) { |
| 82 |
possSubsumerList = CObjectParameterizingAllocator< CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CAnsweringMessageDataCalculationPossibleClassSubsumersData*>,CContext* >::allocateAndConstructAndParameterize(mTempMemAllocMan,mTmpContext); |
| 83 |
} |
| 84 |
CAnsweringMessageDataCalculationPossibleClassSubsumersData* possSubsumData = CObjectAllocator< CAnsweringMessageDataCalculationPossibleClassSubsumersData >::allocateAndConstruct(mTempMemAllocMan); |
| 85 |
possSubsumData->initClassificationPossibleSubsumptionData(concept); |
| 86 |
possSubsumerList->append(possSubsumData); |
| 87 |
} |
| 88 |
conSetIt.moveNext(); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
CAnsweringMessageDataCalculationPossibleClassSubsumers* possSubsumMessageData = CObjectAllocator<CAnsweringMessageDataCalculationPossibleClassSubsumers>::allocateAndConstruct(mTempMemAllocMan); |
| 94 |
possSubsumMessageData->initAnsweringPossibleSubsumptionMessageData(testingConcept,testingConceptNegation,possSubsumerList); |
| 95 |
messageDataLinker = possSubsumMessageData->append(messageDataLinker); |
| 96 |
return messageDataLinker; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
bool CSatisfiableTaskComplexAnsweringMessageAnalyser::analyseSatisfiableTask(CSatisfiableCalculationTask* statCalcTask, CCalculationAlgorithmContext* calcAlgContext) { |
| 102 |
bool analysed = false; |
| 103 |
mStatCalcTask = statCalcTask; |
| 104 |
analysed |= analyseSatisfiableTaskMaterialization(mStatCalcTask, calcAlgContext); |
| 105 |
analysed |= analyseSatisfiableTaskSubsumption(mStatCalcTask, calcAlgContext); |
| 106 |
analysed |= analyseSatisfiableTaskInstancePropagation(mStatCalcTask, calcAlgContext); |
| 107 |
return analysed; |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
bool CSatisfiableTaskComplexAnsweringMessageAnalyser::analyseSatisfiableTaskInstancePropagation(CSatisfiableCalculationTask* statCalcTask, CCalculationAlgorithmContext* calcAlgContext) { |
| 118 |
mStatCalcTask = statCalcTask; |
| 119 |
CSatisfiableTaskAnswererInstancePropagationMessageAdapter* answererInstancePropagationAdapter = statCalcTask->getSatisfiableAnswererInstancePropagationMessageAdapter(); |
| 120 |
if (answererInstancePropagationAdapter) { |
| 121 |
CAnsweringMessageDataObserver* conceptMessClassObserver = answererInstancePropagationAdapter->getAnswererMessageDataObserver(); |
| 122 |
CAnsweringMessageData* propagatedIndiMessageDataLinker = nullptr; |
| 123 |
CAnsweringMessageData* possiblePropagatedIndiMessageDataLinker = nullptr; |
| 124 |
|
| 125 |
|
| 126 |
CTaskProcessorContext* taskProcessorContext = calcAlgContext->getUsedTaskProcessorContext(); |
| 127 |
CTaskHandleMemoryAllocationManager* taskMemMan = calcAlgContext->getTemporaryMemoryAllocationManager(); |
| 128 |
CConcept* testingConcept = answererInstancePropagationAdapter->getTestingConcept(); |
| 129 |
bool candidatePropagation = answererInstancePropagationAdapter->isCandidatePropagation(); |
| 130 |
bool testingConceptNegation = answererInstancePropagationAdapter->getTestingConceptNegation(); |
| 131 |
|
| 132 |
//QString iriClassNameString = CIRIName::getRecentIRIName(testingConcept->getClassNameLinker()); |
| 133 |
//if (iriClassNameString == "http://www.owllink.org/testsuite/galen#LowerLobeOfLeftLung") { |
| 134 |
// bool bug = true; |
| 135 |
//} |
| 136 |
//} |
| 137 |
//considerOtherNode = false; |
| 138 |
|
| 139 |
CAnsweringHandler* answeringHandler = answererInstancePropagationAdapter->getAnsweringHandler(); |
| 140 |
CConcreteOntology* testOntology = answererInstancePropagationAdapter->getTestingOntology(); |
| 141 |
CProcessingDataBox* processingDataBox = statCalcTask->getProcessingDataBox(); |
| 142 |
CIndividualProcessNodeVector* indiNodeVec = processingDataBox->getIndividualProcessNodeVector(); |
| 143 |
|
| 144 |
cint64 maxDetBranchTag = processingDataBox->getMaximumDeterministicBranchTag(); |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
if (testOntology && testingConcept) { |
| 150 |
|
| 151 |
CMemoryPoolContainer memPoolCon; |
| 152 |
CTaskMemoryPoolAllocationManager classMessMemManCreaterMemMan(&memPoolCon, calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 153 |
mTempMemAllocMan = CObjectAllocator<CTaskMemoryPoolAllocationManager>::allocateAndConstruct(&classMessMemManCreaterMemMan); |
| 154 |
mTempMemAllocMan->initTaskMemoryPoolAllocationManager(&memPoolCon, calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 155 |
mTmpContext = CObjectParameterizingAllocator< CContextBase, CMemoryAllocationManager* >::allocateAndConstructAndParameterize(mTempMemAllocMan, mTempMemAllocMan); |
| 156 |
|
| 157 |
|
| 158 |
CProcessingDataBox* procDataBox = calcAlgContext->getProcessingDataBox(); |
| 159 |
CIndividualVector* indiVec = procDataBox->getIndividualVector(); |
| 160 |
CMarkerIndividualNodeHash* markerIndiNodeHash = procDataBox->getMarkerIndividualNodeHash(false); |
| 161 |
|
| 162 |
bool hasMarkedPropagatedConceptIndis = false; |
| 163 |
if (markerIndiNodeHash) { |
| 164 |
|
| 165 |
for (CPROCESSHASH< CConcept*, CMarkerIndividualNodeData >::const_iterator it = markerIndiNodeHash->constBegin(), itEnd = markerIndiNodeHash->constEnd(); it != itEnd; ++it) { |
| 166 |
CConcept* markerConcept = it.key(); |
| 167 |
CXLinker<CIndividualReference>* detIndiCandLinker = nullptr; |
| 168 |
CXLinker<CIndividualReference>* ndetIndiCandLinker = nullptr; |
| 169 |
CXNegLinker<CIndividualProcessNode*>* candIndiLinker = it.value().getMarkerIndividualNodeLinker(); |
| 170 |
CCLASSSUBSUMPTIONMESSAGELIST<CIndividualReference>* indiList = nullptr; |
| 171 |
CCLASSSUBSUMPTIONMESSAGELIST<CIndividualReference>* possIndiList = nullptr; |
| 172 |
|
| 173 |
for (CXNegLinker<CIndividualProcessNode*>* candIndiLinkerIt = candIndiLinker; candIndiLinkerIt; candIndiLinkerIt = candIndiLinkerIt->getNext()) { |
| 174 |
CIndividualProcessNode* indiNode = candIndiLinkerIt->getData(); |
| 175 |
CIndividual* candIndividual = indiNode->getNominalIndividual(); |
| 176 |
if (candIndividual) { |
| 177 |
|
| 178 |
hasMarkedPropagatedConceptIndis = true; |
| 179 |
|
| 180 |
bool nondeterministicallyAdded = candIndiLinkerIt->isNegated(); |
| 181 |
if (nondeterministicallyAdded || candidatePropagation) { |
| 182 |
addIndividualToReferenceList(possIndiList, candIndividual); |
| 183 |
} else { |
| 184 |
addIndividualToReferenceList(indiList, candIndividual); |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
CIndividualMergingHash* indiMergingHash = indiNode->getIndividualMergingHash(false); |
| 189 |
if (indiMergingHash) { |
| 190 |
|
| 191 |
for (CIndividualMergingHash::const_iterator indiIt = indiMergingHash->constBegin(), indiItEnd = indiMergingHash->constEnd(); indiIt != indiItEnd; ++indiIt) { |
| 192 |
cint64 indiIDIt = indiIt.key(); |
| 193 |
|
| 194 |
if (indiIt.value().isMergedWithIndividual()) { |
| 195 |
|
| 196 |
|
| 197 |
if (indiIDIt != candIndividual->getIndividualID()) { |
| 198 |
CIndividual* mergedIndividual = indiVec->getData(indiIDIt); |
| 199 |
|
| 200 |
CDependencyTrackPoint* mergeDepTrackPoint = indiIt.value().getDependencyTrackPoint(); |
| 201 |
bool nonDetMerged = true; |
| 202 |
if (mergeDepTrackPoint && mergeDepTrackPoint->getBranchingTag() <= maxDetBranchTag) { |
| 203 |
nonDetMerged = false; |
| 204 |
} |
| 205 |
|
| 206 |
if (nonDetMerged || candidatePropagation) { |
| 207 |
addIndividualToReferenceList(possIndiList, mergedIndividual); |
| 208 |
} else { |
| 209 |
addIndividualToReferenceList(indiList, mergedIndividual); |
| 210 |
} |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
|
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
if (possIndiList) { |
| 223 |
CAnsweringMessageDataInstancePossiblePropagationsData* possInstancePropMessageData = CObjectAllocator<CAnsweringMessageDataInstancePossiblePropagationsData>::allocateAndConstruct(mTempMemAllocMan); |
| 224 |
possInstancePropMessageData->initInstancePropagationsData(testingConcept, testingConceptNegation, markerConcept, possIndiList); |
| 225 |
possiblePropagatedIndiMessageDataLinker = possInstancePropMessageData->append(possiblePropagatedIndiMessageDataLinker); |
| 226 |
} |
| 227 |
|
| 228 |
if (indiList) { |
| 229 |
CAnsweringMessageDataInstanceCertainPropagationsData* certainInstancePropMessageData = CObjectAllocator<CAnsweringMessageDataInstanceCertainPropagationsData>::allocateAndConstruct(mTempMemAllocMan); |
| 230 |
certainInstancePropMessageData->initInstancePropagationsData(testingConcept, testingConceptNegation, markerConcept, indiList); |
| 231 |
propagatedIndiMessageDataLinker = certainInstancePropMessageData->append(propagatedIndiMessageDataLinker); |
| 232 |
} |
| 233 |
|
| 234 |
} |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
CAnsweringMessageData* messageDataLinker = possiblePropagatedIndiMessageDataLinker; |
| 242 |
if (propagatedIndiMessageDataLinker) { |
| 243 |
messageDataLinker = propagatedIndiMessageDataLinker->append(messageDataLinker); |
| 244 |
} |
| 245 |
|
| 246 |
if (messageDataLinker) { |
| 247 |
conceptMessClassObserver->sendMessage(answeringHandler, messageDataLinker, memPoolCon.takeMemoryPools()); |
| 248 |
} else { |
| 249 |
taskMemMan->releaseTemporaryMemoryPools(memPoolCon.takeMemoryPools()); |
| 250 |
} |
| 251 |
|
| 252 |
|
| 253 |
return true; |
| 254 |
|
| 255 |
} |
| 256 |
} |
| 257 |
return false; |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
bool CSatisfiableTaskComplexAnsweringMessageAnalyser::addIndividualToReferenceList(CCLASSSUBSUMPTIONMESSAGELIST<CIndividualReference>*& indiRefList, CIndividual* candIndividual) { |
| 268 |
if (!indiRefList) { |
| 269 |
indiRefList = CObjectParameterizingAllocator< CCLASSSUBSUMPTIONMESSAGELIST<CIndividualReference>, CContext* >::allocateAndConstructAndParameterize(mTempMemAllocMan, mTmpContext); |
| 270 |
} |
| 271 |
if (!candIndividual->isTemporaryIndividual()) { |
| 272 |
indiRefList->append(CIndividualReference(candIndividual)); |
| 273 |
} else { |
| 274 |
indiRefList->append(CIndividualReference(candIndividual->getIndividualID())); |
| 275 |
} |
| 276 |
return true; |
| 277 |
} |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
bool CSatisfiableTaskComplexAnsweringMessageAnalyser::analyseSatisfiableTaskSubsumption(CSatisfiableCalculationTask* statCalcTask, CCalculationAlgorithmContext* calcAlgContext) { |
| 286 |
mStatCalcTask = statCalcTask; |
| 287 |
CSatisfiableTaskAnswererSubsumptionMessageAdapter* answererConceptMarkedAdapter = statCalcTask->getSatisfiableAnswererSubsumptionMessageAdapter(); |
| 288 |
if (answererConceptMarkedAdapter) { |
| 289 |
CAnsweringMessageDataObserver* conceptMessClassObserver = answererConceptMarkedAdapter->getAnswererMessageDataObserver(); |
| 290 |
CAnsweringMessageData* subsumMessageDataLinker = nullptr; |
| 291 |
CAnsweringMessageData* possSubsumMessageDataLinker = nullptr; |
| 292 |
|
| 293 |
|
| 294 |
CTaskProcessorContext* taskProcessorContext = calcAlgContext->getUsedTaskProcessorContext(); |
| 295 |
CTaskHandleMemoryAllocationManager* taskMemMan = calcAlgContext->getTemporaryMemoryAllocationManager(); |
| 296 |
CConcept* testingConcept = answererConceptMarkedAdapter->getTestingConcept(); |
| 297 |
bool testingConceptNegation = answererConceptMarkedAdapter->getTestingConceptNegation(); |
| 298 |
CIndividualProcessNode* baseIndi = statCalcTask->getProcessingDataBox()->getConstructedIndividualNode(); |
| 299 |
|
| 300 |
//QString iriClassNameString = CIRIName::getRecentIRIName(testingConcept->getClassNameLinker()); |
| 301 |
//if (iriClassNameString == "http://www.owllink.org/testsuite/galen#LowerLobeOfLeftLung") { |
| 302 |
// bool bug = true; |
| 303 |
//} |
| 304 |
//} |
| 305 |
//considerOtherNode = false; |
| 306 |
|
| 307 |
CAnsweringHandler* answeringHandler = answererConceptMarkedAdapter->getAnsweringHandler(); |
| 308 |
CConcreteOntology* testOntology = answererConceptMarkedAdapter->getTestingOntology(); |
| 309 |
CProcessingDataBox* processingDataBox = statCalcTask->getProcessingDataBox(); |
| 310 |
CIndividualProcessNodeVector* indiNodeVec = processingDataBox->getIndividualProcessNodeVector(); |
| 311 |
|
| 312 |
cint64 maxDetBranchTag = processingDataBox->getMaximumDeterministicBranchTag(); |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
if (testOntology && testingConcept && baseIndi) { |
| 318 |
cint64 baseIndiID = baseIndi->getIndividualNodeID(); |
| 319 |
CIndividualProcessNode* baseIndiNode = indiNodeVec->getData(baseIndiID); |
| 320 |
bool nondetMerged = false; |
| 321 |
baseIndiNode = getCorrectedIndividualID(baseIndiNode,indiNodeVec,&nondetMerged); |
| 322 |
if (nondetMerged) { |
| 323 |
maxDetBranchTag = 0; |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
CMemoryPoolContainer memPoolCon; |
| 328 |
CTaskMemoryPoolAllocationManager classMessMemManCreaterMemMan(&memPoolCon,calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 329 |
mTempMemAllocMan = CObjectAllocator<CTaskMemoryPoolAllocationManager>::allocateAndConstruct(&classMessMemManCreaterMemMan); |
| 330 |
mTempMemAllocMan->initTaskMemoryPoolAllocationManager(&memPoolCon,calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 331 |
mTmpContext = CObjectParameterizingAllocator< CContextBase,CMemoryAllocationManager* >::allocateAndConstructAndParameterize(mTempMemAllocMan,mTempMemAllocMan); |
| 332 |
|
| 333 |
CCLASSSUBSUMPTIONMESSAGELIST<CConcept*>* subsumerList = nullptr; |
| 334 |
|
| 335 |
CReapplyConceptLabelSet* conSet = baseIndiNode->getReapplyConceptLabelSet(false); |
| 336 |
if (conSet) { |
| 337 |
CReapplyConceptLabelSetIterator conSetIt = conSet->getConceptLabelSetIterator(true,true,true); |
| 338 |
while (conSetIt.hasNext()) { |
| 339 |
CConceptDescriptor* conDes = conSetIt.getConceptDescriptor(); |
| 340 |
if (conDes) { |
| 341 |
CConcept* concept = conDes->getConcept(); |
| 342 |
bool negated = conDes->getNegation(); |
| 343 |
|
| 344 |
if (!negated && concept->hasClassName()) { |
| 345 |
CDependencyTrackPoint* depTrackPoint = conSetIt.getDependencyTrackPoint(); |
| 346 |
bool deterministic = false; |
| 347 |
if (depTrackPoint) { |
| 348 |
if (depTrackPoint->getBranchingTag() <= maxDetBranchTag) { |
| 349 |
deterministic = true; |
| 350 |
} |
| 351 |
} |
| 352 |
|
| 353 |
if (deterministic) { |
| 354 |
if (!subsumerList) { |
| 355 |
subsumerList = CObjectParameterizingAllocator< CCLASSSUBSUMPTIONMESSAGELIST<CConcept*>,CContext* >::allocateAndConstructAndParameterize(mTempMemAllocMan,mTmpContext); |
| 356 |
} |
| 357 |
subsumerList->append(concept); |
| 358 |
} |
| 359 |
} |
| 360 |
} |
| 361 |
conSetIt.moveNext(); |
| 362 |
} |
| 363 |
|
| 364 |
CAnsweringMessageData* messageData = extractPossibleSubsumptionInformation(testingConcept, testingConceptNegation,baseIndiNode,conSet,calcAlgContext); |
| 365 |
if (messageData) { |
| 366 |
possSubsumMessageDataLinker = messageData->append(possSubsumMessageDataLinker); |
| 367 |
} |
| 368 |
|
| 369 |
} |
| 370 |
|
| 371 |
CAnsweringMessageDataCalculationClassSubsumers* subsumMessageData = CObjectAllocator<CAnsweringMessageDataCalculationClassSubsumers>::allocateAndConstruct(mTempMemAllocMan); |
| 372 |
subsumMessageData->initAnsweringSubsumptionMessageData(testingConcept,testingConceptNegation,subsumerList); |
| 373 |
subsumMessageDataLinker = subsumMessageData->append(subsumMessageDataLinker); |
| 374 |
subsumerList = nullptr; |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
CAnsweringMessageData* messageDataLinker = possSubsumMessageDataLinker; |
| 381 |
if (subsumMessageDataLinker) { |
| 382 |
messageDataLinker = subsumMessageDataLinker->append(messageDataLinker); |
| 383 |
} |
| 384 |
|
| 385 |
if (messageDataLinker) { |
| 386 |
conceptMessClassObserver->sendMessage(answeringHandler,messageDataLinker,memPoolCon.takeMemoryPools()); |
| 387 |
} else { |
| 388 |
taskMemMan->releaseTemporaryMemoryPools(memPoolCon.takeMemoryPools()); |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
return true; |
| 394 |
|
| 395 |
} |
| 396 |
} |
| 397 |
return false; |
| 398 |
} |
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
bool CSatisfiableTaskComplexAnsweringMessageAnalyser::analyseSatisfiableTaskMaterialization(CSatisfiableCalculationTask* statCalcTask, CCalculationAlgorithmContext* calcAlgContext) { |
| 404 |
mStatCalcTask = statCalcTask; |
| 405 |
CSatisfiableTaskAnswererQueryingMaterializationAdapter* matAdapter = statCalcTask->getSatisfiableAnswererMaterializationAdapter(); |
| 406 |
if (matAdapter) { |
| 407 |
CAnsweringMessageDataObserver* conceptMessClassObserver = matAdapter->getAnswererMessageDataObserver(); |
| 408 |
CAnsweringMessageData* subsumMessageDataLinker = nullptr; |
| 409 |
|
| 410 |
|
| 411 |
CTaskProcessorContext* taskProcessorContext = calcAlgContext->getUsedTaskProcessorContext(); |
| 412 |
CTaskHandleMemoryAllocationManager* taskMemMan = calcAlgContext->getTemporaryMemoryAllocationManager(); |
| 413 |
QList<CIndividual*> varIndiList = matAdapter->getIndividualList(); |
| 414 |
|
| 415 |
|
| 416 |
CAnsweringHandler* answeringHandler = matAdapter->getAnsweringHandler(); |
| 417 |
CConcreteOntology* testOntology = matAdapter->getTestingOntology(); |
| 418 |
CProcessingDataBox* processingDataBox = statCalcTask->getProcessingDataBox(); |
| 419 |
CIndividualProcessNodeVector* indiNodeVec = processingDataBox->getIndividualProcessNodeVector(); |
| 420 |
|
| 421 |
cint64 maxDetBranchTag = processingDataBox->getMaximumDeterministicBranchTag(); |
| 422 |
|
| 423 |
cint64 matDataIdentifer = matAdapter->getMaterializationDataIdentifier(); |
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
if (testOntology && !varIndiList.isEmpty()) { |
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
CMemoryPoolContainer memPoolCon; |
| 432 |
CTaskMemoryPoolAllocationManager classMessMemManCreaterMemMan(&memPoolCon, calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 433 |
mTempMemAllocMan = CObjectAllocator<CTaskMemoryPoolAllocationManager>::allocateAndConstruct(&classMessMemManCreaterMemMan); |
| 434 |
mTempMemAllocMan->initTaskMemoryPoolAllocationManager(&memPoolCon, calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 435 |
mTmpContext = CObjectParameterizingAllocator< CContextBase, CMemoryAllocationManager* >::allocateAndConstructAndParameterize(mTempMemAllocMan, mTempMemAllocMan); |
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
for (CIndividual* varIndi : varIndiList) { |
| 440 |
|
| 441 |
cint64 baseIndiID = -varIndi->getIndividualID(); |
| 442 |
CIndividualProcessNode* baseIndiNode = indiNodeVec->getData(baseIndiID); |
| 443 |
bool nondetMerged = false; |
| 444 |
baseIndiNode = getCorrectedIndividualID(baseIndiNode, indiNodeVec, &nondetMerged); |
| 445 |
if (nondetMerged) { |
| 446 |
maxDetBranchTag = -1; |
| 447 |
} |
| 448 |
|
| 449 |
CCLASSSUBSUMPTIONMESSAGELIST<CConcept*>* subsumerList = nullptr; |
| 450 |
|
| 451 |
CReapplyConceptLabelSet* conSet = baseIndiNode->getReapplyConceptLabelSet(false); |
| 452 |
if (conSet) { |
| 453 |
CReapplyConceptLabelSetIterator conSetIt = conSet->getConceptLabelSetIterator(true, true, true); |
| 454 |
while (conSetIt.hasNext()) { |
| 455 |
CConceptDescriptor* conDes = conSetIt.getConceptDescriptor(); |
| 456 |
if (conDes) { |
| 457 |
CConcept* concept = conDes->getConcept(); |
| 458 |
bool negated = conDes->getNegation(); |
| 459 |
|
| 460 |
if (!negated && concept->hasClassName()) { |
| 461 |
CDependencyTrackPoint* depTrackPoint = conSetIt.getDependencyTrackPoint(); |
| 462 |
bool deterministic = false; |
| 463 |
if (depTrackPoint) { |
| 464 |
if (depTrackPoint->getBranchingTag() <= maxDetBranchTag) { |
| 465 |
deterministic = true; |
| 466 |
} |
| 467 |
} |
| 468 |
|
| 469 |
if (deterministic) { |
| 470 |
//if (concept->hasClassName() && CIRIName::getRecentIRIName(concept->getClassNameLinker()) == "http://krono.act.uji.es/people/Ernesto/qimage-ontology/OntologyQimage.owl#right_angle_point") { |
| 471 |
// bool debug = true; |
| 472 |
//} |
| 473 |
if (!subsumerList) { |
| 474 |
subsumerList = CObjectParameterizingAllocator< CCLASSSUBSUMPTIONMESSAGELIST<CConcept*>, CContext* >::allocateAndConstructAndParameterize(mTempMemAllocMan, mTmpContext); |
| 475 |
} |
| 476 |
subsumerList->append(concept); |
| 477 |
} |
| 478 |
} |
| 479 |
} |
| 480 |
conSetIt.moveNext(); |
| 481 |
} |
| 482 |
|
| 483 |
|
| 484 |
} |
| 485 |
|
| 486 |
CAnsweringMessageDataCalculationMaterializedConcepts* subsumMessageData = CObjectAllocator<CAnsweringMessageDataCalculationMaterializedConcepts>::allocateAndConstruct(mTempMemAllocMan); |
| 487 |
subsumMessageData->initMaterializedConceptsMessageData(varIndi, subsumerList, nullptr, matDataIdentifer); |
| 488 |
subsumMessageDataLinker = subsumMessageData->append(subsumMessageDataLinker); |
| 489 |
subsumerList = nullptr; |
| 490 |
|
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
CAnsweringMessageData* messageDataLinker = subsumMessageDataLinker; |
| 496 |
if (messageDataLinker) { |
| 497 |
conceptMessClassObserver->sendMessage(answeringHandler, messageDataLinker, memPoolCon.takeMemoryPools()); |
| 498 |
} else { |
| 499 |
taskMemMan->releaseTemporaryMemoryPools(memPoolCon.takeMemoryPools()); |
| 500 |
} |
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
return true; |
| 505 |
|
| 506 |
} |
| 507 |
} |
| 508 |
return false; |
| 509 |
} |
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
}; // end namespace Algorithm |
| 514 |
|
| 515 |
}; // end namespace Kernel |
| 516 |
|
| 517 |
}; // end namespace Reasoner |
| 518 |
|
| 519 |
}; // end namespace Konclude |