| 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 "CSatisfiableTaskClassificationMessageAnalyser.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Algorithm { |
| 31 |
|
| 32 |
|
| 33 |
CSatisfiableTaskClassificationMessageAnalyser::CSatisfiableTaskClassificationMessageAnalyser() { |
| 34 |
mConfAnalyseSubSumptions = true; |
| 35 |
mConfAnalyseAllSubSumptions = false; |
| 36 |
mConfAnalyseIdentifierOccurence = true; |
| 37 |
mConfAnalysePossibleSubSumptions = true; |
| 38 |
|
| 39 |
mMaxPossibleSubsumerNegationCheckingDepth = 5; |
| 40 |
mMaxModelAnalysingDepth = 20; |
| 41 |
|
| 42 |
mConfStopAnalyseWhenNotChanging = true; |
| 43 |
mEquivalentAlternativesSaturationMerging = true; |
| 44 |
|
| 45 |
mStatSuccessorModelMergingTestCount = 0; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
bool CSatisfiableTaskClassificationMessageAnalyser::readCalculationConfig(CCalculationConfigurationExtension *config) { |
| 51 |
mConfAnalyseSubSumptions = true; |
| 52 |
mConfAnalyseAllSubSumptions = false; |
| 53 |
mConfAnalyseIdentifierOccurence = true; |
| 54 |
mConfAnalysePossibleSubSumptions = true; |
| 55 |
mConfStopAnalyseWhenNotChanging = true; |
| 56 |
mEquivalentAlternativesSaturationMerging = true; |
| 57 |
if (config) { |
| 58 |
mEquivalentAlternativesSaturationMerging = config->isEquivalentAlternativesSaturationMergingActivated(); |
| 59 |
return true; |
| 60 |
} |
| 61 |
return false; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
CIndividualProcessNode* CSatisfiableTaskClassificationMessageAnalyser::getCorrectedIndividualID(CIndividualProcessNode* baseIndiNode, CIndividualProcessNodeVector* indiNodeVec, bool* nondetMergedFlag) { |
| 66 |
CIndividualProcessNode* indi = indiNodeVec->getData(baseIndiNode->getIndividualNodeID()); |
| 67 |
while (indi->hasMergedIntoIndividualNodeID()) { |
| 68 |
if (nondetMergedFlag && *nondetMergedFlag == false) { |
| 69 |
if (!indi->getMergedDependencyTrackPoint() || indi->getMergedDependencyTrackPoint()->getBranchingTag() > 0) { |
| 70 |
*nondetMergedFlag = true; |
| 71 |
} |
| 72 |
} |
| 73 |
indi = indiNodeVec->getData(indi->getMergedIntoIndividualNodeID()); |
| 74 |
} |
| 75 |
return indi; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
bool CSatisfiableTaskClassificationMessageAnalyser::hasDependencyToAncestor(CIndividualProcessNode* individualNode, CDependencyTrackPoint* depTrackPoint, CCalculationAlgorithmContext* calcAlgContext) { |
| 81 |
cint64 ancDepth = individualNode->getIndividualAncestorDepth(); |
| 82 |
bool dependencyToAncestor = false; |
| 83 |
if (ancDepth <= 0) { |
| 84 |
dependencyToAncestor = depTrackPoint->isPointingToIndependentDependencyNode(); |
| 85 |
} else { |
| 86 |
CDependencyNode* depNode = depTrackPoint->getDependencyNode(); |
| 87 |
if (depNode->hasAppropriateIndividualNode()) { |
| 88 |
CIndividualProcessNode* appIndiNode = depNode->getAppropriateIndividualNode(); |
| 89 |
cint64 appIndiAncDepth = appIndiNode->getIndividualAncestorDepth(); |
| 90 |
dependencyToAncestor = appIndiAncDepth < ancDepth; |
| 91 |
} else { |
| 92 |
CDependencyNode::DEPENDENCNODEYTYPE depType = depNode->getDependencyType(); |
| 93 |
if (depType == CDependencyNode::DNTMERGEDCONCEPT) { |
| 94 |
dependencyToAncestor = hasDependencyToAncestor(individualNode,depNode->getPreviousDependencyTrackPoint(),calcAlgContext); |
| 95 |
} |
| 96 |
} |
| 97 |
} |
| 98 |
return dependencyToAncestor; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
CConceptDescriptor* CSatisfiableTaskClassificationMessageAnalyser::getIndividualProcessNodeConceptWithSingleAncestorDependency(CIndividualProcessNode* indiNode, CIndividualAnalyseProcessItem* indiAnProcItem, CCalculationAlgorithmContext* calcAlgContext) { |
| 104 |
if (indiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFSUCCESSORNOMINALCONNECTION)) { |
| 105 |
return nullptr; |
| 106 |
} |
| 107 |
CConceptDescriptor* singleAncDepConceptDes = nullptr; |
| 108 |
CReapplyConceptLabelSet* conSet = indiNode->getReapplyConceptLabelSet(false); |
| 109 |
CConceptDescriptor* conDesIt = conSet->getAddingSortedConceptDescriptionLinker(); |
| 110 |
while (conDesIt) { |
| 111 |
CConceptDescriptor* conDes = conDesIt; |
| 112 |
if (conDes->getConceptTag() != 1) { |
| 113 |
CDependencyTrackPoint* depTrackPoint = conDes->getDependencyTrackPoint(); |
| 114 |
if (depTrackPoint) { |
| 115 |
if (hasDependencyToAncestor(indiNode,depTrackPoint,calcAlgContext)) { |
| 116 |
if (singleAncDepConceptDes != nullptr) { |
| 117 |
return nullptr; |
| 118 |
} |
| 119 |
singleAncDepConceptDes = conDes; |
| 120 |
} |
| 121 |
} else { |
| 122 |
return nullptr; |
| 123 |
} |
| 124 |
} |
| 125 |
conDesIt = conDesIt->getNext(); |
| 126 |
} |
| 127 |
return singleAncDepConceptDes; |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
bool CSatisfiableTaskClassificationMessageAnalyser::testSubsumerCandidatePossibleWithMergedSaturatedModel(CIndividualProcessNode* indiNode, CConcept* equivConcept, CCalculationAlgorithmContext* calcAlgContext) { |
| 133 |
CTaskProcessorContext* taskProcessorContext = calcAlgContext->getUsedTaskProcessorContext(); |
| 134 |
|
| 135 |
if (mEquivalentAlternativesSaturationMerging) { |
| 136 |
if (!mTestSaturatedMergedHash) { |
| 137 |
mTestSaturatedMergedHash = CObjectParameterizingAllocator< CPROCESSINGHASH< QPair<CConcept*,bool>,CSaturatedMergedTestItem >,CContext* >::allocateAndConstructAndParameterize(taskProcessorContext->getMemoryAllocationManager(),taskProcessorContext); |
| 138 |
} |
| 139 |
if (mLastMergingTestNode != indiNode) { |
| 140 |
mLastMergingTestNode = indiNode; |
| 141 |
mTestSaturatedMergedHash->clear(); |
| 142 |
} |
| 143 |
STATINC(ANALYSECANDIDATECONCEPTSATURATEDALTERNATIVETESTCOUNT,calcAlgContext); |
| 144 |
|
| 145 |
if (equivConcept->getOperatorCode() == CCEQ) { |
| 146 |
CPROCESSINGSET< QPair<CConcept*,bool> > alternativesSet(taskProcessorContext); |
| 147 |
bool oneMergeSatisfieableFlag = false; |
| 148 |
bool allMergeUnsatisfieableFlag = true; |
| 149 |
if (collectEquivalenceConceptAlternatives(indiNode,equivConcept,true,alternativesSet,mTestSaturatedMergedHash,oneMergeSatisfieableFlag,allMergeUnsatisfieableFlag,calcAlgContext)) { |
| 150 |
if (oneMergeSatisfieableFlag) { |
| 151 |
STATINC(ANALYSECANDIDATECONCEPTSATURATEDALTERNATIVEFOUNDCOUNT,calcAlgContext); |
| 152 |
return false; |
| 153 |
} |
| 154 |
} else { |
| 155 |
if (testEquivalenceConceptAlternatives(indiNode,alternativesSet,mTestSaturatedMergedHash,oneMergeSatisfieableFlag,allMergeUnsatisfieableFlag,calcAlgContext)) { |
| 156 |
if (oneMergeSatisfieableFlag) { |
| 157 |
STATINC(ANALYSECANDIDATECONCEPTSATURATEDALTERNATIVEFOUNDCOUNT,calcAlgContext); |
| 158 |
return false; |
| 159 |
} |
| 160 |
} |
| 161 |
} |
| 162 |
} |
| 163 |
} |
| 164 |
return true; |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
bool CSatisfiableTaskClassificationMessageAnalyser::testConceptSetWithSaturatedModelMergable(CIndividualProcessNode* indiNode, CIndividualSaturationProcessNode* saturationIndiNode, bool& mergeClashedFlag, CCalculationAlgorithmContext* calcAlgContext) { |
| 170 |
STATINC(ANALYSECANDIDATECONCEPTSATURATEDCONCEPTSETMERGINGCOUNT,calcAlgContext); |
| 171 |
CReapplyConceptSaturationLabelSet* saturatedConSet = saturationIndiNode->getReapplyConceptSaturationLabelSet(false); |
| 172 |
CReapplyConceptLabelSet* conSet = indiNode->getReapplyConceptLabelSet(false); |
| 173 |
|
| 174 |
bool mergedConceptsClashed = saturationIndiNode->getIndirectStatusFlags()->hasFlags(CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCLASHED,false); |
| 175 |
|
| 176 |
if (saturatedConSet && conSet) { |
| 177 |
CReapplyConceptSaturationLabelSetIterator satConSetIt(saturatedConSet->getIterator(true,true)); |
| 178 |
while (satConSetIt.hasNext() && !mergedConceptsClashed) { |
| 179 |
cint64 dataTag = satConSetIt.getDataTag(); |
| 180 |
CConceptSaturationDescriptor* satConDes = satConSetIt.getConceptSaturationDescriptor(); |
| 181 |
CImplicationReapplyConceptSaturationDescriptor* satReapplyDes = satConSetIt.getImplicationReapplyConceptSaturationDescriptor(); |
| 182 |
|
| 183 |
CConceptDescriptor* conDes = nullptr; |
| 184 |
CDependencyTrackPoint* depTrackPoint = nullptr; |
| 185 |
CCondensedReapplyQueue* reapplyQueue = nullptr; |
| 186 |
if (conSet->getConceptDescriptorOrReapplyQueue(dataTag,conDes,depTrackPoint,reapplyQueue)) { |
| 187 |
if (conDes && satConDes) { |
| 188 |
if (conDes->isNegated() != satConDes->isNegated()) { |
| 189 |
mergedConceptsClashed = true; |
| 190 |
} |
| 191 |
} else if (conDes) { |
| 192 |
if (!conDes->isNegated() && satReapplyDes) { |
| 193 |
return false; |
| 194 |
} |
| 195 |
} else if (satConDes) { |
| 196 |
if (!satConDes->isNegated() && reapplyQueue && !reapplyQueue->isEmpty()) { |
| 197 |
return false; |
| 198 |
} |
| 199 |
} |
| 200 |
} |
| 201 |
|
| 202 |
satConSetIt.moveNext(); |
| 203 |
} |
| 204 |
|
| 205 |
if (mergedConceptsClashed) { |
| 206 |
mergeClashedFlag = true; |
| 207 |
} |
| 208 |
return true; |
| 209 |
|
| 210 |
} |
| 211 |
return false; |
| 212 |
} |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
bool CSatisfiableTaskClassificationMessageAnalyser::testRoleSuccessorsWithSaturatedModelMergable(CIndividualProcessNode* indiNode, CIndividualSaturationProcessNode* saturationIndiNode, CCalculationAlgorithmContext* calcAlgContext) { |
| 217 |
STATINC(ANALYSECANDIDATECONCEPTSATURATEDROLESUCCESSORMERGINGCOUNT,calcAlgContext); |
| 218 |
CReapplyRoleSuccessorHash* roleSuccHash = indiNode->getReapplyRoleSuccessorHash(false); |
| 219 |
CReapplyConceptLabelSet* conSet = indiNode->getReapplyConceptLabelSet(false); |
| 220 |
CRoleBackwardSaturationPropagationHash* roleBackPropHash = saturationIndiNode->getRoleBackwardPropagationHash(false); |
| 221 |
if (roleSuccHash && roleBackPropHash) { |
| 222 |
CPROCESSHASH<CRole*,CRoleBackwardSaturationPropagationHashData>* roleBackPropDataHash = roleBackPropHash->getRoleBackwardPropagationDataHash(); |
| 223 |
for (CPROCESSHASH<CRole*,CRoleBackwardSaturationPropagationHashData>::const_iterator it = roleBackPropDataHash->constBegin(), itEnd = roleBackPropDataHash->constEnd(); it != itEnd; ++it) { |
| 224 |
CRole* role = it.key(); |
| 225 |
const CRoleBackwardSaturationPropagationHashData& backPropData = it.value(); |
| 226 |
CBackwardSaturationPropagationReapplyDescriptor* reapplyLinker = backPropData.mReapplyLinker; |
| 227 |
if (reapplyLinker) { |
| 228 |
CRoleSuccessorLinkIterator roleSuccIt(roleSuccHash->getRoleSuccessorLinkIterator(role)); |
| 229 |
if (roleSuccIt.hasNext()) { |
| 230 |
for (CBackwardSaturationPropagationReapplyDescriptor* reapplyLinkerIt = reapplyLinker; reapplyLinkerIt; reapplyLinkerIt = reapplyLinkerIt->getNext()) { |
| 231 |
CConceptSaturationDescriptor* conSatDes = reapplyLinkerIt->getReapplyConceptSaturationDescriptor(); |
| 232 |
CConcept* concept = conSatDes->getConcept(); |
| 233 |
bool negation = conSatDes->isNegated(); |
| 234 |
if (!conSet || !conSet->containsConcept(concept,negation)) { |
| 235 |
|
| 236 |
CRoleSuccessorLinkIterator roleSucc2It(roleSuccIt); |
| 237 |
while (roleSucc2It.hasNext()) { |
| 238 |
CIndividualLinkEdge* succLink = roleSucc2It.next(true); |
| 239 |
CIndividualProcessNode* succIndi = nullptr; |
| 240 |
if (succLink->isLocalizationTagUpToDate(calcAlgContext->getUsedProcessTagger()->getCurrentLocalizationTag())) { |
| 241 |
succIndi = succLink->getOppositeIndividual(indiNode); |
| 242 |
} else { |
| 243 |
if (!succIndi->isLocalizationTagUpToDate(calcAlgContext->getUsedProcessTagger()->getCurrentLocalizationTag()) && succIndi->isRelocalized()) { |
| 244 |
cint64 succIndiId = succLink->getOppositeIndividualID(indiNode); |
| 245 |
CIndividualProcessNodeVector* indiProcNodeVec = calcAlgContext->getProcessingDataBox()->getIndividualProcessNodeVector(); |
| 246 |
succIndi = indiProcNodeVec->getData(succIndiId); |
| 247 |
} |
| 248 |
} |
| 249 |
CReapplyConceptLabelSet* succConSet = succIndi->getReapplyConceptLabelSet(false); |
| 250 |
for (CSortedNegLinker<CConcept*>* opConIt = concept->getOperandList(); opConIt; opConIt = opConIt->getNext()) { |
| 251 |
CConcept* opConcept = opConIt->getData(); |
| 252 |
bool opNegation = conSatDes->isNegated()^negation; |
| 253 |
|
| 254 |
if (!succConSet || !succConSet->containsConcept(opConcept,opNegation)) { |
| 255 |
return false; |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 259 |
|
| 260 |
} |
| 261 |
} |
| 262 |
} |
| 263 |
//if (roleSuccHash->hasRoleSuccessor(role)) { |
| 264 |
// return false; |
| 265 |
//} |
| 266 |
} |
| 267 |
} |
| 268 |
} |
| 269 |
return true; |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
bool CSatisfiableTaskClassificationMessageAnalyser::collectSuccessorMergingNodesAndConcepts(CIndividualProcessNode* indiNode, CIndividualSaturationProcessNode* saturationIndiNode, CReapplyRoleSuccessorHash* roleSuccHash, CRole* role, |
| 276 |
CPROCESSINGLIST<CIndividualSaturationProcessNode*>& successorList, CPROCESSINGLIST<TConceptNegationPair>& trivialSuccessorPropagatedConceptList, CPROCESSINGSET<CRole*>& backwardRoleSet, CCalculationAlgorithmContext* calcAlgContext) { |
| 277 |
|
| 278 |
for (CSortedNegLinker<CRole*>* superRoleIt = role->getIndirectSuperRoleList(); superRoleIt; superRoleIt = superRoleIt->getNext()) { |
| 279 |
CRole* superRole = superRoleIt->getData(); |
| 280 |
bool superRoleInversed = superRoleIt->isNegated(); |
| 281 |
if (roleSuccHash && !superRoleInversed) { |
| 282 |
CReapplyQueueIterator reapplyIt(roleSuccHash->getRoleReapplyIterator(superRole,false)); |
| 283 |
while (reapplyIt.hasNext()) { |
| 284 |
CReapplyConceptDescriptor* reapplyConDes = reapplyIt.next(); |
| 285 |
CConceptDescriptor* conDes = reapplyConDes->getConceptDescriptor(); |
| 286 |
CConcept* reapplyConcept = conDes->getConcept(); |
| 287 |
bool reapplyConceptNegation = conDes->isNegated(); |
| 288 |
cint64 reapplyConceptOpCode = reapplyConcept->getOperatorCode(); |
| 289 |
if (reapplyConceptNegation && (reapplyConceptOpCode == CCSOME) || !reapplyConceptNegation && (reapplyConceptOpCode == CCALL || reapplyConceptOpCode == CCIMPLALL || reapplyConceptOpCode == CCBRANCHALL || reapplyConceptOpCode == CCAQALL || reapplyConceptOpCode == CCIMPLAQALL || reapplyConceptOpCode == CCBRANCHAQALL)) { |
| 290 |
for (CSortedNegLinker<CConcept*>* reapplyOperandConLinkerIt = reapplyConcept->getOperandList(); reapplyOperandConLinkerIt; reapplyOperandConLinkerIt = reapplyOperandConLinkerIt->getNext()) { |
| 291 |
CConcept* reapplyOperandCon = reapplyOperandConLinkerIt->getData(); |
| 292 |
bool reapplyOperandConNeg = reapplyOperandConLinkerIt->isNegated()^reapplyConceptNegation; |
| 293 |
|
| 294 |
CIndividualSaturationProcessNode* satIndiNode = getSaturatedIndividualNodeForConcept(reapplyOperandCon,reapplyOperandConNeg,calcAlgContext); |
| 295 |
if (!satIndiNode) { |
| 296 |
if (!collectTrivialPropagationTestingConcepts(reapplyOperandCon,reapplyOperandConNeg,trivialSuccessorPropagatedConceptList,calcAlgContext)) { |
| 297 |
return false; |
| 298 |
} |
| 299 |
} else if (!satIndiNode->isCompleted() || satIndiNode->getIndirectStatusFlags()->hasFlags(CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCARDINALITYPROPLEMATIC | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGINSUFFICIENT | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCLASHED | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGNOMINALCONNECTION,false)) { |
| 300 |
return false; |
| 301 |
} |
| 302 |
|
| 303 |
if (satIndiNode) { |
| 304 |
successorList.append(satIndiNode); |
| 305 |
} |
| 306 |
} |
| 307 |
} else if (!reapplyConceptNegation && (reapplyConceptOpCode == CCAQAND || reapplyConceptOpCode == CCIMPLAQAND || reapplyConceptOpCode == CCBRANCHAQAND)) { |
| 308 |
if (!addAutomateTransactionConcepts(reapplyConcept,reapplyConceptNegation,superRole,successorList,trivialSuccessorPropagatedConceptList,calcAlgContext)) { |
| 309 |
return false; |
| 310 |
} |
| 311 |
} else { |
| 312 |
return false; |
| 313 |
} |
| 314 |
} |
| 315 |
} else { |
| 316 |
backwardRoleSet.insert(superRole); |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
return true; |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
bool CSatisfiableTaskClassificationMessageAnalyser::testSaturatedExistentialsModelMergable(CIndividualProcessNode* indiNode, CIndividualSaturationProcessNode* saturationIndiNode, CCalculationAlgorithmContext* calcAlgContext) { |
| 326 |
STATINC(ANALYSECANDIDATECONCEPTSATURATEDROLESUCCESSOREXTENDEDMERGINGCOUNT,calcAlgContext); |
| 327 |
CTaskProcessorContext* taskProcessorContext = calcAlgContext->getUsedTaskProcessorContext(); |
| 328 |
|
| 329 |
cint64 remainingMergingDepth = 5; |
| 330 |
cint64 remainingMergingCount = 100; |
| 331 |
|
| 332 |
CReapplyRoleSuccessorHash* roleSuccHash = indiNode->getReapplyRoleSuccessorHash(false); |
| 333 |
|
| 334 |
|
| 335 |
if (saturationIndiNode->getDirectStatusFlags()->hasSuccessorNodeExtensionsFlag()) { |
| 336 |
CLinkedRoleSaturationSuccessorHash* linkedSuccHash = saturationIndiNode->getLinkedRoleSuccessorHash(false); |
| 337 |
if (linkedSuccHash) { |
| 338 |
CPROCESSHASH<CRole*,CLinkedRoleSaturationSuccessorData*>* roleLinkedSuccHash = linkedSuccHash->getLinkedRoleSuccessorHash(); |
| 339 |
for (CPROCESSHASH<CRole*,CLinkedRoleSaturationSuccessorData*>::const_iterator itSucc = roleLinkedSuccHash->constBegin(), itEndSucc = roleLinkedSuccHash->constEnd(); itSucc != itEndSucc; ++itSucc) { |
| 340 |
CRole* role = itSucc.key(); |
| 341 |
CLinkedRoleSaturationSuccessorData* linkedSuccData = itSucc.value(); |
| 342 |
CPROCESSMAP<cint64,CSaturationSuccessorData*>* succDataMap = linkedSuccData->getSuccessorNodeDataMap(false); |
| 343 |
if (succDataMap) { |
| 344 |
for (CPROCESSMAP<cint64,CSaturationSuccessorData*>::const_iterator it = succDataMap->constBegin(), itEnd = succDataMap->constEnd(); it != itEnd; ++it) { |
| 345 |
CSaturationSuccessorData* succData = it.value(); |
| 346 |
if (succData->mActiveCount >= 1) { |
| 347 |
for (CXNegLinker<CRole*>* creationRoleLinkerIt = succData->mCreationRoleLinker; creationRoleLinkerIt; creationRoleLinkerIt = creationRoleLinkerIt->getNext()) { |
| 348 |
if (!creationRoleLinkerIt->isNegated()) { |
| 349 |
CRole* creationRole = creationRoleLinkerIt->getData(); |
| 350 |
if (creationRole == role) { |
| 351 |
|
| 352 |
CPROCESSINGLIST<CIndividualSaturationProcessNode*> successorList(taskProcessorContext); |
| 353 |
CPROCESSINGLIST<TConceptNegationPair> trivialSuccessorPropagatedConceptList(taskProcessorContext); |
| 354 |
CPROCESSINGSET<CRole*> backwardRoleSet(taskProcessorContext); |
| 355 |
|
| 356 |
if (!collectSuccessorMergingNodesAndConcepts(indiNode,saturationIndiNode,roleSuccHash,role,successorList,trivialSuccessorPropagatedConceptList,backwardRoleSet,calcAlgContext)) { |
| 357 |
return false; |
| 358 |
} |
| 359 |
|
| 360 |
if (!successorList.isEmpty() || !trivialSuccessorPropagatedConceptList.isEmpty()) { |
| 361 |
CIndividualSaturationProcessNode* extSatIndiNode = succData->mSuccIndiNode; |
| 362 |
successorList.prepend(extSatIndiNode); |
| 363 |
|
| 364 |
if (!testSaturatedSuccessorModelMergable(extSatIndiNode,successorList,&trivialSuccessorPropagatedConceptList,backwardRoleSet,remainingMergingDepth,remainingMergingCount,calcAlgContext)) { |
| 365 |
return false; |
| 366 |
} |
| 367 |
} |
| 368 |
|
| 369 |
} |
| 370 |
} |
| 371 |
} |
| 372 |
} |
| 373 |
} |
| 374 |
} |
| 375 |
} |
| 376 |
} |
| 377 |
} else { |
| 378 |
CReapplyConceptSaturationLabelSet* saturatedConSet = saturationIndiNode->getReapplyConceptSaturationLabelSet(false); |
| 379 |
for (CConceptSaturationDescriptor* conSatDesIt = saturatedConSet->getConceptSaturationDescriptionLinker(); conSatDesIt; conSatDesIt = conSatDesIt->getNext()) { |
| 380 |
CConceptSaturationDescriptor* conSatDes = conSatDesIt; |
| 381 |
CConcept* concept = conSatDes->getConcept(); |
| 382 |
bool negated = conSatDes->isNegated(); |
| 383 |
cint64 opCode = concept->getOperatorCode(); |
| 384 |
cint64 card = concept->getParameter(); |
| 385 |
if (!negated && (opCode == CCSOME || opCode == CCAQSOME || opCode == CCATLEAST && card > 0) || negated && (opCode == CCALL || opCode == CCATMOST && card >= 0)) { |
| 386 |
|
| 387 |
CPROCESSINGLIST<CIndividualSaturationProcessNode*> successorList(taskProcessorContext); |
| 388 |
CPROCESSINGLIST<TConceptNegationPair> trivialSuccessorPropagatedConceptList(taskProcessorContext); |
| 389 |
CPROCESSINGSET<CRole*> backwardRoleSet(taskProcessorContext); |
| 390 |
|
| 391 |
CRole* role = concept->getRole(); |
| 392 |
if (!collectSuccessorMergingNodesAndConcepts(indiNode,saturationIndiNode,roleSuccHash,role,successorList,trivialSuccessorPropagatedConceptList,backwardRoleSet,calcAlgContext)) { |
| 393 |
return false; |
| 394 |
} |
| 395 |
|
| 396 |
if (!successorList.isEmpty() || !trivialSuccessorPropagatedConceptList.isEmpty()) { |
| 397 |
CIndividualSaturationProcessNode* extSatIndiNode = getExistentialSaturatedIndividualNodeForConcept(concept,calcAlgContext); |
| 398 |
if (!extSatIndiNode) { |
| 399 |
return false; |
| 400 |
} |
| 401 |
successorList.prepend(extSatIndiNode); |
| 402 |
|
| 403 |
if (!testSaturatedSuccessorModelMergable(extSatIndiNode,successorList,&trivialSuccessorPropagatedConceptList,backwardRoleSet,remainingMergingDepth,remainingMergingCount,calcAlgContext)) { |
| 404 |
return false; |
| 405 |
} |
| 406 |
} |
| 407 |
|
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
return true; |
| 412 |
} |
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
bool CSatisfiableTaskClassificationMessageAnalyser::collectTrivialPropagationTestingConcepts(CConcept* concept, bool negation, CPROCESSINGLIST<TConceptNegationPair>& trivialConceptTestingList, CCalculationAlgorithmContext* calcAlgContext) { |
| 417 |
CConceptOperator* conOperator = concept->getConceptOperator(); |
| 418 |
cint64 conOpCode = concept->getOperatorCode(); |
| 419 |
if (negation && conOpCode == CCSUB) { |
| 420 |
trivialConceptTestingList.append(TConceptNegationPair(concept,negation)); |
| 421 |
return true; |
| 422 |
} else if (!negation && (conOpCode == CCALL || conOpCode == CCIMPLALL || conOpCode == CCBRANCHALL || conOpCode == CCAQALL || conOpCode == CCIMPLAQALL || conOpCode == CCBRANCHAQALL)) { |
| 423 |
trivialConceptTestingList.append(TConceptNegationPair(concept,negation)); |
| 424 |
return true; |
| 425 |
} else if (!negation && (conOpCode == CCAQAND || conOpCode == CCIMPLAQAND || conOpCode == CCBRANCHAQAND)) { |
| 426 |
bool allOperandsSucceeded = true; |
| 427 |
for (CSortedNegLinker<CConcept*>* operandConLinkerIt = concept->getOperandList(); operandConLinkerIt; operandConLinkerIt = operandConLinkerIt->getNext()) { |
| 428 |
CConcept* operandCon = operandConLinkerIt->getData(); |
| 429 |
bool operandConNeg = operandConLinkerIt->isNegated(); |
| 430 |
allOperandsSucceeded &= collectTrivialPropagationTestingConcepts(operandCon,operandConNeg,trivialConceptTestingList,calcAlgContext); |
| 431 |
} |
| 432 |
return allOperandsSucceeded; |
| 433 |
} |
| 434 |
return false; |
| 435 |
} |
| 436 |
|
| 437 |
|
| 438 |
bool CSatisfiableTaskClassificationMessageAnalyser::addAutomateTransactionConcepts(CConcept* concept, bool negation, CRole* role, CPROCESSINGLIST<CIndividualSaturationProcessNode*>& successorList, CPROCESSINGLIST<TConceptNegationPair>& trivialConceptTestingList, CCalculationAlgorithmContext* calcAlgContext) { |
| 439 |
cint64 conOpCode = concept->getOperatorCode(); |
| 440 |
if (!negation && (conOpCode == CCAQALL || conOpCode == CCIMPLAQALL || conOpCode == CCBRANCHAQALL)) { |
| 441 |
|
| 442 |
if (concept->getRole() == role) { |
| 443 |
|
| 444 |
for (CSortedNegLinker<CConcept*>* operandConLinkerIt = concept->getOperandList(); operandConLinkerIt; operandConLinkerIt = operandConLinkerIt->getNext()) { |
| 445 |
CConcept* reapplyOperandCon = operandConLinkerIt->getData(); |
| 446 |
bool reapplyOperandConNeg = operandConLinkerIt->isNegated(); |
| 447 |
|
| 448 |
CIndividualSaturationProcessNode* satIndiNode = getSaturatedIndividualNodeForConcept(reapplyOperandCon,reapplyOperandConNeg,calcAlgContext); |
| 449 |
if (!satIndiNode) { |
| 450 |
if (!collectTrivialPropagationTestingConcepts(reapplyOperandCon,reapplyOperandConNeg,trivialConceptTestingList,calcAlgContext)) { |
| 451 |
return false; |
| 452 |
} |
| 453 |
} else if (!satIndiNode->isCompleted() || satIndiNode->getIndirectStatusFlags()->hasFlags(CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCARDINALITYPROPLEMATIC | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGINSUFFICIENT | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCLASHED | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGNOMINALCONNECTION,false)) { |
| 454 |
return false; |
| 455 |
} |
| 456 |
|
| 457 |
if (satIndiNode) { |
| 458 |
successorList.append(satIndiNode); |
| 459 |
} |
| 460 |
} |
| 461 |
} |
| 462 |
} else if (!negation && (conOpCode == CCAQAND || conOpCode == CCIMPLAQAND || conOpCode == CCBRANCHAQAND)) { |
| 463 |
bool allOperandsSucceeded = true; |
| 464 |
for (CSortedNegLinker<CConcept*>* operandConLinkerIt = concept->getOperandList(); operandConLinkerIt; operandConLinkerIt = operandConLinkerIt->getNext()) { |
| 465 |
CConcept* reapplyOperandCon = operandConLinkerIt->getData(); |
| 466 |
bool reapplyOperandConNeg = operandConLinkerIt->isNegated(); |
| 467 |
allOperandsSucceeded &= addAutomateTransactionConcepts(reapplyOperandCon,reapplyOperandConNeg,role,successorList,trivialConceptTestingList,calcAlgContext); |
| 468 |
} |
| 469 |
return allOperandsSucceeded; |
| 470 |
} |
| 471 |
return true; |
| 472 |
} |
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
bool CSatisfiableTaskClassificationMessageAnalyser::testSaturatedSuccessorModelMergable(CIndividualSaturationProcessNode* existentialIndiNode, CPROCESSINGLIST<CIndividualSaturationProcessNode*>& successorList, CPROCESSINGLIST<TConceptNegationPair>* trivialSuccessorPropagatedConceptList, CPROCESSINGSET<CRole*>& backwardRoleSet, cint64 remainingMergingDepth, cint64& remainingMergingCount, CCalculationAlgorithmContext* calcAlgContext) { |
| 477 |
++mStatSuccessorModelMergingTestCount; |
| 478 |
|
| 479 |
if (--remainingMergingDepth < 0) { |
| 480 |
return false; |
| 481 |
} |
| 482 |
if (--remainingMergingCount < 0) { |
| 483 |
return false; |
| 484 |
} |
| 485 |
|
| 486 |
if (successorList.count() == 1) { |
| 487 |
return testSingleSaturatedSuccessorModelMergable(existentialIndiNode,successorList,trivialSuccessorPropagatedConceptList,backwardRoleSet,remainingMergingDepth,remainingMergingCount,calcAlgContext); |
| 488 |
} else { |
| 489 |
return testMultipleSaturatedSuccessorModelMergable(existentialIndiNode,successorList,trivialSuccessorPropagatedConceptList,backwardRoleSet,remainingMergingDepth,remainingMergingCount,calcAlgContext); |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
bool CSatisfiableTaskClassificationMessageAnalyser::testSingleSaturatedSuccessorModelMergable(CIndividualSaturationProcessNode* existentialIndiNode, CPROCESSINGLIST<CIndividualSaturationProcessNode*>& successorList, CPROCESSINGLIST<TConceptNegationPair>* trivialSuccessorPropagatedConceptList, CPROCESSINGSET<CRole*>& backwardRoleSet, cint64 remainingMergingDepth, cint64& remainingMergingCount, CCalculationAlgorithmContext* calcAlgContext) { |
| 496 |
|
| 497 |
CTaskProcessorContext* taskProcessorContext = calcAlgContext->getUsedTaskProcessorContext(); |
| 498 |
|
| 499 |
CIndividualSaturationProcessNode* subResolvedExistentialIndiNode = existentialIndiNode; |
| 500 |
while (subResolvedExistentialIndiNode->hasSubstituteIndividualNode()) { |
| 501 |
subResolvedExistentialIndiNode = subResolvedExistentialIndiNode->getSubstituteIndividualNode(); |
| 502 |
} |
| 503 |
CReapplyConceptSaturationLabelSet* satConSet = subResolvedExistentialIndiNode->getReapplyConceptSaturationLabelSet(false); |
| 504 |
CPROCESSINGHASH<CRole*,TConceptNegationPair> successorInfluenceConceptsHash(taskProcessorContext); |
| 505 |
if (trivialSuccessorPropagatedConceptList) { |
| 506 |
for (CPROCESSINGLIST<TConceptNegationPair>::const_iterator trivConIt = trivialSuccessorPropagatedConceptList->constBegin(), trivConItEnd = trivialSuccessorPropagatedConceptList->constEnd(); trivConIt != trivConItEnd; ++trivConIt) { |
| 507 |
TConceptNegationPair conNegPair(*trivConIt); |
| 508 |
CConcept* concept = conNegPair.first; |
| 509 |
bool negation = conNegPair.second; |
| 510 |
cint64 conOpCode = concept->getOperatorCode(); |
| 511 |
|
| 512 |
if (negation && conOpCode == CCSUB) { |
| 513 |
CConceptSaturationDescriptor* conSatDes = nullptr; |
| 514 |
CImplicationReapplyConceptSaturationDescriptor* impConSatDes = nullptr; |
| 515 |
if (satConSet->getConceptSaturationDescriptor(concept,conSatDes,impConSatDes)) { |
| 516 |
if (conSatDes && conSatDes->isNegated() != negation) { |
| 517 |
return false; |
| 518 |
} |
| 519 |
if (!conSatDes && impConSatDes) { |
| 520 |
return false; |
| 521 |
} |
| 522 |
} else { |
| 523 |
CIndividualSaturationProcessNode* tmpSubExistentialIndiNode = existentialIndiNode; |
| 524 |
while (tmpSubExistentialIndiNode->hasSubstituteIndividualNode()) { |
| 525 |
CSaturationConceptDataItem* conceptSatItem = (CSaturationConceptDataItem*)tmpSubExistentialIndiNode->getSaturationConceptReferenceLinking(); |
| 526 |
CConcept* satConcept = conceptSatItem->getSaturationConcept(); |
| 527 |
bool satNegation = conceptSatItem->getSaturationNegation(); |
| 528 |
if (satConcept == concept && negation != satNegation) { |
| 529 |
return false; |
| 530 |
} |
| 531 |
tmpSubExistentialIndiNode = tmpSubExistentialIndiNode->getSubstituteIndividualNode(); |
| 532 |
} |
| 533 |
|
| 534 |
} |
| 535 |
|
| 536 |
} else if (!negation && (conOpCode == CCALL || conOpCode == CCIMPLALL || conOpCode == CCBRANCHALL || conOpCode == CCAQALL || conOpCode == CCIMPLAQALL || conOpCode == CCBRANCHAQALL)) { |
| 537 |
CRole* role = concept->getRole(); |
| 538 |
if (backwardRoleSet.contains(role)) { |
| 539 |
return false; |
| 540 |
} |
| 541 |
for (CSortedNegLinker<CConcept*>* operandConLinkerIt = concept->getOperandList(); operandConLinkerIt; operandConLinkerIt = operandConLinkerIt->getNext()) { |
| 542 |
CConcept* operandCon = operandConLinkerIt->getData(); |
| 543 |
bool operandConNeg = operandConLinkerIt->isNegated()^negation; |
| 544 |
successorInfluenceConceptsHash.insertMulti(role,TConceptNegationPair(operandCon,operandConNeg)); |
| 545 |
} |
| 546 |
} |
| 547 |
} |
| 548 |
} |
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
if (!existentialIndiNode->getDirectStatusFlags()->hasSuccessorNodeExtensionsFlag()) { |
| 553 |
|
| 554 |
for (CConceptSaturationDescriptor* conSatDesIt = satConSet->getConceptSaturationDescriptionLinker(); conSatDesIt; conSatDesIt = conSatDesIt->getNext()) { |
| 555 |
CConcept* concept = conSatDesIt->getConcept(); |
| 556 |
bool negated = conSatDesIt->isNegated(); |
| 557 |
|
| 558 |
cint64 opCode = concept->getOperatorCode(); |
| 559 |
//if (!negated && (opCode == CCSOME || opCode == CCAQSOME) || negated && (opCode == CCALL)) { |
| 560 |
cint64 card = concept->getParameter(); |
| 561 |
if (!negated && (opCode == CCSOME || opCode == CCAQSOME || opCode == CCATLEAST && card > 0) || negated && (opCode == CCALL || opCode == CCATMOST && card >= 0)) { |
| 562 |
|
| 563 |
CPROCESSINGLIST<CIndividualSaturationProcessNode*> nextSuccessorList(taskProcessorContext); |
| 564 |
CPROCESSINGLIST<TConceptNegationPair> nextTrivialSuccessorPropagatedConceptList(taskProcessorContext); |
| 565 |
CPROCESSINGSET<CRole*> nextBackwardRoleSet(taskProcessorContext); |
| 566 |
|
| 567 |
CRole* role = concept->getRole(); |
| 568 |
|
| 569 |
if (!collectSuccessorMergingNodesAndConcepts(existentialIndiNode,role,successorList,*trivialSuccessorPropagatedConceptList,backwardRoleSet,nextSuccessorList,nextTrivialSuccessorPropagatedConceptList,nextBackwardRoleSet,successorInfluenceConceptsHash,calcAlgContext)) { |
| 570 |
return false; |
| 571 |
} |
| 572 |
|
| 573 |
|
| 574 |
if (!nextSuccessorList.isEmpty() || !trivialSuccessorPropagatedConceptList->isEmpty()) { |
| 575 |
CIndividualSaturationProcessNode* extSatIndiNode = getExistentialSaturatedIndividualNodeForConcept(concept,calcAlgContext); |
| 576 |
nextSuccessorList.prepend(extSatIndiNode); |
| 577 |
|
| 578 |
if (!testSaturatedSuccessorModelMergable(extSatIndiNode,nextSuccessorList,&nextTrivialSuccessorPropagatedConceptList,nextBackwardRoleSet,remainingMergingDepth,remainingMergingCount,calcAlgContext)) { |
| 579 |
return false; |
| 580 |
} |
| 581 |
} |
| 582 |
|
| 583 |
} |
| 584 |
} |
| 585 |
} else { |
| 586 |
|
| 587 |
CLinkedRoleSaturationSuccessorHash* linkedSuccHash = existentialIndiNode->getLinkedRoleSuccessorHash(false); |
| 588 |
if (linkedSuccHash) { |
| 589 |
CPROCESSHASH<CRole*,CLinkedRoleSaturationSuccessorData*>* roleLinkedSuccHash = linkedSuccHash->getLinkedRoleSuccessorHash(); |
| 590 |
for (CPROCESSHASH<CRole*,CLinkedRoleSaturationSuccessorData*>::const_iterator itSucc = roleLinkedSuccHash->constBegin(), itEndSucc = roleLinkedSuccHash->constEnd(); itSucc != itEndSucc; ++itSucc) { |
| 591 |
CRole* role = itSucc.key(); |
| 592 |
CLinkedRoleSaturationSuccessorData* linkedSuccData = itSucc.value(); |
| 593 |
CPROCESSMAP<cint64,CSaturationSuccessorData*>* succDataMap = linkedSuccData->getSuccessorNodeDataMap(false); |
| 594 |
if (succDataMap) { |
| 595 |
for (CPROCESSMAP<cint64,CSaturationSuccessorData*>::const_iterator it = succDataMap->constBegin(), itEnd = succDataMap->constEnd(); it != itEnd; ++it) { |
| 596 |
CSaturationSuccessorData* succData = it.value(); |
| 597 |
if (succData->mActiveCount >= 1) { |
| 598 |
for (CXNegLinker<CRole*>* creationRoleLinkerIt = succData->mCreationRoleLinker; creationRoleLinkerIt; creationRoleLinkerIt = creationRoleLinkerIt->getNext()) { |
| 599 |
if (!creationRoleLinkerIt->isNegated()) { |
| 600 |
CRole* creationRole = creationRoleLinkerIt->getData(); |
| 601 |
if (creationRole == role) { |
| 602 |
|
| 603 |
CPROCESSINGLIST<CIndividualSaturationProcessNode*> nextSuccessorList(taskProcessorContext); |
| 604 |
CPROCESSINGLIST<TConceptNegationPair> nextTrivialSuccessorPropagatedConceptList(taskProcessorContext); |
| 605 |
CPROCESSINGSET<CRole*> nextBackwardRoleSet(taskProcessorContext); |
| 606 |
|
| 607 |
if (!collectSuccessorMergingNodesAndConcepts(existentialIndiNode,role,successorList,*trivialSuccessorPropagatedConceptList,backwardRoleSet,nextSuccessorList,nextTrivialSuccessorPropagatedConceptList,nextBackwardRoleSet,successorInfluenceConceptsHash,calcAlgContext)) { |
| 608 |
return false; |
| 609 |
} |
| 610 |
|
| 611 |
if (!nextSuccessorList.isEmpty() || !trivialSuccessorPropagatedConceptList->isEmpty()) { |
| 612 |
CIndividualSaturationProcessNode* extSatIndiNode = succData->mSuccIndiNode; |
| 613 |
nextSuccessorList.prepend(extSatIndiNode); |
| 614 |
|
| 615 |
if (!testSaturatedSuccessorModelMergable(extSatIndiNode,nextSuccessorList,&nextTrivialSuccessorPropagatedConceptList,nextBackwardRoleSet,remainingMergingDepth,remainingMergingCount,calcAlgContext)) { |
| 616 |
return false; |
| 617 |
} |
| 618 |
} |
| 619 |
|
| 620 |
} |
| 621 |
} |
| 622 |
} |
| 623 |
} |
| 624 |
} |
| 625 |
} |
| 626 |
} |
| 627 |
} |
| 628 |
} |
| 629 |
|
| 630 |
return true; |
| 631 |
} |
| 632 |
|
| 633 |
bool CSatisfiableTaskClassificationMessageAnalyser::testMultipleSaturatedSuccessorModelMergable(CIndividualSaturationProcessNode* existentialIndiNode, CPROCESSINGLIST<CIndividualSaturationProcessNode*>& successorList, CPROCESSINGLIST<TConceptNegationPair>* trivialSuccessorPropagatedConceptList, CPROCESSINGSET<CRole*>& backwardRoleSet, cint64 remainingMergingDepth, cint64& remainingMergingCount, CCalculationAlgorithmContext* calcAlgContext) { |
| 634 |
|
| 635 |
CTaskProcessorContext* taskProcessorContext = calcAlgContext->getUsedTaskProcessorContext(); |
| 636 |
// check for problematic forall concepts |
| 637 |
for (CPROCESSINGLIST<CIndividualSaturationProcessNode*>::const_iterator succIt = successorList.constBegin(), succItEnd = successorList.constEnd(); succIt != succItEnd; ++succIt) { |
| 638 |
CIndividualSaturationProcessNode* succIndiNode(*succIt); |
| 639 |
if (succIndiNode != existentialIndiNode) { |
| 640 |
while (succIndiNode->hasSubstituteIndividualNode()) { |
| 641 |
succIndiNode = succIndiNode->getSubstituteIndividualNode(); |
| 642 |
} |
| 643 |
CRoleBackwardSaturationPropagationHash* roleBackwardPropHash = succIndiNode->getRoleBackwardPropagationHash(false); |
| 644 |
if (roleBackwardPropHash) { |
| 645 |
CPROCESSHASH<CRole*,CRoleBackwardSaturationPropagationHashData>* roleBackwardPropDataHash = roleBackwardPropHash->getRoleBackwardPropagationDataHash(); |
| 646 |
for (CPROCESSINGSET<CRole*>::const_iterator it = backwardRoleSet.constBegin(), itEnd = backwardRoleSet.constEnd(); it != itEnd; ++it) { |
| 647 |
CRole* backwardRole(*it); |
| 648 |
const CRoleBackwardSaturationPropagationHashData& roleBackwardRoleData = roleBackwardPropDataHash->value(backwardRole); |
| 649 |
if (roleBackwardRoleData.mLinkLinker) { |
| 650 |
return false; |
| 651 |
} |
| 652 |
} |
| 653 |
} |
| 654 |
} |
| 655 |
} |
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
CPROCESSINGHASH<cint64,CConceptNegationTriggerItem> conceptNegationTriggerHash(taskProcessorContext); |
| 660 |
CPROCESSINGHASH<CRole*,TConceptNegationPair> successorInfluenceConceptsHash(taskProcessorContext); |
| 661 |
if (trivialSuccessorPropagatedConceptList) { |
| 662 |
for (CPROCESSINGLIST<TConceptNegationPair>::const_iterator trivConIt = trivialSuccessorPropagatedConceptList->constBegin(), trivConItEnd = trivialSuccessorPropagatedConceptList->constEnd(); trivConIt != trivConItEnd; ++trivConIt) { |
| 663 |
TConceptNegationPair conNegPair(*trivConIt); |
| 664 |
CConcept* concept = conNegPair.first; |
| 665 |
bool negation = conNegPair.second; |
| 666 |
cint64 conOpCode = concept->getOperatorCode(); |
| 667 |
|
| 668 |
if (negation && conOpCode == CCSUB) { |
| 669 |
CConceptNegationTriggerItem& conNegTriggerItem = conceptNegationTriggerHash[concept->getConceptTag()]; |
| 670 |
if (conNegTriggerItem.mTriggerFlag) { |
| 671 |
return false; |
| 672 |
} |
| 673 |
if (conNegTriggerItem.mConcept && conNegTriggerItem.mNegationFlag != negation) { |
| 674 |
return false; |
| 675 |
} |
| 676 |
conNegTriggerItem.mNegationFlag = negation; |
| 677 |
conNegTriggerItem.mConcept = concept; |
| 678 |
} else if (!negation && (conOpCode == CCALL || conOpCode == CCIMPLALL || conOpCode == CCBRANCHALL || conOpCode == CCAQALL || conOpCode == CCIMPLAQALL || conOpCode == CCBRANCHAQALL)) { |
| 679 |
CRole* role = concept->getRole(); |
| 680 |
if (backwardRoleSet.contains(role)) { |
| 681 |
return false; |
| 682 |
} |
| 683 |
for (CSortedNegLinker<CConcept*>* operandConLinkerIt = concept->getOperandList(); operandConLinkerIt; operandConLinkerIt = operandConLinkerIt->getNext()) { |
| 684 |
CConcept* operandCon = operandConLinkerIt->getData(); |
| 685 |
bool operandConNeg = operandConLinkerIt->isNegated()^negation; |
| 686 |
successorInfluenceConceptsHash.insertMulti(role,TConceptNegationPair(operandCon,operandConNeg)); |
| 687 |
} |
| 688 |
} |
| 689 |
} |
| 690 |
} |
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
for (CPROCESSINGLIST<CIndividualSaturationProcessNode*>::const_iterator succIt = successorList.constBegin(), succItEnd = successorList.constEnd(); succIt != succItEnd; ++succIt) { |
| 695 |
CIndividualSaturationProcessNode* succIndiNode(*succIt); |
| 696 |
|
| 697 |
while (succIndiNode->hasSubstituteIndividualNode()) { |
| 698 |
CSaturationConceptDataItem* conceptSatItem = (CSaturationConceptDataItem*)succIndiNode->getSaturationConceptReferenceLinking(); |
| 699 |
CConcept* satConcept = conceptSatItem->getSaturationConcept(); |
| 700 |
bool satNegation = conceptSatItem->getSaturationNegation(); |
| 701 |
CConceptNegationTriggerItem& conNegTriggerItem = conceptNegationTriggerHash[satConcept->getConceptTag()]; |
| 702 |
if (conNegTriggerItem.mTriggerFlag) { |
| 703 |
return false; |
| 704 |
} |
| 705 |
if (conNegTriggerItem.mConcept && conNegTriggerItem.mNegationFlag != satNegation) { |
| 706 |
return false; |
| 707 |
} |
| 708 |
if (!conNegTriggerItem.mIndiSatNode) { |
| 709 |
conNegTriggerItem.mIndiSatNode = succIndiNode; |
| 710 |
} |
| 711 |
conNegTriggerItem.mNegationFlag = satNegation; |
| 712 |
conNegTriggerItem.mConcept = satConcept; |
| 713 |
|
| 714 |
succIndiNode = succIndiNode->getSubstituteIndividualNode(); |
| 715 |
} |
| 716 |
|
| 717 |
CReapplyConceptSaturationLabelSet* satConSet = succIndiNode->getReapplyConceptSaturationLabelSet(false); |
| 718 |
if (satConSet) { |
| 719 |
CReapplyConceptSaturationLabelSetIterator satConSetIt = satConSet->getIterator(true,true); |
| 720 |
while (satConSetIt.hasNext()) { |
| 721 |
CConceptSaturationDescriptor* conSatDes = satConSetIt.getConceptSaturationDescriptor(); |
| 722 |
CImplicationReapplyConceptSaturationDescriptor* implTrigger = satConSetIt.getImplicationReapplyConceptSaturationDescriptor(); |
| 723 |
CConceptNegationTriggerItem& conNegTriggerItem = conceptNegationTriggerHash[satConSetIt.getDataTag()]; |
| 724 |
if (conSatDes) { |
| 725 |
CConcept* satConcept = conSatDes->getConcept(); |
| 726 |
bool satNegation = conSatDes->isNegated(); |
| 727 |
if (conNegTriggerItem.mTriggerFlag) { |
| 728 |
return false; |
| 729 |
} |
| 730 |
if (conNegTriggerItem.mConcept && conNegTriggerItem.mNegationFlag != satNegation) { |
| 731 |
return false; |
| 732 |
} |
| 733 |
if (!conNegTriggerItem.mIndiSatNode) { |
| 734 |
conNegTriggerItem.mIndiSatNode = succIndiNode; |
| 735 |
} |
| 736 |
conNegTriggerItem.mNegationFlag = satNegation; |
| 737 |
conNegTriggerItem.mConcept = satConcept; |
| 738 |
} else if (implTrigger) { |
| 739 |
if (conNegTriggerItem.mConcept) { |
| 740 |
return false; |
| 741 |
} |
| 742 |
conNegTriggerItem.mTriggerFlag = true; |
| 743 |
} |
| 744 |
satConSetIt.moveNext(); |
| 745 |
} |
| 746 |
} |
| 747 |
} |
| 748 |
|
| 749 |
for (CPROCESSINGHASH<cint64,CConceptNegationTriggerItem>::const_iterator conIt = conceptNegationTriggerHash.constBegin(), conItEnd = conceptNegationTriggerHash.constEnd(); conIt != conItEnd; ++conIt) { |
| 750 |
CConceptNegationTriggerItem conNegTriggerItem(conIt.value()); |
| 751 |
if (conNegTriggerItem.mConcept) { |
| 752 |
CConcept* concept = conNegTriggerItem.mConcept; |
| 753 |
bool negated = conNegTriggerItem.mNegationFlag; |
| 754 |
CIndividualSaturationProcessNode* satIndiNode = conNegTriggerItem.mIndiSatNode; |
| 755 |
|
| 756 |
cint64 opCode = concept->getOperatorCode(); |
| 757 |
//if (!negated && (opCode == CCSOME || opCode == CCAQSOME) || negated && (opCode == CCALL)) { |
| 758 |
cint64 card = concept->getParameter(); |
| 759 |
if (!negated && (opCode == CCSOME || opCode == CCAQSOME || opCode == CCATLEAST && card > 0) || negated && (opCode == CCALL || opCode == CCATMOST && card >= 0)) { |
| 760 |
|
| 761 |
CPROCESSINGLIST<CIndividualSaturationProcessNode*> nextSuccessorList(taskProcessorContext); |
| 762 |
CPROCESSINGLIST<TConceptNegationPair> nextTrivialSuccessorPropagatedConceptList(taskProcessorContext); |
| 763 |
CPROCESSINGSET<CRole*> nextBackwardRoleSet(taskProcessorContext); |
| 764 |
|
| 765 |
CRole* role = concept->getRole(); |
| 766 |
|
| 767 |
if (!collectSuccessorMergingNodesAndConcepts(satIndiNode,role,successorList,*trivialSuccessorPropagatedConceptList,backwardRoleSet,nextSuccessorList,nextTrivialSuccessorPropagatedConceptList,nextBackwardRoleSet,successorInfluenceConceptsHash,calcAlgContext)) { |
| 768 |
return false; |
| 769 |
} |
| 770 |
|
| 771 |
|
| 772 |
if (!nextSuccessorList.isEmpty() || !trivialSuccessorPropagatedConceptList->isEmpty()) { |
| 773 |
CIndividualSaturationProcessNode* extSatIndiNode = getExistentialSaturatedIndividualNodeForConcept(concept,calcAlgContext); |
| 774 |
nextSuccessorList.prepend(extSatIndiNode); |
| 775 |
|
| 776 |
if (!testSaturatedSuccessorModelMergable(extSatIndiNode,nextSuccessorList,&nextTrivialSuccessorPropagatedConceptList,nextBackwardRoleSet,remainingMergingDepth,remainingMergingCount,calcAlgContext)) { |
| 777 |
return false; |
| 778 |
} |
| 779 |
} |
| 780 |
|
| 781 |
} |
| 782 |
|
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
|
| 787 |
for (CPROCESSINGLIST<CIndividualSaturationProcessNode*>::const_iterator succIt = successorList.constBegin(), succItEnd = successorList.constEnd(); succIt != succItEnd; ++succIt) { |
| 788 |
CIndividualSaturationProcessNode* succIndiNode(*succIt); |
| 789 |
|
| 790 |
if (succIndiNode->getDirectStatusFlags()->hasSuccessorNodeExtensionsFlag()) { |
| 791 |
CLinkedRoleSaturationSuccessorHash* linkedSuccHash = succIndiNode->getLinkedRoleSuccessorHash(false); |
| 792 |
if (linkedSuccHash) { |
| 793 |
CPROCESSHASH<CRole*,CLinkedRoleSaturationSuccessorData*>* roleLinkedSuccHash = linkedSuccHash->getLinkedRoleSuccessorHash(); |
| 794 |
for (CPROCESSHASH<CRole*,CLinkedRoleSaturationSuccessorData*>::const_iterator itSucc = roleLinkedSuccHash->constBegin(), itEndSucc = roleLinkedSuccHash->constEnd(); itSucc != itEndSucc; ++itSucc) { |
| 795 |
CRole* role = itSucc.key(); |
| 796 |
CLinkedRoleSaturationSuccessorData* linkedSuccData = itSucc.value(); |
| 797 |
CPROCESSMAP<cint64,CSaturationSuccessorData*>* succDataMap = linkedSuccData->getSuccessorNodeDataMap(false); |
| 798 |
if (succDataMap) { |
| 799 |
for (CPROCESSMAP<cint64,CSaturationSuccessorData*>::const_iterator it = succDataMap->constBegin(), itEnd = succDataMap->constEnd(); it != itEnd; ++it) { |
| 800 |
CSaturationSuccessorData* succData = it.value(); |
| 801 |
if (succData->mActiveCount >= 1) { |
| 802 |
for (CXNegLinker<CRole*>* creationRoleLinkerIt = succData->mCreationRoleLinker; creationRoleLinkerIt; creationRoleLinkerIt = creationRoleLinkerIt->getNext()) { |
| 803 |
if (!creationRoleLinkerIt->isNegated()) { |
| 804 |
CRole* creationRole = creationRoleLinkerIt->getData(); |
| 805 |
if (creationRole == role) { |
| 806 |
|
| 807 |
CPROCESSINGLIST<CIndividualSaturationProcessNode*> nextSuccessorList(taskProcessorContext); |
| 808 |
CPROCESSINGLIST<TConceptNegationPair> nextTrivialSuccessorPropagatedConceptList(taskProcessorContext); |
| 809 |
CPROCESSINGSET<CRole*> nextBackwardRoleSet(taskProcessorContext); |
| 810 |
|
| 811 |
if (!collectSuccessorMergingNodesAndConcepts(succIndiNode,role,successorList,*trivialSuccessorPropagatedConceptList,backwardRoleSet,nextSuccessorList,nextTrivialSuccessorPropagatedConceptList,nextBackwardRoleSet,successorInfluenceConceptsHash,calcAlgContext)) { |
| 812 |
return false; |
| 813 |
} |
| 814 |
|
| 815 |
if (!nextSuccessorList.isEmpty() || !trivialSuccessorPropagatedConceptList->isEmpty()) { |
| 816 |
CIndividualSaturationProcessNode* extSatIndiNode = succData->mSuccIndiNode; |
| 817 |
nextSuccessorList.prepend(extSatIndiNode); |
| 818 |
|
| 819 |
if (!testSaturatedSuccessorModelMergable(extSatIndiNode,nextSuccessorList,&nextTrivialSuccessorPropagatedConceptList,nextBackwardRoleSet,remainingMergingDepth,remainingMergingCount,calcAlgContext)) { |
| 820 |
return false; |
| 821 |
} |
| 822 |
} |
| 823 |
|
| 824 |
} |
| 825 |
} |
| 826 |
} |
| 827 |
} |
| 828 |
} |
| 829 |
} |
| 830 |
} |
| 831 |
} |
| 832 |
} |
| 833 |
} |
| 834 |
|
| 835 |
return true; |
| 836 |
|
| 837 |
} |
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
bool CSatisfiableTaskClassificationMessageAnalyser::collectSuccessorMergingNodesAndConcepts(CIndividualSaturationProcessNode* excludeSaturationIndiNode, CRole* role, CPROCESSINGLIST<CIndividualSaturationProcessNode*>& successorList, CPROCESSINGLIST<TConceptNegationPair>& trivialSuccessorPropagatedConceptList, CPROCESSINGSET<CRole*>& backwardRoleSet, |
| 852 |
CPROCESSINGLIST<CIndividualSaturationProcessNode*>& nextSuccessorList, CPROCESSINGLIST<TConceptNegationPair>& nextTrivialSuccessorPropagatedConceptList, CPROCESSINGSET<CRole*>& nextBackwardRoleSet, |
| 853 |
CPROCESSINGHASH<CRole*,TConceptNegationPair>& successorInfluenceConceptsHash, CCalculationAlgorithmContext* calcAlgContext) { |
| 854 |
|
| 855 |
for (CSortedNegLinker<CRole*>* superRoleIt = role->getIndirectSuperRoleList(); superRoleIt; superRoleIt = superRoleIt->getNext()) { |
| 856 |
CRole* superRole = superRoleIt->getData(); |
| 857 |
bool superRoleInversed = superRoleIt->isNegated(); |
| 858 |
|
| 859 |
if (!superRoleInversed) { |
| 860 |
|
| 861 |
|
| 862 |
for (CPROCESSINGHASH<CRole*,TConceptNegationPair>::const_iterator it = successorInfluenceConceptsHash.constFind(superRole), itEnd = successorInfluenceConceptsHash.constEnd(); it != itEnd; ++it) { |
| 863 |
CRole* hashRole(it.key()); |
| 864 |
if (role == hashRole) { |
| 865 |
TConceptNegationPair conNegPair(it.value()); |
| 866 |
CConcept* reapplyOperandCon = conNegPair.first; |
| 867 |
bool reapplyOperandConNeg = conNegPair.second; |
| 868 |
|
| 869 |
CIndividualSaturationProcessNode* satIndiNode = getSaturatedIndividualNodeForConcept(reapplyOperandCon,reapplyOperandConNeg,calcAlgContext); |
| 870 |
if (!satIndiNode) { |
| 871 |
if (!collectTrivialPropagationTestingConcepts(reapplyOperandCon,reapplyOperandConNeg,nextTrivialSuccessorPropagatedConceptList,calcAlgContext)) { |
| 872 |
return false; |
| 873 |
} |
| 874 |
} else if (!satIndiNode->isCompleted() || satIndiNode->getIndirectStatusFlags()->hasFlags(CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCARDINALITYPROPLEMATIC | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGINSUFFICIENT | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCLASHED | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGNOMINALCONNECTION,false)) { |
| 875 |
return false; |
| 876 |
} |
| 877 |
|
| 878 |
if (satIndiNode) { |
| 879 |
nextSuccessorList.append(satIndiNode); |
| 880 |
} |
| 881 |
} else { |
| 882 |
break; |
| 883 |
} |
| 884 |
} |
| 885 |
|
| 886 |
|
| 887 |
for (CPROCESSINGLIST<CIndividualSaturationProcessNode*>::const_iterator succIt = successorList.constBegin(), succItEnd = successorList.constEnd(); succIt != succItEnd; ++succIt) { |
| 888 |
CIndividualSaturationProcessNode* succIndiNode(*succIt); |
| 889 |
|
| 890 |
while (succIndiNode->hasSubstituteIndividualNode()) { |
| 891 |
succIndiNode = succIndiNode->getSubstituteIndividualNode(); |
| 892 |
} |
| 893 |
|
| 894 |
if (succIndiNode != excludeSaturationIndiNode) { |
| 895 |
|
| 896 |
CRoleBackwardSaturationPropagationHash* roleBackPropHash = succIndiNode->getRoleBackwardPropagationHash(false); |
| 897 |
if (roleBackPropHash) { |
| 898 |
CPROCESSHASH<CRole*,CRoleBackwardSaturationPropagationHashData>* roleBackPropDataHash = roleBackPropHash->getRoleBackwardPropagationDataHash(); |
| 899 |
const CRoleBackwardSaturationPropagationHashData& backPropData = roleBackPropDataHash->value(superRole); |
| 900 |
for (CBackwardSaturationPropagationReapplyDescriptor* reapplyLinkerIt = backPropData.mReapplyLinker; reapplyLinkerIt; reapplyLinkerIt = reapplyLinkerIt->getNext()) { |
| 901 |
CConceptSaturationDescriptor* reapplyConDes = reapplyLinkerIt->getReapplyConceptSaturationDescriptor(); |
| 902 |
|
| 903 |
|
| 904 |
CConcept* reapplyConcept = reapplyConDes->getConcept(); |
| 905 |
bool reapplyConceptNegation = reapplyConDes->isNegated(); |
| 906 |
cint64 reapplyConceptOpCode = reapplyConcept->getOperatorCode(); |
| 907 |
if (reapplyConceptNegation && (reapplyConceptOpCode == CCSOME) || !reapplyConceptNegation && (reapplyConceptOpCode == CCALL || reapplyConceptOpCode == CCIMPLALL || reapplyConceptOpCode == CCBRANCHALL || reapplyConceptOpCode == CCAQALL || reapplyConceptOpCode == CCIMPLAQALL || reapplyConceptOpCode == CCBRANCHAQALL)) { |
| 908 |
for (CSortedNegLinker<CConcept*>* reapplyOperandConLinkerIt = reapplyConcept->getOperandList(); reapplyOperandConLinkerIt; reapplyOperandConLinkerIt = reapplyOperandConLinkerIt->getNext()) { |
| 909 |
CConcept* reapplyOperandCon = reapplyOperandConLinkerIt->getData(); |
| 910 |
bool reapplyOperandConNeg = reapplyOperandConLinkerIt->isNegated()^reapplyConceptNegation; |
| 911 |
|
| 912 |
CIndividualSaturationProcessNode* satIndiNode = getSaturatedIndividualNodeForConcept(reapplyOperandCon,reapplyOperandConNeg,calcAlgContext); |
| 913 |
if (!satIndiNode) { |
| 914 |
if (!collectTrivialPropagationTestingConcepts(reapplyOperandCon,reapplyOperandConNeg,nextTrivialSuccessorPropagatedConceptList,calcAlgContext)) { |
| 915 |
return false; |
| 916 |
} |
| 917 |
} else if (!satIndiNode->isCompleted() || satIndiNode->getIndirectStatusFlags()->hasFlags(CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCARDINALITYPROPLEMATIC | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGINSUFFICIENT | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCLASHED | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGNOMINALCONNECTION,false)) { |
| 918 |
return false; |
| 919 |
} |
| 920 |
|
| 921 |
nextSuccessorList.append(satIndiNode); |
| 922 |
} |
| 923 |
} else { |
| 924 |
return false; |
| 925 |
} |
| 926 |
|
| 927 |
} |
| 928 |
} |
| 929 |
} |
| 930 |
} |
| 931 |
} else { |
| 932 |
nextBackwardRoleSet.insert(superRole); |
| 933 |
} |
| 934 |
} |
| 935 |
|
| 936 |
return true; |
| 937 |
} |
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
CIndividualSaturationProcessNode* CSatisfiableTaskClassificationMessageAnalyser::getExistentialSaturatedIndividualNodeForConcept(CConcept* concept, CCalculationAlgorithmContext* calcAlgContext) { |
| 944 |
CIndividualSaturationProcessNode* satIndiNode = nullptr; |
| 945 |
CConceptProcessData* conProcData = (CConceptProcessData*)concept->getConceptData(); |
| 946 |
if (conProcData) { |
| 947 |
CConceptReferenceLinking* conRefLinking = conProcData->getConceptReferenceLinking(); |
| 948 |
if (conRefLinking) { |
| 949 |
CConceptSaturationReferenceLinkingData* confSatRefLinkingData = (CConceptSaturationReferenceLinkingData*)conRefLinking; |
| 950 |
CSaturationConceptReferenceLinking* satCalcRefLinkData = confSatRefLinkingData->getExistentialSuccessorConceptSaturationReferenceLinkingData(); |
| 951 |
if (satCalcRefLinkData) { |
| 952 |
satIndiNode = (CIndividualSaturationProcessNode*)satCalcRefLinkData->getIndividualProcessNodeForConcept(); |
| 953 |
} |
| 954 |
} |
| 955 |
} |
| 956 |
if (!satIndiNode) { |
| 957 |
CSortedNegLinker<CConcept*>* opConceptLinker = concept->getOperandList(); |
| 958 |
CConcept* opConcept = nullptr; |
| 959 |
bool opNegation = false; |
| 960 |
if (!opConceptLinker) { |
| 961 |
opConcept = calcAlgContext->getProcessingDataBox()->getOntologyTopConcept(); |
| 962 |
} else { |
| 963 |
if (!opConceptLinker->hasNext()) { |
| 964 |
opConcept = opConceptLinker->getData(); |
| 965 |
bool negateOp = false; |
| 966 |
if (concept->getOperatorCode() == CCALL) { |
| 967 |
negateOp = true; |
| 968 |
} |
| 969 |
opNegation = opConceptLinker->isNegated()^negateOp; |
| 970 |
} |
| 971 |
} |
| 972 |
if (opConcept) { |
| 973 |
satIndiNode = getSaturatedIndividualNodeForConcept(opConcept,opNegation,calcAlgContext); |
| 974 |
} |
| 975 |
} |
| 976 |
return satIndiNode; |
| 977 |
} |
| 978 |
|
| 979 |
CIndividualSaturationProcessNode* CSatisfiableTaskClassificationMessageAnalyser::getSaturatedIndividualNodeForConcept(CConcept* concept, bool conceptNegation, CCalculationAlgorithmContext* calcAlgContext) { |
| 980 |
CIndividualSaturationProcessNode* satIndiNode = nullptr; |
| 981 |
CConceptProcessData* conProcData = (CConceptProcessData*)concept->getConceptData(); |
| 982 |
if (conProcData) { |
| 983 |
CConceptReferenceLinking* conRefLinking = conProcData->getConceptReferenceLinking(); |
| 984 |
if (conRefLinking) { |
| 985 |
CConceptSaturationReferenceLinkingData* confSatRefLinkingData = (CConceptSaturationReferenceLinkingData*)conRefLinking; |
| 986 |
CSaturationConceptReferenceLinking* satCalcRefLinkData = confSatRefLinkingData->getConceptSaturationReferenceLinkingData(conceptNegation); |
| 987 |
if (satCalcRefLinkData) { |
| 988 |
satIndiNode = (CIndividualSaturationProcessNode*)satCalcRefLinkData->getIndividualProcessNodeForConcept(); |
| 989 |
} |
| 990 |
} |
| 991 |
} |
| 992 |
return satIndiNode; |
| 993 |
} |
| 994 |
|
| 995 |
|
| 996 |
bool CSatisfiableTaskClassificationMessageAnalyser::testSubsumerCandidatePossibleWithMergedSaturatedModel(CIndividualProcessNode* indiNode, CConcept* testConcept, bool negation, bool& mergeSatisfieableFlag, CCalculationAlgorithmContext* calcAlgContext) { |
| 997 |
|
| 998 |
CIndividualSaturationProcessNode* saturationIndiNode = getSaturatedIndividualNodeForConcept(testConcept,negation,calcAlgContext); |
| 999 |
if (saturationIndiNode) { |
| 1000 |
|
| 1001 |
if (saturationIndiNode->isCompleted() && !saturationIndiNode->getIndirectStatusFlags()->hasFlags(CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGCARDINALITYPROPLEMATIC | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGINSUFFICIENT | CIndividualSaturationProcessNodeStatusFlags::INDSATFLAGNOMINALCONNECTION,false)) { |
| 1002 |
|
| 1003 |
|
| 1004 |
bool clashedFlag = false; |
| 1005 |
|
| 1006 |
if (!testConceptSetWithSaturatedModelMergable(indiNode,saturationIndiNode,clashedFlag,calcAlgContext)) { |
| 1007 |
return false; |
| 1008 |
} |
| 1009 |
if (clashedFlag) { |
| 1010 |
mergeSatisfieableFlag = false; |
| 1011 |
return true; |
| 1012 |
} |
| 1013 |
|
| 1014 |
if (!testRoleSuccessorsWithSaturatedModelMergable(indiNode,saturationIndiNode,calcAlgContext)) { |
| 1015 |
return false; |
| 1016 |
} |
| 1017 |
|
| 1018 |
if (!testSaturatedExistentialsModelMergable(indiNode,saturationIndiNode,calcAlgContext)) { |
| 1019 |
return false; |
| 1020 |
} |
| 1021 |
mergeSatisfieableFlag = true; |
| 1022 |
return true; |
| 1023 |
|
| 1024 |
} |
| 1025 |
return false; |
| 1026 |
} |
| 1027 |
return false; |
| 1028 |
} |
| 1029 |
|
| 1030 |
bool CSatisfiableTaskClassificationMessageAnalyser::testEquivalenceConceptAlternatives(CIndividualProcessNode* indiNode, CPROCESSINGSET< QPair<CConcept*,bool> >& alternativesSet, CPROCESSINGHASH< QPair<CConcept*,bool>,CSaturatedMergedTestItem >* testSaturatedMergedHash, bool& oneMergeSatisfieableFlag, bool& allMergeUnsatisfieableFlag, CCalculationAlgorithmContext* calcAlgContext) { |
| 1031 |
for (CPROCESSINGSET< QPair<CConcept*,bool> >::const_iterator it = alternativesSet.constBegin(), itEnd = alternativesSet.constEnd(); it != itEnd; ++it) { |
| 1032 |
QPair<CConcept*,bool> conNegPair(*it); |
| 1033 |
CConcept* concept = conNegPair.first; |
| 1034 |
bool negation = conNegPair.second; |
| 1035 |
bool mergedSatisfiableFlag = false; |
| 1036 |
STATINC(ANALYSECANDIDATECONCEPTSATURATEDALTERNATIVEMERGINGCOUNT,calcAlgContext); |
| 1037 |
bool mergedSuccessfullyFlag = testSubsumerCandidatePossibleWithMergedSaturatedModel(indiNode,concept,negation,mergedSatisfiableFlag,calcAlgContext); |
| 1038 |
CSaturatedMergedTestItem& saturatedMergedTestItem = (*testSaturatedMergedHash)[conNegPair]; |
| 1039 |
saturatedMergedTestItem.mSuccessfullyMerged = mergedSuccessfullyFlag; |
| 1040 |
saturatedMergedTestItem.mSatisfiableMerged = mergedSatisfiableFlag; |
| 1041 |
if (!mergedSuccessfullyFlag) { |
| 1042 |
allMergeUnsatisfieableFlag = false; |
| 1043 |
} else { |
| 1044 |
if (mergedSatisfiableFlag) { |
| 1045 |
oneMergeSatisfieableFlag = true; |
| 1046 |
allMergeUnsatisfieableFlag = false; |
| 1047 |
return true; |
| 1048 |
} |
| 1049 |
} |
| 1050 |
} |
| 1051 |
if (allMergeUnsatisfieableFlag) { |
| 1052 |
return true; |
| 1053 |
} |
| 1054 |
return false; |
| 1055 |
} |
| 1056 |
|
| 1057 |
|
| 1058 |
bool CSatisfiableTaskClassificationMessageAnalyser::collectEquivalenceConceptAlternatives(CIndividualProcessNode* indiNode, CConcept* testConcept, bool testConceptNegation, CPROCESSINGSET< QPair<CConcept*,bool> >& alternativesSet, CPROCESSINGHASH< QPair<CConcept*,bool>,CSaturatedMergedTestItem >* testSaturatedMergedHash, bool& oneMergeSatisfieableFlag, bool& allMergeUnsatisfieableFlag, CCalculationAlgorithmContext* calcAlgContext) { |
| 1059 |
CTaskProcessorContext* taskProcessorContext = calcAlgContext->getUsedTaskProcessorContext(); |
| 1060 |
CPROCESSINGLIST< QPair<CConcept*,bool> > alternativeExpList(taskProcessorContext); |
| 1061 |
CPROCESSINGSET< QPair<CConcept*,bool> > alternativeExpSet(taskProcessorContext); |
| 1062 |
CReapplyConceptLabelSet* conSet = indiNode->getReapplyConceptLabelSet(false); |
| 1063 |
|
| 1064 |
allMergeUnsatisfieableFlag = true; |
| 1065 |
QPair<CConcept*,bool> conNegPair(testConcept,testConceptNegation); |
| 1066 |
alternativeExpList.append(conNegPair); |
| 1067 |
alternativeExpSet.insert(conNegPair); |
| 1068 |
while (!alternativeExpList.isEmpty()) { |
| 1069 |
conNegPair = alternativeExpList.takeFirst(); |
| 1070 |
CConcept* concept = conNegPair.first; |
| 1071 |
bool negation = conNegPair.second; |
| 1072 |
cint64 conOpCode = concept->getOperatorCode(); |
| 1073 |
if (negation && (conOpCode == CCEQ || conOpCode == CCAND) || !negation && (conOpCode == CCOR)) { |
| 1074 |
for (CSortedNegLinker<CConcept*>* operandConceptLinkerIt = concept->getOperandList(); operandConceptLinkerIt; operandConceptLinkerIt = operandConceptLinkerIt->getNext()) { |
| 1075 |
CConcept* operandConcept = operandConceptLinkerIt->getData(); |
| 1076 |
bool operandNegation = operandConceptLinkerIt->isNegated()^negation; |
| 1077 |
QPair<CConcept*,bool> opConNegPair(operandConcept,operandNegation); |
| 1078 |
if (!alternativeExpSet.contains(opConNegPair)) { |
| 1079 |
alternativeExpSet.insert(opConNegPair); |
| 1080 |
alternativeExpList.append(opConNegPair); |
| 1081 |
} |
| 1082 |
} |
| 1083 |
} else if (conOpCode == CCAQCHOOCE) { |
| 1084 |
|
| 1085 |
for (CSortedNegLinker<CConcept*>* operandConceptLinkerIt = concept->getOperandList(); operandConceptLinkerIt; operandConceptLinkerIt = operandConceptLinkerIt->getNext()) { |
| 1086 |
CConcept* operandConcept = operandConceptLinkerIt->getData(); |
| 1087 |
bool operandNegation = operandConceptLinkerIt->isNegated(); |
| 1088 |
if (negation == operandNegation) { |
| 1089 |
QPair<CConcept*,bool> opConNegPair(operandConcept,operandNegation); |
| 1090 |
if (!alternativeExpSet.contains(opConNegPair)) { |
| 1091 |
alternativeExpSet.insert(opConNegPair); |
| 1092 |
alternativeExpList.append(opConNegPair); |
| 1093 |
} |
| 1094 |
} |
| 1095 |
} |
| 1096 |
|
| 1097 |
} else if (negation && (conOpCode == CCALL) || !negation && (conOpCode == CCSOME || conOpCode == CCAQSOME)) { |
| 1098 |
|
| 1099 |
bool containsNegation = false; |
| 1100 |
if (!conSet->containsConcept(concept,&containsNegation)) { |
| 1101 |
CSaturatedMergedTestItem& saturatedMergedTestItem = (*testSaturatedMergedHash)[conNegPair]; |
| 1102 |
if (saturatedMergedTestItem.mSuccessfullyMerged) { |
| 1103 |
if (saturatedMergedTestItem.mSatisfiableMerged) { |
| 1104 |
oneMergeSatisfieableFlag = true; |
| 1105 |
allMergeUnsatisfieableFlag = false; |
| 1106 |
return true; |
| 1107 |
} |
| 1108 |
} else { |
| 1109 |
alternativesSet.insert(conNegPair); |
| 1110 |
} |
| 1111 |
} else { |
| 1112 |
if (containsNegation == negation) { |
| 1113 |
oneMergeSatisfieableFlag = true; |
| 1114 |
allMergeUnsatisfieableFlag = false; |
| 1115 |
return true; |
| 1116 |
} |
| 1117 |
} |
| 1118 |
|
| 1119 |
} else { |
| 1120 |
bool containsNegation = false; |
| 1121 |
if (!conSet->containsConcept(concept,&containsNegation)) { |
| 1122 |
allMergeUnsatisfieableFlag = false; |
| 1123 |
} else { |
| 1124 |
if (containsNegation == negation) { |
| 1125 |
oneMergeSatisfieableFlag = true; |
| 1126 |
allMergeUnsatisfieableFlag = false; |
| 1127 |
return true; |
| 1128 |
} |
| 1129 |
} |
| 1130 |
} |
| 1131 |
} |
| 1132 |
if (alternativesSet.isEmpty() && allMergeUnsatisfieableFlag) { |
| 1133 |
return true; |
| 1134 |
} |
| 1135 |
return false; |
| 1136 |
} |
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
CClassificationMessageData* CSatisfiableTaskClassificationMessageAnalyser::extractPossibleSubsumptionInformation(CConceptDescriptor* conDes, CIndividualProcessNode* indiNode, CReapplyConceptLabelSet* conSet, CCalculationAlgorithmContext* calcAlgContext) { |
| 1141 |
STATINC(ANALYSEPOSSIBLESUBSUMPTIONSCOUNT,calcAlgContext); |
| 1142 |
|
| 1143 |
CClassificationMessageData* messageDataLinker = nullptr; |
| 1144 |
|
| 1145 |
CConcept* testingConcept = conDes->getConcept(); |
| 1146 |
bool negated = conDes->getNegation(); |
| 1147 |
|
| 1148 |
//if (CIRIName::getRecentIRIName(testingConcept->getClassNameLinker()) == "http://www.owllink.org/testsuite/particle-D#Neutrino") { |
| 1149 |
// bool bug = true; |
| 1150 |
//} |
| 1151 |
CConceptReferenceLinking* conRefLinking = nullptr; |
| 1152 |
CConceptData* conData = testingConcept->getConceptData(); |
| 1153 |
if (conData && !mUseAlwaysConRefLinkDataHash) { |
| 1154 |
CConceptProcessData* conProcData = (CConceptProcessData*)conData; |
| 1155 |
if (!conProcData->isInvalidatedReferenceLinking()) { |
| 1156 |
conRefLinking = conProcData->getConceptReferenceLinking(); |
| 1157 |
} |
| 1158 |
} |
| 1159 |
CClassificationConceptReferenceLinking* classConRefLinkData = nullptr; |
| 1160 |
if (conRefLinking) { |
| 1161 |
CConceptSatisfiableReferenceLinkingData* conSatRefLinkData = (CConceptSatisfiableReferenceLinkingData*)conRefLinking; |
| 1162 |
classConRefLinkData = conSatRefLinkData->getClassifierReferenceLinkingData(); |
| 1163 |
} else { |
| 1164 |
classConRefLinkData = mConRefLinkDataHash->value(testingConcept); |
| 1165 |
} |
| 1166 |
if (classConRefLinkData) { |
| 1167 |
CClassificationSatisfiablePossibleSubsumptionCalculationConceptReferenceLinking* possSubsumRefLinkData = (CClassificationSatisfiablePossibleSubsumptionCalculationConceptReferenceLinking*)classConRefLinkData; |
| 1168 |
if (possSubsumRefLinkData) { |
| 1169 |
if (!possSubsumRefLinkData->isPossibleSubsumptionMapInitialized()) { |
| 1170 |
// initialize possible subsumption list |
| 1171 |
CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CClassificationInitializePossibleClassSubsumptionData*>* possSubsumerList = nullptr; |
| 1172 |
|
| 1173 |
if (!mMultiplePossSubsumInitAvoidHash) { |
| 1174 |
mMultiplePossSubsumInitAvoidHash = CObjectParameterizingAllocator< CPROCESSINGHASH< CConcept*,CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CClassificationInitializePossibleClassSubsumptionData*>* >,CContext* >::allocateAndConstructAndParameterize(calcAlgContext->getTemporaryMemoryAllocationManager(),calcAlgContext->getTaskProcessorContext()); |
| 1175 |
} |
| 1176 |
possSubsumerList = mMultiplePossSubsumInitAvoidHash->value(testingConcept); |
| 1177 |
|
| 1178 |
CReapplyConceptLabelSetIterator conSetIt = conSet->getConceptLabelSetIterator(true,true,false); |
| 1179 |
if (possSubsumerList) { |
| 1180 |
|
| 1181 |
// prune already initialization list for possible subsumers |
| 1182 |
CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CClassificationInitializePossibleClassSubsumptionData*>::iterator itPossSubsum = possSubsumerList->begin(), itPossSubsumEnd = possSubsumerList->end(); |
| 1183 |
while (conSetIt.hasNext() && itPossSubsum != itPossSubsumEnd) { |
| 1184 |
CConceptDescriptor* conDes = conSetIt.getConceptDescriptor(); |
| 1185 |
CConcept* concept = conDes->getConcept(); |
| 1186 |
bool negated = conDes->getNegation(); |
| 1187 |
|
| 1188 |
CClassificationInitializePossibleClassSubsumptionData* possSubsumConData = *itPossSubsum; |
| 1189 |
CConcept* possSubsumConcept = possSubsumConData->getPossibleSubsumerConcept(); |
| 1190 |
cint64 conDesTag = conDes->getConceptTag(); |
| 1191 |
cint64 possSubsumConTag = possSubsumConcept->getConceptTag(); |
| 1192 |
|
| 1193 |
if (conDesTag < possSubsumConTag) { |
| 1194 |
conSetIt.moveNext(); |
| 1195 |
} else if (conDesTag == possSubsumConTag) { |
| 1196 |
|
| 1197 |
//if (concept->getOperatorCode() == CCEQCAND) { |
| 1198 |
// if (!testSubsumerCandidatePossibleWithMergedSaturatedModel(indiNode,concept->getOperandList()->getData(),calcAlgContext)) { |
| 1199 |
// possSubsumConData->setPossibleSubsumerInvalid(); |
| 1200 |
// } |
| 1201 |
//} |
| 1202 |
|
| 1203 |
conSetIt.moveNext(); |
| 1204 |
++itPossSubsum; |
| 1205 |
} else { |
| 1206 |
possSubsumConData->setPossibleSubsumerInvalid(); |
| 1207 |
++itPossSubsum; |
| 1208 |
} |
| 1209 |
} |
| 1210 |
while (itPossSubsum != itPossSubsumEnd) { |
| 1211 |
CClassificationInitializePossibleClassSubsumptionData* subsumData(*itPossSubsum); |
| 1212 |
subsumData->setPossibleSubsumerInvalid(); |
| 1213 |
++itPossSubsum; |
| 1214 |
} |
| 1215 |
|
| 1216 |
} else { |
| 1217 |
// create new initialization list for possible subsumers |
| 1218 |
while (conSetIt.hasNext()) { |
| 1219 |
CConceptDescriptor* conDes = conSetIt.getConceptDescriptor(); |
| 1220 |
CConcept* concept = conDes->getConcept(); |
| 1221 |
bool negated = conDes->getNegation(); |
| 1222 |
|
| 1223 |
|
| 1224 |
if (!negated && (concept->hasClassName() && concept->getConceptTag() != 1 && concept != testingConcept)) { |
| 1225 |
if (!possSubsumerList) { |
| 1226 |
possSubsumerList = CObjectParameterizingAllocator< CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CClassificationInitializePossibleClassSubsumptionData*>,CContext* >::allocateAndConstructAndParameterize(mTempMemAllocMan,mTmpContext); |
| 1227 |
} |
| 1228 |
CClassificationInitializePossibleClassSubsumptionData* possSubsumData = CObjectAllocator< CClassificationInitializePossibleClassSubsumptionData >::allocateAndConstruct(mTempMemAllocMan); |
| 1229 |
possSubsumData->initClassificationPossibleSubsumptionData(concept); |
| 1230 |
possSubsumerList->append(possSubsumData); |
| 1231 |
} |
| 1232 |
if (concept->getOperatorCode() == CCEQCAND) { |
| 1233 |
CConcept* eqConcept = concept->getOperandList()->getData(); |
| 1234 |
|
| 1235 |
//if (CIRIName::getRecentIRIName(testingConcept->getClassNameLinker()) == "http://oiled.man.example.net/facts#All+Friends+Happy+or+All+Friends+Students") { |
| 1236 |
// if (CIRIName::getRecentIRIName(eqConcept->getClassNameLinker()) == "http://oiled.man.example.net/facts#All+Friends+Happy+or+Students") { |
| 1237 |
// bool bug = true; |
| 1238 |
// } |
| 1239 |
//} |
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
if (testSubsumerCandidatePossibleWithMergedSaturatedModel(indiNode,eqConcept,calcAlgContext)) { |
| 1244 |
if (!possSubsumerList) { |
| 1245 |
possSubsumerList = CObjectParameterizingAllocator< CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CClassificationInitializePossibleClassSubsumptionData*>,CContext* >::allocateAndConstructAndParameterize(mTempMemAllocMan,mTmpContext); |
| 1246 |
} |
| 1247 |
CClassificationInitializePossibleClassSubsumptionData* possSubsumData = CObjectAllocator< CClassificationInitializePossibleClassSubsumptionData >::allocateAndConstruct(mTempMemAllocMan); |
| 1248 |
possSubsumData->initClassificationPossibleSubsumptionData(concept); |
| 1249 |
possSubsumerList->append(possSubsumData); |
| 1250 |
} |
| 1251 |
} |
| 1252 |
conSetIt.moveNext(); |
| 1253 |
} |
| 1254 |
|
| 1255 |
CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CConcept*>* eqConNonCandPossSubsumerList = nullptr; |
| 1256 |
|
| 1257 |
bool eqConceptsNonCandidatePossSubsumers = false; |
| 1258 |
QSet<CConcept*>* equivConceptNonCandidateSet = calcAlgContext->getUsedProcessingDataBox()->getOntology()->getTBox()->getEquivalentConceptNonCandidateSet(false); |
| 1259 |
if (equivConceptNonCandidateSet) { |
| 1260 |
eqConceptsNonCandidatePossSubsumers = true; |
| 1261 |
for (QSet<CConcept*>::const_iterator it = equivConceptNonCandidateSet->constBegin(), itEnd = equivConceptNonCandidateSet->constEnd(); it != itEnd; ++it) { |
| 1262 |
CConcept* eqConcept = *it; |
| 1263 |
|
| 1264 |
//if (CIRIName::getRecentIRIName(testingConcept->getClassNameLinker()) == "http://oiled.man.example.net/facts#All+Friends+Happy+or+All+Friends+Students") { |
| 1265 |
// if (CIRIName::getRecentIRIName(eqConcept->getClassNameLinker()) == "http://oiled.man.example.net/facts#All+Friends+Happy+or+Students") { |
| 1266 |
// bool bug = true; |
| 1267 |
// } |
| 1268 |
//} |
| 1269 |
|
| 1270 |
if (testSubsumerCandidatePossibleWithMergedSaturatedModel(indiNode,eqConcept,calcAlgContext)) { |
| 1271 |
if (!eqConNonCandPossSubsumerList) { |
| 1272 |
eqConNonCandPossSubsumerList = CObjectParameterizingAllocator< CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CConcept*>,CContext* >::allocateAndConstructAndParameterize(mTempMemAllocMan,mTmpContext); |
| 1273 |
} |
| 1274 |
eqConNonCandPossSubsumerList->append(eqConcept); |
| 1275 |
} |
| 1276 |
} |
| 1277 |
} |
| 1278 |
|
| 1279 |
if (possSubsumerList) { |
| 1280 |
mMultiplePossSubsumInitAvoidHash->insert(testingConcept,possSubsumerList); |
| 1281 |
} |
| 1282 |
|
| 1283 |
CClassificationInitializePossibleClassSubsumptionMessageData* possSubsumMessageData = CObjectAllocator<CClassificationInitializePossibleClassSubsumptionMessageData>::allocateAndConstruct(mTempMemAllocMan); |
| 1284 |
possSubsumMessageData->initClassificationPossibleSubsumptionMessageData(testingConcept,possSubsumerList,eqConceptsNonCandidatePossSubsumers,eqConNonCandPossSubsumerList); |
| 1285 |
messageDataLinker = possSubsumMessageData->append(messageDataLinker); |
| 1286 |
} |
| 1287 |
} else { |
| 1288 |
CClassPossibleSubsumptionMap* possSubsumMap = possSubsumRefLinkData->getClassPossibleSubsumptionMap(); |
| 1289 |
if (possSubsumMap && possSubsumMap->hasRemainingPossibleSubsumptions()) { |
| 1290 |
// update / prune possible subsumer list |
| 1291 |
|
| 1292 |
bool updatedPossSubsumptions = false; |
| 1293 |
|
| 1294 |
CClassPossibleSubsumptionMapIterator* possSubsumIt = possSubsumMap->getIterator(mReusePossSubsumMapIterator,calcAlgContext); |
| 1295 |
mReusePossSubsumMapIterator = possSubsumIt; |
| 1296 |
CReapplyConceptLabelSetIterator conSetIt = conSet->getConceptLabelSetIterator(true,true,false); |
| 1297 |
while (possSubsumIt->hasNext() && conSetIt.hasNext()) { |
| 1298 |
CConceptDescriptor* conDes = conSetIt.getConceptDescriptor(); |
| 1299 |
CConcept* concept = conDes->getConcept(); |
| 1300 |
bool negated = conDes->getNegation(); |
| 1301 |
CConcept* possSubCon = possSubsumIt->getSubsumptionConcept(); |
| 1302 |
cint64 conDesTag = conDes->getConceptTag(); |
| 1303 |
cint64 possSubsumConTag = possSubCon->getConceptTag(); |
| 1304 |
|
| 1305 |
if (conDesTag == possSubsumConTag) { |
| 1306 |
|
| 1307 |
//if (concept->getOperatorCode() == CCEQCAND) { |
| 1308 |
// if (!testSubsumerCandidatePossibleWithMergedSaturatedModel(indiNode,concept->getOperandList()->getData(),calcAlgContext)) { |
| 1309 |
// updatedPossSubsumptions |= possSubsumIt->invalidateSubsumption(); |
| 1310 |
// } |
| 1311 |
//} |
| 1312 |
|
| 1313 |
possSubsumIt->moveNext(); |
| 1314 |
conSetIt.moveNext(); |
| 1315 |
} else if (conDesTag < possSubsumConTag) { |
| 1316 |
conSetIt.moveNext(); |
| 1317 |
} else if (possSubsumConTag < conDesTag) { |
| 1318 |
if (possSubCon->getOperatorCode() != CCEQ) { |
| 1319 |
updatedPossSubsumptions |= possSubsumIt->invalidateSubsumption(); |
| 1320 |
} |
| 1321 |
possSubsumIt->moveNext(); |
| 1322 |
} |
| 1323 |
} |
| 1324 |
while (possSubsumIt->hasNext()) { |
| 1325 |
CConcept* possSubCon = possSubsumIt->getSubsumptionConcept(); |
| 1326 |
if (possSubCon->getOperatorCode() != CCEQ) { |
| 1327 |
possSubsumIt->invalidateSubsumption(); |
| 1328 |
} |
| 1329 |
possSubsumIt->moveNext(); |
| 1330 |
} |
| 1331 |
|
| 1332 |
if (updatedPossSubsumptions) { |
| 1333 |
CClassificationUpdatePossibleClassSubsumptionMessageData* possSubsumMessageData = CObjectAllocator<CClassificationUpdatePossibleClassSubsumptionMessageData>::allocateAndConstruct(mTempMemAllocMan); |
| 1334 |
possSubsumMessageData->initClassificationPossibleSubsumptionMessageData(testingConcept); |
| 1335 |
messageDataLinker = possSubsumMessageData->append(messageDataLinker); |
| 1336 |
} |
| 1337 |
|
| 1338 |
} |
| 1339 |
} |
| 1340 |
} |
| 1341 |
} |
| 1342 |
return messageDataLinker; |
| 1343 |
} |
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
void CSatisfiableTaskClassificationMessageAnalyser::verifySubsumptionPossibleWithModel(CIndividualProcessNode* indiNode, CConcept* testingConcept, CClassificationMessageData* possSubsumMessageData, CCLASSSUBSUMPTIONMESSAGELIST<CConcept*>* subsumerList) { |
| 1348 |
if (possSubsumMessageData) { |
| 1349 |
if (possSubsumMessageData->getClassificationMessageDataType() == CClassificationInitializePossibleClassSubsumptionMessageData::TELLCLASSINITIALIZEPOSSIBLESUBSUM) { |
| 1350 |
CClassificationInitializePossibleClassSubsumptionMessageData* initPossSubMessageData = (CClassificationInitializePossibleClassSubsumptionMessageData*)possSubsumMessageData; |
| 1351 |
if (initPossSubMessageData) { |
| 1352 |
CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CClassificationInitializePossibleClassSubsumptionData*>* possSubsumList = initPossSubMessageData->getClassPossibleSubsumerList(); |
| 1353 |
if (possSubsumList) { |
| 1354 |
for (CCLASSPOSSIBLESUBSUMPTIONMESSAGELIST<CClassificationInitializePossibleClassSubsumptionData*>::const_iterator it = possSubsumList->constBegin(), itEnd = possSubsumList->constEnd(); it != itEnd; ++it) { |
| 1355 |
CClassificationInitializePossibleClassSubsumptionData* possSubsumData = *it; |
| 1356 |
if (possSubsumData->isPossibleSubsumerValid()) { |
| 1357 |
CConcept* possSubsumerConcept = possSubsumData->getPossibleSubsumerConcept(); |
| 1358 |
if (possSubsumerConcept->getOperatorCode() == CCEQCAND) { |
| 1359 |
possSubsumerConcept = possSubsumerConcept->getOperandList()->getData(); |
| 1360 |
} |
| 1361 |
} |
| 1362 |
} |
| 1363 |
} |
| 1364 |
} |
| 1365 |
} |
| 1366 |
} |
| 1367 |
} |
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
void CSatisfiableTaskClassificationMessageAnalyser::checkCanHaveClashWithModel(CIndividualProcessNode* indiNode, CConcept* concept, bool negated, bool& clashFoundFlag, bool& unknownFlag, bool& clashFreeFlag, cint64 depth, QSet<CIndividualProcessNode*>* testedIndividualsSet, CIndividualProcessNode* lastNode, CIndividualProcessNodeVector* indiNodeVec) { |
| 1372 |
if (depth > mMaxPossibleSubsumerNegationCheckingDepth) { |
| 1373 |
unknownFlag = true; |
| 1374 |
} else { |
| 1375 |
if (indiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFINVALIDATEBLOCKERFLAGSCOMPINATION) || (lastNode != indiNode && testedIndividualsSet->contains(indiNode))) { |
| 1376 |
unknownFlag = true; |
| 1377 |
} else { |
| 1378 |
if (lastNode != indiNode) { |
| 1379 |
testedIndividualsSet->insert(indiNode); |
| 1380 |
} |
| 1381 |
CReapplyConceptLabelSet* labelSet = indiNode->getReapplyConceptLabelSet(false); |
| 1382 |
bool containsNegated = false; |
| 1383 |
CConceptDescriptor* conDes = nullptr; |
| 1384 |
CCondensedReapplyQueue* reapplyQueue = labelSet->getConceptDescriptorAndReapplyQueue(concept,conDes,false); |
| 1385 |
if (conDes || reapplyQueue) { |
| 1386 |
if (conDes) { |
| 1387 |
containsNegated = conDes->getNegation(); |
| 1388 |
if (containsNegated ^ negated) { |
| 1389 |
CDependencyTrackPoint* depTrackPoint = conDes->getDependencyTrackPoint(); |
| 1390 |
if (!depTrackPoint || depTrackPoint->getBranchingTag() > 0) { |
| 1391 |
unknownFlag = true; |
| 1392 |
} else { |
| 1393 |
clashFoundFlag = true; |
| 1394 |
} |
| 1395 |
} else { |
| 1396 |
clashFreeFlag = true; |
| 1397 |
} |
| 1398 |
} else { |
| 1399 |
unknownFlag = true; |
| 1400 |
} |
| 1401 |
} else { |
| 1402 |
// not contained by the model |
| 1403 |
cint64 opCode = concept->getOperatorCode(); |
| 1404 |
cint64 opCount = concept->getOperandCount(); |
| 1405 |
CConceptOperator* conOperator = concept->getConceptOperator(); |
| 1406 |
|
| 1407 |
if (negated && (opCode == CCAND) || !negated && (opCode == CCOR || opCode == CCEQ)) { |
| 1408 |
bool allClashFoundFlag = true; |
| 1409 |
bool oneClashFreeFoundFlag = false; |
| 1410 |
bool oneUnknownFound = false; |
| 1411 |
for (CSortedNegLinker<CConcept*>* operandLinker = concept->getOperandList(); !oneClashFreeFoundFlag && operandLinker; operandLinker = operandLinker->getNext()) { |
| 1412 |
CConcept* opConcept = operandLinker->getData(); |
| 1413 |
bool opConNegation = operandLinker->isNegated() ^ negated; |
| 1414 |
|
| 1415 |
bool tmpClashFoundFlag = false; |
| 1416 |
bool tmpClashFreeFoundFlag = false; |
| 1417 |
bool tmpUnknownFound = false; |
| 1418 |
checkCanHaveClashWithModel(indiNode,opConcept,opConNegation,tmpClashFoundFlag,tmpUnknownFound,tmpClashFreeFoundFlag,depth+1,testedIndividualsSet,indiNode,indiNodeVec); |
| 1419 |
|
| 1420 |
oneClashFreeFoundFlag |= tmpClashFreeFoundFlag; |
| 1421 |
oneUnknownFound |= tmpUnknownFound; |
| 1422 |
allClashFoundFlag &= tmpClashFoundFlag; |
| 1423 |
} |
| 1424 |
|
| 1425 |
if (oneClashFreeFoundFlag) { |
| 1426 |
clashFreeFlag = true; |
| 1427 |
} else if (allClashFoundFlag) { |
| 1428 |
clashFoundFlag = true; |
| 1429 |
} else { |
| 1430 |
unknownFlag = true; |
| 1431 |
} |
| 1432 |
} else if (opCount == 1 && (opCode == CCOR || opCode == CCEQ || opCode == CCAND)) { |
| 1433 |
|
| 1434 |
CSortedNegLinker<CConcept*>* operandLinker = concept->getOperandList(); |
| 1435 |
CConcept* opConcept = operandLinker->getData(); |
| 1436 |
bool opConNegation = operandLinker->isNegated() ^ negated; |
| 1437 |
checkCanHaveClashWithModel(indiNode,opConcept,opConNegation,clashFoundFlag,unknownFlag,clashFreeFlag,depth+1,testedIndividualsSet,indiNode,indiNodeVec); |
| 1438 |
|
| 1439 |
} else if (negated && (opCode == CCSUB || conOperator->hasPartialOperatorCodeFlag(CConceptOperator::CCFS_TRIG_TYPE))) { |
| 1440 |
clashFreeFlag = true; |
| 1441 |
} else if (opCode == CCAQCHOOCE) { |
| 1442 |
|
| 1443 |
bool allClashFoundFlag = true; |
| 1444 |
bool oneClashFreeFoundFlag = false; |
| 1445 |
bool oneUnknownFound = false; |
| 1446 |
for (CSortedNegLinker<CConcept*>* operandLinker = concept->getOperandList(); !oneClashFreeFoundFlag && operandLinker; operandLinker = operandLinker->getNext()) { |
| 1447 |
CConcept* opConcept = operandLinker->getData(); |
| 1448 |
bool opConNegation = operandLinker->isNegated(); |
| 1449 |
|
| 1450 |
if (opConNegation == negated) { |
| 1451 |
|
| 1452 |
bool tmpClashFoundFlag = false; |
| 1453 |
bool tmpClashFreeFoundFlag = false; |
| 1454 |
bool tmpUnknownFound = false; |
| 1455 |
checkCanHaveClashWithModel(indiNode,opConcept,opConNegation,tmpClashFoundFlag,tmpUnknownFound,tmpClashFreeFoundFlag,depth+1,testedIndividualsSet,indiNode,indiNodeVec); |
| 1456 |
|
| 1457 |
oneClashFreeFoundFlag |= tmpClashFreeFoundFlag; |
| 1458 |
oneUnknownFound |= tmpUnknownFound; |
| 1459 |
allClashFoundFlag &= tmpClashFoundFlag; |
| 1460 |
} |
| 1461 |
} |
| 1462 |
|
| 1463 |
if (oneClashFreeFoundFlag) { |
| 1464 |
clashFreeFlag = true; |
| 1465 |
} else if (allClashFoundFlag) { |
| 1466 |
clashFoundFlag = true; |
| 1467 |
} else { |
| 1468 |
unknownFlag = true; |
| 1469 |
} |
| 1470 |
|
| 1471 |
} else if (negated && (opCode == CCSOME) || !negated && (conOperator->hasPartialOperatorCodeFlag(CConceptOperator::CCFS_ALL_AQALL_TYPE))) { |
| 1472 |
CRole* role = concept->getRole(); |
| 1473 |
|
| 1474 |
CRoleSuccessorLinkIterator linkIt = indiNode->getRoleSuccessorLinkIterator(role); |
| 1475 |
if (!linkIt.hasNext()) { |
| 1476 |
clashFreeFlag = true; |
| 1477 |
} else { |
| 1478 |
bool oneClashFoundFlag = false; |
| 1479 |
bool allClashFreeFoundFlag = true; |
| 1480 |
bool oneUnknownFound = false; |
| 1481 |
|
| 1482 |
while (!oneClashFoundFlag && linkIt.hasNext()) { |
| 1483 |
CIndividualLinkEdge* link = linkIt.next(true); |
| 1484 |
cint64 succIndiID = link->getOppositeIndividualID(indiNode->getIndividualNodeID()); |
| 1485 |
CIndividualProcessNode* succIndiNode = indiNodeVec->getData(succIndiID); |
| 1486 |
|
| 1487 |
for (CSortedNegLinker<CConcept*>* operandLinker = concept->getOperandList(); !oneClashFoundFlag && operandLinker; operandLinker = operandLinker->getNext()) { |
| 1488 |
CConcept* opConcept = operandLinker->getData(); |
| 1489 |
bool opConNegation = operandLinker->isNegated() ^ negated; |
| 1490 |
|
| 1491 |
bool tmpClashFoundFlag = false; |
| 1492 |
bool tmpClashFreeFoundFlag = false; |
| 1493 |
bool tmpUnknownFound = false; |
| 1494 |
checkCanHaveClashWithModel(succIndiNode,opConcept,opConNegation,tmpClashFoundFlag,tmpUnknownFound,tmpClashFreeFoundFlag,depth+1,testedIndividualsSet,indiNode,indiNodeVec); |
| 1495 |
|
| 1496 |
allClashFreeFoundFlag &= tmpClashFreeFoundFlag; |
| 1497 |
oneUnknownFound |= tmpUnknownFound; |
| 1498 |
oneClashFoundFlag |= tmpClashFoundFlag; |
| 1499 |
} |
| 1500 |
} |
| 1501 |
|
| 1502 |
if (oneClashFoundFlag) { |
| 1503 |
clashFreeFlag = true; |
| 1504 |
} else if (allClashFreeFoundFlag) { |
| 1505 |
clashFoundFlag = true; |
| 1506 |
} else { |
| 1507 |
unknownFlag = true; |
| 1508 |
} |
| 1509 |
|
| 1510 |
} |
| 1511 |
|
| 1512 |
} else { |
| 1513 |
unknownFlag = true; |
| 1514 |
} |
| 1515 |
} |
| 1516 |
} |
| 1517 |
} |
| 1518 |
} |
| 1519 |
|
| 1520 |
|
| 1521 |
bool CSatisfiableTaskClassificationMessageAnalyser::analyseSatisfiableTask(CSatisfiableCalculationTask* statCalcTask, CCalculationAlgorithmContext* calcAlgContext) { |
| 1522 |
mStatCalcTask = statCalcTask; |
| 1523 |
mReusePossSubsumMapIterator = nullptr; |
| 1524 |
CSatisfiableTaskClassificationMessageAdapter* classMessAdapter = statCalcTask->getClassificationMessageAdapter(); |
| 1525 |
if (classMessAdapter) { |
| 1526 |
mConRefLinkDataHash = classMessAdapter->getConceptReferenceLinkingDataHash(); |
| 1527 |
CClassificationMessageDataObserver* classMessObserver = classMessAdapter->getClassificationMessageDataObserver(); |
| 1528 |
CClassificationMessageData* subsumMessageDataLinker = nullptr; |
| 1529 |
CClassificationMessageData* possSubsumMessageDataLinker = nullptr; |
| 1530 |
CClassificationMessageData* pmMessageDataLinker = nullptr; |
| 1531 |
|
| 1532 |
bool extractSubsumersRootNode = classMessAdapter->hasExtractionFlags(CSatisfiableTaskClassificationMessageAdapter::EFEXTRACTSUBSUMERSROOTNODE); |
| 1533 |
bool extractSubsumersOtherNodes = classMessAdapter->hasExtractionFlags(CSatisfiableTaskClassificationMessageAdapter::EFEXTRACTSUBSUMERSOTHERNODES); |
| 1534 |
|
| 1535 |
bool extractPossibleSubsumersRootNode = classMessAdapter->hasExtractionFlags(CSatisfiableTaskClassificationMessageAdapter::EFEXTRACTPOSSIBLESUBSUMERSROOTNODE); |
| 1536 |
bool extractPossibleSubsumersOtherNodes = classMessAdapter->hasExtractionFlags(CSatisfiableTaskClassificationMessageAdapter::EFEXTRACTPOSSIBLESUBSUMERSOTHERNODES); |
| 1537 |
|
| 1538 |
bool extractPseudoModelRootNode = classMessAdapter->hasExtractionFlags(CSatisfiableTaskClassificationMessageAdapter::EFEXTRACTIDENTIFIERPSEUDOMODEL); |
| 1539 |
|
| 1540 |
|
| 1541 |
bool extractOtherNodesSingleDependency = classMessAdapter->hasExtractionFlags(CSatisfiableTaskClassificationMessageAdapter::EFEXTRACTOTHERNODESSINGLEDEPENDENCY); |
| 1542 |
bool extractOtherNodesMultipleDependency = classMessAdapter->hasExtractionFlags(CSatisfiableTaskClassificationMessageAdapter::EFEXTRACTOTHERNODESMULTIPLEDEPENDENCY); |
| 1543 |
|
| 1544 |
|
| 1545 |
bool considerRootNode = extractSubsumersRootNode | extractPossibleSubsumersRootNode; |
| 1546 |
bool considerOtherNode = extractSubsumersOtherNodes | extractPossibleSubsumersOtherNodes; |
| 1547 |
|
| 1548 |
mMultiplePossSubsumInitAvoidHash = nullptr; |
| 1549 |
mLastMergingTestNode = nullptr; |
| 1550 |
mTestSaturatedMergedHash = nullptr; |
| 1551 |
|
| 1552 |
CTaskProcessorContext* taskProcessorContext = calcAlgContext->getUsedTaskProcessorContext(); |
| 1553 |
CTaskHandleMemoryAllocationManager* taskMemMan = calcAlgContext->getTemporaryMemoryAllocationManager(); |
| 1554 |
CConcept* testingConcept = classMessAdapter->getTestingConcept(); |
| 1555 |
|
| 1556 |
//QString iriClassNameString = CIRIName::getRecentIRIName(testingConcept->getClassNameLinker()); |
| 1557 |
//if (iriClassNameString == "http://www.owllink.org/testsuite/galen#LowerLobeOfLeftLung") { |
| 1558 |
// bool bug = true; |
| 1559 |
//} |
| 1560 |
//} |
| 1561 |
//considerOtherNode = false; |
| 1562 |
|
| 1563 |
CConcreteOntology* testOntology = classMessAdapter->getTestingOntology(); |
| 1564 |
CProcessingDataBox* processingDataBox = statCalcTask->getProcessingDataBox(); |
| 1565 |
CIndividualProcessNode* constructedIndiNode = processingDataBox->getConstructedIndividualNode(); |
| 1566 |
CIndividualProcessNodeVector* indiNodeVec = processingDataBox->getIndividualProcessNodeVector(); |
| 1567 |
|
| 1568 |
cint64 maxDetBranchTag = processingDataBox->getMaximumDeterministicBranchTag(); |
| 1569 |
|
| 1570 |
if (processingDataBox->getOntology()->getDataBoxes()->getMBox()->getValueSpacesTriggers(false)) { |
| 1571 |
extractPseudoModelRootNode = false; |
| 1572 |
} |
| 1573 |
|
| 1574 |
|
| 1575 |
mUseAlwaysConRefLinkDataHash = false; |
| 1576 |
|
| 1577 |
if (testOntology && testingConcept && constructedIndiNode) { |
| 1578 |
cint64 constructedID = constructedIndiNode->getIndividualNodeID(); |
| 1579 |
bool nondetMerged = false; |
| 1580 |
CIndividualProcessNode* baseIndi = getCorrectedIndividualID(constructedIndiNode,indiNodeVec,&nondetMerged); |
| 1581 |
cint64 baseIndiID = baseIndi->getIndividualNodeID(); |
| 1582 |
if (nondetMerged) { |
| 1583 |
maxDetBranchTag = 0; |
| 1584 |
} |
| 1585 |
|
| 1586 |
CPROCESSINGSET<CConcept*>* analysedConceptSet = nullptr; |
| 1587 |
|
| 1588 |
|
| 1589 |
CMemoryPoolContainer memPoolCon; |
| 1590 |
CTaskMemoryPoolAllocationManager classMessMemManCreaterMemMan(&memPoolCon,calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 1591 |
mTempMemAllocMan = CObjectAllocator<CTaskMemoryPoolAllocationManager>::allocateAndConstruct(&classMessMemManCreaterMemMan); |
| 1592 |
mTempMemAllocMan->initTaskMemoryPoolAllocationManager(&memPoolCon,calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 1593 |
mTmpContext = CObjectParameterizingAllocator< CContextBase,CMemoryAllocationManager* >::allocateAndConstructAndParameterize(mTempMemAllocMan,mTempMemAllocMan); |
| 1594 |
|
| 1595 |
CCLASSSUBSUMPTIONMESSAGELIST<CConcept*>* subsumerList = nullptr; |
| 1596 |
|
| 1597 |
if (considerRootNode) { |
| 1598 |
CReapplyConceptLabelSet* conSet = baseIndi->getReapplyConceptLabelSet(false); |
| 1599 |
if (conSet) { |
| 1600 |
CReapplyConceptLabelSetIterator conSetIt = conSet->getConceptLabelSetIterator(true,true,true); |
| 1601 |
while (conSetIt.hasNext()) { |
| 1602 |
CConceptDescriptor* conDes = conSetIt.getConceptDescriptor(); |
| 1603 |
if (conDes) { |
| 1604 |
CConcept* concept = conDes->getConcept(); |
| 1605 |
bool negated = conDes->getNegation(); |
| 1606 |
|
| 1607 |
if (concept->hasClassName()) { |
| 1608 |
CDependencyTrackPoint* depTrackPoint = conSetIt.getDependencyTrackPoint(); |
| 1609 |
bool deterministic = false; |
| 1610 |
if (depTrackPoint) { |
| 1611 |
if (depTrackPoint->getBranchingTag() <= maxDetBranchTag) { |
| 1612 |
deterministic = true; |
| 1613 |
} |
| 1614 |
} |
| 1615 |
|
| 1616 |
if (extractSubsumersRootNode && deterministic && !negated && concept != testingConcept && concept->getConceptTag() != 1) { |
| 1617 |
if (!subsumerList) { |
| 1618 |
subsumerList = CObjectParameterizingAllocator< CCLASSSUBSUMPTIONMESSAGELIST<CConcept*>,CContext* >::allocateAndConstructAndParameterize(mTempMemAllocMan,mTmpContext); |
| 1619 |
} |
| 1620 |
subsumerList->append(concept); |
| 1621 |
} |
| 1622 |
|
| 1623 |
if (extractPossibleSubsumersRootNode && !negated) { |
| 1624 |
CClassificationMessageData* messageData = extractPossibleSubsumptionInformation(conDes,baseIndi,conSet,calcAlgContext); |
| 1625 |
if (messageData) { |
| 1626 |
possSubsumMessageDataLinker = messageData->append(possSubsumMessageDataLinker); |
| 1627 |
} |
| 1628 |
if (conDes->getConcept() == testingConcept) { |
| 1629 |
//verifySubsumptionPossibleWithModel(CIndividualProcessNode* indiNode, ); |
| 1630 |
} |
| 1631 |
} |
| 1632 |
} |
| 1633 |
} |
| 1634 |
conSetIt.moveNext(); |
| 1635 |
} |
| 1636 |
} |
| 1637 |
|
| 1638 |
CClassificationClassSubsumptionMessageData* subsumMessageData = CObjectAllocator<CClassificationClassSubsumptionMessageData>::allocateAndConstruct(mTempMemAllocMan); |
| 1639 |
subsumMessageData->initClassificationSubsumptionMessageData(testingConcept,subsumerList); |
| 1640 |
subsumMessageDataLinker = subsumMessageData->append(subsumMessageDataLinker); |
| 1641 |
subsumerList = nullptr; |
| 1642 |
STATINC(ANALYSESUBSUMERCOUNT,calcAlgContext); |
| 1643 |
} |
| 1644 |
|
| 1645 |
if (considerOtherNode) { |
| 1646 |
|
| 1647 |
cint64 consideredOtherNodeCount = 0; |
| 1648 |
cint64 extractedPossibleSubsumerOtherNodeCount = 0; |
| 1649 |
|
| 1650 |
CSuccessorIterator succIt(baseIndi->getSuccessorIterator()); |
| 1651 |
if (succIt.hasNext()) { |
| 1652 |
|
| 1653 |
CPROCESSINGHASH<cint64,CIndividualAnalyseProcessItem*> succIndiProcHash(taskProcessorContext); |
| 1654 |
CPROCESSINGLIST<CIndividualAnalyseProcessItem*> succIndiProcList(taskProcessorContext); |
| 1655 |
|
| 1656 |
CIndividualAnalyseProcessItem* baseAncItem = CObjectAllocator<CIndividualAnalyseProcessItem>::allocateAndConstruct(taskMemMan); |
| 1657 |
baseAncItem->initIndividualAnalyseProcessItem(baseIndi->getIndividualNodeID(),0,nullptr,nullptr); |
| 1658 |
|
| 1659 |
succIndiProcHash.insert(0,baseAncItem); |
| 1660 |
while (succIt.hasNext()) { |
| 1661 |
CIndividualLinkEdge* succLink = succIt.nextLink(); |
| 1662 |
cint64 succIndiID = succLink->getOppositeIndividualID(baseIndiID); |
| 1663 |
if (!succIndiProcHash.contains(succIndiID)) { |
| 1664 |
CIndividualAnalyseProcessItem* indiAnProcItem = CObjectAllocator<CIndividualAnalyseProcessItem>::allocateAndConstruct(taskMemMan); |
| 1665 |
indiAnProcItem->initIndividualAnalyseProcessItem(succIndiID,1,baseAncItem,succLink); |
| 1666 |
succIndiProcHash.insert(succIndiID,indiAnProcItem); |
| 1667 |
succIndiProcList.append(indiAnProcItem); |
| 1668 |
} |
| 1669 |
} |
| 1670 |
|
| 1671 |
|
| 1672 |
while (!succIndiProcList.isEmpty()) { |
| 1673 |
++consideredOtherNodeCount; |
| 1674 |
|
| 1675 |
CIndividualAnalyseProcessItem* indiAnProcItem = succIndiProcList.takeFirst(); |
| 1676 |
cint64 indiID = indiAnProcItem->mIndiID; |
| 1677 |
CIndividualProcessNode* indiNode = indiNodeVec->getData(indiID); |
| 1678 |
if (!indiNode->isNominalIndividualNode() && !indiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFINVALIDATEBLOCKERFLAGSCOMPINATION)) { |
| 1679 |
CConceptDescriptor* analyseConDes = nullptr; |
| 1680 |
CConceptDescriptor* conDesSingleDep = nullptr; |
| 1681 |
|
| 1682 |
CReapplyConceptLabelSet* conSet = indiNode->getReapplyConceptLabelSet(false); |
| 1683 |
CConceptDescriptor* conDesMultipleIt = conSet->getAddingSortedConceptDescriptionLinker(); |
| 1684 |
|
| 1685 |
if (extractOtherNodesMultipleDependency) { |
| 1686 |
analyseConDes = conDesMultipleIt; |
| 1687 |
if (conDesMultipleIt) { |
| 1688 |
conDesMultipleIt = conDesMultipleIt->getNext(); |
| 1689 |
} |
| 1690 |
} |
| 1691 |
if (conDesMultipleIt || extractOtherNodesSingleDependency) { |
| 1692 |
if (!indiNode->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFSUCCESSORNOMINALCONNECTION)) { |
| 1693 |
conDesSingleDep = getIndividualProcessNodeConceptWithSingleAncestorDependency(indiNode,indiAnProcItem,calcAlgContext); |
| 1694 |
} |
| 1695 |
} |
| 1696 |
if (!conDesSingleDep) { |
| 1697 |
analyseConDes = conDesMultipleIt; |
| 1698 |
} |
| 1699 |
while (analyseConDes) { |
| 1700 |
if (analyseConDes && analyseConDes->getConcept() != testingConcept && analyseConDes->getConceptTag() != 1 && !analyseConDes->isNegated() && analyseConDes->getConcept()->hasClassName()) { |
| 1701 |
CConcept* analyseConcept = analyseConDes->getConcept(); |
| 1702 |
|
| 1703 |
// test whether the concept has already been analyzed |
| 1704 |
bool analysationRequired = false; |
| 1705 |
CConceptReferenceLinking* conRefLinking = nullptr; |
| 1706 |
CConceptData* conData = analyseConcept->getConceptData(); |
| 1707 |
if (conData && !mUseAlwaysConRefLinkDataHash) { |
| 1708 |
CConceptProcessData* conProcData = (CConceptProcessData*)conData; |
| 1709 |
if (!conProcData->isInvalidatedReferenceLinking()) { |
| 1710 |
conRefLinking = conProcData->getConceptReferenceLinking(); |
| 1711 |
} |
| 1712 |
} |
| 1713 |
CClassificationConceptReferenceLinking* classConRefLinkData = nullptr; |
| 1714 |
if (!conRefLinking) { |
| 1715 |
classConRefLinkData = mConRefLinkDataHash->value(analyseConcept); |
| 1716 |
} else { |
| 1717 |
CConceptSatisfiableReferenceLinkingData* conSatRefLinkData = (CConceptSatisfiableReferenceLinkingData*)conRefLinking; |
| 1718 |
classConRefLinkData = conSatRefLinkData->getClassifierReferenceLinkingData(); |
| 1719 |
} |
| 1720 |
if (classConRefLinkData) { |
| 1721 |
CClassificationSatisfiableCalculationConceptReferenceLinking* classSatCalcConRefLinkData = (CClassificationSatisfiableCalculationConceptReferenceLinking*)classConRefLinkData; |
| 1722 |
analysationRequired = classSatCalcConRefLinkData->isMoreConceptClassificationInformationRequired(); |
| 1723 |
} |
| 1724 |
|
| 1725 |
|
| 1726 |
CDependencyTrackPoint* analyseDepTrackPoint = analyseConDes->getDependencyTrackPoint(); |
| 1727 |
if (analysationRequired && analyseDepTrackPoint) { |
| 1728 |
cint64 analyseBranchTag = analyseDepTrackPoint->getBranchingTag(); |
| 1729 |
bool branchingError = false; |
| 1730 |
|
| 1731 |
if (!analysedConceptSet) { |
| 1732 |
analysedConceptSet = CObjectParameterizingAllocator< CPROCESSINGSET<CConcept*>,CContext* >::allocateAndConstructAndParameterize(taskMemMan,taskProcessorContext); |
| 1733 |
} |
| 1734 |
if (!analysedConceptSet->contains(analyseConcept)) { |
| 1735 |
analysedConceptSet->insert(analyseConcept); |
| 1736 |
|
| 1737 |
if (extractSubsumersOtherNodes && analyseConDes == conDesSingleDep) { |
| 1738 |
|
| 1739 |
if (conSet) { |
| 1740 |
CReapplyConceptLabelSetIterator conSetIt = conSet->getConceptLabelSetIterator(true,true,false); |
| 1741 |
while (conSetIt.hasNext() && !branchingError) { |
| 1742 |
CConceptDescriptor* conDes = conSetIt.getConceptDescriptor(); |
| 1743 |
if (conDes) { |
| 1744 |
CConcept* concept = conDes->getConcept(); |
| 1745 |
bool negated = conDes->getNegation(); |
| 1746 |
|
| 1747 |
if (concept->hasClassName()) { |
| 1748 |
CDependencyTrackPoint* depTrackPoint = conSetIt.getDependencyTrackPoint(); |
| 1749 |
bool deterministic = false; |
| 1750 |
if (depTrackPoint) { |
| 1751 |
if (depTrackPoint->getBranchingTag() == analyseBranchTag) { |
| 1752 |
deterministic = true; |
| 1753 |
} else if (depTrackPoint->getBranchingTag() < analyseBranchTag) { |
| 1754 |
branchingError = true; |
| 1755 |
} |
| 1756 |
} |
| 1757 |
|
| 1758 |
if (deterministic && !negated && concept != analyseConcept && concept->getConceptTag() != 1) { |
| 1759 |
if (!subsumerList) { |
| 1760 |
subsumerList = CObjectParameterizingAllocator< CCLASSSUBSUMPTIONMESSAGELIST<CConcept*>,CContext* >::allocateAndConstructAndParameterize(mTempMemAllocMan,mTmpContext); |
| 1761 |
} |
| 1762 |
subsumerList->append(concept); |
| 1763 |
} |
| 1764 |
} |
| 1765 |
} |
| 1766 |
conSetIt.moveNext(); |
| 1767 |
} |
| 1768 |
} |
| 1769 |
} |
| 1770 |
|
| 1771 |
if (!branchingError && subsumerList) { |
| 1772 |
CClassificationClassSubsumptionMessageData* subsumMessageData = CObjectAllocator<CClassificationClassSubsumptionMessageData>::allocateAndConstruct(mTempMemAllocMan); |
| 1773 |
subsumMessageData->initClassificationSubsumptionMessageData(analyseConcept,subsumerList); |
| 1774 |
subsumMessageDataLinker = subsumMessageData->append(subsumMessageDataLinker); |
| 1775 |
subsumerList = nullptr; |
| 1776 |
STATINC(ANALYSESUBSUMERCOUNT,calcAlgContext); |
| 1777 |
} |
| 1778 |
|
| 1779 |
if (extractPossibleSubsumersOtherNodes) { |
| 1780 |
CClassificationMessageData* messageData = extractPossibleSubsumptionInformation(analyseConDes,indiNode,conSet,calcAlgContext); |
| 1781 |
if (messageData) { |
| 1782 |
++extractedPossibleSubsumerOtherNodeCount; |
| 1783 |
possSubsumMessageDataLinker = messageData->append(possSubsumMessageDataLinker); |
| 1784 |
} |
| 1785 |
} |
| 1786 |
|
| 1787 |
} |
| 1788 |
} |
| 1789 |
} |
| 1790 |
|
| 1791 |
if (extractOtherNodesMultipleDependency) { |
| 1792 |
if (analyseConDes == conDesMultipleIt) { |
| 1793 |
conDesMultipleIt = conDesMultipleIt->getNext(); |
| 1794 |
} |
| 1795 |
analyseConDes = conDesMultipleIt; |
| 1796 |
if (conDesMultipleIt) { |
| 1797 |
conDesMultipleIt = conDesMultipleIt->getNext(); |
| 1798 |
} |
| 1799 |
} else { |
| 1800 |
analyseConDes = nullptr; |
| 1801 |
} |
| 1802 |
} |
| 1803 |
|
| 1804 |
|
| 1805 |
// next successor nodes |
| 1806 |
CSuccessorIterator nextSuccIt(indiNode->getSuccessorIterator()); |
| 1807 |
while (nextSuccIt.hasNext()) { |
| 1808 |
CIndividualLinkEdge* nextSuccLink = nextSuccIt.nextLink(); |
| 1809 |
cint64 nextSuccIndiID = nextSuccLink->getOppositeIndividualID(indiID); |
| 1810 |
if (!succIndiProcHash.contains(nextSuccIndiID)) { |
| 1811 |
CIndividualAnalyseProcessItem* nextIndiAnProcItem = CObjectAllocator<CIndividualAnalyseProcessItem>::allocateAndConstruct(taskMemMan); |
| 1812 |
nextIndiAnProcItem->initIndividualAnalyseProcessItem(nextSuccIndiID,indiAnProcItem->mRootDistance+1,indiAnProcItem,nextSuccLink); |
| 1813 |
succIndiProcHash.insert(nextSuccIndiID,nextIndiAnProcItem); |
| 1814 |
succIndiProcList.append(nextIndiAnProcItem); |
| 1815 |
} |
| 1816 |
} |
| 1817 |
|
| 1818 |
} |
| 1819 |
} |
| 1820 |
} |
| 1821 |
|
| 1822 |
mStatConsideredOtherNodeCount += consideredOtherNodeCount; |
| 1823 |
mStatExtractedPossibleSubsumerOtherNodeCount += extractedPossibleSubsumerOtherNodeCount; |
| 1824 |
} |
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
if (extractPseudoModelRootNode) { |
| 1833 |
|
| 1834 |
// create pseudo model |
| 1835 |
|
| 1836 |
mMaxPseudoModelDepth = 3; |
| 1837 |
mMaxPseudoModelNodes = 30; |
| 1838 |
|
| 1839 |
cint64 currentPMModelNodesCount = 0; |
| 1840 |
|
| 1841 |
CConceptReferenceLinking* conRefLinking = nullptr; |
| 1842 |
CConceptData* conData = testingConcept->getConceptData(); |
| 1843 |
if (conData && !mUseAlwaysConRefLinkDataHash) { |
| 1844 |
CConceptProcessData* conProcData = (CConceptProcessData*)conData; |
| 1845 |
if (!conProcData->isInvalidatedReferenceLinking()) { |
| 1846 |
conRefLinking = conProcData->getConceptReferenceLinking(); |
| 1847 |
} |
| 1848 |
} |
| 1849 |
CClassificationConceptReferenceLinking* classConRefLinkData = nullptr; |
| 1850 |
if (!conRefLinking) { |
| 1851 |
classConRefLinkData = mConRefLinkDataHash->value(testingConcept); |
| 1852 |
} else { |
| 1853 |
CConceptSatisfiableReferenceLinkingData* conSatRefLinkData = (CConceptSatisfiableReferenceLinkingData*)conRefLinking; |
| 1854 |
classConRefLinkData = conSatRefLinkData->getClassifierReferenceLinkingData(); |
| 1855 |
} |
| 1856 |
if (classConRefLinkData) { |
| 1857 |
CClassificationSatisfiablePossibleSubsumptionCalculationConceptReferenceLinking* possSubsumRefLinkData = (CClassificationSatisfiablePossibleSubsumptionCalculationConceptReferenceLinking*)classConRefLinkData; |
| 1858 |
if (possSubsumRefLinkData) { |
| 1859 |
|
| 1860 |
CMemoryPoolContainer pmMemPoolCon; |
| 1861 |
CTaskMemoryPoolAllocationManager classMessMemManCreaterMemMan(&pmMemPoolCon,calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 1862 |
mPMTempMemAllocMan = CObjectAllocator<CTaskMemoryPoolAllocationManager>::allocateAndConstruct(&classMessMemManCreaterMemMan); |
| 1863 |
mPMTempMemAllocMan->initTaskMemoryPoolAllocationManager(&pmMemPoolCon,calcAlgContext->getTemporaryMemoryAllocationManager()); |
| 1864 |
mPMTmpContext = CObjectParameterizingAllocator< CContextBase,CMemoryAllocationManager* >::allocateAndConstructAndParameterize(mPMTempMemAllocMan,mPMTempMemAllocMan); |
| 1865 |
|
| 1866 |
|
| 1867 |
CClassificationClassPseudoModel* pmModel = possSubsumRefLinkData->getClassPseudoModel(); |
| 1868 |
CClassificationClassPseudoModelHash* pmModelHash = CObjectParameterizingAllocator< CClassificationClassPseudoModelHash,CContext* >::allocateAndConstructAndParameterize(mPMTempMemAllocMan,mPMTmpContext); |
| 1869 |
cint64 nextModelID = 1; |
| 1870 |
|
| 1871 |
CPseudoModelAnalyseProcessItem* basePMItem = CObjectAllocator<CPseudoModelAnalyseProcessItem>::allocateAndConstruct(taskMemMan); |
| 1872 |
basePMItem->initPseudoModelAnalyseProcessItem(0,0); |
| 1873 |
CXNegLinker<CIndividualProcessNode*>* pmBaseNodeLinker = CObjectAllocator< CXNegLinker<CIndividualProcessNode*> >::allocateAndConstruct(taskMemMan); |
| 1874 |
pmBaseNodeLinker->initNegLinker(baseIndi,false); |
| 1875 |
basePMItem->addNodeLinker(pmBaseNodeLinker); |
| 1876 |
|
| 1877 |
CXLinker<CPseudoModelAnalyseProcessItem*>* processItemLinker = CObjectAllocator< CXLinker<CPseudoModelAnalyseProcessItem*> >::allocateAndConstruct(taskMemMan); |
| 1878 |
processItemLinker->initLinker(basePMItem); |
| 1879 |
|
| 1880 |
|
| 1881 |
while (processItemLinker) { |
| 1882 |
++currentPMModelNodesCount; |
| 1883 |
CXLinker<CPseudoModelAnalyseProcessItem*>* tmpItemLinker = processItemLinker; |
| 1884 |
processItemLinker = processItemLinker->getNext(); |
| 1885 |
|
| 1886 |
|
| 1887 |
CPseudoModelAnalyseProcessItem* pmAnalyseProcessItem = tmpItemLinker->getData(); |
| 1888 |
cint64 pmModelID = pmAnalyseProcessItem->mPMModelID; |
| 1889 |
CClassificationClassPseudoModelData* pmModel = pmModelHash->getPseudoModelData(pmModelID,true); |
| 1890 |
|
| 1891 |
|
| 1892 |
bool vaidConcepts = true; |
| 1893 |
bool vaidSuccessors = true; |
| 1894 |
|
| 1895 |
|
| 1896 |
for (CXNegLinker<CIndividualProcessNode*>* nodeIt = pmAnalyseProcessItem->mNodeLinker; nodeIt; nodeIt = nodeIt->getNext()) { |
| 1897 |
CIndividualProcessNode* node = nodeIt->getData(); |
| 1898 |
|
| 1899 |
bool blockedOrCached = node->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFINVALIDATEBLOCKERFLAGSCOMPINATION | CIndividualProcessNode::PRFSATURATIONBLOCKINGCACHED | CIndividualProcessNode::PRFSYNCHRONIZEDBACKENDSUCCESSOREXPANSIONBLOCKED) || node->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFCOMPLETIONGRAPHCACHED) && !node->hasPartialProcessingRestrictionFlags(CIndividualProcessNode::PRFCOMPLETIONGRAPHCACHINGINVALID |CIndividualProcessNode::PRFCOMPLETIONGRAPHCACHINGINVALIDATED); |
| 1900 |
if (blockedOrCached) { |
| 1901 |
vaidConcepts = false; |
| 1902 |
vaidSuccessors = false; |
| 1903 |
} |
| 1904 |
bool nominalNode = node->isNominalIndividualNode(); |
| 1905 |
if (nominalNode) { |
| 1906 |
vaidSuccessors = false; |
| 1907 |
} |
| 1908 |
} |
| 1909 |
if (pmAnalyseProcessItem->mRootDistance > mMaxPseudoModelDepth || currentPMModelNodesCount > mMaxPseudoModelNodes) { |
| 1910 |
vaidSuccessors = false; |
| 1911 |
} |
| 1912 |
|
| 1913 |
pmModel->setValidConceptMap(vaidConcepts); |
| 1914 |
pmModel->setValidRoleMap(vaidSuccessors); |
| 1915 |
|
| 1916 |
if (vaidConcepts) { |
| 1917 |
// update pseudo model concept map |
| 1918 |
CClassificationClassPseudoModelConceptMap* pmModelConMap = pmModel->getPseudoModelConceptMap(true); |
| 1919 |
for (CXNegLinker<CIndividualProcessNode*>* nodeIt = pmAnalyseProcessItem->mNodeLinker; nodeIt; nodeIt = nodeIt->getNext()) { |
| 1920 |
bool nonDeterministicConnected = nodeIt->isNegated(); |
| 1921 |
CIndividualProcessNode* node = nodeIt->getData(); |
| 1922 |
CReapplyConceptLabelSet* conSet = node->getReapplyConceptLabelSet(false); |
| 1923 |
if (conSet) { |
| 1924 |
CReapplyConceptLabelSetIterator conSetIt = conSet->getConceptLabelSetIterator(true,true,false); |
| 1925 |
while (conSetIt.hasNext()) { |
| 1926 |
CConceptDescriptor* conDes = conSetIt.getConceptDescriptor(); |
| 1927 |
if (conDes) { |
| 1928 |
CDependencyTrackPoint* depTrackPoint = conSetIt.getDependencyTrackPoint(); |
| 1929 |
bool deterministic = false; |
| 1930 |
if (depTrackPoint) { |
| 1931 |
if (depTrackPoint->getBranchingTag() <= maxDetBranchTag) { |
| 1932 |
if (!nonDeterministicConnected) { |
| 1933 |
deterministic = true; |
| 1934 |
} |
| 1935 |
} |
| 1936 |
} |
| 1937 |
CConcept* concept = conDes->getConcept(); |
| 1938 |
cint64 conOpCode = concept->getOperatorCode(); |
| 1939 |
bool insertCon = false; |
| 1940 |
if (!conDes->isNegated()) { |
| 1941 |
if ((concept->hasClassName() && conOpCode == CCATOM) || conOpCode == CCSUB || conOpCode == CCIMPLTRIG || conOpCode == CCEQCAND) { |
| 1942 |
insertCon = true; |
| 1943 |
} |
| 1944 |
} |
| 1945 |
|
| 1946 |
if (insertCon) { |
| 1947 |
pmModelConMap->insert(CConceptTagComparer(concept),CClassificationClassPseudoModelConceptData(deterministic)); |
| 1948 |
} |
| 1949 |
} |
| 1950 |
conSetIt.moveNext(); |
| 1951 |
} |
| 1952 |
} |
| 1953 |
} |
| 1954 |
} |
| 1955 |
|
| 1956 |
if (vaidSuccessors) { |
| 1957 |
// update pseudo model role map |
| 1958 |
CPROCESSINGSET<CRole*> processedRoles(taskProcessorContext); |
| 1959 |
CClassificationClassPseudoModelRoleMap* pmModelRoleMap = pmModel->getPseudoModelRoleMap(true); |
| 1960 |
for (CXNegLinker<CIndividualProcessNode*>* nodeIt = pmAnalyseProcessItem->mNodeLinker; nodeIt; nodeIt = nodeIt->getNext()) { |
| 1961 |
bool nonDeterministicConnected = nodeIt->isNegated(); |
| 1962 |
CIndividualProcessNode* node = nodeIt->getData(); |
| 1963 |
CRoleSuccessorIterator roleIt = node->getRoleIterator(); |
| 1964 |
while (roleIt.hasNext()) { |
| 1965 |
CRole* role = roleIt.next(); |
| 1966 |
if (!role->isComplexRole()) { |
| 1967 |
// do not analyze complex roles |
| 1968 |
if (!processedRoles.contains(role)) { |
| 1969 |
processedRoles.insert(role); |
| 1970 |
|
| 1971 |
|
| 1972 |
CPROCESSINGSET<cint64> roleSuccessorIDSet(taskProcessorContext); |
| 1973 |
// collect all successors for this role over all nodes |
| 1974 |
|
| 1975 |
cint64 lowerDetAtLeastBound = 0; |
| 1976 |
cint64 upperAtLeastBound = 0; |
| 1977 |
|
| 1978 |
cint64 upperDetAtMostBound = CINT64_MAX; |
| 1979 |
cint64 lowerAtMostBound = CINT64_MAX; |
| 1980 |
|
| 1981 |
CXNegLinker<CIndividualProcessNode*>* succNodeLinker = nullptr; |
| 1982 |
|
| 1983 |
bool hasDeterministicSuccessor = false; |
| 1984 |
|
| 1985 |
|
| 1986 |
for (CXNegLinker<CIndividualProcessNode*>* nodeIt2 = pmAnalyseProcessItem->mNodeLinker; nodeIt2; nodeIt2 = nodeIt2->getNext()) { |
| 1987 |
CIndividualProcessNode* node2 = nodeIt2->getData(); |
| 1988 |
|
| 1989 |
CReapplyRoleSuccessorHash* roleSuccHash = node2->getReapplyRoleSuccessorHash(false); |
| 1990 |
if (roleSuccHash) { |
| 1991 |
cint64 linkCount = 0; |
| 1992 |
CRoleSuccessorLinkIterator roleSuccIt = roleSuccHash->getRoleSuccessorLinkIterator(role,&linkCount); |
| 1993 |
upperAtLeastBound = qMax(upperAtLeastBound,linkCount); |
| 1994 |
lowerAtMostBound = qMin(lowerAtMostBound,linkCount); |
| 1995 |
while (roleSuccIt.hasNext()) { |
| 1996 |
CIndividualLinkEdge* succLink = roleSuccIt.next(); |
| 1997 |
cint64 succIndiID = succLink->getOppositeIndividualID(node2); |
| 1998 |
if (!roleSuccessorIDSet.contains(succIndiID)) { |
| 1999 |
roleSuccessorIDSet.insert(succIndiID); |
| 2000 |
|
| 2001 |
bool deterministicLink = !nonDeterministicConnected; |
| 2002 |
CDependencyTrackPoint* depTrackPoint = succLink->getDependencyTrackPoint(); |
| 2003 |
if (depTrackPoint && depTrackPoint->getBranchingTag() <= maxDetBranchTag) { |
| 2004 |
lowerDetAtLeastBound = qMax(lowerDetAtLeastBound,(cint64)1); |
| 2005 |
if (!nonDeterministicConnected) { |
| 2006 |
hasDeterministicSuccessor = true; |
| 2007 |
} |
| 2008 |
deterministicLink = false; |
| 2009 |
} |
| 2010 |
|
| 2011 |
CIndividualProcessNode* succIndiNode = indiNodeVec->getData(succIndiID); |
| 2012 |
CXNegLinker<CIndividualProcessNode*>* nextSuccNodeLinker = CObjectAllocator< CXNegLinker<CIndividualProcessNode*> >::allocateAndConstruct(taskMemMan); |
| 2013 |
nextSuccNodeLinker->initNegLinker(succIndiNode,deterministicLink); |
| 2014 |
succNodeLinker = nextSuccNodeLinker->append(succNodeLinker); |
| 2015 |
|
| 2016 |
} |
| 2017 |
} |
| 2018 |
} else { |
| 2019 |
lowerAtMostBound = 0; |
| 2020 |
} |
| 2021 |
|
| 2022 |
|
| 2023 |
CReapplyConceptLabelSet* conSet = node2->getReapplyConceptLabelSet(false); |
| 2024 |
if (conSet) { |
| 2025 |
for (CConceptDescriptor* conDesLinkerIt = conSet->getAddingSortedConceptDescriptionLinker(); conDesLinkerIt; conDesLinkerIt = conDesLinkerIt->getNextConceptDesciptor()) { |
| 2026 |
CConcept* concept = conDesLinkerIt->getConcept(); |
| 2027 |
if (concept->getRole() == role) { |
| 2028 |
bool conNegation = conDesLinkerIt->getNegation(); |
| 2029 |
cint64 opCode = concept->getOperatorCode(); |
| 2030 |
CDependencyTrackPoint* depTrackPoint = conDesLinkerIt->getDependencyTrackPoint(); |
| 2031 |
if (depTrackPoint && depTrackPoint->getBranchingTag() <= maxDetBranchTag) { |
| 2032 |
if (!conNegation && opCode == CCATLEAST || conNegation && opCode == CCATMOST) { |
| 2033 |
cint64 atLeastParam = concept->getParameter() + 1 * conNegation; |
| 2034 |
if (atLeastParam >= 0) { |
| 2035 |
lowerDetAtLeastBound = qMax(lowerDetAtLeastBound,atLeastParam); |
| 2036 |
} |
| 2037 |
} else if (conNegation && opCode == CCATLEAST || !conNegation && opCode == CCATMOST && concept->getOperandList() == nullptr) { |
| 2038 |
cint64 atMostParam = concept->getParameter() - 1 * conNegation; |
| 2039 |
if (atMostParam >= 0) { |
| 2040 |
upperDetAtMostBound = qMin(upperDetAtMostBound,atMostParam); |
| 2041 |
} |
| 2042 |
} |
| 2043 |
} |
| 2044 |
} |
| 2045 |
} |
| 2046 |
} |
| 2047 |
} |
| 2048 |
|
| 2049 |
|
| 2050 |
cint64 succPMModelID = 0; |
| 2051 |
|
| 2052 |
|
| 2053 |
if (succPMModelID == 0) { |
| 2054 |
succPMModelID = nextModelID++; |
| 2055 |
} |
| 2056 |
|
| 2057 |
CClassificationClassPseudoModelRoleData& roleSuccModelData = (*pmModelRoleMap)[CRoleTagComparer(role)]; |
| 2058 |
roleSuccModelData.setSuccessorModelID(succPMModelID); |
| 2059 |
roleSuccModelData.setDeterministic(hasDeterministicSuccessor); |
| 2060 |
roleSuccModelData.setLowerAtLeastBound(lowerDetAtLeastBound); |
| 2061 |
roleSuccModelData.setUpperAtLeastBound(upperAtLeastBound); |
| 2062 |
roleSuccModelData.setUpperAtMostBound(upperDetAtMostBound); |
| 2063 |
roleSuccModelData.setLowerAtMostBound(lowerAtMostBound); |
| 2064 |
|
| 2065 |
CPseudoModelAnalyseProcessItem* roleSuccessorsPMItem = CObjectAllocator<CPseudoModelAnalyseProcessItem>::allocateAndConstruct(taskMemMan); |
| 2066 |
roleSuccessorsPMItem->initPseudoModelAnalyseProcessItem(succPMModelID,pmAnalyseProcessItem->mRootDistance+1); |
| 2067 |
roleSuccessorsPMItem->addNodeLinker(succNodeLinker); |
| 2068 |
|
| 2069 |
CXLinker<CPseudoModelAnalyseProcessItem*>* nextProcessItemLinker = CObjectAllocator< CXLinker<CPseudoModelAnalyseProcessItem*> >::allocateAndConstruct(taskMemMan); |
| 2070 |
nextProcessItemLinker->initLinker(roleSuccessorsPMItem); |
| 2071 |
processItemLinker = nextProcessItemLinker->append(processItemLinker); |
| 2072 |
|
| 2073 |
|
| 2074 |
} |
| 2075 |
} |
| 2076 |
} |
| 2077 |
} |
| 2078 |
} |
| 2079 |
|
| 2080 |
} |
| 2081 |
|
| 2082 |
STATINC(ANALYSEPSEUDOMODELCOUNT,calcAlgContext); |
| 2083 |
|
| 2084 |
CClassificationPseudoModelIdentifierMessageData* pmMessageData = CObjectAllocator<CClassificationPseudoModelIdentifierMessageData>::allocateAndConstruct(mTempMemAllocMan); |
| 2085 |
pmMessageData->initClassificationPseudoModelIdentifierMessageData(testingConcept,pmModelHash,pmMemPoolCon.takeMemoryPools()); |
| 2086 |
pmMessageDataLinker = pmMessageData->append(pmMessageDataLinker); |
| 2087 |
|
| 2088 |
|
| 2089 |
} |
| 2090 |
} |
| 2091 |
} |
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
|
| 2097 |
CClassificationMessageData* messageDataLinker = subsumMessageDataLinker; |
| 2098 |
if (pmMessageDataLinker) { |
| 2099 |
messageDataLinker = pmMessageDataLinker->append(messageDataLinker); |
| 2100 |
} |
| 2101 |
if (possSubsumMessageDataLinker) { |
| 2102 |
messageDataLinker = possSubsumMessageDataLinker->append(messageDataLinker); |
| 2103 |
} |
| 2104 |
|
| 2105 |
if (messageDataLinker) { |
| 2106 |
classMessObserver->tellClassificationMessage(testOntology,messageDataLinker,memPoolCon.takeMemoryPools()); |
| 2107 |
} else { |
| 2108 |
taskMemMan->releaseTemporaryMemoryPools(memPoolCon.takeMemoryPools()); |
| 2109 |
} |
| 2110 |
|
| 2111 |
|
| 2112 |
|
| 2113 |
return true; |
| 2114 |
|
| 2115 |
} |
| 2116 |
} |
| 2117 |
return false; |
| 2118 |
} |
| 2119 |
|
| 2120 |
|
| 2121 |
|
| 2122 |
|
| 2123 |
}; // end namespace Algorithm |
| 2124 |
|
| 2125 |
}; // end namespace Kernel |
| 2126 |
|
| 2127 |
}; // end namespace Reasoner |
| 2128 |
|
| 2129 |
}; // end namespace Konclude |