| 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 "COptimizedRepresentativeKPSetOntologyRealizingThread.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Realizer { |
| 29 |
|
| 30 |
|
| 31 |
COptimizedRepresentativeKPSetOntologyRealizingThread::COptimizedRepresentativeKPSetOntologyRealizingThread(CReasonerManager *reasonerManager) : CRealizerThread(reasonerManager),CLogDomain("::Konclude::Reasoner::Kernel::Realizer") { |
| 32 |
mTestedPossibleInstancesCount = 0; |
| 33 |
mOpenPossibleInstancesCount = 0; |
| 34 |
mRealizingCount = 0; |
| 35 |
|
| 36 |
mBackendAssocCache = nullptr; |
| 37 |
CBackendCache* backendCache = reasonerManager->getBackendAssociationCache(); |
| 38 |
if (backendCache) { |
| 39 |
mBackendAssocCache = dynamic_cast<CBackendRepresentativeMemoryCache*>(backendCache); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
COptimizedRepresentativeKPSetOntologyRealizingThread::~COptimizedRepresentativeKPSetOntologyRealizingThread() { |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
COntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingThread::initializeOntologyRealizingItem(CConcreteOntology* ontology, CConfigurationBase* config) { |
| 49 |
CBackendRepresentativeMemoryCacheReader* backendAssocCacheReader = nullptr; |
| 50 |
if (mBackendAssocCache) { |
| 51 |
backendAssocCacheReader = mBackendAssocCache->createOntologyFixedCacheReader(ontology->getOntologyID()); |
| 52 |
} |
| 53 |
|
| 54 |
COptimizedRepresentativeKPSetOntologyRealizingItem* item = new COptimizedRepresentativeKPSetOntologyRealizingItem(); |
| 55 |
item->initRequirementConfigRealizingItem(ontology,config, backendAssocCacheReader); |
| 56 |
|
| 57 |
if (mTestedPossibleInstancesCount == mOpenPossibleInstancesCount) { |
| 58 |
mTestedPossibleInstancesCount = 0; |
| 59 |
mOpenPossibleInstancesCount = 0; |
| 60 |
mRealStartTime.start(); |
| 61 |
} |
| 62 |
initializeItems(item); |
| 63 |
++mRealizingCount; |
| 64 |
|
| 65 |
|
| 66 |
CRealization* realization = ontology->getRealization(); |
| 67 |
realization->setConceptRealization(item); |
| 68 |
realization->setRoleRealization(item); |
| 69 |
realization->setSameRealization(item); |
| 70 |
|
| 71 |
|
| 72 |
return item; |
| 73 |
} |
| 74 |
|
| 75 |
void COptimizedRepresentativeKPSetOntologyRealizingThread::readCalculationConfig(CConfigurationBase *config) { |
| 76 |
if (config) { |
| 77 |
mConfPossibleInstanceConceptsUpfrontMerging = CConfigDataReader::readConfigBoolean(config, "Konclude.Calculation.Realization.OptimizedKPSetOntologyConceptRealizer.PossibleInstanceConceptsUpfrontMerging", true); |
| 78 |
mConfPossibleInstanceIndividualsAfterwardsMerging = CConfigDataReader::readConfigBoolean(config, "Konclude.Calculation.Realization.OptimizedKPSetOntologyConceptRealizer.PossibleInstanceIndividualsAfterwardsMerging", true); |
| 79 |
mConfPossibleInstanceIndividualsAfterwardsMergingOnlyWithSameRepresentativeLabel = CConfigDataReader::readConfigBoolean(config, "Konclude.Calculation.Realization.OptimizedKPSetOntologyConceptRealizer.PossibleInstanceIndividualsAfterwardsMergingOnlyWithSameRepresentativeLabel", false); |
| 80 |
mAlternateShufflePossibleConceptInstanceTestingItemsOnCalculations = CConfigDataReader::readConfigBoolean(config, "Konclude.Calculation.Realization.OptimizedKPSetOntologyConceptRealizer.AlternatePossibleConceptInstanceTestingItemsOnCalculations", true); |
| 81 |
mConfPossibleInstanceIndividualsAfterwardsMergingProvidingCount = CConfigDataReader::readConfigInteger(config, "Konclude.Calculation.Realization.OptimizedKPSetOntologyConceptRealizer.PossibleInstanceIndividualsAfterwardsMergingProvidingCount", -1); |
| 82 |
mConfPossibleInstanceIndividualsAfterwardsMergingMaximumAttemptCount = CConfigDataReader::readConfigInteger(config, "Konclude.Calculation.Realization.OptimizedKPSetOntologyConceptRealizer.PossibleInstanceIndividualsAfterwardsMergingMaximumAttemptCount", 3); |
| 83 |
mConfMinimumPossibleInstanceIndividualsAfterwardsMergingCount = CConfigDataReader::readConfigInteger(config, "Konclude.Calculation.Realization.OptimizedKPSetOntologyConceptRealizer.PossibleInstanceIndividualsAfterwardsMergingMinimumCount", 10); |
| 84 |
|
| 85 |
mConfNonDeterministicSatisfiableCalculationContinuation = CConfigDataReader::readConfigBoolean(config, "Konclude.Calculation.Realization.NonDeterministicCachedCompletionGraphContinuationPropagationTests", true); |
| 86 |
|
| 87 |
mConfConcurrentIndividualPossibleConceptInstantiationInitialization = CConfigDataReader::readConfigBoolean(config, "Konclude.Calculation.Realization.ConcurrentIndividualPossibleConceptInstantiationInitialization", true); |
| 88 |
mConfConcurrentHandlingVectorSize = 200; |
| 89 |
|
| 90 |
bool configErrorFlag = false; |
| 91 |
cint64 processorCount = 1; |
| 92 |
QString processorCountString = CConfigDataReader::readConfigString(config,"Konclude.Calculation.ProcessorCount",QString(),&configErrorFlag); |
| 93 |
if (!configErrorFlag) { |
| 94 |
if (processorCountString == "AUTO") { |
| 95 |
processorCount = CThread::idealThreadCount(); |
| 96 |
} else { |
| 97 |
qint64 convertedWorkerCount = processorCountString.toInt(&configErrorFlag); |
| 98 |
if (configErrorFlag) { |
| 99 |
processorCount = convertedWorkerCount; |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
bool mulConfigErrorFlag = false; |
| 105 |
cint64 multiplicator = CConfigDataReader::readConfigInteger(config,"Konclude.Calculation.Realization.OptimizedKPSetOntologyConceptRealizer.MultipliedUnitsParallelTestingCalculationCount",1,&mulConfigErrorFlag); |
| 106 |
mConfMaxTestParallelCount = processorCount*multiplicator; |
| 107 |
bool maxConfigErrorFlag = false; |
| 108 |
cint64 maxParallel = CConfigDataReader::readConfigInteger(config,"Konclude.Calculation.Realization.OptimizedKPSetOntologyConceptRealizer.MaximumParallelTestingCalculationCount",1,&maxConfigErrorFlag); |
| 109 |
if (!maxConfigErrorFlag) { |
| 110 |
if (!mulConfigErrorFlag) { |
| 111 |
mConfMaxTestParallelCount = qMin(mConfMaxTestParallelCount,maxParallel); |
| 112 |
} else { |
| 113 |
mConfMaxTestParallelCount = maxParallel; |
| 114 |
} |
| 115 |
} |
| 116 |
} else { |
| 117 |
mConfPossibleInstanceIndividualsAfterwardsMerging = true; |
| 118 |
mConfPossibleInstanceConceptsUpfrontMerging = true; |
| 119 |
mAlternateShufflePossibleConceptInstanceTestingItemsOnCalculations = true; |
| 120 |
mConfPossibleInstanceIndividualsAfterwardsMergingOnlyWithSameRepresentativeLabel = false; |
| 121 |
mConfPossibleInstanceIndividualsAfterwardsMergingProvidingCount = -1; |
| 122 |
mConfPossibleInstanceIndividualsAfterwardsMergingMaximumAttemptCount = 3; |
| 123 |
mConfNonDeterministicSatisfiableCalculationContinuation = true; |
| 124 |
|
| 125 |
mConfMaxTestParallelCount = 1; |
| 126 |
} |
| 127 |
|
| 128 |
} |
| 129 |
|
| 130 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::initializeItems(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 131 |
if (!reqConfPreCompItem->hasItemsInitialized()) { |
| 132 |
reqConfPreCompItem->initConceptItemsFromHierarchy(); |
| 133 |
reqConfPreCompItem->initRoleItemsFromHierarchy(); |
| 134 |
reqConfPreCompItem->initComplexRolesStarterCandidates(); |
| 135 |
|
| 136 |
readCalculationConfig(reqConfPreCompItem->getCalculationConfiguration()); |
| 137 |
|
| 138 |
QTime timer; |
| 139 |
timer.start(); |
| 140 |
initializeRepresentativeConceptSetCacheLabelItems(reqConfPreCompItem); |
| 141 |
cint64 initConTime = timer.elapsed(); |
| 142 |
initializeRepresentativeRoleSetCacheLabelItems(reqConfPreCompItem); |
| 143 |
cint64 initRoleTime = timer.elapsed() - initConTime; |
| 144 |
initializeIndividualProcessingKPSetsFromConsistencyData(reqConfPreCompItem); |
| 145 |
cint64 initIndiTime = timer.elapsed() - initRoleTime; |
| 146 |
reqConfPreCompItem->setItemsInitialized(true); |
| 147 |
|
| 148 |
|
| 149 |
QList<COptimizedKPSetConceptInstancesItem*>* itemInstancesList = reqConfPreCompItem->getProcessingPossibleConceptInstancesItemList(); |
| 150 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = itemInstancesList->constBegin(), itEnd = itemInstancesList->constEnd(); it != itEnd; ++it) { |
| 151 |
COptimizedKPSetConceptInstancesItem* item(*it); |
| 152 |
if (item->hasAllSuccessorProcessedFlag() && !item->hasPossibleInstances() && !item->hasTestingPossibleInstances()) { |
| 153 |
updateParentItemsSuccessorProcessed(item); |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
CRealizingTestingStep* ontProcStep = reqConfPreCompItem->getInitRealizeProcessingStep(); |
| 158 |
ontProcStep->setStepFinished(true); |
| 159 |
ontProcStep->submitRequirementsUpdate(); |
| 160 |
QString concurrentString; |
| 161 |
if (mConfConcurrentIndividualPossibleConceptInstantiationInitialization) { |
| 162 |
concurrentString = QString("(concurrently) "); |
| 163 |
} |
| 164 |
LOG(INFO, getDomain(), logTr("Realization items %4initialized for ontology (%1 ms for concept items, %2 ms for role items, %3 ms for individual items).").arg(initConTime).arg(initRoleTime).arg(initIndiTime).arg(concurrentString), this); |
| 165 |
|
| 166 |
|
| 167 |
//COptimizedKPSetRoleInstancesItem* testRoleInstancesItem = nullptr; |
| 168 |
//bool testRoleInversion = false; |
| 169 |
//CRBox* rbox = reqConfPreCompItem->getOntology()->getRBox(); |
| 170 |
//for (cint64 i = 0; i < rbox->getRoleCount(); i++) { |
| 171 |
// CRole* role = rbox->getRoleVector()->getData(i); |
| 172 |
// if (role && CIRIName::getRecentIRIName(role->getPropertyNameLinker())== "http://ontology.dumontierlab.com/hasPart") { |
| 173 |
// COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)reqConfPreCompItem->getRoleInstantiatedItem(role); |
| 174 |
// if (redRoleItem) { |
| 175 |
// COptimizedKPSetRoleInstancesItem* roleInstancesItem = redRoleItem->getRedirectedItem(); |
| 176 |
// bool itemInversed = redRoleItem->isInversed(); |
| 177 |
// testRoleInstancesItem = roleInstancesItem; |
| 178 |
|
| 179 |
// if (CIRIName::getRecentIRIName(role->getPropertyNameLinker()) == "http://ontology.dumontierlab.com/hasPart" && !itemInversed) { |
| 180 |
// testRoleInversion = true; |
| 181 |
// } |
| 182 |
// break; |
| 183 |
// } |
| 184 |
// } |
| 185 |
//} |
| 186 |
//QList<CRealizationIndividualInstanceItemReference> list; |
| 187 |
//CABox* abox = reqConfPreCompItem->getOntology()->getABox(); |
| 188 |
//for (cint64 i = 0; i < abox->getIndividualCount(); i++) { |
| 189 |
// CIndividual* indi = abox->getIndividualVector()->getData(i); |
| 190 |
// if (indi && CIRIName::getRecentIRIName(indi->getIndividualNameLinker()).contains("http://ontology.dumontierlab.com/eswc-example-graph-3#x") && !CIRIName::getRecentIRIName(indi->getIndividualNameLinker()).contains("http://ontology.dumontierlab.com/eswc-example-graph-3#xx")) { |
| 191 |
// CRealizationIndividualInstanceItemReference indiItemRef(indi, i, nullptr); |
| 192 |
// list.append(indiItemRef); |
| 193 |
// } |
| 194 |
//} |
| 195 |
// |
| 196 |
//for (CRealizationIndividualInstanceItemReference itemRef : list) { |
| 197 |
// COptimizedKPSetIndividualComplexRoleData* indiComplexSubRoleData = testRoleInstancesItem->getIndividualIdComplexRoleData(itemRef.getIndividualID(), true); |
| 198 |
// collectTransitiveLinks(reqConfPreCompItem, testRoleInstancesItem, testRoleInversion, itemRef, indiComplexSubRoleData); |
| 199 |
//} |
| 200 |
|
| 201 |
} |
| 202 |
return true; |
| 203 |
} |
| 204 |
|
| 205 |
bool itemSortLessThan(COptimizedKPSetConceptInstancesItem* item1, COptimizedKPSetConceptInstancesItem* item2) { |
| 206 |
return item1->getHierarchyNode()->getPredecessorNodeSet()->count() > item2->getHierarchyNode()->getPredecessorNodeSet()->count(); |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::initializeRepresentativeRoleSetCacheLabelItems(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 218 |
|
| 219 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelCacheEntries(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL, [&](CBackendRepresentativeMemoryLabelCacheItem* combinedNeighbourRoleLabelCacheItem)->bool { |
| 220 |
|
| 221 |
if (combinedNeighbourRoleLabelCacheItem->getIndividualAssociationCount() > 0) { |
| 222 |
|
| 223 |
COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* combinedNeighbourRoleLabelCacheItemData = reqConfPreCompItem->getRepresentativeCacheCombinedNeighbourRoleSetLabelItemData(combinedNeighbourRoleLabelCacheItem); |
| 224 |
|
| 225 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelsOfAssociatedNeigbourRoleSetCombinationLabel(nullptr, combinedNeighbourRoleLabelCacheItem, [&](CBackendRepresentativeMemoryLabelCacheItem* singleNeighbourRoleLabelCacheItem)->bool { |
| 226 |
COptimizedRepresentativeKPSetSingleNeighbourRoleSetCacheLabelItemData* singleNeighbourRoleLabelCacheItemData = reqConfPreCompItem->getRepresentativeCacheSingleNeighbourRoleSetLabelItemData(singleNeighbourRoleLabelCacheItem); |
| 227 |
singleNeighbourRoleLabelCacheItemData->addReferencingCombinedNeighbourRoleLabelDataItem(combinedNeighbourRoleLabelCacheItemData); |
| 228 |
return true; |
| 229 |
}); |
| 230 |
} |
| 231 |
return true; |
| 232 |
}); |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetSingleNeighbourRoleSetCacheLabelItemData*>* singleNeighbourRoleLabelCacheItemDataHash = reqConfPreCompItem->getRepresentativeCacheSingleNeighbourRoleSetLabelItemDataHash(); |
| 240 |
for (auto it = singleNeighbourRoleLabelCacheItemDataHash->constBegin(), itEnd = singleNeighbourRoleLabelCacheItemDataHash->constEnd(); it != itEnd; ++it) { |
| 241 |
|
| 242 |
COptimizedRepresentativeKPSetSingleNeighbourRoleSetCacheLabelItemData* singleNeighbourRoleLabelCacheItemData = it.value(); |
| 243 |
CBackendRepresentativeMemoryLabelCacheItem* singleNeighbourRoleLabelCacheItem = it.key(); |
| 244 |
|
| 245 |
|
| 246 |
QSet<COptimizedKPSetRoleInstancesItem*> singleLabelItemSet; |
| 247 |
QSet<COptimizedKPSetRoleInstancesItem*> singleInverseLabelItemSet; |
| 248 |
|
| 249 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitRolesOfAssociatedNeigbourRoleSetLabel(nullptr, singleNeighbourRoleLabelCacheItem, [&](CRole* role, bool roleInversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)->bool { |
| 250 |
|
| 251 |
|
| 252 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)reqConfPreCompItem->getRoleInstantiatedItem(role); |
| 253 |
if (redRoleItem) { |
| 254 |
COptimizedKPSetRoleInstancesItem* roleInstancesItem = redRoleItem->getRedirectedItem(); |
| 255 |
bool itemInversed = redRoleItem->isInversed(); |
| 256 |
|
| 257 |
bool inversed = roleInversed ^ itemInversed; |
| 258 |
QSet<COptimizedKPSetRoleInstancesItem*>* singleRoleLabelItemSet = &singleLabelItemSet; |
| 259 |
if (inversed) { |
| 260 |
singleRoleLabelItemSet = &singleInverseLabelItemSet; |
| 261 |
} |
| 262 |
|
| 263 |
|
| 264 |
if (!singleRoleLabelItemSet->contains(roleInstancesItem)) { |
| 265 |
singleRoleLabelItemSet->insert(roleInstancesItem); |
| 266 |
|
| 267 |
|
| 268 |
if (!nondeterministic) { |
| 269 |
singleNeighbourRoleLabelCacheItemData->addKnownInstancesItem(roleInstancesItem, inversed); |
| 270 |
} else { |
| 271 |
singleNeighbourRoleLabelCacheItemData->addPossibleInstancesItem(roleInstancesItem, inversed); |
| 272 |
} |
| 273 |
|
| 274 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash* itemLabelDataHash = roleInstancesItem->getCombinedNeighbourCacheLabelItemDataHash(inversed); |
| 275 |
|
| 276 |
for (COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* combinedNeighbourRoleLabelCacheItemData : *singleNeighbourRoleLabelCacheItemData->getReferencingCombinedNeighbourRoleLabelItemDataList()) { |
| 277 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeighbourRoleLabelCacheItem = combinedNeighbourRoleLabelCacheItemData->getCombinedNeighbourRoleLabelCacheItem(); |
| 278 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData*& roleItemLabelData = (*itemLabelDataHash)[combinedNeighbourRoleLabelCacheItem]; |
| 279 |
|
| 280 |
if (!roleItemLabelData) { |
| 281 |
roleItemLabelData = new COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData(); |
| 282 |
} |
| 283 |
|
| 284 |
CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData* arrayIndex = (CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData*)combinedNeighbourRoleLabelCacheItem->getExtensionData(CBackendRepresentativeMemoryLabelCacheItemIndividualRoleSetNeighbourArrayIndexExtensionData::INDIVIDUAL_NEIGHBOUR_ARRAY_INDEX); |
| 285 |
|
| 286 |
COptimizedKPSetRoleInstancesSingleNeighbourRoleSetCacheLabelData* singleLabelData = new COptimizedKPSetRoleInstancesSingleNeighbourRoleSetCacheLabelData(arrayIndex->getIndex(singleNeighbourRoleLabelCacheItem), singleNeighbourRoleLabelCacheItem); |
| 287 |
|
| 288 |
if (!nondeterministic) { |
| 289 |
roleItemLabelData->addKnownInstancesLabelItemData(singleLabelData); |
| 290 |
itemLabelDataHash->setKnownInstances(true); |
| 291 |
combinedNeighbourRoleLabelCacheItemData->addKnownInstancesItem(roleInstancesItem, inversed); |
| 292 |
} else { |
| 293 |
itemLabelDataHash->setPossibleInstances(true); |
| 294 |
combinedNeighbourRoleLabelCacheItemData->setPossibleInstances(true); |
| 295 |
roleItemLabelData->addPossibleInstancesLabelItemData(singleLabelData); |
| 296 |
combinedNeighbourRoleLabelCacheItemData->addPossibleInstancesItem(roleInstancesItem, inversed); |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
if (!roleInversed) { |
| 305 |
for (COptimizedKPSetRoleInstancesItem* complexRoleItemCandidate : reqConfPreCompItem->getComplexStarterCandidateRoleInstancesItems(role)) { |
| 306 |
for (COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* combinedNeighbourRoleLabelCacheItemData : *singleNeighbourRoleLabelCacheItemData->getReferencingCombinedNeighbourRoleLabelItemDataList()) { |
| 307 |
combinedNeighbourRoleLabelCacheItemData->addComplexCandiateInstancesItem(complexRoleItemCandidate, false); |
| 308 |
complexRoleItemCandidate->addComplexStarterCandidateCombinedNeighbourRoleLabelCacheItem(false, combinedNeighbourRoleLabelCacheItemData->getCombinedNeighbourRoleLabelCacheItem()); |
| 309 |
if (nondeterministic) { |
| 310 |
complexRoleItemCandidate->setOnlyDeterministicComplexRoleStarterCandidatesUsage(false); |
| 311 |
} |
| 312 |
} |
| 313 |
} |
| 314 |
for (COptimizedKPSetRoleInstancesItem* complexRoleItemCandidate : reqConfPreCompItem->getInverseComplexStarterCandidateRoleInstancesItems(role)) { |
| 315 |
for (COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* combinedNeighbourRoleLabelCacheItemData : *singleNeighbourRoleLabelCacheItemData->getReferencingCombinedNeighbourRoleLabelItemDataList()) { |
| 316 |
combinedNeighbourRoleLabelCacheItemData->addComplexCandiateInstancesItem(complexRoleItemCandidate, true); |
| 317 |
complexRoleItemCandidate->addComplexStarterCandidateCombinedNeighbourRoleLabelCacheItem(true, combinedNeighbourRoleLabelCacheItemData->getCombinedNeighbourRoleLabelCacheItem()); |
| 318 |
if (nondeterministic) { |
| 319 |
complexRoleItemCandidate->setOnlyDeterministicComplexRoleStarterCandidatesUsage(false); |
| 320 |
} |
| 321 |
} |
| 322 |
} |
| 323 |
} |
| 324 |
|
| 325 |
|
| 326 |
return true; |
| 327 |
}); |
| 328 |
|
| 329 |
} |
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
function<void(CBackendRepresentativeMemoryLabelCacheItem* cacheLabelItem, bool deterministic)> existentialCacheLabelItemHandlingFunction = [&](CBackendRepresentativeMemoryLabelCacheItem* cacheLabelItem, bool deterministic) { |
| 334 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitRolesOfAssociatedCompinationRoleSetLabel(nullptr, cacheLabelItem, [&](CRole* role, bool inversed)->bool { |
| 335 |
|
| 336 |
if (!inversed) { |
| 337 |
|
| 338 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* combinedExistentialRoleLabelCacheItemData = reqConfPreCompItem->getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(cacheLabelItem, true); |
| 339 |
combinedExistentialRoleLabelCacheItemData->setNondeterministic(!deterministic); |
| 340 |
|
| 341 |
for (COptimizedKPSetRoleInstancesItem* complexRoleItemCandidate : reqConfPreCompItem->getComplexStarterCandidateRoleInstancesItems(role)) { |
| 342 |
combinedExistentialRoleLabelCacheItemData->addComplexCandiateInstancesItem(complexRoleItemCandidate, false); |
| 343 |
complexRoleItemCandidate->addComplexStarterCandidateCombinedExistentialRoleLabelCacheItem(false, combinedExistentialRoleLabelCacheItemData->getCombinedNeighbourRoleLabelCacheItem()); |
| 344 |
} |
| 345 |
|
| 346 |
for (COptimizedKPSetRoleInstancesItem* complexRoleItemCandidate : reqConfPreCompItem->getInverseComplexStarterCandidateRoleInstancesItems(role)) { |
| 347 |
combinedExistentialRoleLabelCacheItemData->addComplexCandiateInstancesItem(complexRoleItemCandidate, true); |
| 348 |
complexRoleItemCandidate->addComplexStarterCandidateCombinedExistentialRoleLabelCacheItem(true, combinedExistentialRoleLabelCacheItemData->getCombinedNeighbourRoleLabelCacheItem()); |
| 349 |
} |
| 350 |
|
| 351 |
|
| 352 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)reqConfPreCompItem->getRoleInstantiatedItem(role); |
| 353 |
if (redRoleItem) { |
| 354 |
COptimizedKPSetRoleInstancesItem* roleInstancesItem = redRoleItem->getRedirectedItem(); |
| 355 |
bool itemInversed = redRoleItem->isInversed(); |
| 356 |
|
| 357 |
roleInstancesItem->addExistentialRoleLabelCacheItem(itemInversed, cacheLabelItem); |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
return true; |
| 364 |
}); |
| 365 |
|
| 366 |
}; |
| 367 |
|
| 368 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelCacheEntries(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, [&](CBackendRepresentativeMemoryLabelCacheItem* detExistentialRoleLabelCacheItem)->bool { |
| 369 |
existentialCacheLabelItemHandlingFunction(detExistentialRoleLabelCacheItem, true); |
| 370 |
return true; |
| 371 |
}); |
| 372 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelCacheEntries(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL, [&](CBackendRepresentativeMemoryLabelCacheItem* detExistentialRoleLabelCacheItem)->bool { |
| 373 |
existentialCacheLabelItemHandlingFunction(detExistentialRoleLabelCacheItem, false); |
| 374 |
return true; |
| 375 |
}); |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
function<void(CBackendRepresentativeMemoryLabelCacheItem* cacheLabelItem, bool deterministic)> dataCacheLabelItemHandlingFunction = [&](CBackendRepresentativeMemoryLabelCacheItem* cacheLabelItem, bool deterministic) { |
| 382 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitRolesOfAssociatedCompinationRoleSetLabel(nullptr, cacheLabelItem, [&](CRole* role, bool inversed)->bool { |
| 383 |
|
| 384 |
if (!inversed) { |
| 385 |
reqConfPreCompItem->addDataRoleCacheLabelItem(role, cacheLabelItem, deterministic); |
| 386 |
|
| 387 |
if (!deterministic) { |
| 388 |
reqConfPreCompItem->addDataRoleNondeterministicCacheLabelItems(role); |
| 389 |
} |
| 390 |
} |
| 391 |
|
| 392 |
return true; |
| 393 |
}); |
| 394 |
|
| 395 |
}; |
| 396 |
|
| 397 |
|
| 398 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelCacheEntries(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, [&](CBackendRepresentativeMemoryLabelCacheItem* detDataRoleLabelCacheItem)->bool { |
| 399 |
dataCacheLabelItemHandlingFunction(detDataRoleLabelCacheItem, true); |
| 400 |
return true; |
| 401 |
}); |
| 402 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelCacheEntries(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_DATA_INSTANTIATED_ROLE_SET_LABEL, [&](CBackendRepresentativeMemoryLabelCacheItem* detDataRoleLabelCacheItem)->bool { |
| 403 |
dataCacheLabelItemHandlingFunction(detDataRoleLabelCacheItem, false); |
| 404 |
return true; |
| 405 |
}); |
| 406 |
|
| 407 |
|
| 408 |
return this; |
| 409 |
} |
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::initializeRepresentativeConceptSetCacheLabelItems(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 418 |
QHash<CConcept*, COptimizedKPSetConceptInstancesItem*>* conceptInstancesItemHash = reqConfPreCompItem->getConceptInstancesItemHash(); |
| 419 |
|
| 420 |
QList<COptimizedKPSetConceptInstancesItem*> equivClassList; |
| 421 |
initializeEquivalentClassList(&equivClassList, reqConfPreCompItem); |
| 422 |
|
| 423 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelCacheEntries(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL, [&](CBackendRepresentativeMemoryLabelCacheItem* labelCacheItem)->bool { |
| 424 |
|
| 425 |
if (labelCacheItem->getIndividualAssociationCount() > 0) { |
| 426 |
|
| 427 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* labelCacheItemData = reqConfPreCompItem->getRepresentativeCacheConceptSetLabelItemData(labelCacheItem); |
| 428 |
|
| 429 |
QList<COptimizedKPSetConceptInstancesItem*>* knownInstancesItemList = labelCacheItemData->getKnownInstancesItemList(); |
| 430 |
QList<COptimizedKPSetConceptInstancesItem*>* possibleInstancesItemList = labelCacheItemData->getPossibleInstancesItemList(); |
| 431 |
QSet<COptimizedKPSetConceptInstancesItem*> singleLabelItemSet; |
| 432 |
bool hasPossibleConceptCandidates = false; |
| 433 |
bool hasPossibleConceptInstantiations = false; |
| 434 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitConceptsOfFullConceptSetLabel(labelCacheItem, [&](CConcept* concept, bool negated, bool deterministic)->bool { |
| 435 |
|
| 436 |
if (!negated && concept->hasClassName()) { |
| 437 |
COptimizedKPSetConceptInstancesItem* conceptInstancesItem = conceptInstancesItemHash->value(concept); |
| 438 |
if (conceptInstancesItem) { |
| 439 |
if (deterministic) { |
| 440 |
if (!singleLabelItemSet.contains(conceptInstancesItem)) { |
| 441 |
singleLabelItemSet.insert(conceptInstancesItem); |
| 442 |
conceptInstancesItem->addKnownInstancesLabelCacheItem(labelCacheItem); |
| 443 |
knownInstancesItemList->append(conceptInstancesItem); |
| 444 |
} |
| 445 |
} else { |
| 446 |
hasPossibleConceptCandidates = true; |
| 447 |
} |
| 448 |
} |
| 449 |
} |
| 450 |
if (!negated && concept->getOperatorCode() == CCEQCAND) { |
| 451 |
hasPossibleConceptCandidates = true; |
| 452 |
} |
| 453 |
|
| 454 |
return true; |
| 455 |
}, true, true); |
| 456 |
|
| 457 |
|
| 458 |
if (hasPossibleConceptCandidates) { |
| 459 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitConceptsOfFullConceptSetLabel(labelCacheItem, [&](CConcept* concept, bool negated, bool deterministic)->bool { |
| 460 |
|
| 461 |
if (!negated && concept->hasClassName() && !deterministic) { |
| 462 |
COptimizedKPSetConceptInstancesItem* conceptInstancesItem = conceptInstancesItemHash->value(concept); |
| 463 |
if (conceptInstancesItem && !singleLabelItemSet.contains(conceptInstancesItem)) { |
| 464 |
singleLabelItemSet.insert(conceptInstancesItem); |
| 465 |
hasPossibleConceptInstantiations = true; |
| 466 |
conceptInstancesItem->addPossibleInstancesLabelCacheItem(labelCacheItem); |
| 467 |
possibleInstancesItemList->append(conceptInstancesItem); |
| 468 |
} |
| 469 |
} |
| 470 |
if (!negated && concept->getOperatorCode() == CCEQCAND) { |
| 471 |
CConcept* resolvedConcept = concept->getOperandList()->getData(); |
| 472 |
COptimizedKPSetConceptInstancesItem* conceptInstancesItem = conceptInstancesItemHash->value(resolvedConcept); |
| 473 |
if (conceptInstancesItem && !singleLabelItemSet.contains(conceptInstancesItem)) { |
| 474 |
singleLabelItemSet.insert(conceptInstancesItem); |
| 475 |
hasPossibleConceptInstantiations = true; |
| 476 |
conceptInstancesItem->addPossibleInstancesLabelCacheItem(labelCacheItem); |
| 477 |
possibleInstancesItemList->append(conceptInstancesItem); |
| 478 |
} |
| 479 |
} |
| 480 |
|
| 481 |
return true; |
| 482 |
}, true, true); |
| 483 |
} |
| 484 |
if (!equivClassList.isEmpty()) { |
| 485 |
hasPossibleConceptInstantiations = true; |
| 486 |
possibleInstancesItemList->append(equivClassList); |
| 487 |
} |
| 488 |
|
| 489 |
labelCacheItemData->setPossibleInstances(hasPossibleConceptInstantiations); |
| 490 |
qSort(knownInstancesItemList->begin(), knownInstancesItemList->end(), itemSortLessThan); |
| 491 |
qSort(possibleInstancesItemList->begin(), possibleInstancesItemList->end(), itemSortLessThan); |
| 492 |
|
| 493 |
|
| 494 |
for (COptimizedKPSetConceptInstancesItem* conceptInstancesItem : *knownInstancesItemList) { |
| 495 |
addRepresentativeCacheLabelItemToConceptInstancesItem(reqConfPreCompItem, labelCacheItem, labelCacheItemData, conceptInstancesItem, true); |
| 496 |
} |
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
for (COptimizedKPSetConceptInstancesItem* conceptInstancesItem : *possibleInstancesItemList) { |
| 501 |
addRepresentativeCacheLabelItemToConceptInstancesItem(reqConfPreCompItem, labelCacheItem, labelCacheItemData, conceptInstancesItem, false); |
| 502 |
} |
| 503 |
|
| 504 |
|
| 505 |
QHash<COptimizedKPSetConceptInstancesItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData*>* instancesItemDataHash = labelCacheItemData->getInstancesItemDataHash(); |
| 506 |
for (auto it = instancesItemDataHash->constBegin(), itEnd = instancesItemDataHash->constEnd(); it != itEnd; ++it) { |
| 507 |
COptimizedKPSetConceptInstancesItem* conceptInstancesItem = it.key(); |
| 508 |
if (it.value()->hasMostSpecificKnownInstances() && it.value()->hasMostSpecificInstances()) { |
| 509 |
conceptInstancesItem->addKnownMostSpecificInstancesLabelCacheItem(labelCacheItem); |
| 510 |
} else if (it.value()->hasMostSpecificKnownInstances() && !it.value()->hasMostSpecificInstances()) { |
| 511 |
conceptInstancesItem->addPossibleMostSpecificInstancesLabelCacheItem(labelCacheItem); |
| 512 |
} else if (it.value()->hasPossibleInstances()) { |
| 513 |
conceptInstancesItem->addPossibleMostSpecificInstancesLabelCacheItem(labelCacheItem); |
| 514 |
} |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
return true; |
| 521 |
}); |
| 522 |
return true; |
| 523 |
} |
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::addRepresentativeCacheLabelItemToConceptInstancesItem(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, CBackendRepresentativeMemoryLabelCacheItem* labelCacheItem, COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* labelCacheItemData, COptimizedKPSetConceptInstancesItem* instancesItem, bool knownInstancesItem) { |
| 532 |
QHash<COptimizedKPSetConceptInstancesItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData*>* instancesItemDataHash = labelCacheItemData->getInstancesItemDataHash(); |
| 533 |
QList<COptimizedKPSetConceptInstancesItem*> tmpInstancesList; |
| 534 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData*& instancesItemData = (*instancesItemDataHash)[instancesItem]; |
| 535 |
if (!instancesItemData) { |
| 536 |
instancesItemData = new COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData(); |
| 537 |
instancesItemData->setMostSpecificInstances(true); |
| 538 |
instancesItemData->setPossibleInstances(!knownInstancesItem); |
| 539 |
if (knownInstancesItem) { |
| 540 |
instancesItemData->setMostSpecificKnownInstances(true); |
| 541 |
} |
| 542 |
|
| 543 |
tmpInstancesList.append(*instancesItem->getParentItemList()); |
| 544 |
while (!tmpInstancesList.isEmpty()) { |
| 545 |
COptimizedKPSetConceptInstancesItem* superInstanceItem = tmpInstancesList.takeFirst(); |
| 546 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData*& superInstancesItemData = (*instancesItemDataHash)[superInstanceItem]; |
| 547 |
if (!superInstancesItemData) { |
| 548 |
superInstancesItemData = new COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData(); |
| 549 |
superInstancesItemData->setMostSpecificInstances(false); |
| 550 |
superInstancesItemData->setMostSpecificKnownInstances(false); |
| 551 |
superInstancesItemData->setPossibleInstances(!knownInstancesItem); |
| 552 |
tmpInstancesList.append(*superInstanceItem->getParentItemList()); |
| 553 |
} else { |
| 554 |
if (knownInstancesItem && superInstancesItemData->hasMostSpecificKnownInstances()) { |
| 555 |
superInstancesItemData->setMostSpecificKnownInstances(false); |
| 556 |
} |
| 557 |
|
| 558 |
if (superInstancesItemData->hasMostSpecificInstances()) { |
| 559 |
superInstancesItemData->setMostSpecificInstances(false); |
| 560 |
} |
| 561 |
} |
| 562 |
} |
| 563 |
} |
| 564 |
return true; |
| 565 |
} |
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::initializeRepresentativeIndividualProcessing(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, cint64 indiId, CBackendRepresentativeMemoryLabelCacheItem* conSetLabelItem, COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* conSetLabelCacheItemData, QHash<cint64, QList<CIndividualReference> >** individualPossibleSameIndividualListHash) { |
| 571 |
|
| 572 |
CIndividualVector* indiVec = reqConfPreCompItem->getOntology()->getABox()->getIndividualVector(false); |
| 573 |
|
| 574 |
// TODO: the known instance data may should not be represented in the individual item since this information can be resolved via the individual association data and, therefore, it would just waste some memory |
| 575 |
QList<COptimizedKPSetConceptInstancesItem*>* knownInstancesItemList = conSetLabelCacheItemData->getKnownInstancesItemList(); |
| 576 |
QList<COptimizedKPSetConceptInstancesItem*>* possibleInstancesItemList = conSetLabelCacheItemData->getPossibleInstancesItemList(); |
| 577 |
|
| 578 |
QList<CIndividualReference> knownSameIndividualIdList; |
| 579 |
CBackendRepresentativeMemoryLabelCacheItem* knownSameIndilabelItem = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociatedCacheLabelItem(indiId, CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL); |
| 580 |
if (knownSameIndilabelItem) { |
| 581 |
reqConfPreCompItem->setPotentiallySameIndividuals(true); |
| 582 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitIndividualIdsOfAssociatedIndividualSetLabel(nullptr, knownSameIndilabelItem, [&](cint64 sameIndiId)->bool { |
| 583 |
if (sameIndiId < indiId) { |
| 584 |
CIndividual* sameIndividual = indiVec->getData(indiId); |
| 585 |
knownSameIndividualIdList.append(CIndividualReference(sameIndividual, indiId)); |
| 586 |
indiId = sameIndiId; |
| 587 |
} else if (sameIndiId != indiId) { |
| 588 |
CIndividual* sameIndividual = indiVec->getData(sameIndiId); |
| 589 |
knownSameIndividualIdList.append(CIndividualReference(sameIndividual, sameIndiId)); |
| 590 |
} |
| 591 |
return true; |
| 592 |
}); |
| 593 |
} |
| 594 |
CBackendRepresentativeMemoryLabelCacheItem* possibleSameIndilabelItem = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociatedCacheLabelItem(indiId, CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL); |
| 595 |
if (possibleSameIndilabelItem) { |
| 596 |
reqConfPreCompItem->setPotentiallySameIndividuals(true); |
| 597 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitIndividualIdsOfAssociatedIndividualSetLabel(nullptr, possibleSameIndilabelItem, [&](cint64 possibleSameIndiId)->bool { |
| 598 |
if (possibleSameIndiId != indiId && !reqConfPreCompItem->getBackendAssociationCacheReader()->hasIndividualIdsInAssociatedIndividualSetLabel(nullptr, knownSameIndilabelItem, possibleSameIndiId)) { |
| 599 |
CIndividual* possibleSameIndividual = indiVec->getData(possibleSameIndiId); |
| 600 |
cint64 indiPos = indiId % mConfConcurrentHandlingVectorSize; |
| 601 |
|
| 602 |
(*individualPossibleSameIndividualListHash[indiPos])[indiId].append(CIndividualReference(possibleSameIndividual, possibleSameIndiId)); |
| 603 |
} |
| 604 |
return true; |
| 605 |
}); |
| 606 |
} |
| 607 |
|
| 608 |
CIndividual* individual = indiVec->getData(indiId); |
| 609 |
initializeKPSetsForIndividual(reqConfPreCompItem, indiId, individual, *knownInstancesItemList, *possibleInstancesItemList, knownSameIndividualIdList); |
| 610 |
|
| 611 |
return true; |
| 612 |
} |
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
CIndividualProcessNode* COptimizedRepresentativeKPSetOntologyRealizingThread::getMergeCorrectedIndividualProcessNode(CIndividualProcessNode* indiProcNode, CIndividualProcessNodeVector* indiProcVector, bool* nonDeterministicallyMergedFlag, COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 621 |
bool nonDeterministicMerged = false; |
| 622 |
while (indiProcNode && indiProcNode->getMergedIntoIndividualNodeID() != indiProcNode->getIndividualNodeID()) { |
| 623 |
cint64 mergeID = indiProcNode->getMergedIntoIndividualNodeID(); |
| 624 |
CDependencyTrackPoint* mergedDepTrackPoint = indiProcNode->getMergedDependencyTrackPoint(); |
| 625 |
indiProcNode = indiProcVector->getData(mergeID); |
| 626 |
if (!mergedDepTrackPoint || mergedDepTrackPoint->getBranchingTag() > 0) { |
| 627 |
nonDeterministicMerged = true; |
| 628 |
} |
| 629 |
} |
| 630 |
if (nonDeterministicallyMergedFlag) { |
| 631 |
*nonDeterministicallyMergedFlag = nonDeterministicMerged; |
| 632 |
} |
| 633 |
return indiProcNode; |
| 634 |
} |
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::addKPSetDirectSuperInstances(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash, COptimizedKPSetConceptInstancesItem* instanceItem, bool knownInstance) { |
| 640 |
QList<COptimizedKPSetConceptInstancesItem*> tmpInstancesList; |
| 641 |
COptimizedKPSetConceptInstancesHashData& hashData = (*knownPossibleInstancesHash)[instanceItem]; |
| 642 |
if (hashData.mInstanceItemData == nullptr) { |
| 643 |
COptimizedKPSetConceptInstancesData* data = new COptimizedKPSetConceptInstancesData(); |
| 644 |
hashData.mInstanceItemData = data; |
| 645 |
data->mInstanceItem = instanceItem; |
| 646 |
data->mKnownInstance = knownInstance; |
| 647 |
data->mPossibleInstance = !knownInstance; |
| 648 |
data->mMostSpecific = true; |
| 649 |
tmpInstancesList.append(*instanceItem->getParentItemList()); |
| 650 |
while (!tmpInstancesList.isEmpty()) { |
| 651 |
COptimizedKPSetConceptInstancesItem* superInstanceItem = tmpInstancesList.takeFirst(); |
| 652 |
COptimizedKPSetConceptInstancesHashData& superHashData = (*knownPossibleInstancesHash)[superInstanceItem]; |
| 653 |
if (superHashData.mInstanceItemData == nullptr) { |
| 654 |
COptimizedKPSetConceptInstancesData* superData = new COptimizedKPSetConceptInstancesData(); |
| 655 |
superHashData.mInstanceItemData = superData; |
| 656 |
superData->mInstanceItem = superInstanceItem; |
| 657 |
superData->mKnownInstance = knownInstance; |
| 658 |
superData->mPossibleInstance = !knownInstance; |
| 659 |
superData->mMostSpecific = false; |
| 660 |
tmpInstancesList.append(*superInstanceItem->getParentItemList()); |
| 661 |
} else { |
| 662 |
if (knownInstance && superHashData.mInstanceItemData->mKnownInstance && superHashData.mInstanceItemData->mMostSpecific) { |
| 663 |
superHashData.mInstanceItemData->mMostSpecific = false; |
| 664 |
} |
| 665 |
if (!knownInstance && superHashData.mInstanceItemData->mPossibleInstance && superHashData.mInstanceItemData->mMostSpecific) { |
| 666 |
superHashData.mInstanceItemData->mMostSpecific = false; |
| 667 |
} |
| 668 |
} |
| 669 |
} |
| 670 |
} |
| 671 |
return true; |
| 672 |
} |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
COptimizedKPSetIndividualItem* COptimizedRepresentativeKPSetOntologyRealizingThread::initializeKPSetsForIndividualConcurrently(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, cint64 indiId, CIndividual* individual, QList<COptimizedKPSetConceptInstancesItem*>& knownInstancesList, QList<COptimizedKPSetConceptInstancesItem*>& possibleInstancesList, QList<CIndividualReference>& knownSameIndividualIdList) { |
| 678 |
COptimizedKPSetIndividualItem* instantiatedItem = reqConfPreCompItem->getIndividualInstantiatedItem(indiId, true, individual); |
| 679 |
cint64 indiVecPos = indiId % mConfConcurrentHandlingVectorSize; |
| 680 |
|
| 681 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = instantiatedItem->getKnownPossibleInstancesHash(); |
| 682 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = knownInstancesList.constBegin(), itEnd = knownInstancesList.constEnd(); it != itEnd; ++it) { |
| 683 |
COptimizedKPSetConceptInstancesItem* instanceItem(*it); |
| 684 |
addKPSetDirectSuperInstances(reqConfPreCompItem, knownPossibleInstancesHash, instanceItem, true); |
| 685 |
} |
| 686 |
|
| 687 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = possibleInstancesList.constBegin(), itEnd = possibleInstancesList.constEnd(); it != itEnd; ++it) { |
| 688 |
COptimizedKPSetConceptInstancesItem* instanceItem(*it); |
| 689 |
addKPSetDirectSuperInstances(reqConfPreCompItem, knownPossibleInstancesHash, instanceItem, false); |
| 690 |
} |
| 691 |
|
| 692 |
for (COptimizedKPSetConceptInstancesHash::const_iterator it = knownPossibleInstancesHash->constBegin(), itEnd = knownPossibleInstancesHash->constEnd(); it != itEnd; ++it) { |
| 693 |
const COptimizedKPSetConceptInstancesHashData& hashData = it.value(); |
| 694 |
if (hashData.mInstanceItemData->mMostSpecific) { |
| 695 |
COptimizedKPSetConceptInstancesItem* instanceItem = hashData.mInstanceItemData->mInstanceItem; |
| 696 |
if (hashData.mInstanceItemData->mKnownInstance) { |
| 697 |
instanceItem->addKnownInstanceConcurrently(instantiatedItem, indiVecPos); |
| 698 |
} else { |
| 699 |
//incOpenPossibleConceptInstancesCount(reqConfPreCompItem); |
| 700 |
instantiatedItem->incPossibleInstantiatedCount(); |
| 701 |
instanceItem->addPossibleInstanceConcurrently(instantiatedItem, indiVecPos); |
| 702 |
} |
| 703 |
} |
| 704 |
} |
| 705 |
|
| 706 |
if (!knownSameIndividualIdList.isEmpty()) { |
| 707 |
for (QList<CIndividualReference>::const_iterator it = knownSameIndividualIdList.constBegin(), itEnd = knownSameIndividualIdList.constEnd(); it != itEnd; ++it) { |
| 708 |
CIndividualReference sameIndividualReference(*it); |
| 709 |
instantiatedItem->addKnownSameIndividual(sameIndividualReference); |
| 710 |
} |
| 711 |
} |
| 712 |
|
| 713 |
|
| 714 |
return instantiatedItem; |
| 715 |
} |
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::initializeKPSetsForIndividual(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, cint64 indiId, CIndividual* individual, QList<COptimizedKPSetConceptInstancesItem*>& knownInstancesList, QList<COptimizedKPSetConceptInstancesItem*>& possibleInstancesList, QList<CIndividualReference>& knownSameIndividualIdList) { |
| 720 |
COptimizedKPSetIndividualItem* instantiatedItem = reqConfPreCompItem->getIndividualInstantiatedItem(indiId, true, individual); |
| 721 |
qSort(knownInstancesList.begin(),knownInstancesList.end(),itemSortLessThan); |
| 722 |
qSort(possibleInstancesList.begin(),possibleInstancesList.end(),itemSortLessThan); |
| 723 |
|
| 724 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = instantiatedItem->getKnownPossibleInstancesHash(); |
| 725 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = knownInstancesList.constBegin(), itEnd = knownInstancesList.constEnd(); it != itEnd; ++it) { |
| 726 |
COptimizedKPSetConceptInstancesItem* instanceItem(*it); |
| 727 |
addKPSetDirectSuperInstances(reqConfPreCompItem,knownPossibleInstancesHash,instanceItem,true); |
| 728 |
} |
| 729 |
|
| 730 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = possibleInstancesList.constBegin(), itEnd = possibleInstancesList.constEnd(); it != itEnd; ++it) { |
| 731 |
COptimizedKPSetConceptInstancesItem* instanceItem(*it); |
| 732 |
addKPSetDirectSuperInstances(reqConfPreCompItem,knownPossibleInstancesHash,instanceItem,false); |
| 733 |
} |
| 734 |
|
| 735 |
for (COptimizedKPSetConceptInstancesHash::const_iterator it = knownPossibleInstancesHash->constBegin(), itEnd = knownPossibleInstancesHash->constEnd(); it != itEnd; ++it) { |
| 736 |
const COptimizedKPSetConceptInstancesHashData& hashData = it.value(); |
| 737 |
if (hashData.mInstanceItemData->mMostSpecific) { |
| 738 |
COptimizedKPSetConceptInstancesItem* instanceItem = hashData.mInstanceItemData->mInstanceItem; |
| 739 |
if (hashData.mInstanceItemData->mKnownInstance) { |
| 740 |
instanceItem->addKnownInstance(instantiatedItem); |
| 741 |
} else { |
| 742 |
incOpenPossibleConceptInstancesCount(reqConfPreCompItem); |
| 743 |
instantiatedItem->incPossibleInstantiatedCount(); |
| 744 |
instanceItem->addPossibleInstance(instantiatedItem); |
| 745 |
} |
| 746 |
} |
| 747 |
} |
| 748 |
if (!knownSameIndividualIdList.isEmpty()) { |
| 749 |
for (QList<CIndividualReference>::const_iterator it = knownSameIndividualIdList.constBegin(), itEnd = knownSameIndividualIdList.constEnd(); it != itEnd; ++it) { |
| 750 |
CIndividualReference sameIndividualReference(*it); |
| 751 |
instantiatedItem->addKnownSameIndividual(sameIndividualReference); |
| 752 |
reqConfPreCompItem->getIndividualInstantiatedItemHash()->updateIndividualInstantiatedItem(sameIndividualReference.getIndividualID(),instantiatedItem); |
| 753 |
} |
| 754 |
} |
| 755 |
|
| 756 |
return true; |
| 757 |
} |
| 758 |
|
| 759 |
|
| 760 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::initializeEquivalentClassList(QList<COptimizedKPSetConceptInstancesItem*>* equivClassList, COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 761 |
CTBox* tBox = reqConfPreCompItem->getOntology()->getTBox(); |
| 762 |
CBOXHASH<CConcept*,CConcept*>* eqCandHash = tBox->getEquivalentConceptCandidateHash(false); |
| 763 |
QHash<CHierarchyNode*,COptimizedKPSetConceptInstancesItem*>* hierItemHash = reqConfPreCompItem->getHierarchyNodeInstancesItemHash(); |
| 764 |
QHash<CConcept*,COptimizedKPSetConceptInstancesItem*>* conInstItemHash = reqConfPreCompItem->getConceptInstancesItemHash(); |
| 765 |
for (QHash<CHierarchyNode*,COptimizedKPSetConceptInstancesItem*>::const_iterator it = hierItemHash->constBegin(), itEnd = hierItemHash->constEnd(); it != itEnd; ++it) { |
| 766 |
COptimizedKPSetConceptInstancesItem* item = it.value(); |
| 767 |
CHierarchyNode* hierNode = item->getHierarchyNode(); |
| 768 |
QList<CConcept*>* eqConList = hierNode->getEquivalentConceptList(); |
| 769 |
bool hasEqConCand = false; |
| 770 |
for (QList<CConcept*>::const_iterator itCon = eqConList->constBegin(), itConEnd = eqConList->constEnd(); !hasEqConCand && itCon != itConEnd; ++itCon) { |
| 771 |
CConcept* eqConcept(*itCon); |
| 772 |
if (eqConcept->getOperatorCode() == CCSUB || eqConcept->getOperatorCode() == CCATOM || eqConcept->getOperatorCode() == CCTOP || eqConcept->getOperatorCode() == CCBOTTOM) { |
| 773 |
hasEqConCand = true; |
| 774 |
} else if (eqConcept->getOperatorCode() == CCEQ) { |
| 775 |
if (eqCandHash->contains(eqConcept)) { |
| 776 |
hasEqConCand = true; |
| 777 |
} |
| 778 |
} |
| 779 |
} |
| 780 |
if (!hasEqConCand) { |
| 781 |
COptimizedKPSetConceptInstancesItem* instantiatedItem = conInstItemHash->value(eqConList->first()); |
| 782 |
equivClassList->append(instantiatedItem); |
| 783 |
} |
| 784 |
} |
| 785 |
return true; |
| 786 |
} |
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::extractKnownPossibleIndividualDataFromConsistencyData(CIndividualProcessNode* indiProcNode, QList<COptimizedKPSetConceptInstancesItem*>* knownInstancesList, QList<COptimizedKPSetConceptInstancesItem*>* possibleInstancesList, QList<CIndividualReference>* knownSameIndividualList, QList<CIndividualReference>* possibleSameIndividualList, CIndividualProcessNodeVector* indiProcVector, const QList<COptimizedKPSetConceptInstancesItem*>& equivClassList, COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 796 |
QHash<CConcept*,COptimizedKPSetConceptInstancesItem*>* conInstItemHash = reqConfPreCompItem->getConceptInstancesItemHash(); |
| 797 |
|
| 798 |
bool indiInitialized = false; |
| 799 |
if (indiProcVector) { |
| 800 |
|
| 801 |
CIndividualProcessNode* baseIndiProcNode = indiProcNode; |
| 802 |
if (indiProcNode) { |
| 803 |
CIndividual* individual = indiProcNode->getNominalIndividual(); |
| 804 |
CIndividualVector* indiVec = reqConfPreCompItem->getOntology()->getABox()->getIndividualVector(); |
| 805 |
bool nondeterministicallyMergedFlag = false; |
| 806 |
indiProcNode = getMergeCorrectedIndividualProcessNode(indiProcNode,indiProcVector,&nondeterministicallyMergedFlag,reqConfPreCompItem); |
| 807 |
|
| 808 |
|
| 809 |
CReapplyConceptLabelSet* conLabelSet = indiProcNode->getReapplyConceptLabelSet(false); |
| 810 |
if (conLabelSet) { |
| 811 |
|
| 812 |
CConceptDescriptor* conDesLinker = conLabelSet->getAddingSortedConceptDescriptionLinker(); |
| 813 |
while (conDesLinker) { |
| 814 |
CConcept* concept = conDesLinker->getConcept(); |
| 815 |
bool negated = conDesLinker->getNegation(); |
| 816 |
CDependencyTrackPoint* depTrackPoint = conDesLinker->getDependencyTrackPoint(); |
| 817 |
bool deterministicTrackPoint = false; |
| 818 |
if (depTrackPoint) { |
| 819 |
if (depTrackPoint->getBranchingTag() <= 0) { |
| 820 |
deterministicTrackPoint = true; |
| 821 |
} |
| 822 |
} |
| 823 |
if (!negated) { |
| 824 |
CConcept* resolvedConcept = concept; |
| 825 |
bool resolved = false; |
| 826 |
CConceptOperator* conOperator = concept->getConceptOperator(); |
| 827 |
if (conOperator->hasPartialOperatorCodeFlag(CConceptOperator::CCF_ATOM | CConceptOperator::CCF_SUB | CConceptOperator::CCF_TOP | CConceptOperator::CCF_EQ | CConceptOperator::CCF_EQCAND)) { |
| 828 |
cint64 opCode = conOperator->getOperatorCode(); |
| 829 |
if (opCode == CCEQCAND) { |
| 830 |
resolvedConcept = concept->getOperandList()->getData(); |
| 831 |
resolved = true; |
| 832 |
} |
| 833 |
//if (CIRIName::getRecentIRIName(resolvedConcept->getClassNameLinker()) != "http://uob.iodt.ibm.com/univ-bench-dl.owl#PeopleWithManyHobbies") { |
| 834 |
COptimizedKPSetConceptInstancesItem* instantiatedItem = conInstItemHash->value(resolvedConcept); |
| 835 |
if (instantiatedItem) { |
| 836 |
if (deterministicTrackPoint && !resolved) { |
| 837 |
knownInstancesList->append(instantiatedItem); |
| 838 |
} |
| 839 |
else { |
| 840 |
possibleInstancesList->append(instantiatedItem); |
| 841 |
} |
| 842 |
} |
| 843 |
//} |
| 844 |
} |
| 845 |
} |
| 846 |
|
| 847 |
conDesLinker = conDesLinker->getNextConceptDesciptor(); |
| 848 |
} |
| 849 |
} |
| 850 |
|
| 851 |
|
| 852 |
CIndividualMergingHash* indiMergingHash = indiProcNode->getIndividualMergingHash(false); |
| 853 |
if (indiMergingHash) { |
| 854 |
for (CIndividualMergingHash::const_iterator it = indiMergingHash->constBegin(), itEnd = indiMergingHash->constEnd(); it != itEnd; ++it) { |
| 855 |
if (it.value().isMergedWithIndividual()) { |
| 856 |
cint64 mergedIndiId = it.key(); |
| 857 |
CIndividual* mergedIndi = indiVec->getData(mergedIndiId); |
| 858 |
CDependencyTrackPoint* mergedDepTrackPoint = it.value().getDependencyTrackPoint(); |
| 859 |
bool nondeterministicallyMerged = false; |
| 860 |
if (!mergedDepTrackPoint || mergedDepTrackPoint->getBranchingTag() > 0) { |
| 861 |
nondeterministicallyMerged = true; |
| 862 |
} |
| 863 |
if (mergedIndi != individual && !mergedIndi->isAnonymousIndividual()) { |
| 864 |
if (nondeterministicallyMerged) { |
| 865 |
possibleSameIndividualList->append(mergedIndi); |
| 866 |
} else { |
| 867 |
knownSameIndividualList->append(mergedIndi); |
| 868 |
} |
| 869 |
} |
| 870 |
} |
| 871 |
} |
| 872 |
} |
| 873 |
if (indiProcNode != baseIndiProcNode) { |
| 874 |
if (nondeterministicallyMergedFlag) { |
| 875 |
possibleSameIndividualList->append(indiProcNode->getNominalIndividual()); |
| 876 |
} else { |
| 877 |
knownSameIndividualList->append(indiProcNode->getNominalIndividual()); |
| 878 |
} |
| 879 |
} |
| 880 |
|
| 881 |
if (nondeterministicallyMergedFlag) { |
| 882 |
possibleInstancesList->append(*knownInstancesList); |
| 883 |
knownInstancesList->clear(); |
| 884 |
possibleSameIndividualList->append(*knownSameIndividualList); |
| 885 |
knownSameIndividualList->clear(); |
| 886 |
|
| 887 |
QSet<CConcept*> knownConceptSet; |
| 888 |
QSet<CIndividualReference> knownSameIndividualSet; |
| 889 |
|
| 890 |
CIndividualProcessNode* detIndiProcNode = baseIndiProcNode; |
| 891 |
bool stillDeterministicllyMerged = true; |
| 892 |
while (stillDeterministicllyMerged && detIndiProcNode) { |
| 893 |
|
| 894 |
CReapplyConceptLabelSet* detConLabelSet = detIndiProcNode->getReapplyConceptLabelSet(false); |
| 895 |
if (detConLabelSet) { |
| 896 |
|
| 897 |
|
| 898 |
CIndividualMergingHash* detIndiMergingHash = detIndiProcNode->getIndividualMergingHash(false); |
| 899 |
if (detIndiMergingHash) { |
| 900 |
for (CIndividualMergingHash::const_iterator it = detIndiMergingHash->constBegin(), itEnd = detIndiMergingHash->constEnd(); it != itEnd; ++it) { |
| 901 |
if (it.value().isMergedWithIndividual()) { |
| 902 |
cint64 mergedIndiId = it.key(); |
| 903 |
CIndividual* mergedIndi = indiVec->getData(mergedIndiId); |
| 904 |
CDependencyTrackPoint* mergedDepTrackPoint = it.value().getDependencyTrackPoint(); |
| 905 |
bool nondeterministicallyMerged = false; |
| 906 |
if (!mergedDepTrackPoint || mergedDepTrackPoint->getBranchingTag() > 0) { |
| 907 |
nondeterministicallyMerged = true; |
| 908 |
} |
| 909 |
if (mergedIndi != individual && !mergedIndi->isAnonymousIndividual()) { |
| 910 |
if (!nondeterministicallyMerged) { |
| 911 |
knownSameIndividualSet.insert(mergedIndi); |
| 912 |
} |
| 913 |
} |
| 914 |
} |
| 915 |
} |
| 916 |
} |
| 917 |
|
| 918 |
if (stillDeterministicllyMerged) { |
| 919 |
CConceptDescriptor* conDesLinker = detConLabelSet->getAddingSortedConceptDescriptionLinker(); |
| 920 |
for (CConceptDescriptor* conDesLinkerIt = conDesLinker; conDesLinkerIt; conDesLinkerIt = conDesLinkerIt->getNext()) { |
| 921 |
CConcept* concept = conDesLinkerIt->getConcept(); |
| 922 |
bool negated = conDesLinkerIt->getNegation(); |
| 923 |
CDependencyTrackPoint* depTrackPoint = conDesLinkerIt->getDependencyTrackPoint(); |
| 924 |
bool deterministicTrackPoint = false; |
| 925 |
if (depTrackPoint) { |
| 926 |
if (depTrackPoint->getBranchingTag() <= 0) { |
| 927 |
deterministicTrackPoint = true; |
| 928 |
} |
| 929 |
} |
| 930 |
if (!negated) { |
| 931 |
CConceptOperator* conOperator = concept->getConceptOperator(); |
| 932 |
if (conOperator->hasPartialOperatorCodeFlag(CConceptOperator::CCF_ATOM | CConceptOperator::CCF_SUB | CConceptOperator::CCF_TOP | CConceptOperator::CCF_EQ)) { |
| 933 |
cint64 opCode = conOperator->getOperatorCode(); |
| 934 |
if (deterministicTrackPoint) { |
| 935 |
knownConceptSet.insert(concept); |
| 936 |
} |
| 937 |
} |
| 938 |
} |
| 939 |
} |
| 940 |
} |
| 941 |
} |
| 942 |
|
| 943 |
if (stillDeterministicllyMerged) { |
| 944 |
detIndiProcNode = indiProcVector->getData(detIndiProcNode->getMergedIntoIndividualNodeID()); |
| 945 |
CDependencyTrackPoint* mergedDepTrackPoint = detIndiProcNode->getMergedDependencyTrackPoint(); |
| 946 |
if (!mergedDepTrackPoint || mergedDepTrackPoint->getBranchingTag() > 0) { |
| 947 |
stillDeterministicllyMerged = false; |
| 948 |
} |
| 949 |
} |
| 950 |
} |
| 951 |
|
| 952 |
for (QSet<CConcept*>::const_iterator it = knownConceptSet.constBegin(), itEnd = knownConceptSet.constEnd(); it != itEnd; ++it) { |
| 953 |
CConcept* concept(*it); |
| 954 |
COptimizedKPSetConceptInstancesItem* instantiatedItem = conInstItemHash->value(concept); |
| 955 |
knownInstancesList->append(instantiatedItem); |
| 956 |
} |
| 957 |
for (QSet<CIndividualReference>::const_iterator it = knownSameIndividualSet.constBegin(), itEnd = knownSameIndividualSet.constEnd(); it != itEnd; ++it) { |
| 958 |
CIndividualReference sameIndividual(*it); |
| 959 |
knownSameIndividualList->append(sameIndividual); |
| 960 |
} |
| 961 |
|
| 962 |
QList<CIndividualReference> tmpPossibleSameIndividualList(*possibleSameIndividualList); |
| 963 |
possibleSameIndividualList->clear(); |
| 964 |
while (!tmpPossibleSameIndividualList.isEmpty()) { |
| 965 |
CIndividualReference possSameIndividual = tmpPossibleSameIndividualList.takeFirst(); |
| 966 |
if (!knownSameIndividualSet.contains(possSameIndividual)) { |
| 967 |
possibleSameIndividualList->append(possSameIndividual); |
| 968 |
} |
| 969 |
} |
| 970 |
} |
| 971 |
indiInitialized = true; |
| 972 |
} |
| 973 |
} |
| 974 |
|
| 975 |
if (!equivClassList.isEmpty()) { |
| 976 |
possibleInstancesList->append(equivClassList); |
| 977 |
} |
| 978 |
|
| 979 |
return indiInitialized; |
| 980 |
} |
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::initializeIndividualProcessingKPSetsFromConsistencyData(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 991 |
|
| 992 |
|
| 993 |
mConfConcurrentHandlingVectorSize = reqConfPreCompItem->getConcurrentHandlingVectorSize(); |
| 994 |
|
| 995 |
CIndividualVector* indiVec = reqConfPreCompItem->getOntology()->getABox()->getIndividualVector(false); |
| 996 |
if (indiVec) { |
| 997 |
CIndividualProcessNodeVector* indiProcVector = nullptr; |
| 998 |
CConsistence* consistence = reqConfPreCompItem->getOntology()->getConsistence(); |
| 999 |
if (consistence) { |
| 1000 |
CConsistenceData* consData = consistence->getConsistenceModelData(); |
| 1001 |
if (consData) { |
| 1002 |
CConsistenceTaskData* consTaskData = dynamic_cast<CConsistenceTaskData*>(consData); |
| 1003 |
CSatisfiableCalculationTask* satConsTask = consTaskData->getCompletionGraphCachedSatisfiableTask(); |
| 1004 |
if (!satConsTask) { |
| 1005 |
satConsTask = consTaskData->getDeterministicSatisfiableTask(); |
| 1006 |
} |
| 1007 |
if (satConsTask) { |
| 1008 |
CProcessingDataBox* procDataBox = satConsTask->getProcessingDataBox(); |
| 1009 |
if (procDataBox) { |
| 1010 |
indiProcVector = procDataBox->getIndividualProcessNodeVector(); |
| 1011 |
} |
| 1012 |
} |
| 1013 |
} |
| 1014 |
} |
| 1015 |
|
| 1016 |
|
| 1017 |
QList<COptimizedKPSetConceptInstancesItem*> equivClassList; |
| 1018 |
initializeEquivalentClassList(&equivClassList,reqConfPreCompItem); |
| 1019 |
|
| 1020 |
QHash<CConcept*,COptimizedKPSetConceptInstancesItem*>* conInstItemHash = reqConfPreCompItem->getConceptInstancesItemHash(); |
| 1021 |
|
| 1022 |
QHash<cint64,QList<CIndividualReference> >* individualPossibleSameIndividualListHash = new QHash<cint64, QList<CIndividualReference> >[mConfConcurrentHandlingVectorSize]; |
| 1023 |
|
| 1024 |
CBOXSET<CIndividual*>* activeIndividualSet = reqConfPreCompItem->getOntology()->getABox()->getActiveIndividualSet(false); |
| 1025 |
|
| 1026 |
if (indiProcVector) { |
| 1027 |
for (cint64 indiNodeID = 0; indiNodeID >= indiProcVector->getItemMinIndex(); --indiNodeID) { |
| 1028 |
|
| 1029 |
CIndividualProcessNode* indiProcNode = indiProcVector->getData(indiNodeID); |
| 1030 |
if (indiProcNode) { |
| 1031 |
CIndividual* individual = indiProcNode->getNominalIndividual(); |
| 1032 |
if (individual && !individual->isAnonymousIndividual() && !reqConfPreCompItem->hasIndividualInstantiatedItem(individual) && activeIndividualSet->contains(individual)) { |
| 1033 |
|
| 1034 |
QList<COptimizedKPSetConceptInstancesItem*> knownInstancesList; |
| 1035 |
QList<COptimizedKPSetConceptInstancesItem*> possibleInstancesList; |
| 1036 |
|
| 1037 |
QList<CIndividualReference> knownSameIndividualList; |
| 1038 |
QList<CIndividualReference> possibleSameIndividualList; |
| 1039 |
|
| 1040 |
extractKnownPossibleIndividualDataFromConsistencyData(indiProcNode, &knownInstancesList, &possibleInstancesList, &knownSameIndividualList, &possibleSameIndividualList, indiProcVector, equivClassList, reqConfPreCompItem); |
| 1041 |
|
| 1042 |
initializeKPSetsForIndividual(reqConfPreCompItem, individual->getIndividualID(), individual, knownInstancesList, possibleInstancesList, knownSameIndividualList); |
| 1043 |
|
| 1044 |
if (!possibleSameIndividualList.isEmpty()) { |
| 1045 |
cint64 indiPos = individual->getIndividualID() % mConfConcurrentHandlingVectorSize; |
| 1046 |
individualPossibleSameIndividualListHash[indiPos].insert(individual->getIndividualID(), possibleSameIndividualList); |
| 1047 |
} |
| 1048 |
} |
| 1049 |
} |
| 1050 |
} |
| 1051 |
} |
| 1052 |
|
| 1053 |
|
| 1054 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemData*>* repCacheConSetLabelItemDataHash = reqConfPreCompItem->getRepresentativeCacheConceptSetLabelItemDataHash(); |
| 1055 |
if (mConfConcurrentIndividualPossibleConceptInstantiationInitialization) { |
| 1056 |
|
| 1057 |
QTime timer; |
| 1058 |
timer.start(); |
| 1059 |
|
| 1060 |
QHash<CConcept*, COptimizedKPSetConceptInstancesItem*>* conceptInstItemHash = reqConfPreCompItem->getConceptInstancesItemHash(); |
| 1061 |
QSet<COptimizedKPSetConceptInstancesItem*> conceptInstItemSet = conceptInstItemHash->values().toSet(); |
| 1062 |
|
| 1063 |
|
| 1064 |
function<void(COptimizedKPSetConceptInstancesItem* const & conceptItem)> keyMapFunc0 = |
| 1065 |
[&](COptimizedKPSetConceptInstancesItem* const & conceptItem) ->void { |
| 1066 |
|
| 1067 |
conceptItem->prepareConcurrentInitialization(mConfConcurrentHandlingVectorSize); |
| 1068 |
}; |
| 1069 |
|
| 1070 |
QtConcurrent::blockingMap(conceptInstItemSet, keyMapFunc0); |
| 1071 |
|
| 1072 |
cint64 timeStep1 = timer.elapsed(); |
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
QVector<CPossibleConceptInstancesInitializationBatchingData*> batchedPossInstDataVec(mConfConcurrentHandlingVectorSize); |
| 1077 |
cint64 nextVecPos = 0; |
| 1078 |
for (QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemData*>::const_iterator it = repCacheConSetLabelItemDataHash->constBegin(), itEnd = repCacheConSetLabelItemDataHash->constEnd(); it != itEnd; ++it) { |
| 1079 |
CBackendRepresentativeMemoryLabelCacheItem* repConSetCacheLabelItem = it.key(); |
| 1080 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* repConSetCacheLabelItemData = it.value(); |
| 1081 |
if (nextVecPos >= mConfConcurrentHandlingVectorSize) { |
| 1082 |
nextVecPos = 0; |
| 1083 |
} |
| 1084 |
CPossibleConceptInstancesInitializationBatchingData*& data = batchedPossInstDataVec[nextVecPos++]; |
| 1085 |
if (!data) { |
| 1086 |
data = new CPossibleConceptInstancesInitializationBatchingData(); |
| 1087 |
} |
| 1088 |
data->addLabelItemData(repConSetCacheLabelItemData); |
| 1089 |
} |
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
function<QVector<CPossibleConceptInstanceInitializationLinkerData>(const CPossibleConceptInstancesInitializationBatchingData* const & batchData)> keyMapFunc1 = |
| 1096 |
[&](const CPossibleConceptInstancesInitializationBatchingData* const & batchData) ->QVector<CPossibleConceptInstanceInitializationLinkerData> { |
| 1097 |
|
| 1098 |
QVector<CPossibleConceptInstanceInitializationLinkerData> indiLinkerVec(mConfConcurrentHandlingVectorSize); |
| 1099 |
|
| 1100 |
if (batchData) { |
| 1101 |
for (COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* repConSetCacheLabelItemData : batchData->mLabelItemDataList) { |
| 1102 |
CBackendRepresentativeMemoryLabelCacheItem* repConSetCacheLabelItem = repConSetCacheLabelItemData->getLabelCacheItem(); |
| 1103 |
|
| 1104 |
if (repConSetCacheLabelItemData->hasPossibleInstances()) { |
| 1105 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelItemIndividualIdAssociations(repConSetCacheLabelItem, [&](cint64 indiId, bool sameIndividualMerged)->bool { |
| 1106 |
if (!sameIndividualMerged) { |
| 1107 |
|
| 1108 |
cint64 indiVecPos = indiId % mConfConcurrentHandlingVectorSize; |
| 1109 |
CPossibleConceptInstanceInitializationLinkerData& prevLinkerData = indiLinkerVec[indiVecPos]; |
| 1110 |
|
| 1111 |
CPossibleConceptInstanceInitializationLinker* newLinker = new CPossibleConceptInstanceInitializationLinker(); |
| 1112 |
newLinker->initInitializationLinker(indiId, repConSetCacheLabelItemData); |
| 1113 |
prevLinkerData.addLinker(newLinker); |
| 1114 |
|
| 1115 |
} |
| 1116 |
return true; |
| 1117 |
}, true, true, false); |
| 1118 |
} |
| 1119 |
} |
| 1120 |
} |
| 1121 |
|
| 1122 |
return indiLinkerVec; |
| 1123 |
}; |
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
function<void(QVector<CPossibleConceptInstanceInitializationLinkerData>& vec, const QVector<CPossibleConceptInstanceInitializationLinkerData>& reduceVec)> reduceFunc1 = |
| 1129 |
[&](QVector<CPossibleConceptInstanceInitializationLinkerData>& vec, const QVector<CPossibleConceptInstanceInitializationLinkerData>& reduceVec) -> void { |
| 1130 |
|
| 1131 |
if (vec.size() < mConfConcurrentHandlingVectorSize) { |
| 1132 |
vec.resize(mConfConcurrentHandlingVectorSize); |
| 1133 |
} |
| 1134 |
for (cint64 i = 0; i < mConfConcurrentHandlingVectorSize; ++i) { |
| 1135 |
vec[i].addLinkerData(reduceVec[i]); |
| 1136 |
} |
| 1137 |
}; |
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
QVector<CPossibleConceptInstanceInitializationLinkerData> mappedIndi1HashKeyVec = QtConcurrent::blockingMappedReduced<QVector<CPossibleConceptInstanceInitializationLinkerData>>(batchedPossInstDataVec, keyMapFunc1, reduceFunc1); |
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
cint64 timeStep2 = timer.elapsed(); |
| 1148 |
timer.restart(); |
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
function<QVector<CSameIndividualInstanceInitializationLinkerData>(const CPossibleConceptInstanceInitializationLinkerData& initData)> keyMapFunc2 = |
| 1156 |
[&](const CPossibleConceptInstanceInitializationLinkerData& initData) ->QVector<CSameIndividualInstanceInitializationLinkerData> { |
| 1157 |
|
| 1158 |
QVector<CSameIndividualInstanceInitializationLinkerData> indiLinkerVec(mConfConcurrentHandlingVectorSize); |
| 1159 |
|
| 1160 |
CIndividualVector* indiVec = reqConfPreCompItem->getOntology()->getABox()->getIndividualVector(false); |
| 1161 |
|
| 1162 |
for (CPossibleConceptInstanceInitializationLinker* linkerIt = initData.mFirst; linkerIt; linkerIt = linkerIt->getNext()) { |
| 1163 |
cint64 indiId = linkerIt->getData(); |
| 1164 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* conSetLabelCacheItemData = linkerIt->mLabelItemData; |
| 1165 |
CBackendRepresentativeMemoryLabelCacheItem* repConSetCacheLabelItem = conSetLabelCacheItemData->getLabelCacheItem(); |
| 1166 |
|
| 1167 |
// TODO: the known instance data may should not be represented in the individual item since this information can be resolved via the individual association data and, therefore, it would just waste some memory |
| 1168 |
QList<COptimizedKPSetConceptInstancesItem*>* knownInstancesItemList = conSetLabelCacheItemData->getKnownInstancesItemList(); |
| 1169 |
QList<COptimizedKPSetConceptInstancesItem*>* possibleInstancesItemList = conSetLabelCacheItemData->getPossibleInstancesItemList(); |
| 1170 |
|
| 1171 |
QList<CIndividualReference> knownSameIndividualIdList; |
| 1172 |
CBackendRepresentativeMemoryLabelCacheItem* knownSameIndilabelItem = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociatedCacheLabelItem(indiId, CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL); |
| 1173 |
if (knownSameIndilabelItem) { |
| 1174 |
reqConfPreCompItem->setPotentiallySameIndividuals(true); |
| 1175 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitIndividualIdsOfAssociatedIndividualSetLabel(nullptr, knownSameIndilabelItem, [&](cint64 sameIndiId)->bool { |
| 1176 |
if (sameIndiId != indiId) { |
| 1177 |
CIndividual* sameIndividual = indiVec->getData(sameIndiId); |
| 1178 |
knownSameIndividualIdList.append(CIndividualReference(sameIndividual, sameIndiId)); |
| 1179 |
} |
| 1180 |
return true; |
| 1181 |
}); |
| 1182 |
} |
| 1183 |
CBackendRepresentativeMemoryLabelCacheItem* possibleSameIndilabelItem = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociatedCacheLabelItem(indiId, CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL); |
| 1184 |
if (possibleSameIndilabelItem) { |
| 1185 |
reqConfPreCompItem->setPotentiallySameIndividuals(true); |
| 1186 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitIndividualIdsOfAssociatedIndividualSetLabel(nullptr, possibleSameIndilabelItem, [&](cint64 possibleSameIndiId)->bool { |
| 1187 |
if (possibleSameIndiId != indiId && !reqConfPreCompItem->getBackendAssociationCacheReader()->hasIndividualIdsInAssociatedIndividualSetLabel(nullptr, knownSameIndilabelItem, possibleSameIndiId)) { |
| 1188 |
CIndividual* possibleSameIndividual = indiVec->getData(possibleSameIndiId); |
| 1189 |
cint64 indiPos = indiId % mConfConcurrentHandlingVectorSize; |
| 1190 |
|
| 1191 |
(individualPossibleSameIndividualListHash[indiPos])[indiId].append(CIndividualReference(possibleSameIndividual, possibleSameIndiId)); |
| 1192 |
} |
| 1193 |
return true; |
| 1194 |
}); |
| 1195 |
} |
| 1196 |
|
| 1197 |
CIndividual* individual = indiVec->getData(indiId); |
| 1198 |
COptimizedKPSetIndividualItem* indiItem = initializeKPSetsForIndividualConcurrently(reqConfPreCompItem, indiId, individual, *knownInstancesItemList, *possibleInstancesItemList, knownSameIndividualIdList); |
| 1199 |
|
| 1200 |
|
| 1201 |
for (CIndividualReference indiRef : knownSameIndividualIdList) { |
| 1202 |
if (indiId != indiRef.getIndividualID()) { |
| 1203 |
cint64 sameIndiPos = indiRef.getIndividualID() % mConfConcurrentHandlingVectorSize; |
| 1204 |
CSameIndividualInstanceInitializationLinkerData& prevLinkerData = indiLinkerVec[sameIndiPos]; |
| 1205 |
|
| 1206 |
CSameIndividualInstanceInitializationLinker* newLinker = new CSameIndividualInstanceInitializationLinker(); |
| 1207 |
newLinker->initInitializationLinker(indiId, indiItem); |
| 1208 |
prevLinkerData.addLinker(newLinker); |
| 1209 |
} |
| 1210 |
} |
| 1211 |
} |
| 1212 |
|
| 1213 |
|
| 1214 |
return indiLinkerVec; |
| 1215 |
}; |
| 1216 |
|
| 1217 |
|
| 1218 |
|
| 1219 |
|
| 1220 |
function<void(QVector<CSameIndividualInstanceInitializationLinkerData>& vec, const QVector<CSameIndividualInstanceInitializationLinkerData>& reduceVec)> reduceFunc2 = |
| 1221 |
[&](QVector<CSameIndividualInstanceInitializationLinkerData>& vec, const QVector<CSameIndividualInstanceInitializationLinkerData>& reduceVec) -> void { |
| 1222 |
|
| 1223 |
if (vec.size() < mConfConcurrentHandlingVectorSize) { |
| 1224 |
vec.resize(mConfConcurrentHandlingVectorSize); |
| 1225 |
} |
| 1226 |
for (cint64 i = 0; i < mConfConcurrentHandlingVectorSize; ++i) { |
| 1227 |
vec[i].addLinkerData(reduceVec[i]); |
| 1228 |
} |
| 1229 |
}; |
| 1230 |
|
| 1231 |
|
| 1232 |
QVector<CSameIndividualInstanceInitializationLinkerData> mappedIndi2HashKeyVec = QtConcurrent::blockingMappedReduced<QVector<CSameIndividualInstanceInitializationLinkerData>>(mappedIndi1HashKeyVec, keyMapFunc2, reduceFunc2); |
| 1233 |
cint64 timeStep3 = timer.elapsed(); |
| 1234 |
timer.restart(); |
| 1235 |
|
| 1236 |
function<void(const CSameIndividualInstanceInitializationLinkerData& initData)> keyMapFunc3 = |
| 1237 |
[&](const CSameIndividualInstanceInitializationLinkerData& initData) ->void { |
| 1238 |
|
| 1239 |
for (CSameIndividualInstanceInitializationLinker* linkerIt = initData.mFirst; linkerIt; linkerIt = linkerIt->getNext()) { |
| 1240 |
cint64 indiId = linkerIt->getData(); |
| 1241 |
COptimizedKPSetIndividualItem* indiItem = linkerIt->mIndiItem; |
| 1242 |
reqConfPreCompItem->getIndividualInstantiatedItemHash()->updateIndividualInstantiatedItem(indiId, indiItem); |
| 1243 |
} |
| 1244 |
}; |
| 1245 |
|
| 1246 |
QtConcurrent::blockingMap(mappedIndi2HashKeyVec, keyMapFunc3); |
| 1247 |
cint64 timeStep4 = timer.elapsed(); |
| 1248 |
timer.restart(); |
| 1249 |
|
| 1250 |
|
| 1251 |
function<cint64(COptimizedKPSetConceptInstancesItem* const & conceptItem)> keyMapFunc4 = |
| 1252 |
[&](COptimizedKPSetConceptInstancesItem* const & conceptItem) ->cint64 { |
| 1253 |
|
| 1254 |
cint64 possInstances = conceptItem->finishConcurrentInitialization(mConfConcurrentHandlingVectorSize); |
| 1255 |
return possInstances; |
| 1256 |
}; |
| 1257 |
|
| 1258 |
function<void(cint64& count, const cint64& reduceCount)> reduceFunc4 = [&](cint64& count, const cint64& reduceCount) -> void { |
| 1259 |
count += reduceCount; |
| 1260 |
}; |
| 1261 |
cint64 possInstances = QtConcurrent::blockingMappedReduced<cint64>(conceptInstItemSet, keyMapFunc4, reduceFunc4); |
| 1262 |
cint64 timeStep5 = timer.elapsed(); |
| 1263 |
|
| 1264 |
incOpenPossibleConceptInstancesCount(reqConfPreCompItem, possInstances); |
| 1265 |
|
| 1266 |
LOG(INFO, getDomain(), logTr("Individual items initialized concurrently (%1 ms for step 1, %2 ms for step 2, %3 ms for step 3, %4 ms for step 4, %5 ms for step 5).").arg(timeStep1).arg(timeStep2).arg(timeStep3).arg(timeStep4).arg(timeStep5), this); |
| 1267 |
|
| 1268 |
|
| 1269 |
} else { |
| 1270 |
for (QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemData*>::const_iterator it = repCacheConSetLabelItemDataHash->constBegin(), itEnd = repCacheConSetLabelItemDataHash->constEnd(); it != itEnd; ++it) { |
| 1271 |
CBackendRepresentativeMemoryLabelCacheItem* repConSetCacheLabelItem = it.key(); |
| 1272 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* repConSetCacheLabelItemData = it.value(); |
| 1273 |
if (repConSetCacheLabelItemData->hasPossibleInstances()) { |
| 1274 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelItemIndividualIdAssociations(repConSetCacheLabelItem, [&](cint64 indiId, bool sameIndividualMerged)->bool { |
| 1275 |
if (!sameIndividualMerged) { |
| 1276 |
initializeRepresentativeIndividualProcessing(reqConfPreCompItem, indiId, repConSetCacheLabelItem, repConSetCacheLabelItemData, &individualPossibleSameIndividualListHash); |
| 1277 |
} |
| 1278 |
return true; |
| 1279 |
}, true, true, false); |
| 1280 |
} |
| 1281 |
} |
| 1282 |
} |
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
CRole* topPropertyRole = reqConfPreCompItem->getOntology()->getRBox()->getTopObjectRole(); |
| 1287 |
|
| 1288 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData*>* repCacheCombNeighRoleSetLabelItemDataHash = reqConfPreCompItem->getRepresentativeCacheCombinedNeighbourRoleSetLabelItemDataHash(); |
| 1289 |
for (QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData*>::const_iterator it = repCacheCombNeighRoleSetLabelItemDataHash->constBegin(), itEnd = repCacheCombNeighRoleSetLabelItemDataHash->constEnd(); it != itEnd; ++it) { |
| 1290 |
CBackendRepresentativeMemoryLabelCacheItem* repCombNeighRoleSetCacheLabelItem = it.key(); |
| 1291 |
COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* repCombNeighRoleSetCacheLabelItemData = it.value(); |
| 1292 |
if (repCombNeighRoleSetCacheLabelItemData->hasPossibleInstances()) { |
| 1293 |
|
| 1294 |
for (COptimizedKPSetRoleInstancesItem* roleInstItem : *repCombNeighRoleSetCacheLabelItemData->getPossibleInstancesItemSet(false)) { |
| 1295 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash* combinedNeigRoleSetLabelDataHash = roleInstItem->getCombinedNeighbourCacheLabelItemDataHash(false); |
| 1296 |
if (roleInstItem->getRole() != topPropertyRole && combinedNeigRoleSetLabelDataHash->hasPossibleInstances()) { |
| 1297 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* combinedNeigRoleSetLabelData = combinedNeigRoleSetLabelDataHash->value(repCombNeighRoleSetCacheLabelItem); |
| 1298 |
if (combinedNeigRoleSetLabelData && combinedNeigRoleSetLabelData->hasPossibleInstancesLabelItems()) { |
| 1299 |
|
| 1300 |
|
| 1301 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelItemIndividualIdAssociations(repCombNeighRoleSetCacheLabelItem, [&](cint64 indiId, bool sameIndividualMerged)->bool { |
| 1302 |
if (!sameIndividualMerged) { |
| 1303 |
|
| 1304 |
|
| 1305 |
CIndividualVector* indiVec = reqConfPreCompItem->getOntology()->getABox()->getIndividualVector(false); |
| 1306 |
|
| 1307 |
COptimizedKPSetIndividualItem* individualItem = reqConfPreCompItem->getIndividualInstantiatedItem(indiId, true, indiVec->getData(indiId)); |
| 1308 |
COptimizedKPSetRoleNeighbourInstancesHash* roleNeighbourInstanceHash = individualItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 1309 |
COptimizedKPSetRoleNeighbourInstancesHashData& roleNeighbourInstanceHashData = (*roleNeighbourInstanceHash)[roleInstItem]; |
| 1310 |
|
| 1311 |
roleNeighbourInstanceHashData.mRoleSuccessorInstancesInitializing = true; |
| 1312 |
roleNeighbourInstanceHashData.mRoleSuccessorInstancesInitialized = true; |
| 1313 |
|
| 1314 |
|
| 1315 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(indiId); |
| 1316 |
if (indiAssData) { |
| 1317 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* neighbourRoleArray = indiAssData->getRoleSetNeighbourArray(); |
| 1318 |
|
| 1319 |
for (COptimizedKPSetRoleInstancesSingleNeighbourRoleSetCacheLabelData* data : *combinedNeigRoleSetLabelData->getPossibleInstancesLabelItemDataHash()) { |
| 1320 |
neighbourRoleArray->at(data->getLabelArrayIndex()).visitNeighbourIndividualIds([&](cint64 neighbourIndiId)->bool { |
| 1321 |
|
| 1322 |
COptimizedKPSetRoleInstancesHash* roleNeighbourSuccessorHash = roleNeighbourInstanceHashData.getRoleSuccessorInstancesHash(true); |
| 1323 |
COptimizedKPSetIndividualItem* precIndiItem = reqConfPreCompItem->getIndividualInstantiatedItem(neighbourIndiId, true, indiVec->getData(neighbourIndiId)); |
| 1324 |
if (precIndiItem->getIndividualId() == neighbourIndiId) { |
| 1325 |
COptimizedKPSetRoleInstancesHashData& roleNeighbourSuccessorHashData = (*roleNeighbourSuccessorHash)[neighbourIndiId]; |
| 1326 |
|
| 1327 |
if (!roleNeighbourSuccessorHashData.mInstanceItemData) { |
| 1328 |
|
| 1329 |
COptimizedKPSetRoleNeighbourInstancesHashData& precRoleNeighbourData = precIndiItem->getKnownPossibleRoleNeighboursInstancesHash()->operator[](roleInstItem); |
| 1330 |
COptimizedKPSetRoleInstancesHash* precNeighbourHash = precRoleNeighbourData.getRolePredecessorInstancesHash(true); |
| 1331 |
COptimizedKPSetRoleInstancesHashData& precHashData = (*precNeighbourHash)[indiId]; |
| 1332 |
|
| 1333 |
// only correct as long as all individuals are initialized |
| 1334 |
precRoleNeighbourData.mRolePredecessorInstancesInitializing = true; |
| 1335 |
precRoleNeighbourData.mRolePredecessorInstancesInitialized = true; |
| 1336 |
|
| 1337 |
|
| 1338 |
COptimizedKPSetRoleInstancesData* instanceData = new COptimizedKPSetRoleInstancesData(); |
| 1339 |
instanceData->mPossibleInstance = true; |
| 1340 |
roleNeighbourSuccessorHashData.mInstanceItemData = instanceData; |
| 1341 |
precHashData.mInstanceItemData = instanceData; |
| 1342 |
precHashData.mNeighbourIndividualItem = individualItem; |
| 1343 |
roleNeighbourSuccessorHashData.mNeighbourIndividualItem = precIndiItem; |
| 1344 |
|
| 1345 |
|
| 1346 |
roleInstItem->addPossibleInstance(COptimizedKPSetIndividualItemPair(individualItem, precIndiItem), false); |
| 1347 |
individualItem->incPossibleRoleInstantiatedCount(); |
| 1348 |
precIndiItem->incPossibleRoleInstantiatedCount(); |
| 1349 |
//if (roleInstItem->hasToProcessPossibleInstancesFlag()) { |
| 1350 |
// reqConfPreCompItem->addRoleInstanceItemToProcessPossibleInstances(roleInstItem); |
| 1351 |
//} |
| 1352 |
} |
| 1353 |
} |
| 1354 |
|
| 1355 |
|
| 1356 |
return true; |
| 1357 |
}); |
| 1358 |
} |
| 1359 |
} |
| 1360 |
|
| 1361 |
|
| 1362 |
} |
| 1363 |
return true; |
| 1364 |
}, true, true, false); |
| 1365 |
|
| 1366 |
} |
| 1367 |
} |
| 1368 |
} |
| 1369 |
|
| 1370 |
|
| 1371 |
} |
| 1372 |
} |
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
CIndividualVector* indiVec = reqConfPreCompItem->getOntology()->getABox()->getIndividualVector(false); |
| 1377 |
|
| 1378 |
function<void(COptimizedKPSetRoleInstancesItem* complexRoleInstItem, QSet<CBackendRepresentativeMemoryLabelCacheItem*>* labelCacheItemSet, QHash<cint64, COptimizedKPSetIndividualComplexRoleData*>* indiComplexRoleDataHash, QSet<CBackendRepresentativeMemoryLabelCacheItem*>& initLabelCacheItemSet)> individualComplexRoleInitHandlingFunction = [&](COptimizedKPSetRoleInstancesItem* complexRoleInstItem, QSet<CBackendRepresentativeMemoryLabelCacheItem*>* labelCacheItemSet, QHash<cint64, COptimizedKPSetIndividualComplexRoleData*>* indiComplexRoleDataHash, QSet<CBackendRepresentativeMemoryLabelCacheItem*>& initLabelCacheItemSet) { |
| 1379 |
for (CBackendRepresentativeMemoryLabelCacheItem* candLabelCacheItem : *labelCacheItemSet) { |
| 1380 |
if (!initLabelCacheItemSet.contains(candLabelCacheItem)) { |
| 1381 |
initLabelCacheItemSet.insert(candLabelCacheItem); |
| 1382 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelItemIndividualIdAssociations(candLabelCacheItem, [&](cint64 indiId, bool sameIndividualMerged)->bool { |
| 1383 |
indiComplexRoleDataHash->insert(indiId, nullptr); |
| 1384 |
return true; |
| 1385 |
}); |
| 1386 |
} |
| 1387 |
} |
| 1388 |
}; |
| 1389 |
|
| 1390 |
|
| 1391 |
for (COptimizedKPSetRoleInstancesItem* complexRoleInstItem : *reqConfPreCompItem->getComplexRoleInstancesItemList()) { |
| 1392 |
|
| 1393 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> initLabelCacheItemSet; |
| 1394 |
|
| 1395 |
QHash<cint64, COptimizedKPSetIndividualComplexRoleData*>* indiComplexRoleDataHash = complexRoleInstItem->getIndividualIdComplexRoleDataHash(); |
| 1396 |
|
| 1397 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* existentialLabelCacheItemSet = complexRoleInstItem->getComplexStarterCandidateCombinedExistentialRoleLabelCacheItemSet(false); |
| 1398 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* existentialInversedLabelCacheItemSet = complexRoleInstItem->getComplexStarterCandidateCombinedExistentialRoleLabelCacheItemSet(true); |
| 1399 |
|
| 1400 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* neighbourLabelCacheItemSet = complexRoleInstItem->getComplexStarterCandidateCombinedNeighbourRoleLabelCacheItemSet(false); |
| 1401 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* neighbourInversedLabelCacheItemSet = complexRoleInstItem->getComplexStarterCandidateCombinedNeighbourRoleLabelCacheItemSet(true); |
| 1402 |
|
| 1403 |
bool initComplexInstanceCandidateData = false; |
| 1404 |
if (existentialLabelCacheItemSet->isEmpty() && existentialInversedLabelCacheItemSet->isEmpty() && complexRoleInstItem->hasOnlyTransitiveComplexRoleCandidates()) { |
| 1405 |
|
| 1406 |
if (neighbourLabelCacheItemSet->intersects(*neighbourInversedLabelCacheItemSet)) { |
| 1407 |
initComplexInstanceCandidateData = true; |
| 1408 |
} |
| 1409 |
|
| 1410 |
} else { |
| 1411 |
initComplexInstanceCandidateData = true; |
| 1412 |
} |
| 1413 |
|
| 1414 |
if (initComplexInstanceCandidateData) { |
| 1415 |
individualComplexRoleInitHandlingFunction(complexRoleInstItem, neighbourLabelCacheItemSet, indiComplexRoleDataHash, initLabelCacheItemSet); |
| 1416 |
individualComplexRoleInitHandlingFunction(complexRoleInstItem, neighbourInversedLabelCacheItemSet, indiComplexRoleDataHash, initLabelCacheItemSet); |
| 1417 |
|
| 1418 |
individualComplexRoleInitHandlingFunction(complexRoleInstItem, neighbourLabelCacheItemSet, indiComplexRoleDataHash, initLabelCacheItemSet); |
| 1419 |
individualComplexRoleInitHandlingFunction(complexRoleInstItem, existentialInversedLabelCacheItemSet, indiComplexRoleDataHash, initLabelCacheItemSet); |
| 1420 |
} |
| 1421 |
} |
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitLabelCacheEntries(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL, [&](CBackendRepresentativeMemoryLabelCacheItem* possSameIndiLabelCacheItem)->bool { |
| 1427 |
reqConfPreCompItem->setPotentiallySameIndividuals(true); |
| 1428 |
|
| 1429 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitIndividualIdsOfAssociatedIndividualSetLabel(nullptr, possSameIndiLabelCacheItem, [&](cint64 indiId)->bool { |
| 1430 |
|
| 1431 |
cint64 indiVecPos = indiId % mConfConcurrentHandlingVectorSize; |
| 1432 |
if (possSameIndiLabelCacheItem->getIndividualAssociationCount() > 0 && !individualPossibleSameIndividualListHash[indiVecPos].contains(indiId)) { |
| 1433 |
|
| 1434 |
QList<CIndividualReference> possibleSameIndividualList; |
| 1435 |
|
| 1436 |
|
| 1437 |
CBackendRepresentativeMemoryLabelCacheItem* sameIndilabelItem = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociatedCacheLabelItem(indiId, CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL); |
| 1438 |
CBackendRepresentativeMemoryLabelCacheItem* possibleSameIndilabelItem = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociatedCacheLabelItem(indiId, CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL); |
| 1439 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitIndividualIdsOfAssociatedIndividualSetLabel(nullptr, possibleSameIndilabelItem, [&](cint64 possibleSameIndiId)->bool { |
| 1440 |
|
| 1441 |
if (possibleSameIndiId != indiId && !reqConfPreCompItem->getBackendAssociationCacheReader()->hasIndividualIdsInAssociatedIndividualSetLabel(nullptr, sameIndilabelItem, possibleSameIndiId)) { |
| 1442 |
CIndividual* possibleSameIndividual = indiVec->getData(possibleSameIndiId); |
| 1443 |
possibleSameIndividualList.append(CIndividualReference(possibleSameIndividual, possibleSameIndiId)); |
| 1444 |
} |
| 1445 |
return true; |
| 1446 |
}); |
| 1447 |
|
| 1448 |
individualPossibleSameIndividualListHash[indiVecPos].insert(indiId, possibleSameIndividualList); |
| 1449 |
|
| 1450 |
} |
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
return false; |
| 1455 |
}); |
| 1456 |
|
| 1457 |
|
| 1458 |
return true; |
| 1459 |
}); |
| 1460 |
|
| 1461 |
|
| 1462 |
for (cint64 i = 0; i < mConfConcurrentHandlingVectorSize; ++i) { |
| 1463 |
if (!individualPossibleSameIndividualListHash[i].isEmpty()) { |
| 1464 |
QSet<COptimizedKPSetIndividualItem*> singleIndividualSet; |
| 1465 |
for (QHash<cint64, QList<CIndividualReference> >::const_iterator it = individualPossibleSameIndividualListHash[i].constBegin(), itEnd = individualPossibleSameIndividualListHash[i].constEnd(); it != itEnd; ++it) { |
| 1466 |
cint64 individualId = it.key(); |
| 1467 |
COptimizedKPSetIndividualItem* individualItem = reqConfPreCompItem->getIndividualInstantiatedItem(individualId, true); |
| 1468 |
if (!singleIndividualSet.contains(individualItem)) { |
| 1469 |
singleIndividualSet.insert(individualItem); |
| 1470 |
const QList<CIndividualReference> possibleSameIndividualList = it.value(); |
| 1471 |
initializeSamePossibleIndividuals(reqConfPreCompItem, individualItem, possibleSameIndividualList); |
| 1472 |
} |
| 1473 |
} |
| 1474 |
} |
| 1475 |
} |
| 1476 |
|
| 1477 |
} |
| 1478 |
|
| 1479 |
return true; |
| 1480 |
} |
| 1481 |
|
| 1482 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::initializeSamePossibleIndividuals(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetIndividualItem* individualItem, const QList<CIndividualReference>& possibleSameIndividualList) { |
| 1483 |
reqConfPreCompItem->addPossibleSameIndividualsItem(individualItem); |
| 1484 |
for (QList<CIndividualReference>::const_iterator it = possibleSameIndividualList.constBegin(), itEnd = possibleSameIndividualList.constEnd(); it != itEnd; ++it) { |
| 1485 |
CIndividualReference possSameIndividual(*it); |
| 1486 |
COptimizedKPSetIndividualItem* possSameIndividualItem = reqConfPreCompItem->getIndividualInstantiatedItem(possSameIndividual.getIndividualID(),true); |
| 1487 |
individualItem->addPossibleSameIndividualItem(possSameIndividualItem); |
| 1488 |
possSameIndividualItem->addPossibleSameIndividualItem(individualItem); |
| 1489 |
incOpenPossibleSameIndividualsCount(reqConfPreCompItem); |
| 1490 |
} |
| 1491 |
return true; |
| 1492 |
} |
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
CPossibleInstancesIndividualsMergingData* COptimizedRepresentativeKPSetOntologyRealizingThread::getPossibleInstancesMergingData(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetConceptInstancesItem* instancesItem, COptimizedKPSetIndividualItem* instantiatedItem, cint64 remainingTestingCount) { |
| 1500 |
if (!mConfPossibleInstanceIndividualsAfterwardsMerging) { |
| 1501 |
return nullptr; |
| 1502 |
} |
| 1503 |
if (reqConfPreCompItem->requiresIndividualDependenceTracking()) { |
| 1504 |
return nullptr; |
| 1505 |
} |
| 1506 |
QHash<COptimizedKPSetIndividualItem*, CPossibleInstancesIndividualsMergingLinker*>* mergingDataHash = instancesItem->getIndividualItemPossibleInstanceMergingLinkerHash(false); |
| 1507 |
if (mergingDataHash && mergingDataHash->contains(instantiatedItem)) { |
| 1508 |
CPossibleInstancesIndividualsMergingLinker* mergingIndiLinker = mergingDataHash->value(instantiatedItem); |
| 1509 |
CPossibleInstancesIndividualsMergingData* mergingData = mergingIndiLinker->getMergingData(); |
| 1510 |
return mergingData; |
| 1511 |
} |
| 1512 |
|
| 1513 |
if (remainingTestingCount < mConfMinimumPossibleInstanceIndividualsAfterwardsMergingCount) { |
| 1514 |
return nullptr; |
| 1515 |
} |
| 1516 |
|
| 1517 |
// test whether it is worthwhile to try merging with other individuals |
| 1518 |
QMap<cint64, COptimizedKPSetIndividualItem*>* possibleInstanceItemSet = instancesItem->getPossibleInstancesMap(); |
| 1519 |
QMap<cint64, COptimizedKPSetIndividualItem*>* prefferedInstanceItemTestingSet = instancesItem->getPrefferedPossibleInstanceTestingSet(); |
| 1520 |
|
| 1521 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, bool>* testConceptLabelSetHash = nullptr; |
| 1522 |
|
| 1523 |
cint64 compatibleLabelItemCount = 0; |
| 1524 |
cint64 clashingLabelItemCount = 0; |
| 1525 |
cint64 possibleInstanceIndividualsMergingCount = 0; |
| 1526 |
|
| 1527 |
cint64 maxMergingCount = mConfPossibleInstanceIndividualsAfterwardsMergingProvidingCount; |
| 1528 |
if (possibleInstanceItemSet && possibleInstanceItemSet->count() > 1 && maxMergingCount != 0) { |
| 1529 |
CPossibleInstancesIndividualsMergingData* mergingData = nullptr; |
| 1530 |
cint64 individualId = instantiatedItem->getIndividualId(); |
| 1531 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* assData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(individualId); |
| 1532 |
if (assData) { |
| 1533 |
CBackendRepresentativeMemoryLabelCacheItem* conceptLabelDataItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL); |
| 1534 |
// find the individuals with the same/a compatible representative label |
| 1535 |
|
| 1536 |
auto possibleInstanceMapCollectFunction = [&](QMap<cint64, COptimizedKPSetIndividualItem*>* possInstanceItemMap)->bool { |
| 1537 |
for (QMap<cint64, COptimizedKPSetIndividualItem*>::iterator possInstanceItemIt = possInstanceItemMap->begin(); possInstanceItemIt != possInstanceItemMap->end(); ) { |
| 1538 |
COptimizedKPSetIndividualItem* otherPossibleInstanceItem(*possInstanceItemIt); |
| 1539 |
|
| 1540 |
bool iterateNextPossibleInstance = true; |
| 1541 |
|
| 1542 |
if (!mergingDataHash || !mergingDataHash->contains(otherPossibleInstanceItem)) { |
| 1543 |
cint64 otherPossibleIndividualId = otherPossibleInstanceItem->getIndividualId(); |
| 1544 |
bool otherPossibleIndiSuitable = true; |
| 1545 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* otherPossInstAssData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(otherPossibleIndividualId); |
| 1546 |
CBackendRepresentativeMemoryLabelCacheItem* oterConceptLabelItem = otherPossInstAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL); |
| 1547 |
if (oterConceptLabelItem == conceptLabelDataItem) { |
| 1548 |
otherPossibleIndiSuitable = true; |
| 1549 |
} else if (mConfPossibleInstanceIndividualsAfterwardsMergingOnlyWithSameRepresentativeLabel) { |
| 1550 |
otherPossibleIndiSuitable = false; |
| 1551 |
} else { |
| 1552 |
if (testConceptLabelSetHash && testConceptLabelSetHash->contains(oterConceptLabelItem)) { |
| 1553 |
otherPossibleIndiSuitable = testConceptLabelSetHash->value(oterConceptLabelItem); |
| 1554 |
} else { |
| 1555 |
otherPossibleIndiSuitable = true; |
| 1556 |
reqConfPreCompItem->getBackendAssociationCacheReader()->visitConceptsOfAssociatedConceptSetLabel(assData, conceptLabelDataItem, [&](CConcept* concept, bool negation)->bool { |
| 1557 |
if (reqConfPreCompItem->getBackendAssociationCacheReader()->hasConceptInAssociatedFullConceptSetLabel(otherPossInstAssData, oterConceptLabelItem, concept, !negation)) { |
| 1558 |
otherPossibleIndiSuitable = false; |
| 1559 |
return false; |
| 1560 |
} |
| 1561 |
return true; |
| 1562 |
}); |
| 1563 |
if (!testConceptLabelSetHash) { |
| 1564 |
testConceptLabelSetHash = new QHash<CBackendRepresentativeMemoryLabelCacheItem*, bool>(); |
| 1565 |
} |
| 1566 |
testConceptLabelSetHash->insert(oterConceptLabelItem, otherPossibleIndiSuitable); |
| 1567 |
if (otherPossibleIndiSuitable) { |
| 1568 |
compatibleLabelItemCount++; |
| 1569 |
} else { |
| 1570 |
clashingLabelItemCount++; |
| 1571 |
} |
| 1572 |
} |
| 1573 |
} |
| 1574 |
|
| 1575 |
if (otherPossibleIndiSuitable) { |
| 1576 |
possibleInstanceIndividualsMergingCount++; |
| 1577 |
|
| 1578 |
bool isInstanceByModelMerging = false; |
| 1579 |
if (checkTrivialConceptInstanceModelMerging(reqConfPreCompItem, instancesItem, otherPossibleInstanceItem, isInstanceByModelMerging, true)) { |
| 1580 |
|
| 1581 |
instancesItem->incTestingPossibleInstancesCount(); |
| 1582 |
otherPossibleInstanceItem->incTestingPossibleInstantiatedCount(); |
| 1583 |
otherPossibleInstanceItem->decPossibleInstantiatedCount(); |
| 1584 |
otherPossibleInstanceItem->setTestingPossibleInstantiated(instancesItem); |
| 1585 |
reqConfPreCompItem->incTestingPossibleConceptInstanceCount(); |
| 1586 |
reqConfPreCompItem->incModelMergingsSucessCount(); |
| 1587 |
|
| 1588 |
possInstanceItemIt = possInstanceItemMap->erase(possInstanceItemIt); |
| 1589 |
if (possInstanceItemMap == prefferedInstanceItemTestingSet) { |
| 1590 |
if (possibleInstanceItemSet) { |
| 1591 |
possibleInstanceItemSet->remove(otherPossibleInstanceItem->getIndividualId()); |
| 1592 |
} |
| 1593 |
} else { |
| 1594 |
if (prefferedInstanceItemTestingSet) { |
| 1595 |
prefferedInstanceItemTestingSet->remove(otherPossibleInstanceItem->getIndividualId()); |
| 1596 |
} |
| 1597 |
} |
| 1598 |
iterateNextPossibleInstance = false; |
| 1599 |
|
| 1600 |
if (isInstanceByModelMerging) { |
| 1601 |
reqConfPreCompItem->incModelMergingsInstanceFoundCount(); |
| 1602 |
} else { |
| 1603 |
reqConfPreCompItem->incModelMergingsNonInstanceFoundCount(); |
| 1604 |
} |
| 1605 |
interpretConceptInstantiationResult(reqConfPreCompItem, instancesItem, otherPossibleInstanceItem, isInstanceByModelMerging); |
| 1606 |
|
| 1607 |
} else { |
| 1608 |
|
| 1609 |
if (!mergingData) { |
| 1610 |
reqConfPreCompItem->incProvidedPossibleInstancesMergingsCount(); |
| 1611 |
mergingData = new CPossibleInstancesIndividualsMergingData(mConfPossibleInstanceIndividualsAfterwardsMergingMaximumAttemptCount); |
| 1612 |
|
| 1613 |
CPossibleInstancesIndividualsMergingLinker* linker = new CPossibleInstancesIndividualsMergingLinker(); |
| 1614 |
linker->initPossibleInstancesIndividualsMergingLinker(individualId, mergingData); |
| 1615 |
reqConfPreCompItem->incProvidedPossibleInstancesMergingIndividualsCount(); |
| 1616 |
mergingData->addPossibleInstancesIndividualsMergingLinker(linker); |
| 1617 |
if (!mergingDataHash) { |
| 1618 |
mergingDataHash = instancesItem->getIndividualItemPossibleInstanceMergingLinkerHash(true); |
| 1619 |
} |
| 1620 |
mergingDataHash->insert(instantiatedItem, linker); |
| 1621 |
} |
| 1622 |
CPossibleInstancesIndividualsMergingLinker* linker = new CPossibleInstancesIndividualsMergingLinker(); |
| 1623 |
linker->initPossibleInstancesIndividualsMergingLinker(otherPossibleIndividualId, mergingData); |
| 1624 |
reqConfPreCompItem->incProvidedPossibleInstancesMergingIndividualsCount(); |
| 1625 |
mergingData->addPossibleInstancesIndividualsMergingLinker(linker); |
| 1626 |
if (!mergingDataHash) { |
| 1627 |
mergingDataHash = instancesItem->getIndividualItemPossibleInstanceMergingLinkerHash(true); |
| 1628 |
} |
| 1629 |
mergingDataHash->insert(otherPossibleInstanceItem, linker); |
| 1630 |
|
| 1631 |
if (mConfPossibleInstanceIndividualsAfterwardsMergingProvidingCount > 0 && maxMergingCount-- <= 0) { |
| 1632 |
return false; |
| 1633 |
} |
| 1634 |
} |
| 1635 |
} |
| 1636 |
} |
| 1637 |
|
| 1638 |
if (iterateNextPossibleInstance) { |
| 1639 |
++possInstanceItemIt; |
| 1640 |
} |
| 1641 |
} |
| 1642 |
return true; |
| 1643 |
}; |
| 1644 |
|
| 1645 |
|
| 1646 |
bool continueCollect = true; |
| 1647 |
if (continueCollect && prefferedInstanceItemTestingSet && !prefferedInstanceItemTestingSet->isEmpty()) { |
| 1648 |
continueCollect = possibleInstanceMapCollectFunction(prefferedInstanceItemTestingSet); |
| 1649 |
} |
| 1650 |
|
| 1651 |
if (continueCollect && possibleInstanceItemSet && !possibleInstanceItemSet->isEmpty()) { |
| 1652 |
continueCollect = possibleInstanceMapCollectFunction(possibleInstanceItemSet); |
| 1653 |
} |
| 1654 |
|
| 1655 |
|
| 1656 |
} |
| 1657 |
|
| 1658 |
if (mergingData) { |
| 1659 |
instancesItem->getPossibleInstanceMergingDataContainer(true)->append(mergingData); |
| 1660 |
} |
| 1661 |
return mergingData; |
| 1662 |
} |
| 1663 |
if (testConceptLabelSetHash) { |
| 1664 |
delete testConceptLabelSetHash; |
| 1665 |
} |
| 1666 |
return nullptr; |
| 1667 |
} |
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
|
| 1673 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::visitRepresentativeCacheNeighbours(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, CRole* role, CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData, function<bool(cint64 neighbourIndiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* neighbourAssData, bool deterministicNeighbour)> visitFunc) { |
| 1674 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)reqConfPreCompItem->getRoleInstantiatedItem(role); |
| 1675 |
if (redRoleItem) { |
| 1676 |
COptimizedKPSetRoleInstancesItem* roleInstancesItem = redRoleItem->getRedirectedItem(); |
| 1677 |
bool itemInversed = redRoleItem->isInversed(); |
| 1678 |
|
| 1679 |
bool inversed = itemInversed; |
| 1680 |
|
| 1681 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* roleItemCompNeighLabelData = roleInstancesItem->getCombinedNeighbourCacheLabelItemDataHash(inversed)->value(indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL)); |
| 1682 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* roleSetNeighbourArray = indiAssData->getRoleSetNeighbourArray(); |
| 1683 |
|
| 1684 |
bool continueVisiting = true; |
| 1685 |
if (roleItemCompNeighLabelData) { |
| 1686 |
if (continueVisiting && roleItemCompNeighLabelData->hasKnownInstancesLabelItems()) { |
| 1687 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedKPSetRoleInstancesSingleNeighbourRoleSetCacheLabelData*>* singleNeighLabelDataHash = roleItemCompNeighLabelData->getKnownInstancesLabelItemDataHash(); |
| 1688 |
|
| 1689 |
for (auto it = singleNeighLabelDataHash->constBegin(), itEnd = singleNeighLabelDataHash->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 1690 |
roleSetNeighbourArray->at(it.value()->getLabelArrayIndex()).visitNeighbourIndividualIds([&](cint64 neighbourId)->bool { |
| 1691 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* neighbourIndiAssData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(neighbourId); |
| 1692 |
continueVisiting = visitFunc(neighbourId, neighbourIndiAssData, true); |
| 1693 |
return continueVisiting; |
| 1694 |
}); |
| 1695 |
} |
| 1696 |
} |
| 1697 |
if (continueVisiting && roleItemCompNeighLabelData->hasPossibleInstancesLabelItems()) { |
| 1698 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedKPSetRoleInstancesSingleNeighbourRoleSetCacheLabelData*>* singleNeighLabelDataHash = roleItemCompNeighLabelData->getPossibleInstancesLabelItemDataHash(); |
| 1699 |
|
| 1700 |
for (auto it = singleNeighLabelDataHash->constBegin(), itEnd = singleNeighLabelDataHash->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 1701 |
roleSetNeighbourArray->at(it.value()->getLabelArrayIndex()).visitNeighbourIndividualIds([&](cint64 neighbourId)->bool { |
| 1702 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* neighbourIndiAssData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(neighbourId); |
| 1703 |
continueVisiting = visitFunc(neighbourId, neighbourIndiAssData, false); |
| 1704 |
return continueVisiting; |
| 1705 |
}); |
| 1706 |
} |
| 1707 |
} |
| 1708 |
} |
| 1709 |
return true; |
| 1710 |
|
| 1711 |
} |
| 1712 |
return false; |
| 1713 |
} |
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::checkTrivialInstanceConceptRepresentativeCacheBasedMerging(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, CConcept* concept, bool conceptNegation, CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, bool* mergableFlag, bool* unmergableFlag, cint64* mergingOperationLimit) { |
| 1718 |
if (mergingOperationLimit && *mergingOperationLimit-- <= 0) { |
| 1719 |
return false; |
| 1720 |
} |
| 1721 |
|
| 1722 |
// mergeable means that the concept could safely be added without causing a clash |
| 1723 |
bool mergeable = false; |
| 1724 |
|
| 1725 |
// unmergable means that the addition of the concept would certainly cause a clash |
| 1726 |
bool unmergeable = false; |
| 1727 |
|
| 1728 |
cint64 opCode = concept->getOperatorCode(); |
| 1729 |
|
| 1730 |
CBackendRepresentativeMemoryLabelCacheItem* conceptSetLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL); |
| 1731 |
|
| 1732 |
bool negatedConceptOccurrence = false; |
| 1733 |
bool deterministicOccurrence = false; |
| 1734 |
if (reqConfPreCompItem->getBackendAssociationCacheReader()->getConceptOccurrenceInAssociatedFullConceptSetLabel(assData, conceptSetLabelItem, concept, negatedConceptOccurrence, deterministicOccurrence)) { |
| 1735 |
if (negatedConceptOccurrence == conceptNegation) { |
| 1736 |
mergeable = true; |
| 1737 |
} else { |
| 1738 |
if (deterministicOccurrence) { |
| 1739 |
unmergeable = true; |
| 1740 |
} |
| 1741 |
} |
| 1742 |
} else { |
| 1743 |
if (conceptNegation && (opCode == CCSUB)) { |
| 1744 |
mergeable = true; |
| 1745 |
|
| 1746 |
} else if (!conceptNegation && (opCode == CCOR) || conceptNegation && (opCode == CCAND || opCode == CCEQ)) { |
| 1747 |
// mergeable if we find one concept that is not in the label or the sub concept is mergeable |
| 1748 |
|
| 1749 |
bool oneMergable = false; |
| 1750 |
bool allUnmergeable = true; |
| 1751 |
|
| 1752 |
if (conceptSetLabelItem) { |
| 1753 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && (!oneMergable || allUnmergeable); opConLinkerIt = opConLinkerIt->getNext()) { |
| 1754 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 1755 |
bool opConNegation = opConLinkerIt->isNegated() ^ conceptNegation; |
| 1756 |
|
| 1757 |
bool opConMergeable = false; |
| 1758 |
bool opConUnmergeable = false; |
| 1759 |
|
| 1760 |
checkTrivialInstanceConceptRepresentativeCacheBasedMerging(reqConfPreCompItem, opConcept, opConNegation, assData, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 1761 |
oneMergable |= opConMergeable; |
| 1762 |
allUnmergeable &= opConUnmergeable; |
| 1763 |
} |
| 1764 |
} |
| 1765 |
|
| 1766 |
mergeable = oneMergable; |
| 1767 |
unmergeable = allUnmergeable; |
| 1768 |
|
| 1769 |
|
| 1770 |
} else if (!conceptNegation && (opCode == CCOR) || conceptNegation && (opCode == CCAND || opCode == CCEQ)) { |
| 1771 |
|
| 1772 |
bool allMergable = true; |
| 1773 |
bool oneUnmergeable = true; |
| 1774 |
|
| 1775 |
if (conceptSetLabelItem) { |
| 1776 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && (allMergable || !oneUnmergeable); opConLinkerIt = opConLinkerIt->getNext()) { |
| 1777 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 1778 |
bool opConNegation = opConLinkerIt->isNegated() ^ conceptNegation; |
| 1779 |
|
| 1780 |
bool opConMergeable = false; |
| 1781 |
bool opConUnmergeable = false; |
| 1782 |
|
| 1783 |
checkTrivialInstanceConceptRepresentativeCacheBasedMerging(reqConfPreCompItem, opConcept, opConNegation, assData, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 1784 |
allMergable &= opConMergeable; |
| 1785 |
oneUnmergeable |= opConUnmergeable; |
| 1786 |
} |
| 1787 |
} |
| 1788 |
|
| 1789 |
mergeable = allMergable; |
| 1790 |
unmergeable = oneUnmergeable; |
| 1791 |
|
| 1792 |
|
| 1793 |
} else if (!conceptNegation && (opCode == CCATMOST) || conceptNegation && (opCode == CCATLEAST)) { |
| 1794 |
cint64 cardinality = concept->getParameter() - 1 * conceptNegation; |
| 1795 |
// mergeable if the node does not have n corresponding neighbours |
| 1796 |
CRole* role = concept->getRole(); |
| 1797 |
|
| 1798 |
|
| 1799 |
cint64 ignoreableNeighbourCount = 0; |
| 1800 |
cint64 certainlyRelevantNeighbourCount = 0; |
| 1801 |
cint64 succCount = 0; |
| 1802 |
bool cancled = false; |
| 1803 |
|
| 1804 |
CBackendRepresentativeMemoryLabelCacheItem* detExtLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 1805 |
CBackendRepresentativeMemoryLabelCacheItem* nondetExtLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 1806 |
|
| 1807 |
if (!reqConfPreCompItem->getBackendAssociationCacheReader()->hasRoleInAssociatedCompinationRoleSetLabel(assData, detExtLabelItem, role, false) && !reqConfPreCompItem->getBackendAssociationCacheReader()->hasRoleInAssociatedCompinationRoleSetLabel(assData, nondetExtLabelItem, role, false)) { |
| 1808 |
|
| 1809 |
if (visitRepresentativeCacheNeighbours(reqConfPreCompItem, role, assData, [&](cint64 neighbourIndiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* neighbourAssData, bool deterministicNeighbour)->bool { |
| 1810 |
|
| 1811 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt; opConLinkerIt = opConLinkerIt->getNext()) { |
| 1812 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 1813 |
bool opConNegation = opConLinkerIt->isNegated(); |
| 1814 |
|
| 1815 |
bool opConMergeable = false; |
| 1816 |
bool opConUnmergeable = false; |
| 1817 |
|
| 1818 |
checkTrivialInstanceConceptRepresentativeCacheBasedMerging(reqConfPreCompItem, opConcept, !opConNegation, neighbourAssData, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 1819 |
// if the negation of the qualifying concept can safely be added, then it does not have to be considered for the merging |
| 1820 |
if (opConMergeable) { |
| 1821 |
ignoreableNeighbourCount++; |
| 1822 |
} |
| 1823 |
if (opConUnmergeable) { |
| 1824 |
certainlyRelevantNeighbourCount++; |
| 1825 |
} |
| 1826 |
} |
| 1827 |
|
| 1828 |
++succCount; |
| 1829 |
|
| 1830 |
|
| 1831 |
if (mergingOperationLimit && *mergingOperationLimit-- <= 0) { |
| 1832 |
cancled = true; |
| 1833 |
return false; |
| 1834 |
} |
| 1835 |
|
| 1836 |
if (certainlyRelevantNeighbourCount > cardinality) { |
| 1837 |
return false; |
| 1838 |
} else { |
| 1839 |
return true; |
| 1840 |
} |
| 1841 |
|
| 1842 |
})) { |
| 1843 |
|
| 1844 |
if (!cancled) { |
| 1845 |
if (cardinality == 0 && certainlyRelevantNeighbourCount >= 1) { |
| 1846 |
unmergeable = true; |
| 1847 |
} |
| 1848 |
if (certainlyRelevantNeighbourCount <= cardinality && succCount - ignoreableNeighbourCount <= cardinality) { |
| 1849 |
mergeable = true; |
| 1850 |
} |
| 1851 |
} |
| 1852 |
|
| 1853 |
} |
| 1854 |
} |
| 1855 |
|
| 1856 |
} else if (!conceptNegation && (opCode == CCSOME) || conceptNegation && (opCode == CCALL)) { |
| 1857 |
// mergeable if there is one neighbour that satisfies the qualifying restriction |
| 1858 |
// unmergeable is non-trivial to detect (maybe we can use the saturation graph somehow?) |
| 1859 |
|
| 1860 |
CRole* role = concept->getRole(); |
| 1861 |
|
| 1862 |
bool oneMergable = false; |
| 1863 |
bool allUnmergeable = true; |
| 1864 |
bool cancled = false; |
| 1865 |
|
| 1866 |
if (visitRepresentativeCacheNeighbours(reqConfPreCompItem, role, assData, [&](cint64 neighbourIndiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* neighbourAssData, bool deterministicNeighbour)->bool { |
| 1867 |
|
| 1868 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && !oneMergable; opConLinkerIt = opConLinkerIt->getNext()) { |
| 1869 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 1870 |
bool opConNegation = opConLinkerIt->isNegated() ^ conceptNegation; |
| 1871 |
|
| 1872 |
bool opConMergeable = false; |
| 1873 |
bool opConUnmergeable = false; |
| 1874 |
|
| 1875 |
checkTrivialInstanceConceptRepresentativeCacheBasedMerging(reqConfPreCompItem, opConcept, opConNegation, neighbourAssData, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 1876 |
oneMergable |= opConMergeable; |
| 1877 |
} |
| 1878 |
|
| 1879 |
|
| 1880 |
if (mergingOperationLimit && *mergingOperationLimit-- <= 0) { |
| 1881 |
cancled = true; |
| 1882 |
return false; |
| 1883 |
} |
| 1884 |
|
| 1885 |
|
| 1886 |
return !oneMergable; |
| 1887 |
|
| 1888 |
})) { |
| 1889 |
if (!cancled) { |
| 1890 |
mergeable = oneMergable; |
| 1891 |
} |
| 1892 |
} |
| 1893 |
|
| 1894 |
|
| 1895 |
} else if (!conceptNegation && (opCode == CCALL) || conceptNegation && (opCode == CCSOME)) { |
| 1896 |
|
| 1897 |
CRole* role = concept->getRole(); |
| 1898 |
|
| 1899 |
bool allMergable = true; |
| 1900 |
bool oneUnmergeable = false; |
| 1901 |
bool cancled = false; |
| 1902 |
|
| 1903 |
CBackendRepresentativeMemoryLabelCacheItem* detExtLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 1904 |
CBackendRepresentativeMemoryLabelCacheItem* nondetExtLabelItem = assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 1905 |
|
| 1906 |
if (!reqConfPreCompItem->getBackendAssociationCacheReader()->hasRoleInAssociatedCompinationRoleSetLabel(assData, detExtLabelItem, role, false) && !reqConfPreCompItem->getBackendAssociationCacheReader()->hasRoleInAssociatedCompinationRoleSetLabel(assData, nondetExtLabelItem, role, false)) { |
| 1907 |
|
| 1908 |
if (visitRepresentativeCacheNeighbours(reqConfPreCompItem, role, assData, [&](cint64 neighbourIndiId, CBackendRepresentativeMemoryCacheIndividualAssociationData* neighbourAssData, bool deterministicNeighbour)->bool { |
| 1909 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && (allMergable || !oneUnmergeable); opConLinkerIt = opConLinkerIt->getNext()) { |
| 1910 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 1911 |
bool opConNegation = opConLinkerIt->isNegated() ^ conceptNegation; |
| 1912 |
|
| 1913 |
bool opConMergeable = false; |
| 1914 |
bool opConUnmergeable = false; |
| 1915 |
|
| 1916 |
checkTrivialInstanceConceptRepresentativeCacheBasedMerging(reqConfPreCompItem, opConcept, opConNegation, neighbourAssData, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 1917 |
allMergable &= opConMergeable; |
| 1918 |
if (deterministicNeighbour) { |
| 1919 |
oneUnmergeable |= opConUnmergeable; |
| 1920 |
} |
| 1921 |
} |
| 1922 |
|
| 1923 |
if (mergingOperationLimit && *mergingOperationLimit-- <= 0) { |
| 1924 |
cancled = true; |
| 1925 |
return false; |
| 1926 |
} |
| 1927 |
|
| 1928 |
return (allMergable || !oneUnmergeable); |
| 1929 |
})) { |
| 1930 |
if (!cancled) { |
| 1931 |
mergeable = allMergable; |
| 1932 |
unmergeable = oneUnmergeable; |
| 1933 |
} |
| 1934 |
} |
| 1935 |
} |
| 1936 |
|
| 1937 |
|
| 1938 |
} else if (!conceptNegation && (opCode == CCNOMINAL)) { |
| 1939 |
|
| 1940 |
CIndividual* nominalIndi = concept->getNominalIndividual(); |
| 1941 |
if (nominalIndi->getIndividualID() == assData->getAssociatedIndividualId()) { |
| 1942 |
mergeable = true; |
| 1943 |
} else { |
| 1944 |
if (reqConfPreCompItem->getBackendAssociationCacheReader()->hasIndividualIdsInAssociatedIndividualSetLabel(assData, assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL), nominalIndi->getIndividualID()) || |
| 1945 |
reqConfPreCompItem->getBackendAssociationCacheReader()->hasIndividualIdsInAssociatedIndividualSetLabel(assData, assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL), nominalIndi->getIndividualID())) { |
| 1946 |
mergeable = true; |
| 1947 |
} else if (reqConfPreCompItem->getBackendAssociationCacheReader()->hasIndividualIdsInAssociatedIndividualSetLabel(assData, assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_DIFFRENT_INDIVIDUAL_SET_LABEL), nominalIndi->getIndividualID())) { |
| 1948 |
unmergeable = true; |
| 1949 |
} |
| 1950 |
} |
| 1951 |
|
| 1952 |
} else if (conceptNegation && (opCode == CCNOMINAL)) { |
| 1953 |
|
| 1954 |
CIndividual* nominalIndi = concept->getNominalIndividual(); |
| 1955 |
if (nominalIndi->getIndividualID() == assData->getAssociatedIndividualId()) { |
| 1956 |
unmergeable = true; |
| 1957 |
} else { |
| 1958 |
if (reqConfPreCompItem->getBackendAssociationCacheReader()->hasIndividualIdsInAssociatedIndividualSetLabel(assData, assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_DIFFRENT_INDIVIDUAL_SET_LABEL), nominalIndi->getIndividualID()) || |
| 1959 |
reqConfPreCompItem->getBackendAssociationCacheReader()->hasIndividualIdsInAssociatedIndividualSetLabel(assData, assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_DIFFRENT_INDIVIDUAL_SET_LABEL), nominalIndi->getIndividualID())) { |
| 1960 |
mergeable = true; |
| 1961 |
} else if (reqConfPreCompItem->getBackendAssociationCacheReader()->hasIndividualIdsInAssociatedIndividualSetLabel(assData, assData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL), nominalIndi->getIndividualID())) { |
| 1962 |
unmergeable = true; |
| 1963 |
} |
| 1964 |
} |
| 1965 |
|
| 1966 |
} |
| 1967 |
} |
| 1968 |
|
| 1969 |
if (mergableFlag) { |
| 1970 |
*mergableFlag = mergeable; |
| 1971 |
} |
| 1972 |
if (unmergableFlag) { |
| 1973 |
*unmergableFlag = unmergeable; |
| 1974 |
} |
| 1975 |
|
| 1976 |
if (mergeable || unmergeable) { |
| 1977 |
return true; |
| 1978 |
} else { |
| 1979 |
return false; |
| 1980 |
} |
| 1981 |
} |
| 1982 |
|
| 1983 |
|
| 1984 |
|
| 1985 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::checkTrivialInstanceConceptCachedCompletionGraphBasedMerging(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, CConcept* concept, bool conceptNegation, CIndividualProcessNode* indiNode, CIndividualProcessNodeVector* indiProcVector, bool* mergableFlag, bool* unmergableFlag, cint64* mergingOperationLimit) { |
| 1986 |
if (mergingOperationLimit && *mergingOperationLimit-- <= 0) { |
| 1987 |
return false; |
| 1988 |
} |
| 1989 |
|
| 1990 |
// mergeable means that the concept could safely be added without causing a clash |
| 1991 |
bool mergeable = false; |
| 1992 |
|
| 1993 |
// unmergable means that the addition of the concept would certainly cause a clash |
| 1994 |
bool unmergeable = false; |
| 1995 |
|
| 1996 |
cint64 opCode = concept->getOperatorCode(); |
| 1997 |
CReapplyConceptLabelSet* labelSet = indiNode->getReapplyConceptLabelSet(false); |
| 1998 |
|
| 1999 |
CConceptDescriptor* conDes = nullptr; |
| 2000 |
CDependencyTrackPoint* depTrackPoint = nullptr; |
| 2001 |
if (labelSet->getConceptDescriptor(concept, conDes, depTrackPoint)) { |
| 2002 |
if (conDes->getNegation() == conceptNegation) { |
| 2003 |
mergeable = true; |
| 2004 |
} else { |
| 2005 |
if (depTrackPoint && depTrackPoint->getBranchingTag() <= 0) { |
| 2006 |
unmergeable = true; |
| 2007 |
} |
| 2008 |
} |
| 2009 |
} else { |
| 2010 |
if (conceptNegation && (opCode == CCSUB)) { |
| 2011 |
mergeable = true; |
| 2012 |
|
| 2013 |
} else if (!conceptNegation && (opCode == CCOR) || conceptNegation && (opCode == CCAND || opCode == CCEQ)) { |
| 2014 |
// mergeable if we find one concept that is not in the label or the sub concept is mergeable |
| 2015 |
|
| 2016 |
bool oneMergable = false; |
| 2017 |
bool allUnmergeable = true; |
| 2018 |
|
| 2019 |
if (labelSet) { |
| 2020 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && (!oneMergable || allUnmergeable); opConLinkerIt = opConLinkerIt->getNext()) { |
| 2021 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 2022 |
bool opConNegation = opConLinkerIt->isNegated() ^ conceptNegation; |
| 2023 |
|
| 2024 |
bool opConMergeable = false; |
| 2025 |
bool opConUnmergeable = false; |
| 2026 |
|
| 2027 |
checkTrivialInstanceConceptCachedCompletionGraphBasedMerging(reqConfPreCompItem, opConcept, opConNegation, indiNode, indiProcVector, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 2028 |
oneMergable |= opConMergeable; |
| 2029 |
allUnmergeable &= opConUnmergeable; |
| 2030 |
} |
| 2031 |
} |
| 2032 |
|
| 2033 |
mergeable = oneMergable; |
| 2034 |
unmergeable = allUnmergeable; |
| 2035 |
|
| 2036 |
|
| 2037 |
} else if (!conceptNegation && (opCode == CCOR) || conceptNegation && (opCode == CCAND || opCode == CCEQ)) { |
| 2038 |
|
| 2039 |
bool allMergable = true; |
| 2040 |
bool oneUnmergeable = true; |
| 2041 |
|
| 2042 |
if (labelSet) { |
| 2043 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && (allMergable || !oneUnmergeable); opConLinkerIt = opConLinkerIt->getNext()) { |
| 2044 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 2045 |
bool opConNegation = opConLinkerIt->isNegated() ^ conceptNegation; |
| 2046 |
|
| 2047 |
bool opConMergeable = false; |
| 2048 |
bool opConUnmergeable = false; |
| 2049 |
|
| 2050 |
checkTrivialInstanceConceptCachedCompletionGraphBasedMerging(reqConfPreCompItem, opConcept, opConNegation, indiNode, indiProcVector, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 2051 |
allMergable &= opConMergeable; |
| 2052 |
oneUnmergeable |= opConUnmergeable; |
| 2053 |
} |
| 2054 |
} |
| 2055 |
|
| 2056 |
mergeable = allMergable; |
| 2057 |
unmergeable = oneUnmergeable; |
| 2058 |
|
| 2059 |
|
| 2060 |
} else if (!conceptNegation && (opCode == CCATMOST) || conceptNegation && (opCode == CCATLEAST)) { |
| 2061 |
cint64 cardinality = concept->getParameter() - 1 * conceptNegation; |
| 2062 |
// mergeable if the node does not have n corresponding neighbours |
| 2063 |
CRole* role = concept->getRole(); |
| 2064 |
CReapplyRoleSuccessorHash* roleSuccHash = indiNode->getReapplyRoleSuccessorHash(false); |
| 2065 |
if (roleSuccHash) { |
| 2066 |
cint64 succCount = roleSuccHash->getRoleSuccessorCount(role); |
| 2067 |
if (succCount <= cardinality) { |
| 2068 |
mergeable = true; |
| 2069 |
} else { |
| 2070 |
|
| 2071 |
cint64 ignoreableNeighbourCount = 0; |
| 2072 |
cint64 certainlyRelevantNeighbourCount = 0; |
| 2073 |
|
| 2074 |
|
| 2075 |
CSortedNegLinker<CConcept*>* opConLinker = concept->getOperandList(); |
| 2076 |
if (opConLinker) { |
| 2077 |
// count the number of neighbours without the qualifying concept or mergeable |
| 2078 |
CRoleSuccessorLinkIterator roleSuccIt = roleSuccHash->getRoleSuccessorLinkIterator(role); |
| 2079 |
while (roleSuccIt.hasNext() && succCount - ignoreableNeighbourCount > cardinality && certainlyRelevantNeighbourCount <= cardinality) { |
| 2080 |
CIndividualLinkEdge* neighbourLink = roleSuccIt.next(); |
| 2081 |
cint64 neighbourId = neighbourLink->getOppositeIndividualID(indiNode->getIndividualNodeID()); |
| 2082 |
CIndividualProcessNode* neighbourIndiNode = indiProcVector->getData(neighbourId); |
| 2083 |
|
| 2084 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt; opConLinkerIt = opConLinkerIt->getNext()) { |
| 2085 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 2086 |
bool opConNegation = opConLinkerIt->isNegated(); |
| 2087 |
|
| 2088 |
bool opConMergeable = false; |
| 2089 |
bool opConUnmergeable = false; |
| 2090 |
|
| 2091 |
checkTrivialInstanceConceptCachedCompletionGraphBasedMerging(reqConfPreCompItem, opConcept, !opConNegation, neighbourIndiNode, indiProcVector, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 2092 |
// if the negation of the qualifying concept can safely be added, then it does not have to be considered for the merging |
| 2093 |
if (opConMergeable) { |
| 2094 |
ignoreableNeighbourCount++; |
| 2095 |
} |
| 2096 |
if (opConUnmergeable) { |
| 2097 |
certainlyRelevantNeighbourCount++; |
| 2098 |
} |
| 2099 |
} |
| 2100 |
|
| 2101 |
|
| 2102 |
} |
| 2103 |
} |
| 2104 |
|
| 2105 |
if (succCount - ignoreableNeighbourCount <= cardinality) { |
| 2106 |
mergeable = true; |
| 2107 |
} |
| 2108 |
if (cardinality == 0 && certainlyRelevantNeighbourCount >= 1) { |
| 2109 |
unmergeable = true; |
| 2110 |
} |
| 2111 |
|
| 2112 |
} |
| 2113 |
} else if (cardinality >= 0) { |
| 2114 |
mergeable = true; |
| 2115 |
} |
| 2116 |
|
| 2117 |
} else if (!conceptNegation && (opCode == CCSOME) || conceptNegation && (opCode == CCALL)) { |
| 2118 |
// mergeable if there is one neighbour that satisfies the qualifying restriction |
| 2119 |
// unmergeable is non-trivial to detect (maybe we can use the saturation graph somehow?) |
| 2120 |
|
| 2121 |
CRole* role = concept->getRole(); |
| 2122 |
CReapplyRoleSuccessorHash* roleSuccHash = indiNode->getReapplyRoleSuccessorHash(false); |
| 2123 |
|
| 2124 |
bool oneMergable = false; |
| 2125 |
bool allUnmergeable = true; |
| 2126 |
|
| 2127 |
CRoleSuccessorLinkIterator roleSuccIt = roleSuccHash->getRoleSuccessorLinkIterator(role); |
| 2128 |
while (roleSuccIt.hasNext() && !oneMergable) { |
| 2129 |
|
| 2130 |
CIndividualLinkEdge* neighbourLink = roleSuccIt.next(); |
| 2131 |
cint64 neighbourId = neighbourLink->getOppositeIndividualID(indiNode->getIndividualNodeID()); |
| 2132 |
CIndividualProcessNode* neighbourIndiNode = indiProcVector->getData(neighbourId); |
| 2133 |
|
| 2134 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && !oneMergable; opConLinkerIt = opConLinkerIt->getNext()) { |
| 2135 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 2136 |
bool opConNegation = opConLinkerIt->isNegated() ^ conceptNegation; |
| 2137 |
|
| 2138 |
bool opConMergeable = false; |
| 2139 |
bool opConUnmergeable = false; |
| 2140 |
|
| 2141 |
checkTrivialInstanceConceptCachedCompletionGraphBasedMerging(reqConfPreCompItem, opConcept, opConNegation, neighbourIndiNode, indiProcVector, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 2142 |
oneMergable |= opConMergeable; |
| 2143 |
} |
| 2144 |
} |
| 2145 |
|
| 2146 |
mergeable = oneMergable; |
| 2147 |
|
| 2148 |
} else if (!conceptNegation && (opCode == CCALL) || conceptNegation && (opCode == CCSOME)) { |
| 2149 |
|
| 2150 |
CRole* role = concept->getRole(); |
| 2151 |
CReapplyRoleSuccessorHash* roleSuccHash = indiNode->getReapplyRoleSuccessorHash(false); |
| 2152 |
|
| 2153 |
bool allMergable = true; |
| 2154 |
bool oneUnmergeable = false; |
| 2155 |
|
| 2156 |
CRoleSuccessorLinkIterator roleSuccIt = roleSuccHash->getRoleSuccessorLinkIterator(role); |
| 2157 |
while (roleSuccIt.hasNext() && (allMergable || !oneUnmergeable)) { |
| 2158 |
|
| 2159 |
CIndividualLinkEdge* neighbourLink = roleSuccIt.next(); |
| 2160 |
cint64 neighbourId = neighbourLink->getOppositeIndividualID(indiNode->getIndividualNodeID()); |
| 2161 |
CIndividualProcessNode* neighbourIndiNode = indiProcVector->getData(neighbourId); |
| 2162 |
|
| 2163 |
for (CSortedNegLinker<CConcept*>* opConLinkerIt = concept->getOperandList(); opConLinkerIt && (allMergable || !oneUnmergeable); opConLinkerIt = opConLinkerIt->getNext()) { |
| 2164 |
CConcept* opConcept = opConLinkerIt->getData(); |
| 2165 |
bool opConNegation = opConLinkerIt->isNegated() ^ conceptNegation; |
| 2166 |
|
| 2167 |
bool opConMergeable = false; |
| 2168 |
bool opConUnmergeable = false; |
| 2169 |
|
| 2170 |
checkTrivialInstanceConceptCachedCompletionGraphBasedMerging(reqConfPreCompItem, opConcept, opConNegation, neighbourIndiNode, indiProcVector, &opConMergeable, &opConUnmergeable, mergingOperationLimit); |
| 2171 |
allMergable &= opConMergeable; |
| 2172 |
if (opConUnmergeable && neighbourLink->getDependencyTrackPoint() && neighbourLink->getDependencyTrackPoint()->getBranchingTag() <= 0) { |
| 2173 |
oneUnmergeable = true; |
| 2174 |
} |
| 2175 |
} |
| 2176 |
} |
| 2177 |
|
| 2178 |
mergeable = allMergable; |
| 2179 |
unmergeable = oneUnmergeable; |
| 2180 |
|
| 2181 |
|
| 2182 |
} else if (!conceptNegation && (opCode == CCNOMINAL)) { |
| 2183 |
|
| 2184 |
CIndividual* nominalIndi = concept->getNominalIndividual(); |
| 2185 |
if (-nominalIndi->getIndividualID() == indiNode->getIndividualNodeID()) { |
| 2186 |
mergeable = true; |
| 2187 |
} else { |
| 2188 |
CIndividualMergingHash* indiMergingHash = indiNode->getIndividualMergingHash(false); |
| 2189 |
if (indiMergingHash->value(-nominalIndi->getIndividualID()).isMergedWithIndividual()) { |
| 2190 |
mergeable = true; |
| 2191 |
} |
| 2192 |
} |
| 2193 |
|
| 2194 |
} else if (conceptNegation && (opCode == CCNOMINAL)) { |
| 2195 |
|
| 2196 |
CIndividual* nominalIndi = concept->getNominalIndividual(); |
| 2197 |
if (-nominalIndi->getIndividualID() == indiNode->getIndividualNodeID()) { |
| 2198 |
unmergeable = true; |
| 2199 |
} else { |
| 2200 |
CIndividualMergingHash* indiMergingHash = indiNode->getIndividualMergingHash(false); |
| 2201 |
if (indiMergingHash->value(-nominalIndi->getIndividualID()).isMergedWithIndividual()) { |
| 2202 |
unmergeable = true; |
| 2203 |
} |
| 2204 |
} |
| 2205 |
|
| 2206 |
} |
| 2207 |
} |
| 2208 |
|
| 2209 |
if (mergableFlag) { |
| 2210 |
*mergableFlag = mergeable; |
| 2211 |
} |
| 2212 |
if (unmergableFlag) { |
| 2213 |
*unmergableFlag = unmergeable; |
| 2214 |
} |
| 2215 |
|
| 2216 |
if (mergeable || unmergeable) { |
| 2217 |
return true; |
| 2218 |
} else { |
| 2219 |
return false; |
| 2220 |
} |
| 2221 |
|
| 2222 |
} |
| 2223 |
|
| 2224 |
|
| 2225 |
|
| 2226 |
|
| 2227 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::checkTrivialConceptInstanceModelMerging(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetConceptInstancesItem* instancesItem, COptimizedKPSetIndividualItem* instantiatedItem, bool& isInstance, bool shouldRememberChecking) { |
| 2228 |
|
| 2229 |
if (mConfPossibleInstanceConceptsUpfrontMerging) { |
| 2230 |
QMap<cint64, COptimizedKPSetIndividualItem*>* modelMergingCheckedSet = instancesItem->getModelMergingCheckedSet(false); |
| 2231 |
if (!modelMergingCheckedSet || !modelMergingCheckedSet->contains(instantiatedItem->getIndividualId())) { |
| 2232 |
if (shouldRememberChecking) { |
| 2233 |
if (!modelMergingCheckedSet) { |
| 2234 |
modelMergingCheckedSet = instancesItem->getModelMergingCheckedSet(true); |
| 2235 |
} |
| 2236 |
modelMergingCheckedSet->insert(instantiatedItem->getIndividualId(), instantiatedItem); |
| 2237 |
} |
| 2238 |
cint64 indiID = -instantiatedItem->getIndividualId(); |
| 2239 |
|
| 2240 |
CIndividualProcessNodeVector* indiProcVector = nullptr; |
| 2241 |
CConsistence* consistence = reqConfPreCompItem->getOntology()->getConsistence(); |
| 2242 |
if (consistence) { |
| 2243 |
CConsistenceData* consData = consistence->getConsistenceModelData(); |
| 2244 |
if (consData) { |
| 2245 |
CConsistenceTaskData* consTaskData = dynamic_cast<CConsistenceTaskData*>(consData); |
| 2246 |
CSatisfiableCalculationTask* satConsTask = consTaskData->getCompletionGraphCachedSatisfiableTask(); |
| 2247 |
if (!satConsTask) { |
| 2248 |
satConsTask = consTaskData->getDeterministicSatisfiableTask(); |
| 2249 |
} |
| 2250 |
if (satConsTask) { |
| 2251 |
CProcessingDataBox* procDataBox = satConsTask->getProcessingDataBox(); |
| 2252 |
if (procDataBox) { |
| 2253 |
indiProcVector = procDataBox->getIndividualProcessNodeVector(); |
| 2254 |
} |
| 2255 |
} |
| 2256 |
} |
| 2257 |
} |
| 2258 |
|
| 2259 |
if (indiProcVector) { |
| 2260 |
CIndividualProcessNode* baseIndiProcNode = indiProcVector->getData(indiID); |
| 2261 |
CIndividualProcessNode* indiProcNode = baseIndiProcNode; |
| 2262 |
if (indiProcNode) { |
| 2263 |
reqConfPreCompItem->incModelMergingsTriedCount(); |
| 2264 |
bool nondeterministicallyMergedFlag = false; |
| 2265 |
indiProcNode = getMergeCorrectedIndividualProcessNode(indiProcNode, indiProcVector, &nondeterministicallyMergedFlag, reqConfPreCompItem); |
| 2266 |
|
| 2267 |
CConcept* concept = instancesItem->getHierarchyNode()->getOneEquivalentConcept(); |
| 2268 |
|
| 2269 |
//if (CIRIName::getRecentIRIName(concept->getNameLinker()) == "http://www.reactome.org/biopax/46/170905#Protein19") { |
| 2270 |
// bool debug = true; |
| 2271 |
//} |
| 2272 |
|
| 2273 |
bool mergeable = false; |
| 2274 |
bool unmergeable = false; |
| 2275 |
cint64 mergeOperationLimit = 15; |
| 2276 |
if (checkTrivialInstanceConceptCachedCompletionGraphBasedMerging(reqConfPreCompItem, concept, true, indiProcNode, indiProcVector, &mergeable, &unmergeable, &mergeOperationLimit)) { |
| 2277 |
if (mergeable) { |
| 2278 |
isInstance = false; |
| 2279 |
} |
| 2280 |
if (unmergeable && !nondeterministicallyMergedFlag) { |
| 2281 |
isInstance = true; |
| 2282 |
} |
| 2283 |
return true; |
| 2284 |
} |
| 2285 |
} |
| 2286 |
} else { |
| 2287 |
|
| 2288 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* assData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(instantiatedItem->getIndividualId()); |
| 2289 |
CConcept* concept = instancesItem->getHierarchyNode()->getOneEquivalentConcept(); |
| 2290 |
|
| 2291 |
bool mergeable = false; |
| 2292 |
bool unmergeable = false; |
| 2293 |
cint64 mergeOperationLimit = 15; |
| 2294 |
if (checkTrivialInstanceConceptRepresentativeCacheBasedMerging(reqConfPreCompItem, concept, true, assData, &mergeable, &unmergeable, &mergeOperationLimit)) { |
| 2295 |
if (mergeable) { |
| 2296 |
isInstance = false; |
| 2297 |
} |
| 2298 |
if (unmergeable) { |
| 2299 |
isInstance = true; |
| 2300 |
} |
| 2301 |
return true; |
| 2302 |
} |
| 2303 |
|
| 2304 |
} |
| 2305 |
} |
| 2306 |
} |
| 2307 |
return false; |
| 2308 |
} |
| 2309 |
|
| 2310 |
|
| 2311 |
|
| 2312 |
|
| 2313 |
|
| 2314 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createNextConceptInstantiationTest(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetConceptInstancesItem* instancesItem, COptimizedKPSetIndividualItem* instantiatedItem, cint64 remainingTestingCount, COntologyRealizingDynamicRequirmentProcessingData* procData) { |
| 2315 |
instancesItem->incTestingPossibleInstancesCount(); |
| 2316 |
instantiatedItem->incTestingPossibleInstantiatedCount(); |
| 2317 |
instantiatedItem->decPossibleInstantiatedCount(); |
| 2318 |
instantiatedItem->setTestingPossibleInstantiated(instancesItem); |
| 2319 |
reqConfPreCompItem->incTestingPossibleConceptInstanceCount(); |
| 2320 |
|
| 2321 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = instantiatedItem->getKnownPossibleInstancesHash(); |
| 2322 |
COptimizedKPSetConceptInstancesData* instanceItemData = knownPossibleInstancesHash->getInstanceItemData(instancesItem); |
| 2323 |
instanceItemData->mTestingInstance = true; |
| 2324 |
|
| 2325 |
|
| 2326 |
bool isInstanceByModelMerging = false; |
| 2327 |
if (checkTrivialConceptInstanceModelMerging(reqConfPreCompItem, instancesItem, instantiatedItem, isInstanceByModelMerging)) { |
| 2328 |
reqConfPreCompItem->incModelMergingsSucessCount(); |
| 2329 |
|
| 2330 |
if (isInstanceByModelMerging) { |
| 2331 |
reqConfPreCompItem->incModelMergingsInstanceFoundCount(); |
| 2332 |
} else { |
| 2333 |
reqConfPreCompItem->incModelMergingsNonInstanceFoundCount(); |
| 2334 |
} |
| 2335 |
interpretConceptInstantiationResult(reqConfPreCompItem, instancesItem, instantiatedItem, isInstanceByModelMerging); |
| 2336 |
return false; |
| 2337 |
} |
| 2338 |
|
| 2339 |
bool alreadySatisfiable = false; |
| 2340 |
CPossibleInstancesIndividualsMergingLinker* possibleInstanceMergingLinker = nullptr; |
| 2341 |
CPossibleInstancesIndividualsMergingData* possInstanceMergingData = getPossibleInstancesMergingData(reqConfPreCompItem, instancesItem, instantiatedItem, remainingTestingCount); |
| 2342 |
if (possInstanceMergingData) { |
| 2343 |
QHash<COptimizedKPSetIndividualItem*, CPossibleInstancesIndividualsMergingLinker*>* mergingDataHash = instancesItem->getIndividualItemPossibleInstanceMergingLinkerHash(false); |
| 2344 |
possibleInstanceMergingLinker = mergingDataHash->value(instantiatedItem); |
| 2345 |
if (possibleInstanceMergingLinker) { |
| 2346 |
if (possibleInstanceMergingLinker->isSatisfiableMerged()) { |
| 2347 |
alreadySatisfiable = true; |
| 2348 |
} else { |
| 2349 |
possibleInstanceMergingLinker->setFullTestingScheduled(); |
| 2350 |
} |
| 2351 |
} |
| 2352 |
|
| 2353 |
if (alreadySatisfiable) { |
| 2354 |
reqConfPreCompItem->incSucceddedPossibleInstancesMergingsCount(); |
| 2355 |
interpretConceptInstantiationResult(reqConfPreCompItem, instancesItem, instantiatedItem, false); |
| 2356 |
return false; |
| 2357 |
} |
| 2358 |
} |
| 2359 |
|
| 2360 |
|
| 2361 |
//if (CIRIName::getRecentIRIName(instancesItem->getHierarchyNode()->getOneEquivalentConcept()->getClassNameLinker()) == "http://uob.iodt.ibm.com/univ-bench-dl.owl#PeopleWithManyHobbies") { |
| 2362 |
|
| 2363 |
// interpretConceptInstantiationResult(reqConfPreCompItem, instancesItem, instantiatedItem, false); |
| 2364 |
// return false; |
| 2365 |
//} |
| 2366 |
|
| 2367 |
|
| 2368 |
CConcept* concept = instancesItem->getHierarchyNode()->getOneEquivalentConcept(); |
| 2369 |
CIndividualReference indiRef = instantiatedItem->getIndividualReference(); |
| 2370 |
|
| 2371 |
CSatisfiableCalculationJob* satCalcJob = nullptr; |
| 2372 |
CSatisfiableCalculationJobGenerator satCalcJobGen(reqConfPreCompItem->getOntology()); |
| 2373 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(concept,true, indiRef); |
| 2374 |
satCalcJob->setCalculationConfiguration(reqConfPreCompItem->getCalculationConfiguration()); |
| 2375 |
if (reqConfPreCompItem->getPossibleAssertionCollectionSet()) { |
| 2376 |
satCalcJob->setPossibleAssertionCollectionAdapter(new CSatisfiableTaskRealizationPossibleAssertionCollectingAdapter(reqConfPreCompItem->getOntology(),reqConfPreCompItem->getPossibleAssertionCollectionSet())); |
| 2377 |
} |
| 2378 |
if (reqConfPreCompItem->requiresIndividualDependenceTracking()) { |
| 2379 |
if (!instantiatedItem->getIndividualDependenceTrackingCollector()) { |
| 2380 |
instantiatedItem->setIndividualDependenceTrackingCollector(new CIndividualDependenceTrackingCollector()); |
| 2381 |
} |
| 2382 |
} |
| 2383 |
if (instantiatedItem->getIndividualDependenceTrackingCollector()) { |
| 2384 |
satCalcJob->setSatisfiableTaskIndividualDependenceTrackingAdapter(new CSatisfiableTaskIndividualDependenceTrackingAdapter(instantiatedItem->getIndividualDependenceTrackingCollector())); |
| 2385 |
} |
| 2386 |
CSatisfiableTaskRealizationPossibleInstancesMergingAdapter* possInstanceMergingDataAdapter = nullptr; |
| 2387 |
if (possInstanceMergingData) { |
| 2388 |
possInstanceMergingDataAdapter = new CSatisfiableTaskRealizationPossibleInstancesMergingAdapter(possInstanceMergingData, indiRef, possibleInstanceMergingLinker); |
| 2389 |
satCalcJob->setSatisfiablePossibleInstancesMergingAdapter(possInstanceMergingDataAdapter); |
| 2390 |
} else { |
| 2391 |
possInstanceMergingDataAdapter = new CSatisfiableTaskRealizationPossibleInstancesMergingAdapter(nullptr, indiRef, nullptr); |
| 2392 |
satCalcJob->setSatisfiablePossibleInstancesMergingAdapter(possInstanceMergingDataAdapter); |
| 2393 |
} |
| 2394 |
|
| 2395 |
|
| 2396 |
|
| 2397 |
CIndividualConceptInstanceTestingItem* testItem = new CIndividualConceptInstanceTestingItem(reqConfPreCompItem,instancesItem,instantiatedItem,procData, possInstanceMergingDataAdapter); |
| 2398 |
instancesItem->getPossibleInstanceTestingItemHash()->insert(indiRef.getIndividualID(), testItem); |
| 2399 |
|
| 2400 |
processCalculationJob(satCalcJob,reqConfPreCompItem,testItem); |
| 2401 |
return true; |
| 2402 |
} |
| 2403 |
|
| 2404 |
|
| 2405 |
|
| 2406 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createNextRoleInstantiationTest(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetRoleInstancesItem* instancesItem, COptimizedKPSetIndividualItemPair itemPair, COntologyRealizingDynamicRequirmentProcessingData* procData) { |
| 2407 |
instancesItem->incTestingPossibleInstancesCount(); |
| 2408 |
|
| 2409 |
COptimizedKPSetIndividualItem* indItem1 = itemPair.first; |
| 2410 |
COptimizedKPSetIndividualItem* indItem2 = itemPair.second; |
| 2411 |
|
| 2412 |
indItem1->incTestingPossibleRoleInstantiatedCount(); |
| 2413 |
indItem1->decPossibleRoleInstantiatedCount(); |
| 2414 |
indItem1->setTestingPossibleInstantiated(instancesItem,indItem2); |
| 2415 |
|
| 2416 |
CConcept* propConcept = instancesItem->getTemporaryPropagationConcept(); |
| 2417 |
CConcept* markConcept = instancesItem->getTemporaryMarkerConcept(); |
| 2418 |
CIndividual* indi1 = indItem1->getIndividual(); |
| 2419 |
CIndividual* indi2 = indItem2->getIndividual(); |
| 2420 |
|
| 2421 |
CSatisfiableCalculationJob* satCalcJob = nullptr; |
| 2422 |
CSatisfiableCalculationJobGenerator satCalcJobGen(reqConfPreCompItem->getTemporaryRoleRealizationOntology()); |
| 2423 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(propConcept,false,indi1); |
| 2424 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(markConcept,true,indi2,satCalcJob); |
| 2425 |
satCalcJob->setCalculationConfiguration(reqConfPreCompItem->getCalculationConfiguration()); |
| 2426 |
if (reqConfPreCompItem->requiresIndividualDependenceTracking()) { |
| 2427 |
if (!indItem1->getIndividualDependenceTrackingCollector()) { |
| 2428 |
indItem1->setIndividualDependenceTrackingCollector(new CIndividualDependenceTrackingCollector()); |
| 2429 |
} |
| 2430 |
} |
| 2431 |
if (indItem1->getIndividualDependenceTrackingCollector()) { |
| 2432 |
satCalcJob->setSatisfiableTaskIndividualDependenceTrackingAdapter(new CSatisfiableTaskIndividualDependenceTrackingAdapter(indItem1->getIndividualDependenceTrackingCollector())); |
| 2433 |
} |
| 2434 |
|
| 2435 |
CIndividualPairRoleInstanceTestingItem* testItem = new CIndividualPairRoleInstanceTestingItem(reqConfPreCompItem,instancesItem,itemPair, procData); |
| 2436 |
reqConfPreCompItem->incTestingPossibleRoleInstanceCount(); |
| 2437 |
|
| 2438 |
processCalculationJob(satCalcJob,reqConfPreCompItem,testItem); |
| 2439 |
return true; |
| 2440 |
} |
| 2441 |
|
| 2442 |
|
| 2443 |
|
| 2444 |
|
| 2445 |
|
| 2446 |
|
| 2447 |
CIndividualProcessNode* COptimizedRepresentativeKPSetOntologyRealizingThread::getCompletionGraphCachedIndividualProcessNode(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetIndividualItem* indiItem, bool* nondeterministicNodeFlag) { |
| 2448 |
|
| 2449 |
CIndividual* individual = indiItem->getIndividual(); |
| 2450 |
cint64 indiID = -individual->getIndividualID(); |
| 2451 |
|
| 2452 |
CIndividualProcessNodeVector* indiProcVector = nullptr; |
| 2453 |
CConsistence* consistence = reqConfPreCompItem->getOntology()->getConsistence(); |
| 2454 |
if (consistence) { |
| 2455 |
CConsistenceData* consData = consistence->getConsistenceModelData(); |
| 2456 |
if (consData) { |
| 2457 |
CConsistenceTaskData* consTaskData = dynamic_cast<CConsistenceTaskData*>(consData); |
| 2458 |
CSatisfiableCalculationTask* satConsTask = consTaskData->getCompletionGraphCachedSatisfiableTask(); |
| 2459 |
if (!satConsTask) { |
| 2460 |
satConsTask = consTaskData->getDeterministicSatisfiableTask(); |
| 2461 |
} |
| 2462 |
if (satConsTask) { |
| 2463 |
CProcessingDataBox* procDataBox = satConsTask->getProcessingDataBox(); |
| 2464 |
if (procDataBox) { |
| 2465 |
indiProcVector = procDataBox->getIndividualProcessNodeVector(); |
| 2466 |
} |
| 2467 |
} |
| 2468 |
} |
| 2469 |
} |
| 2470 |
|
| 2471 |
if (indiProcVector) { |
| 2472 |
CIndividualProcessNode* baseIndiProcNode = indiProcVector->getData(indiID); |
| 2473 |
CIndividualProcessNode* indiProcNode = baseIndiProcNode; |
| 2474 |
bool nondeterministicallyMergedFlag = false; |
| 2475 |
if (indiProcNode) { |
| 2476 |
indiProcNode = getMergeCorrectedIndividualProcessNode(indiProcNode,indiProcVector,&nondeterministicallyMergedFlag,reqConfPreCompItem); |
| 2477 |
} |
| 2478 |
if (nondeterministicNodeFlag) { |
| 2479 |
*nondeterministicNodeFlag = nondeterministicallyMergedFlag; |
| 2480 |
} |
| 2481 |
return indiProcNode; |
| 2482 |
} |
| 2483 |
return nullptr; |
| 2484 |
} |
| 2485 |
|
| 2486 |
|
| 2487 |
|
| 2488 |
|
| 2489 |
|
| 2490 |
|
| 2491 |
|
| 2492 |
|
| 2493 |
|
| 2494 |
|
| 2495 |
|
| 2496 |
|
| 2497 |
|
| 2498 |
|
| 2499 |
|
| 2500 |
|
| 2501 |
|
| 2502 |
|
| 2503 |
|
| 2504 |
|
| 2505 |
|
| 2506 |
|
| 2507 |
|
| 2508 |
|
| 2509 |
|
| 2510 |
|
| 2511 |
|
| 2512 |
|
| 2513 |
|
| 2514 |
|
| 2515 |
|
| 2516 |
|
| 2517 |
|
| 2518 |
|
| 2519 |
|
| 2520 |
|
| 2521 |
|
| 2522 |
|
| 2523 |
|
| 2524 |
|
| 2525 |
|
| 2526 |
|
| 2527 |
|
| 2528 |
|
| 2529 |
|
| 2530 |
|
| 2531 |
|
| 2532 |
|
| 2533 |
|
| 2534 |
|
| 2535 |
|
| 2536 |
|
| 2537 |
|
| 2538 |
|
| 2539 |
|
| 2540 |
|
| 2541 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createNextRoleInitializingTest(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, const CRealizationIndividualInstanceItemReference& indiRealItemRef) { |
| 2542 |
bool workCreated = false; |
| 2543 |
QSet<COptimizedKPSetRoleInstancesItem*>* complexRoleCandidateItemSet = nullptr; |
| 2544 |
QSet<COptimizedKPSetRoleInstancesItem*>* inverseComplexRoleCandidateItemSet = nullptr; |
| 2545 |
|
| 2546 |
|
| 2547 |
function<void(QSet<COptimizedKPSetRoleInstancesItem*>* roleCandidateItemSet, bool inverse)> complexRoleCandidateItemsHandlingFunction = [&](QSet<COptimizedKPSetRoleInstancesItem*>* roleCandidateItemSet, bool inverse) { |
| 2548 |
if (roleCandidateItemSet && !roleCandidateItemSet->isEmpty()) { |
| 2549 |
if (!complexRoleCandidateItemSet && !inverse) { |
| 2550 |
complexRoleCandidateItemSet = new QSet<COptimizedKPSetRoleInstancesItem *>(); |
| 2551 |
} |
| 2552 |
if (!inverseComplexRoleCandidateItemSet && inverse) { |
| 2553 |
inverseComplexRoleCandidateItemSet = new QSet<COptimizedKPSetRoleInstancesItem *>(); |
| 2554 |
} |
| 2555 |
for (COptimizedKPSetRoleInstancesItem* roleCandidateItem : *roleCandidateItemSet) { |
| 2556 |
if (!inverse) { |
| 2557 |
complexRoleCandidateItemSet->insert(roleCandidateItem); |
| 2558 |
} else { |
| 2559 |
inverseComplexRoleCandidateItemSet->insert(roleCandidateItem); |
| 2560 |
} |
| 2561 |
} |
| 2562 |
} |
| 2563 |
}; |
| 2564 |
|
| 2565 |
cint64 indiId = indiRealItemRef.getIndividualID(); |
| 2566 |
|
| 2567 |
|
| 2568 |
|
| 2569 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(indiId); |
| 2570 |
if (indiAssData) { |
| 2571 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeighbourRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 2572 |
if (combinedNeighbourRoleSetLabel) { |
| 2573 |
COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* combinedNeighbourRoleLabelCacheItemData = reqConfPreCompItem->getRepresentativeCacheCombinedNeighbourRoleSetLabelItemData(combinedNeighbourRoleSetLabel); |
| 2574 |
if (combinedNeighbourRoleLabelCacheItemData->hasComplexCandiateInstancesItems()) { |
| 2575 |
complexRoleCandidateItemsHandlingFunction(combinedNeighbourRoleLabelCacheItemData->getComplexCandiateInstancesItemSet(false), false); |
| 2576 |
complexRoleCandidateItemsHandlingFunction(combinedNeighbourRoleLabelCacheItemData->getComplexCandiateInstancesItemSet(true), true); |
| 2577 |
} |
| 2578 |
} |
| 2579 |
|
| 2580 |
|
| 2581 |
|
| 2582 |
CBackendRepresentativeMemoryLabelCacheItem* combinedDeterministicExistentialRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 2583 |
if (combinedDeterministicExistentialRoleSetLabel) { |
| 2584 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* combinedDeterministicExistentialRoleLabelCacheItemData = reqConfPreCompItem->getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(combinedDeterministicExistentialRoleSetLabel); |
| 2585 |
if (combinedDeterministicExistentialRoleLabelCacheItemData->hasComplexCandiateInstancesItems()) { |
| 2586 |
complexRoleCandidateItemsHandlingFunction(combinedDeterministicExistentialRoleLabelCacheItemData->getComplexCandiateInstancesItemSet(false), false); |
| 2587 |
complexRoleCandidateItemsHandlingFunction(combinedDeterministicExistentialRoleLabelCacheItemData->getComplexCandiateInstancesItemSet(true), true); |
| 2588 |
} |
| 2589 |
} |
| 2590 |
|
| 2591 |
|
| 2592 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNondeterministicExistentialRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 2593 |
if (combinedNondeterministicExistentialRoleSetLabel) { |
| 2594 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* combinedNondeterministicExistentialRoleLabelCacheItemData = reqConfPreCompItem->getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(combinedNondeterministicExistentialRoleSetLabel); |
| 2595 |
if (combinedNondeterministicExistentialRoleLabelCacheItemData->hasComplexCandiateInstancesItems()) { |
| 2596 |
complexRoleCandidateItemsHandlingFunction(combinedNondeterministicExistentialRoleLabelCacheItemData->getComplexCandiateInstancesItemSet(false), false); |
| 2597 |
complexRoleCandidateItemsHandlingFunction(combinedNondeterministicExistentialRoleLabelCacheItemData->getComplexCandiateInstancesItemSet(true), true); |
| 2598 |
} |
| 2599 |
} |
| 2600 |
} |
| 2601 |
|
| 2602 |
if (complexRoleCandidateItemSet || inverseComplexRoleCandidateItemSet) { |
| 2603 |
|
| 2604 |
QList<CIndividualRoleCandidateTestingData> indiRoleCandTestDataList; |
| 2605 |
|
| 2606 |
|
| 2607 |
if (complexRoleCandidateItemSet) { |
| 2608 |
for (COptimizedKPSetRoleInstancesItem* complexRoleCandidateItem : *complexRoleCandidateItemSet) { |
| 2609 |
COptimizedKPSetIndividualComplexRoleData* indiComplexRoleData = complexRoleCandidateItem->getIndividualIdComplexRoleData(indiId, true); |
| 2610 |
if (!indiComplexRoleData->isInitializing(false)) { |
| 2611 |
indiComplexRoleData->setInitializing(false, true); |
| 2612 |
prepareRoleInitializingTestData(reqConfPreCompItem, complexRoleCandidateItem, false, indiRealItemRef, indiComplexRoleData, indiRoleCandTestDataList); |
| 2613 |
} |
| 2614 |
} |
| 2615 |
} |
| 2616 |
|
| 2617 |
if (inverseComplexRoleCandidateItemSet) { |
| 2618 |
for (COptimizedKPSetRoleInstancesItem* complexRoleCandidateItem : *inverseComplexRoleCandidateItemSet) { |
| 2619 |
COptimizedKPSetIndividualComplexRoleData* indiComplexRoleData = complexRoleCandidateItem->getIndividualIdComplexRoleData(indiId, true); |
| 2620 |
if (!indiComplexRoleData->isInitializing(true)) { |
| 2621 |
indiComplexRoleData->setInitializing(true, true); |
| 2622 |
prepareRoleInitializingTestData(reqConfPreCompItem, complexRoleCandidateItem, true, indiRealItemRef, indiComplexRoleData, indiRoleCandTestDataList); |
| 2623 |
} |
| 2624 |
} |
| 2625 |
} |
| 2626 |
|
| 2627 |
|
| 2628 |
workCreated = createNextRoleInitializingTest(reqConfPreCompItem, indiRealItemRef, indiRoleCandTestDataList); |
| 2629 |
|
| 2630 |
delete complexRoleCandidateItemSet; |
| 2631 |
delete inverseComplexRoleCandidateItemSet; |
| 2632 |
} |
| 2633 |
|
| 2634 |
return workCreated; |
| 2635 |
|
| 2636 |
} |
| 2637 |
|
| 2638 |
|
| 2639 |
|
| 2640 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createNextRoleInitializingTest(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, const CRealizationIndividualInstanceItemReference& indiRealItemRef, const QList<CIndividualRoleCandidateTestingData>& indiRoleCandTestDataList) { |
| 2641 |
bool workCreated = false; |
| 2642 |
if (!indiRoleCandTestDataList.isEmpty()) { |
| 2643 |
reqConfPreCompItem->incPropagatingRoleInstanceCandidatesCount(); |
| 2644 |
CIndividualReference indiRef = indiRealItemRef; |
| 2645 |
|
| 2646 |
//if (CIRIName::getRecentIRIName(indiRef.getIndividual()->getIndividualNameLinker()) == "http://ontology.dumontierlab.com/eswc-example-graph-3#datapoint1") { |
| 2647 |
// bool debug = true; |
| 2648 |
//} |
| 2649 |
|
| 2650 |
CSatisfiableCalculationJob* satCalcJob = nullptr; |
| 2651 |
CSatisfiableCalculationJobGenerator satCalcJobGen(reqConfPreCompItem->getTemporaryRoleRealizationOntology()); |
| 2652 |
for (QList<CIndividualRoleCandidateTestingData>::const_iterator it = indiRoleCandTestDataList.constBegin(), itEnd = indiRoleCandTestDataList.constEnd(); it != itEnd; ++it) { |
| 2653 |
CIndividualRoleCandidateTestingData indiRoleCandTestData(*it); |
| 2654 |
COptimizedKPSetRoleInstancesItem* realItem = indiRoleCandTestData.getRoleInstancesItem(); |
| 2655 |
realItem->incTestingInitializationPropagationCount(); |
| 2656 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(indiRoleCandTestData.getPropagationConcept(), false, indiRef, satCalcJob); |
| 2657 |
} |
| 2658 |
|
| 2659 |
CSatisfiableTaskRealizationMarkedCandidatesMessageAdapter* adapter = new CSatisfiableTaskRealizationMarkedCandidatesMessageAdapter(indiRoleCandTestDataList, indiRef, reqConfPreCompItem->getOntology(), this); |
| 2660 |
CIndividualRoleCandidatePropagationTestingItem* testItem = new CIndividualRoleCandidatePropagationTestingItem(reqConfPreCompItem, indiRealItemRef, indiRoleCandTestDataList, adapter); |
| 2661 |
satCalcJob->setRealizationMarkedCandidatesMessageAdapter(adapter); |
| 2662 |
satCalcJob->setCalculationConfiguration(reqConfPreCompItem->getCalculationConfiguration()); |
| 2663 |
//if (reqConfPreCompItem->requiresIndividualDependenceTracking()) { |
| 2664 |
// if (!individualItem->getIndividualDependenceTrackingCollector()) { |
| 2665 |
// individualItem->setIndividualDependenceTrackingCollector(new CIndividualDependenceTrackingCollector()); |
| 2666 |
// } |
| 2667 |
//} |
| 2668 |
//if (individualItem->getIndividualDependenceTrackingCollector()) { |
| 2669 |
// satCalcJob->setSatisfiableTaskIndividualDependenceTrackingAdapter(new CSatisfiableTaskIndividualDependenceTrackingAdapter(individualItem->getIndividualDependenceTrackingCollector())); |
| 2670 |
//} |
| 2671 |
|
| 2672 |
if (mConfNonDeterministicSatisfiableCalculationContinuation) { |
| 2673 |
satCalcJob->setAllowNonDeterministicSatisfiableCalculationContinuation(true); |
| 2674 |
} |
| 2675 |
|
| 2676 |
processCalculationJob(satCalcJob, reqConfPreCompItem, testItem); |
| 2677 |
workCreated = true; |
| 2678 |
} |
| 2679 |
return workCreated; |
| 2680 |
} |
| 2681 |
|
| 2682 |
|
| 2683 |
|
| 2684 |
|
| 2685 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createNextRoleInitializingTest(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetRoleInstancesItem* roleInstancesItem) { |
| 2686 |
bool workCreated = false; |
| 2687 |
|
| 2688 |
COptimizedRepresentativeKPSetCacheMultipleTypeLabelSetItemIterator* iterator = roleInstancesItem->getIndividualComplexCandidateIterator(); |
| 2689 |
while (iterator && !workCreated && !iterator->atEnd()) { |
| 2690 |
CRealizationIndividualInstanceItemReference indiRealItemRef = iterator->currentIndividualInstanceItemReference(); |
| 2691 |
workCreated = createNextRoleInitializingTest(reqConfPreCompItem, roleInstancesItem, false, indiRealItemRef); |
| 2692 |
iterator->moveNext(); |
| 2693 |
} |
| 2694 |
|
| 2695 |
|
| 2696 |
if (iterator && iterator->atEnd()) { |
| 2697 |
delete iterator; |
| 2698 |
roleInstancesItem->setIndividualComplexCandidateIterator(nullptr); |
| 2699 |
roleInstancesItem->setCandidateSuccessorInitializationCompleted(true); |
| 2700 |
} |
| 2701 |
|
| 2702 |
return workCreated; |
| 2703 |
} |
| 2704 |
|
| 2705 |
|
| 2706 |
|
| 2707 |
|
| 2708 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createNextRoleInitializingTest(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetRoleInstancesItem* roleInstancesItem, bool inversed, const CRealizationIndividualInstanceItemReference& indiRealItemRef) { |
| 2709 |
bool workCreated = false; |
| 2710 |
cint64 indiId = indiRealItemRef.getIndividualID(); |
| 2711 |
|
| 2712 |
//QString indiString = CIRIName::getRecentIRIName(indiRealItemRef.getIndividual()->getIndividualNameLinker()); |
| 2713 |
//QString roleString = CIRIName::getRecentIRIName(roleInstancesItem->getRole()->getPropertyNameLinker()); |
| 2714 |
//QString inverseRoleString = CIRIName::getRecentIRIName(roleInstancesItem->getInverseRole()->getPropertyNameLinker()); |
| 2715 |
//if (indiString == "http://purl.obolibrary.org/obo/CHROMOSOME-7227_X" && (roleString == "http://purl.obolibrary.org/obo/RO_0002131" || inverseRoleString == "http://purl.obolibrary.org/obo/RO_0002131")) { |
| 2716 |
// bool debug = true; |
| 2717 |
//} |
| 2718 |
|
| 2719 |
|
| 2720 |
COptimizedKPSetIndividualComplexRoleData* indiComplexRoleData = roleInstancesItem->getIndividualIdComplexRoleData(indiId, true); |
| 2721 |
if (!indiComplexRoleData->isInitializing(inversed)) { |
| 2722 |
indiComplexRoleData->setInitializing(inversed, true); |
| 2723 |
QList<CIndividualRoleCandidateTestingData> indiRoleCandTestDataList; |
| 2724 |
prepareRoleInitializingTestData(reqConfPreCompItem, roleInstancesItem, inversed, indiRealItemRef, indiComplexRoleData, indiRoleCandTestDataList); |
| 2725 |
workCreated = createNextRoleInitializingTest(reqConfPreCompItem, indiRealItemRef, indiRoleCandTestDataList); |
| 2726 |
} |
| 2727 |
return workCreated; |
| 2728 |
} |
| 2729 |
|
| 2730 |
|
| 2731 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::prepareRoleInitializingTestData(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetRoleInstancesItem* roleInstancesItem, bool inversed, const CRealizationIndividualInstanceItemReference& indiRealItemRef, COptimizedKPSetIndividualComplexRoleData* indiComplexRoleData, QList<CIndividualRoleCandidateTestingData>& indiRoleCandTestDataList) { |
| 2732 |
bool workCreated = false; |
| 2733 |
cint64 indiId = indiRealItemRef.getIndividualID(); |
| 2734 |
|
| 2735 |
|
| 2736 |
//if (CIRIName::getRecentIRIName(indiRealItemRef.getIndividual()->getIndividualNameLinker()) == "http://ontology.dumontierlab.com/eswc-example-graph-3#datapoint1") { |
| 2737 |
// bool debug = true; |
| 2738 |
//} |
| 2739 |
|
| 2740 |
|
| 2741 |
bool directCollectable = true; |
| 2742 |
if (roleInstancesItem->hasOnlyTransitiveComplexRoleCandidates() && roleInstancesItem->hasOnlyDeterministicComplexRoleStarterCandidatesUsage()) { |
| 2743 |
for (TRoleItemInversionPair subRoleItemInversePair : *roleInstancesItem->getOnlyTransitiveComplexSubRoleItems()) { |
| 2744 |
COptimizedKPSetRoleInstancesItem* subRoleInstancesItem = subRoleItemInversePair.first; |
| 2745 |
bool subRoleItemInversed = subRoleItemInversePair.second ^ inversed; |
| 2746 |
if (!subRoleInstancesItem->hasOnlyTransitiveComplexRoleCandidates() || !subRoleInstancesItem->hasOnlyDeterministicComplexRoleStarterCandidatesUsage()) { |
| 2747 |
directCollectable = false; |
| 2748 |
break; |
| 2749 |
} |
| 2750 |
} |
| 2751 |
|
| 2752 |
if (directCollectable) { |
| 2753 |
bool linksTransfered = false; |
| 2754 |
for (TRoleItemInversionPair subRoleItemInversePair : *roleInstancesItem->getOnlyTransitiveComplexSubRoleItems()) { |
| 2755 |
COptimizedKPSetRoleInstancesItem* subRoleInstancesItem = subRoleItemInversePair.first; |
| 2756 |
bool subRoleItemInversed = subRoleItemInversePair.second ^ inversed; |
| 2757 |
|
| 2758 |
COptimizedKPSetIndividualComplexRoleData* indiComplexSubRoleData = subRoleInstancesItem->getIndividualIdComplexRoleData(indiId, true); |
| 2759 |
if (!indiComplexSubRoleData->isInitializing(subRoleItemInversed)) { |
| 2760 |
indiComplexSubRoleData->setInitializing(subRoleItemInversed, true); |
| 2761 |
} |
| 2762 |
if (!indiComplexSubRoleData->isInitialized(subRoleItemInversed)) { |
| 2763 |
collectTransitiveLinks(reqConfPreCompItem, subRoleInstancesItem, subRoleItemInversed, indiRealItemRef, indiComplexSubRoleData); |
| 2764 |
} |
| 2765 |
|
| 2766 |
// TODO: if the (transitive) sub role always occurs in the same as the questioned role, then simplify every sub role relation (as long as there is only one) to the following |
| 2767 |
if (subRoleInstancesItem == roleInstancesItem && inversed == subRoleItemInversed && roleInstancesItem->getOnlyTransitiveComplexSubRoleItems()->size() == 1) { |
| 2768 |
linksTransfered = true; |
| 2769 |
} |
| 2770 |
} |
| 2771 |
if (!linksTransfered) { |
| 2772 |
// guaranteed to be deterministic, so no need to check possible neighbour instances |
| 2773 |
COptimizedKPSetRoleNeighbourInstancesHashData* indiRoleNeighbourHashData = nullptr; |
| 2774 |
|
| 2775 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash* combinedNeighbourCacheLabelItemDataHash = roleInstancesItem->getCombinedNeighbourCacheLabelItemDataHash(inversed); |
| 2776 |
|
| 2777 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(indiRealItemRef.getIndividualID()); |
| 2778 |
CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* assNeighbourRoleSetHash = indiAssData->getNeighbourRoleSetHash(); |
| 2779 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetCompinationLabelItem = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 2780 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* combinedNeighbourCacheLabelItemData = combinedNeighbourCacheLabelItemDataHash->value(neighbourRoleSetCompinationLabelItem); |
| 2781 |
|
| 2782 |
|
| 2783 |
for (TRoleItemInversionPair subRoleItemInversePair : *roleInstancesItem->getOnlyTransitiveComplexSubRoleItems()) { |
| 2784 |
COptimizedKPSetRoleInstancesItem* subRoleInstancesItem = subRoleItemInversePair.first; |
| 2785 |
bool subRoleItemInversed = subRoleItemInversePair.second ^ inversed; |
| 2786 |
|
| 2787 |
COptimizedKPSetIndividualComplexRoleData* indiComplexSubRoleData = subRoleInstancesItem->getIndividualIdComplexRoleData(indiId, true); |
| 2788 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRoleRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexRoleData; |
| 2789 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexSubRoleRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexSubRoleData; |
| 2790 |
COptimizedKPSetRoleInstancesHash* subRoleComplexInstancesHash = indiExplicitIndirectLinkComplexSubRoleRepresentationData->getRoleNeighbourInstancesHash(inversed, true); |
| 2791 |
for (QHash<cint64, COptimizedKPSetRoleInstancesHashData>::const_iterator it = subRoleComplexInstancesHash->constBegin(), itEnd = subRoleComplexInstancesHash->constEnd(); it != itEnd; ++it) { |
| 2792 |
cint64 succIndiId = it.key(); |
| 2793 |
CRealizationIndividualInstanceItemReference succIndiItemRef = reqConfPreCompItem->getInstanceItemReference(succIndiId, true); |
| 2794 |
addComplexRoleExplicitIndirectNeighbourLink(roleInstancesItem, inversed, indiRealItemRef, indiExplicitIndirectLinkComplexRoleRepresentationData, indiRoleNeighbourHashData, combinedNeighbourCacheLabelItemData, assNeighbourRoleSetHash, succIndiItemRef, nullptr, true, reqConfPreCompItem); |
| 2795 |
} |
| 2796 |
|
| 2797 |
} |
| 2798 |
} |
| 2799 |
indiComplexRoleData->setInitialized(inversed, true); |
| 2800 |
} |
| 2801 |
} else { |
| 2802 |
directCollectable = false; |
| 2803 |
} |
| 2804 |
if (!directCollectable) { |
| 2805 |
if (!inversed) { |
| 2806 |
indiRoleCandTestDataList.append(CIndividualRoleCandidateTestingData(roleInstancesItem->getTemporaryPropagationConcept(), roleInstancesItem->getTemporaryMarkerConcept(), indiComplexRoleData, roleInstancesItem, false)); |
| 2807 |
} else { |
| 2808 |
indiRoleCandTestDataList.append(CIndividualRoleCandidateTestingData(roleInstancesItem->getTemporaryInversePropagationConcept(), roleInstancesItem->getTemporaryInverseMarkerConcept(), indiComplexRoleData, roleInstancesItem, true)); |
| 2809 |
} |
| 2810 |
workCreated = true; |
| 2811 |
} |
| 2812 |
return workCreated; |
| 2813 |
} |
| 2814 |
|
| 2815 |
|
| 2816 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::collectTransitiveLinks(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetRoleInstancesItem* roleInstancesItem, bool inversed, const CRealizationIndividualInstanceItemReference& indiRealItemRef, COptimizedKPSetIndividualComplexRoleData* indiComplexRoleData) { |
| 2817 |
bool workCreated = false; |
| 2818 |
cint64 indiId = indiRealItemRef.getIndividualID(); |
| 2819 |
|
| 2820 |
|
| 2821 |
#ifdef REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2822 |
mDebugTransitiveCollectionStringList.append(QString("Starting collection over %2 %3for %1").arg(CIRIName::getRecentIRIName(indiRealItemRef.getIndividual()->getIndividualNameLinker())).arg(CIRIName::getRecentIRIName(roleInstancesItem->getRole()->getPropertyNameLinker())).arg(inversed? "inversed " : "")); |
| 2823 |
mDebugTransitiveCollectionString = mDebugTransitiveCollectionStringList.join("\r\n"); |
| 2824 |
#endif // REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2825 |
//if (CIRIName::getRecentIRIName(indiRealItemRef.getIndividual()->getIndividualNameLinker()) == "http://ontology.dumontierlab.com/eswc-example-graph-3#datapoint1") { |
| 2826 |
// bool debug = true; |
| 2827 |
//} |
| 2828 |
|
| 2829 |
|
| 2830 |
if (roleInstancesItem->hasOnlyTransitiveComplexRoleCandidates() && roleInstancesItem->hasOnlyDeterministicComplexRoleStarterCandidatesUsage()) { |
| 2831 |
|
| 2832 |
class RecursiveComplexTransitiveProcessingData { |
| 2833 |
public: |
| 2834 |
~RecursiveComplexTransitiveProcessingData() { |
| 2835 |
if (mAdditionalPropgationList) { |
| 2836 |
delete mAdditionalPropgationList; |
| 2837 |
} |
| 2838 |
} |
| 2839 |
|
| 2840 |
CRealizationIndividualInstanceItemReference mIndiItemRef; |
| 2841 |
COptimizedKPSetIndividualComplexRoleData* mIndiComplexRoleData = nullptr; |
| 2842 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* mIndiAssData = nullptr; |
| 2843 |
|
| 2844 |
bool mExpanded = false; |
| 2845 |
|
| 2846 |
RecursiveComplexTransitiveProcessingData* mParentData = nullptr; |
| 2847 |
QList<RecursiveComplexTransitiveProcessingData*>* mAdditionalPropgationList = nullptr; |
| 2848 |
}; |
| 2849 |
|
| 2850 |
|
| 2851 |
|
| 2852 |
QList<RecursiveComplexTransitiveProcessingData*> processingList; |
| 2853 |
RecursiveComplexTransitiveProcessingData* basicProcessingData = new RecursiveComplexTransitiveProcessingData(); |
| 2854 |
basicProcessingData->mIndiItemRef = indiRealItemRef; |
| 2855 |
basicProcessingData->mIndiComplexRoleData = indiComplexRoleData; |
| 2856 |
processingList.append(basicProcessingData); |
| 2857 |
|
| 2858 |
QList<RecursiveComplexTransitiveProcessingData*> propagationList; |
| 2859 |
|
| 2860 |
QHash<cint64, RecursiveComplexTransitiveProcessingData*> indiProcessingDataHash; |
| 2861 |
indiProcessingDataHash.insert(indiRealItemRef.getIndividualID(), basicProcessingData); |
| 2862 |
|
| 2863 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash* combinedNeighbourCacheLabelItemDataHash = roleInstancesItem->getCombinedNeighbourCacheLabelItemDataHash(inversed); |
| 2864 |
|
| 2865 |
while (!processingList.isEmpty()) { |
| 2866 |
RecursiveComplexTransitiveProcessingData* nextProcessingData = processingList.takeFirst(); |
| 2867 |
|
| 2868 |
#ifdef REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2869 |
mDebugTransitiveCollectionStringList.append(QString("Analysing %1").arg(CIRIName::getRecentIRIName(nextProcessingData->mIndiItemRef.getIndividual()->getIndividualNameLinker()))); |
| 2870 |
mDebugTransitiveCollectionString = mDebugTransitiveCollectionStringList.join("\r\n"); |
| 2871 |
#endif // REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2872 |
|
| 2873 |
propagationList.append(nextProcessingData); |
| 2874 |
if (!nextProcessingData->mIndiComplexRoleData->isInitialized(inversed)) { |
| 2875 |
|
| 2876 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(nextProcessingData->mIndiItemRef.getIndividualID()); |
| 2877 |
nextProcessingData->mIndiAssData = indiAssData; |
| 2878 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeigRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 2879 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* roleSetNeighbourArray = indiAssData->getRoleSetNeighbourArray(); |
| 2880 |
|
| 2881 |
#ifdef REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2882 |
mDebugTransitiveCollectionStringList.append(QString("Analysing neighours of %1").arg(CIRIName::getRecentIRIName(nextProcessingData->mIndiItemRef.getIndividual()->getIndividualNameLinker()))); |
| 2883 |
mDebugTransitiveCollectionString = mDebugTransitiveCollectionStringList.join("\r\n"); |
| 2884 |
#endif // REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2885 |
|
| 2886 |
|
| 2887 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* roleItemCompNeighLabelData = roleInstancesItem->getCombinedNeighbourCacheLabelItemDataHash(inversed)->value(combinedNeigRoleSetLabel); |
| 2888 |
if (roleItemCompNeighLabelData && roleItemCompNeighLabelData->hasKnownInstancesLabelItems()) { |
| 2889 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedKPSetRoleInstancesSingleNeighbourRoleSetCacheLabelData*>* singleNeighLabelDataHash = roleItemCompNeighLabelData->getKnownInstancesLabelItemDataHash(); |
| 2890 |
|
| 2891 |
for (auto it = singleNeighLabelDataHash->constBegin(), itEnd = singleNeighLabelDataHash->constEnd(); it != itEnd; ++it) { |
| 2892 |
roleSetNeighbourArray->at(it.value()->getLabelArrayIndex()).visitNeighbourIndividualIds([&](cint64 neighbourId)->bool { |
| 2893 |
// check same individual merged |
| 2894 |
CRealizationIndividualInstanceItemReference neighbourIndiItemRef = reqConfPreCompItem->getInstanceItemReference(neighbourId, false); |
| 2895 |
if (!reqConfPreCompItem->isSameIndividualsMerged(neighbourIndiItemRef)) { |
| 2896 |
// create new processing data |
| 2897 |
|
| 2898 |
RecursiveComplexTransitiveProcessingData*& successorProcessingData = indiProcessingDataHash[neighbourId]; |
| 2899 |
|
| 2900 |
if (successorProcessingData) { |
| 2901 |
// TODO: check and handle cycles |
| 2902 |
if (!successorProcessingData->mParentData) { |
| 2903 |
successorProcessingData->mParentData = nextProcessingData; |
| 2904 |
|
| 2905 |
|
| 2906 |
#ifdef REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2907 |
mDebugTransitiveCollectionStringList.append(QString("Readding %1 as single").arg(CIRIName::getRecentIRIName(neighbourIndiItemRef.getIndividual()->getIndividualNameLinker()))); |
| 2908 |
mDebugTransitiveCollectionString = mDebugTransitiveCollectionStringList.join("\r\n"); |
| 2909 |
#endif // REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2910 |
|
| 2911 |
} else { |
| 2912 |
if (!successorProcessingData->mAdditionalPropgationList) { |
| 2913 |
successorProcessingData->mAdditionalPropgationList = new QList<RecursiveComplexTransitiveProcessingData*>(); |
| 2914 |
} |
| 2915 |
successorProcessingData->mAdditionalPropgationList->append(nextProcessingData); |
| 2916 |
|
| 2917 |
#ifdef REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2918 |
mDebugTransitiveCollectionStringList.append(QString("Readding %1 as multiple").arg(CIRIName::getRecentIRIName(neighbourIndiItemRef.getIndividual()->getIndividualNameLinker()))); |
| 2919 |
mDebugTransitiveCollectionString = mDebugTransitiveCollectionStringList.join("\r\n"); |
| 2920 |
#endif // REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2921 |
|
| 2922 |
} |
| 2923 |
|
| 2924 |
} else { |
| 2925 |
successorProcessingData = new RecursiveComplexTransitiveProcessingData(); |
| 2926 |
successorProcessingData->mIndiItemRef = neighbourIndiItemRef; |
| 2927 |
|
| 2928 |
#ifdef REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2929 |
mDebugTransitiveCollectionStringList.append(QString("Adding %1").arg(CIRIName::getRecentIRIName(neighbourIndiItemRef.getIndividual()->getIndividualNameLinker()))); |
| 2930 |
mDebugTransitiveCollectionString = mDebugTransitiveCollectionStringList.join("\r\n"); |
| 2931 |
#endif // REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 2932 |
|
| 2933 |
successorProcessingData->mIndiComplexRoleData = roleInstancesItem->getIndividualIdComplexRoleData(neighbourIndiItemRef.getIndividualID(), true); |
| 2934 |
successorProcessingData->mParentData = nextProcessingData; |
| 2935 |
successorProcessingData->mIndiComplexRoleData->setInitializing(inversed, true); |
| 2936 |
processingList.append(successorProcessingData); |
| 2937 |
} |
| 2938 |
|
| 2939 |
} |
| 2940 |
return true; |
| 2941 |
}); |
| 2942 |
} |
| 2943 |
} |
| 2944 |
} |
| 2945 |
} |
| 2946 |
|
| 2947 |
|
| 2948 |
while (!propagationList.isEmpty()) { |
| 2949 |
RecursiveComplexTransitiveProcessingData* nextProcessingData = propagationList.takeLast(); |
| 2950 |
|
| 2951 |
|
| 2952 |
//if (CIRIName::getRecentIRIName(nextProcessingData->mIndiItemRef.getIndividual()->getIndividualNameLinker()) == "http://ontology.dumontierlab.com/eswc-example-graph-3#plot") { |
| 2953 |
// bool debug = true; |
| 2954 |
//} |
| 2955 |
|
| 2956 |
|
| 2957 |
if (nextProcessingData->mParentData) { |
| 2958 |
QList<RecursiveComplexTransitiveProcessingData*> parentDataList; |
| 2959 |
parentDataList.append(nextProcessingData->mParentData); |
| 2960 |
if (nextProcessingData->mAdditionalPropgationList) { |
| 2961 |
parentDataList.append(*nextProcessingData->mAdditionalPropgationList); |
| 2962 |
} |
| 2963 |
|
| 2964 |
QList<RecursiveComplexTransitiveProcessingData*> propagationDataList; |
| 2965 |
for (RecursiveComplexTransitiveProcessingData* parentData : parentDataList) { |
| 2966 |
if (!nextProcessingData->mExpanded) { |
| 2967 |
propagationDataList.append(parentData); |
| 2968 |
} else { |
| 2969 |
if (parentData->mParentData) { |
| 2970 |
propagationDataList.append(parentData->mParentData); |
| 2971 |
} |
| 2972 |
if (parentData->mAdditionalPropgationList) { |
| 2973 |
propagationDataList.append(*parentData->mAdditionalPropgationList); |
| 2974 |
} |
| 2975 |
} |
| 2976 |
} |
| 2977 |
|
| 2978 |
if (!propagationDataList.isEmpty()) { |
| 2979 |
|
| 2980 |
// TODO: add successor itself |
| 2981 |
|
| 2982 |
QList<CRealizationIndividualInstanceItemReference> linkAddingSuccessorIndividualReferenceList; |
| 2983 |
linkAddingSuccessorIndividualReferenceList.append(nextProcessingData->mIndiItemRef); |
| 2984 |
|
| 2985 |
|
| 2986 |
if (!nextProcessingData->mExpanded) { |
| 2987 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = reqConfPreCompItem->getBackendAssociationCacheReader()->getIndividualAssociationData(nextProcessingData->mIndiItemRef.getIndividualID()); |
| 2988 |
nextProcessingData->mIndiAssData = indiAssData; |
| 2989 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeigRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 2990 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* roleSetNeighbourArray = indiAssData->getRoleSetNeighbourArray(); |
| 2991 |
|
| 2992 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* roleItemCompNeighLabelData = roleInstancesItem->getCombinedNeighbourCacheLabelItemDataHash(inversed)->value(combinedNeigRoleSetLabel); |
| 2993 |
if (roleItemCompNeighLabelData && roleItemCompNeighLabelData->hasKnownInstancesLabelItems()) { |
| 2994 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedKPSetRoleInstancesSingleNeighbourRoleSetCacheLabelData*>* singleNeighLabelDataHash = roleItemCompNeighLabelData->getKnownInstancesLabelItemDataHash(); |
| 2995 |
|
| 2996 |
for (auto it = singleNeighLabelDataHash->constBegin(), itEnd = singleNeighLabelDataHash->constEnd(); it != itEnd; ++it) { |
| 2997 |
roleSetNeighbourArray->at(it.value()->getLabelArrayIndex()).visitNeighbourIndividualIds([&](cint64 neighbourId)->bool { |
| 2998 |
// check same individual merged |
| 2999 |
CRealizationIndividualInstanceItemReference neighbourIndiItemRef = reqConfPreCompItem->getInstanceItemReference(neighbourId, false); |
| 3000 |
if (!reqConfPreCompItem->isSameIndividualsMerged(neighbourIndiItemRef)) { |
| 3001 |
linkAddingSuccessorIndividualReferenceList.append(neighbourIndiItemRef); |
| 3002 |
} |
| 3003 |
return true; |
| 3004 |
}); |
| 3005 |
} |
| 3006 |
} |
| 3007 |
} |
| 3008 |
|
| 3009 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* successorIndiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)nextProcessingData->mIndiComplexRoleData; |
| 3010 |
COptimizedKPSetRoleInstancesHash* succInstanceDatahash = successorIndiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstancesHash(inversed, false); |
| 3011 |
if (succInstanceDatahash) { |
| 3012 |
for (COptimizedKPSetRoleInstancesHash::iterator it = succInstanceDatahash->begin(), itEnd = succInstanceDatahash->end(); it != itEnd; ++it) { |
| 3013 |
cint64 indiId = it.key(); |
| 3014 |
COptimizedKPSetRoleInstancesHashData& instanceHashData = it.value(); |
| 3015 |
if (instanceHashData.mInstanceItemData->mKnownInstance) { |
| 3016 |
|
| 3017 |
CRealizationIndividualInstanceItemReference succIndiItemRef = reqConfPreCompItem->getInstanceItemReference(indiId, true); |
| 3018 |
linkAddingSuccessorIndividualReferenceList.append(succIndiItemRef); |
| 3019 |
} |
| 3020 |
} |
| 3021 |
} |
| 3022 |
|
| 3023 |
|
| 3024 |
for (CRealizationIndividualInstanceItemReference succIndiItemRef : linkAddingSuccessorIndividualReferenceList) { |
| 3025 |
|
| 3026 |
|
| 3027 |
QSet<RecursiveComplexTransitiveProcessingData*> propagatedDataSet; |
| 3028 |
QList<RecursiveComplexTransitiveProcessingData*> processingPropagationDataList(propagationDataList); |
| 3029 |
while (!processingPropagationDataList.isEmpty()) { |
| 3030 |
RecursiveComplexTransitiveProcessingData* nextPropagationData = processingPropagationDataList.takeFirst(); |
| 3031 |
|
| 3032 |
if (!propagatedDataSet.contains(nextPropagationData)) { |
| 3033 |
propagatedDataSet.insert(nextPropagationData); |
| 3034 |
|
| 3035 |
|
| 3036 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)nextPropagationData->mIndiComplexRoleData; |
| 3037 |
CRealizationIndividualInstanceItemReference indiRealItemRef = nextPropagationData->mIndiItemRef; |
| 3038 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = nextPropagationData->mIndiAssData; |
| 3039 |
|
| 3040 |
// guaranteed to be deterministic, so no need to check possible neighbour instances |
| 3041 |
COptimizedKPSetRoleNeighbourInstancesHashData* indiRoleNeighbourHashData = nullptr; |
| 3042 |
|
| 3043 |
CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* assNeighbourRoleSetHash = indiAssData->getNeighbourRoleSetHash(); |
| 3044 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetCompinationLabelItem = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 3045 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* combinedNeighbourCacheLabelItemData = combinedNeighbourCacheLabelItemDataHash->value(neighbourRoleSetCompinationLabelItem); |
| 3046 |
|
| 3047 |
|
| 3048 |
bool addedLink = addComplexRoleExplicitIndirectNeighbourLink(roleInstancesItem, inversed, indiRealItemRef, indiExplicitIndirectLinkComplexRepresentationData, indiRoleNeighbourHashData, combinedNeighbourCacheLabelItemData, assNeighbourRoleSetHash, succIndiItemRef, nullptr, true, reqConfPreCompItem); |
| 3049 |
|
| 3050 |
if (nextPropagationData->mParentData) { |
| 3051 |
processingPropagationDataList.append(nextPropagationData->mParentData); |
| 3052 |
} |
| 3053 |
if (nextPropagationData->mAdditionalPropgationList) { |
| 3054 |
processingPropagationDataList.append(*nextPropagationData->mAdditionalPropgationList); |
| 3055 |
} |
| 3056 |
} |
| 3057 |
} |
| 3058 |
} |
| 3059 |
|
| 3060 |
} |
| 3061 |
} |
| 3062 |
} |
| 3063 |
|
| 3064 |
|
| 3065 |
|
| 3066 |
for (auto processingData : indiProcessingDataHash) { |
| 3067 |
processingData->mIndiComplexRoleData->setInitialized(inversed, true); |
| 3068 |
delete processingData; |
| 3069 |
} |
| 3070 |
|
| 3071 |
|
| 3072 |
|
| 3073 |
return true; |
| 3074 |
} |
| 3075 |
return false; |
| 3076 |
} |
| 3077 |
|
| 3078 |
|
| 3079 |
|
| 3080 |
|
| 3081 |
|
| 3082 |
|
| 3083 |
|
| 3084 |
|
| 3085 |
|
| 3086 |
|
| 3087 |
|
| 3088 |
|
| 3089 |
|
| 3090 |
|
| 3091 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createNextRoleComplexCandidateConfirmationTest(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetRoleInstancesItem* roleInstancesItem, COptimizedKPSetIndividualItemReferencePair candidatePair, COntologyRealizingDynamicRequirmentProcessingData* procData) { |
| 3092 |
bool workCreated = false; |
| 3093 |
CRealizationIndividualInstanceItemReference item1Ref = candidatePair.first; |
| 3094 |
CRealizationIndividualInstanceItemReference item2Ref = candidatePair.second; |
| 3095 |
|
| 3096 |
reqConfPreCompItem->incTestingRoleInstanceCandidatesCount(); |
| 3097 |
roleInstancesItem->incTestingComplexCandidateInstancesCount(); |
| 3098 |
|
| 3099 |
|
| 3100 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = roleInstancesItem->getIndividualIdComplexRoleData(item1Ref.getIndividualID(), true); |
| 3101 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 3102 |
|
| 3103 |
COptimizedKPSetRoleInstancesData* instanceData = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstanceItemData(false, item2Ref.getIndividualID(), true); |
| 3104 |
if (!instanceData->mTestedInstance && !instanceData->mTestingInstance && !instanceData->mKnownInstance) { |
| 3105 |
instanceData->mTestingInstance = true; |
| 3106 |
|
| 3107 |
CSatisfiableCalculationJob* satCalcJob = nullptr; |
| 3108 |
CSatisfiableCalculationJobGenerator satCalcJobGen(reqConfPreCompItem->getTemporaryRoleRealizationOntology()); |
| 3109 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(roleInstancesItem->getTemporaryPropagationConcept(), false, item1Ref, satCalcJob); |
| 3110 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(roleInstancesItem->getTemporaryMarkerConcept(), true, item2Ref, satCalcJob); |
| 3111 |
satCalcJob->setCalculationConfiguration(reqConfPreCompItem->getCalculationConfiguration()); |
| 3112 |
|
| 3113 |
CIndividualRoleCandidateConfirmationTestingItem* testItem = new CIndividualRoleCandidateConfirmationTestingItem(reqConfPreCompItem, item1Ref, item2Ref, roleInstancesItem, procData); |
| 3114 |
processCalculationJob(satCalcJob, reqConfPreCompItem, testItem); |
| 3115 |
workCreated = true; |
| 3116 |
} |
| 3117 |
|
| 3118 |
return workCreated; |
| 3119 |
} |
| 3120 |
|
| 3121 |
|
| 3122 |
|
| 3123 |
|
| 3124 |
|
| 3125 |
|
| 3126 |
|
| 3127 |
|
| 3128 |
|
| 3129 |
|
| 3130 |
|
| 3131 |
|
| 3132 |
|
| 3133 |
|
| 3134 |
|
| 3135 |
|
| 3136 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createIndividualsConsistencyTest(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 3137 |
|
| 3138 |
CSatisfiableCalculationJob* satCalcJob = nullptr; |
| 3139 |
CSatisfiableCalculationJobGenerator satCalcJobGen(reqConfPreCompItem->getOntology()); |
| 3140 |
|
| 3141 |
|
| 3142 |
CIndividualVector* indiVec = reqConfPreCompItem->getOntology()->getABox()->getIndividualVector(false); |
| 3143 |
cint64 indiCount = 0; |
| 3144 |
if (indiVec) { |
| 3145 |
indiCount = indiVec->getItemCount(); |
| 3146 |
|
| 3147 |
|
| 3148 |
QList<CIndividual*> indiList; |
| 3149 |
for (cint64 idx = 0; idx < indiCount; ++idx) { |
| 3150 |
CIndividual* indi = indiVec->getData(idx); |
| 3151 |
indiList.append(indi); |
| 3152 |
} |
| 3153 |
CSatisfiableCalculationJobGenerator satCalcJobGen(reqConfPreCompItem->getOntology()); |
| 3154 |
if (!indiList.isEmpty()) { |
| 3155 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(indiList); |
| 3156 |
satCalcJob->setCalculationConfiguration(reqConfPreCompItem->getCalculationConfiguration()); |
| 3157 |
if (reqConfPreCompItem->getPossibleAssertionCollectionSet()) { |
| 3158 |
satCalcJob->setPossibleAssertionCollectionAdapter(new CSatisfiableTaskRealizationPossibleAssertionCollectingAdapter(reqConfPreCompItem->getOntology(),reqConfPreCompItem->getPossibleAssertionCollectionSet())); |
| 3159 |
} |
| 3160 |
|
| 3161 |
CIndividualsConsistencyTestingItem* testItem = new CIndividualsConsistencyTestingItem(reqConfPreCompItem); |
| 3162 |
processCalculationJob(satCalcJob,reqConfPreCompItem,testItem); |
| 3163 |
return true; |
| 3164 |
} |
| 3165 |
} |
| 3166 |
|
| 3167 |
return false; |
| 3168 |
} |
| 3169 |
|
| 3170 |
|
| 3171 |
|
| 3172 |
|
| 3173 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createNextSameIndividualsTest(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetIndividualItem* instantiatedItem1, COptimizedKPSetIndividualItem* instantiatedItem2, COntologyRealizingDynamicRequirmentProcessingData* procData) { |
| 3174 |
instantiatedItem1->incTestingPossibleSameIndividualCount(); |
| 3175 |
instantiatedItem2->incTestingPossibleSameIndividualCount(); |
| 3176 |
|
| 3177 |
bool temporaryNominalConcept = false; |
| 3178 |
CIndividual* individual1 = instantiatedItem1->getIndividual(); |
| 3179 |
CIndividual* individual2 = instantiatedItem2->getIndividual(); |
| 3180 |
CConcept* nominalConcept2 = nullptr; |
| 3181 |
if (individual2) { |
| 3182 |
nominalConcept2 = individual2->getIndividualNominalConcept(); |
| 3183 |
} |
| 3184 |
if (!nominalConcept2) { |
| 3185 |
nominalConcept2 = instantiatedItem2->getTemporaryIndividualNominalConcept(); |
| 3186 |
temporaryNominalConcept = true; |
| 3187 |
} |
| 3188 |
|
| 3189 |
CConcept* testingNominalConcept = nominalConcept2; |
| 3190 |
CIndividualReference testingIndividualReference = instantiatedItem1->getIndividualReference(); |
| 3191 |
CIndividualReference otherTestringIndividualReference = instantiatedItem2->getIndividualReference(); |
| 3192 |
|
| 3193 |
if (!testingNominalConcept) { |
| 3194 |
testingIndividualReference = instantiatedItem2->getIndividualReference(); |
| 3195 |
otherTestringIndividualReference = instantiatedItem1->getIndividualReference(); |
| 3196 |
temporaryNominalConcept = false; |
| 3197 |
testingNominalConcept = nullptr; |
| 3198 |
if (individual1) { |
| 3199 |
testingNominalConcept = individual1->getIndividualNominalConcept(); |
| 3200 |
} |
| 3201 |
if (!testingNominalConcept) { |
| 3202 |
temporaryNominalConcept = true; |
| 3203 |
testingNominalConcept = instantiatedItem1->getTemporaryIndividualNominalConcept(); |
| 3204 |
} |
| 3205 |
} |
| 3206 |
|
| 3207 |
|
| 3208 |
if (testingNominalConcept) { |
| 3209 |
CSatisfiableCalculationJob* satCalcJob = nullptr; |
| 3210 |
CSatisfiableCalculationJobGenerator satCalcJobGen(reqConfPreCompItem->getOntology()); |
| 3211 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(testingNominalConcept,true,testingIndividualReference); |
| 3212 |
|
| 3213 |
if (temporaryNominalConcept) { |
| 3214 |
satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(testingNominalConcept,false,otherTestringIndividualReference, satCalcJob); |
| 3215 |
} |
| 3216 |
|
| 3217 |
satCalcJob->setCalculationConfiguration(reqConfPreCompItem->getCalculationConfiguration()); |
| 3218 |
if (reqConfPreCompItem->getPossibleAssertionCollectionSet()) { |
| 3219 |
satCalcJob->setPossibleAssertionCollectionAdapter(new CSatisfiableTaskRealizationPossibleAssertionCollectingAdapter(reqConfPreCompItem->getOntology(),reqConfPreCompItem->getPossibleAssertionCollectionSet())); |
| 3220 |
} |
| 3221 |
if (reqConfPreCompItem->requiresIndividualDependenceTracking()) { |
| 3222 |
if (!instantiatedItem1->getIndividualDependenceTrackingCollector()) { |
| 3223 |
instantiatedItem1->setIndividualDependenceTrackingCollector(new CIndividualDependenceTrackingCollector()); |
| 3224 |
} |
| 3225 |
} |
| 3226 |
if (instantiatedItem1->getIndividualDependenceTrackingCollector()) { |
| 3227 |
satCalcJob->setSatisfiableTaskIndividualDependenceTrackingAdapter(new CSatisfiableTaskIndividualDependenceTrackingAdapter(instantiatedItem1->getIndividualDependenceTrackingCollector())); |
| 3228 |
} |
| 3229 |
|
| 3230 |
CIndividualSameTestingItem* testItem = new CIndividualSameTestingItem(reqConfPreCompItem,instantiatedItem1,instantiatedItem2, procData); |
| 3231 |
reqConfPreCompItem->incTestingPossibleSameIndividualCount(); |
| 3232 |
|
| 3233 |
instantiatedItem1->getPossibleSameIndividualTestingItemHash()->insert(instantiatedItem2->getIndividualId(), testItem); |
| 3234 |
instantiatedItem2->getPossibleSameIndividualTestingItemHash()->insert(instantiatedItem1->getIndividualId(), testItem); |
| 3235 |
|
| 3236 |
processCalculationJob(satCalcJob,reqConfPreCompItem,testItem); |
| 3237 |
return true; |
| 3238 |
} else { |
| 3239 |
LOG(ERROR,getDomain(),logTr("Failed testing whether '%1' and '%2' are same individuals, nominal concepts are not available.").arg(CIRIName::getRecentIRIName(individual1->getIndividualNameLinker())).arg(CIRIName::getRecentIRIName(individual2->getIndividualNameLinker())),this); |
| 3240 |
return false; |
| 3241 |
} |
| 3242 |
} |
| 3243 |
|
| 3244 |
|
| 3245 |
|
| 3246 |
|
| 3247 |
COptimizedKPSetIndividualItem* COptimizedRepresentativeKPSetOntologyRealizingThread::getMergingResolvedIndividualItem(COptimizedKPSetIndividualItem* indiItem) { |
| 3248 |
while (indiItem->isItemSameIndividualMerged()) { |
| 3249 |
indiItem = indiItem->getItemSameIndividualMerged(); |
| 3250 |
} |
| 3251 |
return indiItem; |
| 3252 |
} |
| 3253 |
|
| 3254 |
|
| 3255 |
CRealizationEntailmentQueuedIndividualConceptInstanceTestingItem* COptimizedRepresentativeKPSetOntologyRealizingThread::getEntailmentIndividualConceptInstanceTestingItem(QList<CRealizationEntailmentQueuedIndividualConceptInstanceTestingItem *>* entIndConInstTestList, COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 3256 |
CRealizationEntailmentQueuedIndividualConceptInstanceTestingItem* conInstTestItem = entIndConInstTestList->takeFirst(); |
| 3257 |
COptimizedKPSetConceptInstancesItem* conceptItem = conInstTestItem->getConceptItem(); |
| 3258 |
COptimizedKPSetIndividualItem* indiItem = conInstTestItem->getIndividualItem(); |
| 3259 |
|
| 3260 |
cint64 maxRemainingShuffeling = qMin(1000, entIndConInstTestList->size()); |
| 3261 |
while (maxRemainingShuffeling-- > 0) { |
| 3262 |
QHash<COptimizedKPSetIndividualItem*, CPossibleInstancesIndividualsMergingLinker*>* mergingDataHash = conceptItem->getIndividualItemPossibleInstanceMergingLinkerHash(false); |
| 3263 |
if (!mergingDataHash) { |
| 3264 |
return conInstTestItem; |
| 3265 |
} else { |
| 3266 |
CPossibleInstancesIndividualsMergingLinker* mergingIndiLinker = mergingDataHash->value(indiItem); |
| 3267 |
if (!mergingIndiLinker || mergingIndiLinker->isSatisfiableMerged()) { |
| 3268 |
return conInstTestItem; |
| 3269 |
} else { |
| 3270 |
entIndConInstTestList->append(conInstTestItem); |
| 3271 |
conInstTestItem = entIndConInstTestList->takeFirst(); |
| 3272 |
conceptItem = conInstTestItem->getConceptItem(); |
| 3273 |
indiItem = conInstTestItem->getIndividualItem(); |
| 3274 |
} |
| 3275 |
} |
| 3276 |
} |
| 3277 |
return conInstTestItem; |
| 3278 |
} |
| 3279 |
|
| 3280 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::createNextTest() { |
| 3281 |
|
| 3282 |
|
| 3283 |
COntologyRealizingItem* loopOntPreCompItem = 0; |
| 3284 |
bool workTestCreated = false; |
| 3285 |
while (!workTestCreated && !mProcessingOntItemList.isEmpty()) { |
| 3286 |
COntologyRealizingItem* ontPreCompItem = mProcessingOntItemList.first(); |
| 3287 |
|
| 3288 |
if (ontPreCompItem == loopOntPreCompItem) { |
| 3289 |
// don't run into infinite loop without doing something |
| 3290 |
break; |
| 3291 |
} |
| 3292 |
|
| 3293 |
COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem = (COptimizedRepresentativeKPSetOntologyRealizingItem*)ontPreCompItem; |
| 3294 |
|
| 3295 |
|
| 3296 |
|
| 3297 |
if (!workTestCreated && reqConfPreCompItem->isExtraConsistencyTestingStepRequired()) { |
| 3298 |
if (!reqConfPreCompItem->isExtraConsistencyTesting() && !reqConfPreCompItem->isExtraConsistencyTested()) { |
| 3299 |
// create consistency test |
| 3300 |
if (createIndividualsConsistencyTest(reqConfPreCompItem)) { |
| 3301 |
reqConfPreCompItem->setExtraConsistencyTesting(true); |
| 3302 |
workTestCreated = true; |
| 3303 |
} else { |
| 3304 |
reqConfPreCompItem->setExtraConsistencyTested(true); |
| 3305 |
} |
| 3306 |
} |
| 3307 |
} |
| 3308 |
|
| 3309 |
|
| 3310 |
if (!workTestCreated && reqConfPreCompItem->isRealizeSameIndividualsStepRequired() && !reqConfPreCompItem->isExtraConsistencyTesting()) { |
| 3311 |
if (!reqConfPreCompItem->isRealizeSameIndividualsStepFinished()) { |
| 3312 |
if (reqConfPreCompItem->areRealizeSameIndividualsStepProcessingRequirementSatisfied()) { |
| 3313 |
|
| 3314 |
if (!reqConfPreCompItem->hasRealizationSameIndividualsInitialized()) { |
| 3315 |
createTemporarySameRealizationOntology(reqConfPreCompItem); |
| 3316 |
reqConfPreCompItem->setRealizationSameIndividualsInitialized(true); |
| 3317 |
|
| 3318 |
if (reqConfPreCompItem->isAllSameIndividualsProcessing()) { |
| 3319 |
LOG(INFO, getDomain(), logTr("Realize same individuals for ontology."), this); |
| 3320 |
} |
| 3321 |
} |
| 3322 |
|
| 3323 |
|
| 3324 |
|
| 3325 |
|
| 3326 |
while (!workTestCreated && reqConfPreCompItem->hasEntailmentIndividualsSameInstanceTestingItems()) { |
| 3327 |
QList<CRealizationEntailmentQueuedIndividualsSameInstanceTestingItem*>* entIndSameInstTestList = reqConfPreCompItem->getEntailmentIndividualsSameInstanceTestingItemList(); |
| 3328 |
CRealizationEntailmentQueuedIndividualsSameInstanceTestingItem* sameInstTestItem = entIndSameInstTestList->takeFirst(); |
| 3329 |
COptimizedKPSetIndividualItem* indiItem1 = sameInstTestItem->getIndividualSourceItem(); |
| 3330 |
COptimizedKPSetIndividualItem* indiItem2 = sameInstTestItem->getIndividualDestinationItem(); |
| 3331 |
COntologyRealizingDynamicRequirmentProcessingData* procData = sameInstTestItem->getProcessingData(); |
| 3332 |
indiItem1 = getMergingResolvedIndividualItem(indiItem1); |
| 3333 |
indiItem2 = getMergingResolvedIndividualItem(indiItem2); |
| 3334 |
if (!indiItem1->isItemSameIndividualMerged() && !indiItem2->isItemSameIndividualMerged() && indiItem1 != indiItem2 && indiItem1->getPossibleSameInstantiatedItemSet()->contains(indiItem2)) { |
| 3335 |
indiItem1->getPossibleSameInstantiatedItemSet()->remove(indiItem2); |
| 3336 |
workTestCreated = createNextSameIndividualsTest(reqConfPreCompItem, indiItem1, indiItem2, procData); |
| 3337 |
} else if (procData) { |
| 3338 |
CRealizingTestingItem* testingItem = indiItem1->getPossibleSameIndividualTestingItemHash()->value(indiItem2->getIndividualId()); |
| 3339 |
if (testingItem) { |
| 3340 |
testingItem->addProcessingData(procData); |
| 3341 |
} else { |
| 3342 |
setDynamicRequirementProcessed(ontPreCompItem, reqConfPreCompItem->getRealizeSameIndividualsProcessingStep(), procData); |
| 3343 |
} |
| 3344 |
} |
| 3345 |
delete sameInstTestItem; |
| 3346 |
} |
| 3347 |
|
| 3348 |
|
| 3349 |
|
| 3350 |
if (reqConfPreCompItem->hasRemainingProcessingSameIndividualsItems()) { |
| 3351 |
QList<COptimizedKPSetIndividualItem*>* processingSameIndividualItemList = reqConfPreCompItem->getProcessingPossibleSameIndividualsItemList(); |
| 3352 |
while (!workTestCreated && !processingSameIndividualItemList->isEmpty()) { |
| 3353 |
COptimizedKPSetIndividualItem* nextProcessingItem = processingSameIndividualItemList->first(); |
| 3354 |
COptimizedKPSetIndividualItem* nextPossibleSameIndividualTestItem = nullptr; |
| 3355 |
|
| 3356 |
if (!nextProcessingItem->isItemSameIndividualMerged()) { |
| 3357 |
|
| 3358 |
nextPossibleSameIndividualTestItem = nextProcessingItem->takeTestingPossibleSameIndividualItem(); |
| 3359 |
if (nextPossibleSameIndividualTestItem) { |
| 3360 |
nextPossibleSameIndividualTestItem->removePossibleSameIndividualItem(nextProcessingItem); |
| 3361 |
|
| 3362 |
if (!nextPossibleSameIndividualTestItem->isItemSameIndividualMerged()) { |
| 3363 |
workTestCreated = createNextSameIndividualsTest(reqConfPreCompItem,nextProcessingItem,nextPossibleSameIndividualTestItem); |
| 3364 |
} |
| 3365 |
} |
| 3366 |
|
| 3367 |
} |
| 3368 |
if (nextProcessingItem->isItemSameIndividualMerged() || !nextProcessingItem->hasPossibleSameIndividuals()) { |
| 3369 |
processingSameIndividualItemList->removeFirst(); |
| 3370 |
nextProcessingItem->setPossibleSameIndividualsProcessingQueuedFlag(false); |
| 3371 |
} |
| 3372 |
checkFinishSameIndividualProcessing(ontPreCompItem, nextProcessingItem); |
| 3373 |
checkFinishSameIndividualProcessing(ontPreCompItem, nextPossibleSameIndividualTestItem); |
| 3374 |
|
| 3375 |
} |
| 3376 |
} |
| 3377 |
|
| 3378 |
|
| 3379 |
if (!workTestCreated && !reqConfPreCompItem->hasRemainingProcessingSameIndividualsItems()) { |
| 3380 |
if (!reqConfPreCompItem->hasTestingPossibleSameIndividual()) { |
| 3381 |
|
| 3382 |
|
| 3383 |
if (reqConfPreCompItem->isAllSameIndividualsProcessing()) { |
| 3384 |
if (!reqConfPreCompItem->isSameRealizationInstalled()) { |
| 3385 |
reqConfPreCompItem->setSameRealizationInstalled(true); |
| 3386 |
|
| 3387 |
CRealizingTestingStep* ontProcStep = reqConfPreCompItem->getRealizeSameIndividualsProcessingStep(); |
| 3388 |
addRealizationStatistics(reqConfPreCompItem, ontProcStep); |
| 3389 |
|
| 3390 |
LOG(INFO, getDomain(), logTr("Same individual realization finished for ontology."), this); |
| 3391 |
reqConfPreCompItem->getRealizeSameIndividualsProcessingStep()->setStepFinished(true); |
| 3392 |
} |
| 3393 |
} |
| 3394 |
reqConfPreCompItem->getRealizeSameIndividualsProcessingStep()->submitRequirementsUpdate(); |
| 3395 |
} |
| 3396 |
} |
| 3397 |
} else { |
| 3398 |
reqConfPreCompItem->getRealizeSameIndividualsProcessingStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSFAILEDREQUIREMENT); |
| 3399 |
} |
| 3400 |
} else { |
| 3401 |
reqConfPreCompItem->getRealizeSameIndividualsProcessingStep()->submitRequirementsUpdate(); |
| 3402 |
} |
| 3403 |
} |
| 3404 |
|
| 3405 |
|
| 3406 |
|
| 3407 |
if (!workTestCreated && reqConfPreCompItem->isRealizeConceptStepRequired() && !reqConfPreCompItem->isExtraConsistencyTesting()) { |
| 3408 |
if (!reqConfPreCompItem->isRealizeConceptStepFinished()) { |
| 3409 |
if (reqConfPreCompItem->areRealizeConceptStepProcessingRequirementSatisfied()) { |
| 3410 |
|
| 3411 |
if (!reqConfPreCompItem->hasRealizationConceptsInitialized()) { |
| 3412 |
if (!reqConfPreCompItem->isCountingPossibleConceptInstancesTesting()) { |
| 3413 |
mOpenPossibleInstancesCount += reqConfPreCompItem->getOpenPossibleConceptInstancesCount(); |
| 3414 |
mTestedPossibleInstancesCount += reqConfPreCompItem->getTestedPossibleConceptInstancesCount(); |
| 3415 |
reqConfPreCompItem->setCountingPossibleConceptInstancesTesting(true); |
| 3416 |
} |
| 3417 |
reqConfPreCompItem->setRealizationConceptsInitialized(true); |
| 3418 |
|
| 3419 |
|
| 3420 |
if (reqConfPreCompItem->isAllConceptInstancesProcessing()) { |
| 3421 |
LOG(INFO, getDomain(), logTr("Realize individual types for ontology."), this); |
| 3422 |
} |
| 3423 |
} |
| 3424 |
|
| 3425 |
while (!workTestCreated && (reqConfPreCompItem->hasEntailmentIndividualConceptInstanceTestingItems() || reqConfPreCompItem->hasRemainingProcessingConceptInstanceItems() || (!reqConfPreCompItem->hasTestingPossibleConceptInstances() && reqConfPreCompItem->isRealizeConceptStepRequired()))) { |
| 3426 |
|
| 3427 |
while (!workTestCreated && reqConfPreCompItem->hasEntailmentIndividualConceptInstanceTestingItems()) { |
| 3428 |
QList<CRealizationEntailmentQueuedIndividualConceptInstanceTestingItem*>* entIndConInstTestList = reqConfPreCompItem->getEntailmentIndividualConceptInstanceTestingItemList(); |
| 3429 |
|
| 3430 |
|
| 3431 |
CRealizationEntailmentQueuedIndividualConceptInstanceTestingItem* conInstTestItem = getEntailmentIndividualConceptInstanceTestingItem(entIndConInstTestList, reqConfPreCompItem); |
| 3432 |
COptimizedKPSetConceptInstancesItem* conceptItem = conInstTestItem->getConceptItem(); |
| 3433 |
COptimizedKPSetIndividualItem* indiItem = conInstTestItem->getIndividualItem(); |
| 3434 |
|
| 3435 |
|
| 3436 |
COntologyRealizingDynamicRequirmentProcessingData* procData = conInstTestItem->getProcessingData(); |
| 3437 |
indiItem = getMergingResolvedIndividualItem(indiItem); |
| 3438 |
if (!indiItem->isItemSameIndividualMerged() && conceptItem->getPossibleInstancesMap()->contains(indiItem->getIndividualId())) { |
| 3439 |
conceptItem->getPossibleInstancesMap()->remove(indiItem->getIndividualId()); |
| 3440 |
workTestCreated = createNextConceptInstantiationTest(reqConfPreCompItem, conceptItem, indiItem, entIndConInstTestList->size(), procData); |
| 3441 |
} |
| 3442 |
if (!workTestCreated && procData) { |
| 3443 |
CRealizingTestingItem* testingItem = conceptItem->getPossibleInstanceTestingItemHash()->value(indiItem->getIndividualId()); |
| 3444 |
if (testingItem) { |
| 3445 |
testingItem->addProcessingData(procData); |
| 3446 |
} else { |
| 3447 |
setDynamicRequirementProcessed(ontPreCompItem, reqConfPreCompItem->getRealizeConceptProcessingStep(), procData); |
| 3448 |
} |
| 3449 |
} |
| 3450 |
delete conInstTestItem; |
| 3451 |
} |
| 3452 |
|
| 3453 |
if (!workTestCreated && reqConfPreCompItem->hasRemainingProcessingConceptInstanceItems()) { |
| 3454 |
QList<COptimizedKPSetConceptInstancesItem*>* processingInstancesItemList = reqConfPreCompItem->getProcessingPossibleConceptInstancesItemList(); |
| 3455 |
while (!workTestCreated && !processingInstancesItemList->isEmpty()) { |
| 3456 |
COptimizedKPSetConceptInstancesItem* nextProcessingItem = processingInstancesItemList->first(); |
| 3457 |
|
| 3458 |
if (nextProcessingItem->hasPossibleInstances()) { |
| 3459 |
COptimizedKPSetIndividualItem* nextInstantiatedTestItem = nextProcessingItem->takeNextTestingPossibleInstance(); |
| 3460 |
|
| 3461 |
if (!nextInstantiatedTestItem->isItemSameIndividualMerged()) { |
| 3462 |
workTestCreated = createNextConceptInstantiationTest(reqConfPreCompItem, nextProcessingItem, nextInstantiatedTestItem, nextProcessingItem->getPossibleInstancesMap()->size()); |
| 3463 |
} else { |
| 3464 |
incTestedPossibleConceptInstancesCount(reqConfPreCompItem); |
| 3465 |
} |
| 3466 |
} |
| 3467 |
if (!nextProcessingItem->hasPossibleInstances()) { |
| 3468 |
processingInstancesItemList->removeFirst(); |
| 3469 |
nextProcessingItem->setPossibleInstancesProcessingQueuedFlag(false); |
| 3470 |
} else if (workTestCreated && mAlternateShufflePossibleConceptInstanceTestingItemsOnCalculations) { |
| 3471 |
processingInstancesItemList->removeFirst(); |
| 3472 |
processingInstancesItemList->append(nextProcessingItem); |
| 3473 |
} |
| 3474 |
checkFinishConceptInstancesProcessing(ontPreCompItem, nextProcessingItem); |
| 3475 |
|
| 3476 |
} |
| 3477 |
} |
| 3478 |
|
| 3479 |
if (!workTestCreated && !reqConfPreCompItem->hasRemainingProcessingConceptInstanceItems() && !reqConfPreCompItem->hasEntailmentIndividualConceptInstanceTestingItems()) { |
| 3480 |
if (!reqConfPreCompItem->hasTestingPossibleConceptInstances()) { |
| 3481 |
|
| 3482 |
if (reqConfPreCompItem->isAllConceptInstancesProcessing()) { |
| 3483 |
if (!reqConfPreCompItem->isConceptRealizationInstalled()) { |
| 3484 |
reqConfPreCompItem->setConceptRealizationInstalled(true); |
| 3485 |
|
| 3486 |
CRealizingTestingStep* ontProcStep = reqConfPreCompItem->getRealizeConceptProcessingStep(); |
| 3487 |
addRealizationStatistics(reqConfPreCompItem, ontProcStep); |
| 3488 |
|
| 3489 |
LOG(INFO, getDomain(), logTr("Concept realization finished for ontology."), this); |
| 3490 |
if (reqConfPreCompItem->getProvidedPossibleInstancesMergingsCount() > 0) { |
| 3491 |
LOG(INFO, getDomain(), logTr("Provided %1 possible instance mergings containing %2 individuals, %3 mergings attempted and %4 succeeded.").arg(reqConfPreCompItem->getProvidedPossibleInstancesMergingsCount()).arg(reqConfPreCompItem->getProvidedPossibleInstancesMergingIndividualsCount()).arg(reqConfPreCompItem->getAttemptedPossibleInstancesMergingsCount()).arg(reqConfPreCompItem->getSucceddedPossibleInstancesMergingsCount()), this); |
| 3492 |
} |
| 3493 |
|
| 3494 |
if (reqConfPreCompItem->getModelMergingsTriedCount() > 0) { |
| 3495 |
LOG(INFO, getDomain(), logTr("Tried %1 trivial pseudo model mergings, %2 succeeded by determing %3 instances and %4 non-instances.").arg(reqConfPreCompItem->getModelMergingsTriedCount()).arg(reqConfPreCompItem->getModelMergingsSucessCount()).arg(reqConfPreCompItem->getModelMergingsInstanceFoundCount()).arg(reqConfPreCompItem->getModelMergingsNonInstanceFoundCount()), this); |
| 3496 |
} |
| 3497 |
reqConfPreCompItem->getRealizeConceptProcessingStep()->setStepFinished(true); |
| 3498 |
} |
| 3499 |
} |
| 3500 |
reqConfPreCompItem->getRealizeConceptProcessingStep()->submitRequirementsUpdate(); |
| 3501 |
} |
| 3502 |
} |
| 3503 |
} |
| 3504 |
} else { |
| 3505 |
reqConfPreCompItem->getRealizeConceptProcessingStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSFAILEDREQUIREMENT); |
| 3506 |
} |
| 3507 |
} else { |
| 3508 |
reqConfPreCompItem->getRealizeConceptProcessingStep()->submitRequirementsUpdate(); |
| 3509 |
} |
| 3510 |
} |
| 3511 |
|
| 3512 |
|
| 3513 |
|
| 3514 |
|
| 3515 |
|
| 3516 |
if (!workTestCreated && reqConfPreCompItem->isRealizeRoleStepRequired() && !reqConfPreCompItem->isExtraConsistencyTesting()) { |
| 3517 |
if (!reqConfPreCompItem->isRealizeRoleStepFinished()) { |
| 3518 |
if (reqConfPreCompItem->areRealizeRoleStepProcessingRequirementSatisfied()) { |
| 3519 |
|
| 3520 |
if (!reqConfPreCompItem->hasRealizationRolesInitialized()) { |
| 3521 |
LOG(INFO,getDomain(),logTr("Create temporary ontology extension for role realization."),this); |
| 3522 |
createTemporaryRoleRealizationOntology(reqConfPreCompItem); |
| 3523 |
//reqConfPreCompItem->initRoleCandidateInitializingIndividualItems(); |
| 3524 |
reqConfPreCompItem->setRealizationRolesInitialized(true); |
| 3525 |
if (!reqConfPreCompItem->isCountingPossibleRoleInstancesTesting()) { |
| 3526 |
mOpenPossibleInstancesCount += reqConfPreCompItem->getOpenPossibleRoleInstancesCount(); |
| 3527 |
mTestedPossibleInstancesCount += reqConfPreCompItem->getTestedPossibleRoleInstancesCount(); |
| 3528 |
reqConfPreCompItem->setCountingPossibleRoleInstancesTesting(true); |
| 3529 |
} |
| 3530 |
|
| 3531 |
if (!reqConfPreCompItem->isRoleRealizationInstalled()) { |
| 3532 |
LOG(INFO, getDomain(), logTr("Realizing role instances for ontology."), this); |
| 3533 |
} |
| 3534 |
} |
| 3535 |
|
| 3536 |
|
| 3537 |
|
| 3538 |
|
| 3539 |
|
| 3540 |
if (reqConfPreCompItem->hasRemainingCandidateConfirmationRoleInstanceItems()) { |
| 3541 |
QList<COptimizedKPSetRoleInstancesItem*>* candidateConfirmationRoleInstancesItemList = reqConfPreCompItem->getCandidateConfirmationRoleInstancesItemList(); |
| 3542 |
while (!workTestCreated && !candidateConfirmationRoleInstancesItemList->isEmpty()) { |
| 3543 |
COptimizedKPSetRoleInstancesItem* nextCandidateConfirmationRoleItem = candidateConfirmationRoleInstancesItemList->first(); |
| 3544 |
|
| 3545 |
if (nextCandidateConfirmationRoleItem->hasComplexInstanceCandidates()) { |
| 3546 |
COptimizedKPSetIndividualItemReferencePair candidatePair = nextCandidateConfirmationRoleItem->takeNextTestingComplexInstanceCandidate(); |
| 3547 |
workTestCreated = createNextRoleComplexCandidateConfirmationTest(reqConfPreCompItem, nextCandidateConfirmationRoleItem, candidatePair); |
| 3548 |
} |
| 3549 |
if (!nextCandidateConfirmationRoleItem->hasComplexInstanceCandidates()) { |
| 3550 |
candidateConfirmationRoleInstancesItemList->removeFirst(); |
| 3551 |
} |
| 3552 |
checkFinishRoleInstancesProcessing(reqConfPreCompItem, nextCandidateConfirmationRoleItem); |
| 3553 |
} |
| 3554 |
} |
| 3555 |
|
| 3556 |
|
| 3557 |
|
| 3558 |
|
| 3559 |
if (reqConfPreCompItem->hasRemainingInitializingRoleInstanceItems()) { |
| 3560 |
QList<COptimizedKPSetRoleInstancesItem*>* initializingInstancesItemList = reqConfPreCompItem->getInitializingRoleInstancesItemList(); |
| 3561 |
while (!workTestCreated && !initializingInstancesItemList->isEmpty()) { |
| 3562 |
COptimizedKPSetRoleInstancesItem* nextInitializingItem = initializingInstancesItemList->first(); |
| 3563 |
|
| 3564 |
if (!nextInitializingItem->isCandidateSuccessorInitializationCompleted()) { |
| 3565 |
|
| 3566 |
|
| 3567 |
if (!nextInitializingItem->isCandidateSuccessorInitializationStarted()) { |
| 3568 |
|
| 3569 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* neighbourRoleLabelCacheItemSet = nextInitializingItem->getComplexStarterCandidateCombinedNeighbourRoleLabelCacheItemSet(false); |
| 3570 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* existentialRoleLabelCacheItemSet = nextInitializingItem->getComplexStarterCandidateCombinedNeighbourRoleLabelCacheItemSet(false); |
| 3571 |
|
| 3572 |
QList<CBackendRepresentativeMemoryLabelCacheItem*> roleLabelCacheItemList; |
| 3573 |
roleLabelCacheItemList.append(neighbourRoleLabelCacheItemSet->toList()); |
| 3574 |
roleLabelCacheItemList.append(existentialRoleLabelCacheItemSet->toList()); |
| 3575 |
COptimizedRepresentativeKPSetCacheMultipleTypeLabelSetItemIterator* iterator = new COptimizedRepresentativeKPSetCacheMultipleTypeLabelSetItemIterator(roleLabelCacheItemList, reqConfPreCompItem->getIndividualInstantiatedItemHash(), reqConfPreCompItem->getOntology()->getABox()->getIndividualVector()); |
| 3576 |
nextInitializingItem->setIndividualComplexCandidateIterator(iterator); |
| 3577 |
|
| 3578 |
nextInitializingItem->setCandidateSuccessorInitializationStarted(true); |
| 3579 |
} |
| 3580 |
|
| 3581 |
workTestCreated = createNextRoleInitializingTest(reqConfPreCompItem, nextInitializingItem); |
| 3582 |
|
| 3583 |
} |
| 3584 |
if (nextInitializingItem->isCandidateSuccessorInitializationCompleted()) { |
| 3585 |
initializingInstancesItemList->removeFirst(); |
| 3586 |
} |
| 3587 |
checkFinishRoleInstancesProcessing(reqConfPreCompItem, nextInitializingItem); |
| 3588 |
} |
| 3589 |
} |
| 3590 |
|
| 3591 |
|
| 3592 |
while (!workTestCreated && (reqConfPreCompItem->hasRemainingInitializingRoleInstanceIndividualItemReferences() || reqConfPreCompItem->hasRemainingInitializingRolePredeccessorInstanceIndividualItemReferencePairs() || |
| 3593 |
(reqConfPreCompItem->hasEntailmentIndividualsRoleInstanceTestingItems() && !reqConfPreCompItem->hasRemainingInitializingRoleInstanceItems() && !reqConfPreCompItem->hasPropagatingRoleInstanceCandidates()))) { |
| 3594 |
|
| 3595 |
if (reqConfPreCompItem->hasRemainingInitializingRoleInstanceIndividualItemReferences()) { |
| 3596 |
QList<CRealizationIndividualInstanceItemReference>* initializingIndividualItemList = reqConfPreCompItem->getInitializingRoleInstancesIndividualItemReferenceList(); |
| 3597 |
while (!workTestCreated && !initializingIndividualItemList->isEmpty()) { |
| 3598 |
CRealizationIndividualInstanceItemReference nextInitializingItem = initializingIndividualItemList->first(); |
| 3599 |
|
| 3600 |
workTestCreated = createNextRoleInitializingTest(reqConfPreCompItem, nextInitializingItem); |
| 3601 |
|
| 3602 |
initializingIndividualItemList->removeFirst(); |
| 3603 |
} |
| 3604 |
} |
| 3605 |
|
| 3606 |
|
| 3607 |
if (reqConfPreCompItem->hasRemainingInitializingRoleSuccessorInstanceIndividualItemReferencePairs()) { |
| 3608 |
QList<QPair<CRealizationIndividualInstanceItemReference, COptimizedKPSetRoleInstancesItem*>>* initializingIndividualItemPairList = reqConfPreCompItem->getInitializingRoleSuccessorInstancesIndividualItemReferencePairList(); |
| 3609 |
while (!workTestCreated && !initializingIndividualItemPairList->isEmpty()) { |
| 3610 |
QPair<CRealizationIndividualInstanceItemReference, COptimizedKPSetRoleInstancesItem*> nextInitializingItemPair = initializingIndividualItemPairList->first(); |
| 3611 |
CRealizationIndividualInstanceItemReference nextInitializingItem = nextInitializingItemPair.first; |
| 3612 |
COptimizedKPSetRoleInstancesItem* roleIntancesItem = nextInitializingItemPair.second; |
| 3613 |
|
| 3614 |
workTestCreated = createNextRoleInitializingTest(reqConfPreCompItem, roleIntancesItem, false, nextInitializingItem); |
| 3615 |
|
| 3616 |
initializingIndividualItemPairList->removeFirst(); |
| 3617 |
} |
| 3618 |
} |
| 3619 |
|
| 3620 |
|
| 3621 |
if (reqConfPreCompItem->hasRemainingInitializingRolePredeccessorInstanceIndividualItemReferencePairs()) { |
| 3622 |
QList<QPair<CRealizationIndividualInstanceItemReference, COptimizedKPSetRoleInstancesItem*>>* initializingIndividualItemPairList = reqConfPreCompItem->getInitializingRolePredecessorInstancesIndividualItemReferencePairList(); |
| 3623 |
while (!workTestCreated && !initializingIndividualItemPairList->isEmpty()) { |
| 3624 |
QPair<CRealizationIndividualInstanceItemReference, COptimizedKPSetRoleInstancesItem*> nextInitializingItemPair = initializingIndividualItemPairList->first(); |
| 3625 |
CRealizationIndividualInstanceItemReference nextInitializingItem = nextInitializingItemPair.first; |
| 3626 |
COptimizedKPSetRoleInstancesItem* roleIntancesItem = nextInitializingItemPair.second; |
| 3627 |
|
| 3628 |
|
| 3629 |
|
| 3630 |
workTestCreated = createNextRoleInitializingTest(reqConfPreCompItem, roleIntancesItem, true, nextInitializingItem); |
| 3631 |
|
| 3632 |
initializingIndividualItemPairList->removeFirst(); |
| 3633 |
} |
| 3634 |
} |
| 3635 |
|
| 3636 |
while (!workTestCreated && reqConfPreCompItem->hasEntailmentIndividualsRoleInstanceTestingItems() && !reqConfPreCompItem->hasRemainingInitializingRoleInstanceItems() && !reqConfPreCompItem->hasPropagatingRoleInstanceCandidates() && |
| 3637 |
!reqConfPreCompItem->hasRemainingInitializingRoleInstanceIndividualItemReferences() && !reqConfPreCompItem->hasRemainingInitializingRolePredeccessorInstanceIndividualItemReferencePairs() && !reqConfPreCompItem->hasRemainingInitializingRoleSuccessorInstanceIndividualItemReferencePairs()) { |
| 3638 |
|
| 3639 |
QList<CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem*>* entIndsRoleInstTestList = reqConfPreCompItem->getEntailmentIndividualsRoleInstanceTestingItemList(); |
| 3640 |
CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem* roleInstTestItem = entIndsRoleInstTestList->takeFirst(); |
| 3641 |
COptimizedKPSetRoleInstancesItem* roleItem = roleInstTestItem->getRoleItem(); |
| 3642 |
CRealizationIndividualInstanceItemReference indiSourceItemRef = roleInstTestItem->getIndividualSourceItemReference(); |
| 3643 |
CRealizationIndividualInstanceItemReference indiDestItemRef = roleInstTestItem->getIndividualDestinationItemReference(); |
| 3644 |
COntologyRealizingDynamicRequirmentProcessingData* procData = roleInstTestItem->getProcessingData(); |
| 3645 |
bool inversed = roleInstTestItem->isRoleInversed(); |
| 3646 |
COptimizedKPSetIndividualItem* indiSourceItem = (COptimizedKPSetIndividualItem*)indiSourceItemRef.getRealizationInstanceItem(); |
| 3647 |
|
| 3648 |
//QString indiString = CIRIName::getRecentIRIName(indiSourceItemRef.getIndividual()->getIndividualNameLinker()); |
| 3649 |
//QString roleString = CIRIName::getRecentIRIName(roleItem->getRole()->getPropertyNameLinker()); |
| 3650 |
//QString inverseRoleString = CIRIName::getRecentIRIName(roleItem->getInverseRole()->getPropertyNameLinker()); |
| 3651 |
//if (indiString == "http://purl.obolibrary.org/obo/CHROMOSOME-7227_X" && (roleString == "http://purl.obolibrary.org/obo/RO_0002131" || inverseRoleString == "http://purl.obolibrary.org/obo/RO_0002131")) { |
| 3652 |
// bool debug = true; |
| 3653 |
//} |
| 3654 |
|
| 3655 |
if (indiSourceItem) { |
| 3656 |
indiSourceItem = getMergingResolvedIndividualItem(indiSourceItem); |
| 3657 |
} |
| 3658 |
if (indiDestItemRef.isNonEmpty()) { |
| 3659 |
COptimizedKPSetIndividualItem* indiDestItem = dynamic_cast<COptimizedKPSetIndividualItem*>(indiDestItemRef.getRealizationInstanceItem()); |
| 3660 |
if (indiDestItem) { |
| 3661 |
indiDestItem = getMergingResolvedIndividualItem(indiDestItem); |
| 3662 |
} |
| 3663 |
|
| 3664 |
bool isInstance = false; |
| 3665 |
bool isPossibleInstance = false; |
| 3666 |
|
| 3667 |
if (indiSourceItem && indiDestItem) { |
| 3668 |
COptimizedKPSetRoleNeighbourInstancesHash* knownPossibleInstancesHash = indiSourceItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 3669 |
if (knownPossibleInstancesHash) { |
| 3670 |
COptimizedKPSetRoleNeighbourInstancesHashData possNeighbourInstanceData = knownPossibleInstancesHash->value(roleItem); |
| 3671 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = possNeighbourInstanceData.getRoleNeighbourInstancesHash(inversed, false); |
| 3672 |
if (possNeighbourInstanceHash) { |
| 3673 |
COptimizedKPSetRoleInstancesData* instanceData = possNeighbourInstanceHash->value(indiDestItem->getIndividualId()).mInstanceItemData; |
| 3674 |
if (instanceData) { |
| 3675 |
isInstance = instanceData->mKnownInstance; |
| 3676 |
isPossibleInstance = isInstance || instanceData->mPossibleInstance && !instanceData->mTestedInstance; |
| 3677 |
} |
| 3678 |
} |
| 3679 |
} |
| 3680 |
|
| 3681 |
if (!indiSourceItem->isItemSameIndividualMerged() && !indiDestItem->isItemSameIndividualMerged() && !isInstance && isPossibleInstance) { |
| 3682 |
COptimizedKPSetIndividualItemPair indiPair = COptimizedKPSetIndividualItemPair(indiSourceItem, indiDestItem); |
| 3683 |
if (inversed) { |
| 3684 |
indiPair = COptimizedKPSetIndividualItemPair(indiDestItem, indiSourceItem); |
| 3685 |
} |
| 3686 |
roleItem->getPossibleInstancesSet()->remove(indiPair); |
| 3687 |
// TODO: prevent that the same tests are repeated if they are required by multiple requirements |
| 3688 |
workTestCreated = createNextRoleInstantiationTest(reqConfPreCompItem, roleItem, indiPair, procData); |
| 3689 |
} |
| 3690 |
} |
| 3691 |
if (!workTestCreated && !isInstance && !isPossibleInstance) { |
| 3692 |
if (roleItem->getIndividualIdComplexRoleDataHash()->contains(indiSourceItemRef.getIndividualID())) { |
| 3693 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = roleItem->getIndividualIdComplexRoleData(indiSourceItemRef.getIndividualID(), true); |
| 3694 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 3695 |
|
| 3696 |
COptimizedKPSetRoleInstancesData* instanceData = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstanceItemData(inversed, indiDestItemRef.getIndividualID(), false); |
| 3697 |
if (instanceData) { |
| 3698 |
isInstance = instanceData->mKnownInstance; |
| 3699 |
isPossibleInstance = isInstance || instanceData->mPossibleInstance && !instanceData->mTestedInstance; |
| 3700 |
} |
| 3701 |
|
| 3702 |
|
| 3703 |
if (!isInstance && isPossibleInstance) { |
| 3704 |
COptimizedKPSetIndividualItemReferencePair candidatePair = COptimizedKPSetIndividualItemReferencePair(indiSourceItemRef, indiDestItemRef); |
| 3705 |
if (inversed) { |
| 3706 |
candidatePair = COptimizedKPSetIndividualItemReferencePair(indiDestItemRef, indiSourceItemRef); |
| 3707 |
} |
| 3708 |
roleItem->removeComplexCandidateInstance(candidatePair, inversed); |
| 3709 |
// TODO: prevent that the same tests are repeated if they are required by multiple requirements |
| 3710 |
workTestCreated = createNextRoleComplexCandidateConfirmationTest(reqConfPreCompItem, roleItem, candidatePair, procData); |
| 3711 |
} |
| 3712 |
} |
| 3713 |
} |
| 3714 |
|
| 3715 |
|
| 3716 |
if (!workTestCreated && procData) { |
| 3717 |
setDynamicRequirementProcessed(ontPreCompItem, reqConfPreCompItem->getRealizeRoleProcessingStep(), procData); |
| 3718 |
} |
| 3719 |
} else { |
| 3720 |
if (indiSourceItem) { |
| 3721 |
COptimizedKPSetRoleNeighbourInstancesHash* knownPossibleInstancesHash = indiSourceItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 3722 |
if (knownPossibleInstancesHash) { |
| 3723 |
COptimizedKPSetRoleNeighbourInstancesHashData possNeighbourInstanceData = knownPossibleInstancesHash->value(roleItem); |
| 3724 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = possNeighbourInstanceData.getRoleNeighbourInstancesHash(inversed, false); |
| 3725 |
if (possNeighbourInstanceHash) { |
| 3726 |
|
| 3727 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeighInst = possNeighbourInstanceHash->constBegin(), itNeighInstEnd = possNeighbourInstanceHash->constEnd(); itNeighInst != itNeighInstEnd; ++itNeighInst) { |
| 3728 |
const COptimizedKPSetRoleInstancesHashData& destIndiInstanceDat = itNeighInst.value(); |
| 3729 |
COptimizedKPSetIndividualItem* destIndiItem = destIndiInstanceDat.mNeighbourIndividualItem; |
| 3730 |
COptimizedKPSetRoleInstancesData* instanceData = destIndiInstanceDat.mInstanceItemData; |
| 3731 |
if (instanceData && !instanceData->mKnownInstance && instanceData->mPossibleInstance && !instanceData->mTestedInstance) { |
| 3732 |
CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem* incRoleInstTestItem = new CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem(indiSourceItemRef, CRealizationIndividualInstanceItemReference(destIndiItem->getIndividualReference(), destIndiItem), roleItem, inversed, procData); |
| 3733 |
procData->incProcessingItemCount(reqConfPreCompItem->getRealizeRoleProcessingStep()); |
| 3734 |
reqConfPreCompItem->addEntailmentIndividualsRoleInstanceTestingItem(incRoleInstTestItem); |
| 3735 |
} |
| 3736 |
} |
| 3737 |
} |
| 3738 |
} |
| 3739 |
} |
| 3740 |
if (roleItem->getIndividualIdComplexRoleDataHash()->contains(indiSourceItemRef.getIndividualID())) { |
| 3741 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = roleItem->getIndividualIdComplexRoleData(indiSourceItemRef.getIndividualID(), true); |
| 3742 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 3743 |
|
| 3744 |
|
| 3745 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstancesHash(inversed, false); |
| 3746 |
if (possNeighbourInstanceHash) { |
| 3747 |
|
| 3748 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeighInst = possNeighbourInstanceHash->constBegin(), itNeighInstEnd = possNeighbourInstanceHash->constEnd(); itNeighInst != itNeighInstEnd; ++itNeighInst) { |
| 3749 |
const COptimizedKPSetRoleInstancesHashData& destIndiInstanceDat = itNeighInst.value(); |
| 3750 |
cint64 destIndiId = itNeighInst.key(); |
| 3751 |
COptimizedKPSetRoleInstancesData* instanceData = destIndiInstanceDat.mInstanceItemData; |
| 3752 |
if (instanceData && !instanceData->mKnownInstance && instanceData->mPossibleInstance && !instanceData->mTestedInstance) { |
| 3753 |
CRealizationIndividualInstanceItemReference destIndiRef = reqConfPreCompItem->getInstanceItemReference(destIndiId, false); |
| 3754 |
CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem* incRoleInstTestItem = new CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem(indiSourceItemRef, destIndiRef, roleItem, inversed, procData); |
| 3755 |
procData->incProcessingItemCount(reqConfPreCompItem->getRealizeRoleProcessingStep()); |
| 3756 |
reqConfPreCompItem->addEntailmentIndividualsRoleInstanceTestingItem(incRoleInstTestItem); |
| 3757 |
} |
| 3758 |
} |
| 3759 |
} |
| 3760 |
|
| 3761 |
} |
| 3762 |
|
| 3763 |
|
| 3764 |
if (procData) { |
| 3765 |
setDynamicRequirementProcessed(reqConfPreCompItem, reqConfPreCompItem->getRealizeRoleProcessingStep(), procData); |
| 3766 |
} |
| 3767 |
|
| 3768 |
|
| 3769 |
} |
| 3770 |
delete roleInstTestItem; |
| 3771 |
} |
| 3772 |
} |
| 3773 |
|
| 3774 |
|
| 3775 |
if (reqConfPreCompItem->hasRemainingProcessingRoleInstanceItems()) { |
| 3776 |
QList<COptimizedKPSetRoleInstancesItem*>* processingInstancesItemList = reqConfPreCompItem->getProcessingPossibleRoleInstancesItemList(); |
| 3777 |
while (!workTestCreated && !processingInstancesItemList->isEmpty()) { |
| 3778 |
COptimizedKPSetRoleInstancesItem* nextProcessingItem = processingInstancesItemList->first(); |
| 3779 |
|
| 3780 |
if (nextProcessingItem->hasPossibleInstances()) { |
| 3781 |
COptimizedKPSetIndividualItemPair nextTestItemPair = nextProcessingItem->takeNextTestingPossibleInstance(); |
| 3782 |
COptimizedKPSetIndividualItem* firstIndiItem = nextTestItemPair.first; |
| 3783 |
COptimizedKPSetIndividualItem* secondIndiItem = nextTestItemPair.second; |
| 3784 |
|
| 3785 |
if (!firstIndiItem->isItemSameIndividualMerged()) { |
| 3786 |
workTestCreated = createNextRoleInstantiationTest(reqConfPreCompItem,nextProcessingItem,nextTestItemPair); |
| 3787 |
} else { |
| 3788 |
incTestedPossibleRoleInstancesCount(reqConfPreCompItem); |
| 3789 |
} |
| 3790 |
} |
| 3791 |
if (!nextProcessingItem->hasPossibleInstances()) { |
| 3792 |
processingInstancesItemList->removeFirst(); |
| 3793 |
nextProcessingItem->setPossibleInstancesProcessingQueuedFlag(false); |
| 3794 |
} |
| 3795 |
checkFinishRoleInstancesProcessing(reqConfPreCompItem, nextProcessingItem); |
| 3796 |
} |
| 3797 |
|
| 3798 |
} |
| 3799 |
|
| 3800 |
if (!workTestCreated && !reqConfPreCompItem->hasRemainingInitializingRoleInstanceItems() && !reqConfPreCompItem->hasRemainingProcessingRoleInstanceItems() && !reqConfPreCompItem->hasRemainingInitializingRoleInstanceIndividualItemReferences() && !reqConfPreCompItem->hasRemainingCandidateConfirmationRoleInstanceItems()) { |
| 3801 |
if (!reqConfPreCompItem->hasTestingPossibleRoleInstances() && !reqConfPreCompItem->hasPropagatingRoleInstanceCandidates() && !reqConfPreCompItem->hasTestingRoleInstanceCandidates()) { |
| 3802 |
|
| 3803 |
if (reqConfPreCompItem->isAllRoleInstancesProcessing()) { |
| 3804 |
if (!reqConfPreCompItem->isRoleRealizationInstalled()) { |
| 3805 |
reqConfPreCompItem->setRoleRealizationInstalled(true); |
| 3806 |
|
| 3807 |
LOG(INFO, getDomain(), logTr("Role realization finished for ontology."), this); |
| 3808 |
reqConfPreCompItem->getRealizeRoleProcessingStep()->setStepFinished(true); |
| 3809 |
} |
| 3810 |
} |
| 3811 |
reqConfPreCompItem->getRealizeRoleProcessingStep()->submitRequirementsUpdate(); |
| 3812 |
} |
| 3813 |
} |
| 3814 |
} else { |
| 3815 |
reqConfPreCompItem->getRealizeRoleProcessingStep()->submitRequirementsUpdate(COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSFAILEDREQUIREMENT); |
| 3816 |
} |
| 3817 |
} else { |
| 3818 |
reqConfPreCompItem->getRealizeRoleProcessingStep()->submitRequirementsUpdate(); |
| 3819 |
} |
| 3820 |
} |
| 3821 |
|
| 3822 |
|
| 3823 |
|
| 3824 |
|
| 3825 |
|
| 3826 |
|
| 3827 |
|
| 3828 |
|
| 3829 |
|
| 3830 |
if (!workTestCreated) { |
| 3831 |
if (!reqConfPreCompItem->hasRemainingProcessingRequirements()) { |
| 3832 |
finishOntologyRealizing(reqConfPreCompItem); |
| 3833 |
mProcessingOntItemList.removeFirst(); |
| 3834 |
} else { |
| 3835 |
mProcessingOntItemList.removeFirst(); |
| 3836 |
mProcessingOntItemList.append(reqConfPreCompItem); |
| 3837 |
loopOntPreCompItem = ontPreCompItem; |
| 3838 |
} |
| 3839 |
} |
| 3840 |
} |
| 3841 |
return workTestCreated; |
| 3842 |
} |
| 3843 |
|
| 3844 |
|
| 3845 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::addRealizationStatistics(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, CRealizingTestingStep* ontProcStep) { |
| 3846 |
COntologyProcessingStatistics* ontProcStats = ontProcStep->getProcessingStepData()->getProcessingStatistics(true); |
| 3847 |
ontProcStats->setProcessingCountStatisticValue("realization-time",reqConfPreCompItem->getInitializationTime()->elapsed()); |
| 3848 |
if (reqConfPreCompItem->getRealizeConceptProcessingStep() == ontProcStep) { |
| 3849 |
ontProcStats->setProcessingCountStatisticValue("realization-concept-instances-possible-testing-count",reqConfPreCompItem->getTestedPossibleConceptInstancesCount()); |
| 3850 |
addIndividualDependencyTrackingStatistics(reqConfPreCompItem,ontProcStep,"realization-concept-instances"); |
| 3851 |
ontProcStats->setProcessingCountStatisticValue("realization-concept-instances-time",reqConfPreCompItem->getInitializationTime()->elapsed()); |
| 3852 |
} else if (reqConfPreCompItem->getRealizeSameIndividualsProcessingStep() == ontProcStep) { |
| 3853 |
addIndividualDependencyTrackingStatistics(reqConfPreCompItem,ontProcStep,"realization-same-individuals"); |
| 3854 |
ontProcStats->setProcessingCountStatisticValue("realization-same-individuals-possible-testing-count",reqConfPreCompItem->getTestedPossibleSameIndividualsCount()); |
| 3855 |
} |
| 3856 |
return this; |
| 3857 |
} |
| 3858 |
|
| 3859 |
|
| 3860 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::addIndividualDependencyTrackingStatistics(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, CRealizingTestingStep* ontProcStep, const QString& realizationTypeString) { |
| 3861 |
if (reqConfPreCompItem->requiresIndividualDependenceTracking()) { |
| 3862 |
COntologyProcessingStatistics* ontProcStats = ontProcStep->getProcessingStepData()->getProcessingStatistics(true); |
| 3863 |
cint64 dependencyCount = 0; |
| 3864 |
cint64 dependencySize = 0; |
| 3865 |
for (QList<COptimizedKPSetIndividualItem*>::const_iterator indiItemIt = reqConfPreCompItem->getInstantiatedItemList()->constBegin(), indiItemItEnd = reqConfPreCompItem->getInstantiatedItemList()->constEnd(); indiItemIt != indiItemItEnd; ++indiItemIt) { |
| 3866 |
COptimizedKPSetIndividualItem* indiItem = (*indiItemIt); |
| 3867 |
if (indiItem->getIndividualDependenceTrackingCollector()) { |
| 3868 |
CIndividualDependenceTracking* indiDepTack = indiItem->getIndividualDependenceTrackingCollector()->getExtendingIndividualDependenceTracking(); |
| 3869 |
if (indiDepTack) { |
| 3870 |
dependencySize += indiDepTack->getDependenceSize(); |
| 3871 |
++dependencyCount; |
| 3872 |
} |
| 3873 |
} |
| 3874 |
} |
| 3875 |
ontProcStats->setProcessingCountStatisticValue(QString("%1-tracked-node-dependency-size").arg(realizationTypeString),dependencySize); |
| 3876 |
ontProcStats->setProcessingCountStatisticValue(QString("%1-tracked-node-dependency-count").arg(realizationTypeString),dependencyCount); |
| 3877 |
} |
| 3878 |
return this; |
| 3879 |
} |
| 3880 |
|
| 3881 |
|
| 3882 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::createTemporarySameRealizationOntology(COptimizedRepresentativeKPSetOntologyRealizingItem* item) { |
| 3883 |
CConcreteOntology* ontology = item->getOntology(); |
| 3884 |
CConcreteOntology* tmpSameRealOntology = item->getTemporarySameRealizationOntology(); |
| 3885 |
if (!tmpSameRealOntology) { |
| 3886 |
|
| 3887 |
|
| 3888 |
QList<COptimizedKPSetIndividualItem*> indiItemNominalCreationList; |
| 3889 |
QList<COptimizedKPSetIndividualItem*>* possibleSameIndiItemList = item->getPossibleSameIndividualsItemList(); |
| 3890 |
if (possibleSameIndiItemList && !possibleSameIndiItemList->isEmpty()) { |
| 3891 |
for (QList<COptimizedKPSetIndividualItem*>::const_iterator it = possibleSameIndiItemList->constBegin(), itEnd = possibleSameIndiItemList->constEnd(); it != itEnd; ++it) { |
| 3892 |
COptimizedKPSetIndividualItem* indiItem(*it); |
| 3893 |
CIndividual* indi = indiItem->getIndividual(); |
| 3894 |
if (!indi || indi->getIndividualNominalConcept() == nullptr) { |
| 3895 |
indiItemNominalCreationList.append(indiItem); |
| 3896 |
} |
| 3897 |
} |
| 3898 |
} |
| 3899 |
|
| 3900 |
if (!indiItemNominalCreationList.isEmpty()) { |
| 3901 |
tmpSameRealOntology = new CConcreteOntology(ontology,ontology->getConfiguration()); |
| 3902 |
tmpSameRealOntology->setConsistence(ontology->getConsistence()); |
| 3903 |
item->setTemporarySameRealizationOntology(tmpSameRealOntology); |
| 3904 |
|
| 3905 |
for (QList<COptimizedKPSetIndividualItem*>::const_iterator it = indiItemNominalCreationList.constBegin(), itEnd = indiItemNominalCreationList.constEnd(); it != itEnd; ++it) { |
| 3906 |
COptimizedKPSetIndividualItem* indiItem(*it); |
| 3907 |
CIndividual* indi = indiItem->getIndividual(); |
| 3908 |
|
| 3909 |
if (!indi) { |
| 3910 |
indi = new CIndividual(indiItem->getIndividualId()); |
| 3911 |
indi->setTemporaryFakeIndividual(true); |
| 3912 |
} |
| 3913 |
|
| 3914 |
CConcept* nominalConcept = createTemporaryConcept(item,tmpSameRealOntology); |
| 3915 |
nominalConcept->setNominalIndividual(indi); |
| 3916 |
nominalConcept->setOperatorCode(CCNOMINAL); |
| 3917 |
|
| 3918 |
indiItem->setTemporaryIndividualNominalConcept(nominalConcept); |
| 3919 |
} |
| 3920 |
|
| 3921 |
} else { |
| 3922 |
item->setTemporarySameRealizationOntology(ontology); |
| 3923 |
} |
| 3924 |
} |
| 3925 |
|
| 3926 |
return this; |
| 3927 |
} |
| 3928 |
|
| 3929 |
|
| 3930 |
|
| 3931 |
|
| 3932 |
|
| 3933 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::createTemporaryRoleRealizationOntology(COptimizedRepresentativeKPSetOntologyRealizingItem* item) { |
| 3934 |
CConcreteOntology* ontology = item->getOntology(); |
| 3935 |
CConcreteOntology* tmpRoleRealOntology = item->getTemporaryRoleRealizationOntology(); |
| 3936 |
if (!tmpRoleRealOntology) { |
| 3937 |
tmpRoleRealOntology = new CConcreteOntology(ontology,ontology->getConfiguration()); |
| 3938 |
tmpRoleRealOntology->setOntologyID(ontology->getOntologyID()); |
| 3939 |
tmpRoleRealOntology->setConsistence(ontology->getConsistence()); |
| 3940 |
tmpRoleRealOntology->getTBox()->setMinimalNextConceptID(ontology->getTBox()->getMinimalNextConceptID()); |
| 3941 |
|
| 3942 |
QSet<CConcept*> compTransformConceptSet; |
| 3943 |
QHash<CConcept*,COptimizedKPSetRoleInstancesItem*>* markerConRolInsItemHash = item->getMarkerConceptInstancesItemHash(); |
| 3944 |
|
| 3945 |
COptimizedKPSetRoleInstancesItem* topRoleInstItem = item->getTopRoleInstancesItem(); |
| 3946 |
QList<COptimizedKPSetRoleInstancesItem*>* roleItemList = item->getRoleInstancesItemList(); |
| 3947 |
for (QList<COptimizedKPSetRoleInstancesItem*>::const_iterator itemIt = roleItemList->constBegin(), itemItEnd = roleItemList->constEnd(); itemIt != itemItEnd; ++itemIt) { |
| 3948 |
COptimizedKPSetRoleInstancesItem* roleItem(*itemIt); |
| 3949 |
if (roleItem != topRoleInstItem) { |
| 3950 |
CRole* role = roleItem->getRole(); |
| 3951 |
CConcept* markerConcept = createTemporaryConcept(item,tmpRoleRealOntology); |
| 3952 |
markerConcept->setOperatorCode(CCMARKER); |
| 3953 |
CConcept* propConcept = createTemporaryConcept(item,tmpRoleRealOntology); |
| 3954 |
propConcept->setOperatorCode(CCALL); |
| 3955 |
propConcept->setRole(role); |
| 3956 |
addTemporaryConceptOperand(propConcept,markerConcept,false,item,tmpRoleRealOntology); |
| 3957 |
roleItem->setTemporaryMarkerConcept(markerConcept); |
| 3958 |
markerConRolInsItemHash->insert(markerConcept,roleItem); |
| 3959 |
roleItem->setTemporaryPropagationConcept(propConcept); |
| 3960 |
if (role->isComplexRole()) { |
| 3961 |
compTransformConceptSet.insert(propConcept); |
| 3962 |
} |
| 3963 |
|
| 3964 |
if (roleItem->hasInverseRole()) { |
| 3965 |
CRole* invRole = roleItem->getInverseRole(); |
| 3966 |
CConcept* invMarkerConcept = createTemporaryConcept(item,tmpRoleRealOntology); |
| 3967 |
invMarkerConcept->setOperatorCode(CCMARKER); |
| 3968 |
CConcept* invPropConcept = createTemporaryConcept(item,tmpRoleRealOntology); |
| 3969 |
invPropConcept->setOperatorCode(CCALL); |
| 3970 |
invPropConcept->setRole(invRole); |
| 3971 |
addTemporaryConceptOperand(invPropConcept,invMarkerConcept,false,item,tmpRoleRealOntology); |
| 3972 |
markerConRolInsItemHash->insert(invMarkerConcept,roleItem); |
| 3973 |
roleItem->setTemporaryInverseMarkerConcept(invMarkerConcept); |
| 3974 |
roleItem->setTemporaryInversePropagationConcept(invPropConcept); |
| 3975 |
if (invRole->isComplexRole()) { |
| 3976 |
compTransformConceptSet.insert(invPropConcept); |
| 3977 |
} |
| 3978 |
} |
| 3979 |
} |
| 3980 |
} |
| 3981 |
|
| 3982 |
if (!compTransformConceptSet.isEmpty()) { |
| 3983 |
CPreProcessContextBase* preprocessContext = new CPreProcessContextBase(tmpRoleRealOntology,ontology->getConfiguration()); |
| 3984 |
CRoleChainAutomataTransformationPreProcess* roleChainAutomataTransformPreprocessor = new CRoleChainAutomataTransformationPreProcess(); |
| 3985 |
roleChainAutomataTransformPreprocessor->preprocess(tmpRoleRealOntology,&compTransformConceptSet,preprocessContext); |
| 3986 |
delete preprocessContext; |
| 3987 |
delete roleChainAutomataTransformPreprocessor; |
| 3988 |
} |
| 3989 |
|
| 3990 |
item->setTemporaryRoleRealizationOntology(tmpRoleRealOntology); |
| 3991 |
} |
| 3992 |
return this; |
| 3993 |
} |
| 3994 |
|
| 3995 |
|
| 3996 |
|
| 3997 |
CConcept* COptimizedRepresentativeKPSetOntologyRealizingThread::createTemporaryConcept(COptimizedRepresentativeKPSetOntologyRealizingItem* item, CConcreteOntology* tmpRoleRealOntology) { |
| 3998 |
CTBox* tBox = tmpRoleRealOntology->getTBox(); |
| 3999 |
CConceptVector* conVec = tBox->getConceptVector(); |
| 4000 |
CConcept* concept = CObjectAllocator< CConcept >::allocateAndConstruct(tmpRoleRealOntology->getOntologyContext()->getMemoryAllocationManager()); |
| 4001 |
concept->initConcept(); |
| 4002 |
cint64 newConTag = tBox->getNextConceptID(); |
| 4003 |
concept->setConceptTag(newConTag); |
| 4004 |
conVec->setData(concept->getConceptTag(),concept); |
| 4005 |
return concept; |
| 4006 |
} |
| 4007 |
|
| 4008 |
|
| 4009 |
|
| 4010 |
void COptimizedRepresentativeKPSetOntologyRealizingThread::addTemporaryConceptOperand(CConcept* concept, CConcept* opConcept, bool negated, COptimizedRepresentativeKPSetOntologyRealizingItem* item, CConcreteOntology* tmpRoleRealOntology) { |
| 4011 |
CSortedNegLinker<CConcept*>* opConLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(tmpRoleRealOntology->getOntologyContext()->getMemoryAllocationManager()); |
| 4012 |
opConLinker->init(opConcept,negated); |
| 4013 |
concept->addOperandLinker(opConLinker); |
| 4014 |
concept->incOperandCount(); |
| 4015 |
} |
| 4016 |
|
| 4017 |
|
| 4018 |
|
| 4019 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::updateCalculatedKnownConceptInstance(COptimizedKPSetIndividualItem* instantiatedItem, COptimizedKPSetConceptInstancesItem* instancesItem, COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 4020 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = instantiatedItem->getKnownPossibleInstancesHash(); |
| 4021 |
COptimizedKPSetConceptInstancesData* instanceItemData = knownPossibleInstancesHash->getInstanceItemData(instancesItem); |
| 4022 |
QList<COptimizedKPSetConceptInstancesItem*> updateItemList; |
| 4023 |
instanceItemData->mTestingInstance = false; |
| 4024 |
if (!instanceItemData->mKnownInstance) { |
| 4025 |
instancesItem->addKnownInstance(instantiatedItem); |
| 4026 |
instanceItemData->mKnownInstance = true; |
| 4027 |
instanceItemData->mPossibleInstance = false; |
| 4028 |
instanceItemData->mMostSpecific = true; |
| 4029 |
instanceItemData->mTestedInstance = true; |
| 4030 |
updateItemList.append(*instancesItem->getParentItemList()); |
| 4031 |
} |
| 4032 |
while (!updateItemList.isEmpty()) { |
| 4033 |
COptimizedKPSetConceptInstancesItem* updateInstanceItem = updateItemList.takeFirst(); |
| 4034 |
COptimizedKPSetConceptInstancesData* updateInstanceItemData = knownPossibleInstancesHash->getInstanceItemData(updateInstanceItem); |
| 4035 |
if (!updateInstanceItemData->mKnownInstance) { |
| 4036 |
updateInstanceItemData->mKnownInstance = true; |
| 4037 |
updateInstanceItemData->mPossibleInstance = false; |
| 4038 |
updateInstanceItemData->mMostSpecific = false; |
| 4039 |
updateInstanceItemData->mDerived = true; |
| 4040 |
updateItemList.append(*updateInstanceItem->getParentItemList()); |
| 4041 |
} else if (updateInstanceItemData->mMostSpecific) { |
| 4042 |
updateInstanceItem->removeKnownInstance(instantiatedItem); |
| 4043 |
updateInstanceItemData->mMostSpecific = false; |
| 4044 |
} |
| 4045 |
} |
| 4046 |
return this; |
| 4047 |
} |
| 4048 |
|
| 4049 |
|
| 4050 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::updateCalculatedNonConceptInstance(COptimizedKPSetIndividualItem* instantiatedItem, COptimizedKPSetConceptInstancesItem* instancesItem, COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 4051 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = instantiatedItem->getKnownPossibleInstancesHash(); |
| 4052 |
COptimizedKPSetConceptInstancesData* instanceItemData = knownPossibleInstancesHash->getInstanceItemData(instancesItem); |
| 4053 |
QList<COptimizedKPSetConceptInstancesItem*> updateItemList; |
| 4054 |
instanceItemData->mTestingInstance = false; |
| 4055 |
if (!instanceItemData->mKnownInstance) { |
| 4056 |
if (instanceItemData->mPossibleInstance) { |
| 4057 |
instanceItemData->mPossibleInstance = false; |
| 4058 |
instanceItemData->mTestedInstance = true; |
| 4059 |
updateItemList.append(*instancesItem->getParentItemList()); |
| 4060 |
} |
| 4061 |
} |
| 4062 |
while (!updateItemList.isEmpty()) { |
| 4063 |
COptimizedKPSetConceptInstancesItem* updateInstanceItem = updateItemList.takeFirst(); |
| 4064 |
COptimizedKPSetConceptInstancesData* updateInstanceItemData = knownPossibleInstancesHash->getInstanceItemData(updateInstanceItem); |
| 4065 |
if (!updateInstanceItemData->mKnownInstance) { |
| 4066 |
if (updateInstanceItemData->mPossibleInstance) { |
| 4067 |
if (!updateInstanceItemData->mMostSpecific && !updateInstanceItemData->mTestingInstance) { |
| 4068 |
updateInstanceItemData->mMostSpecific = true; |
| 4069 |
incOpenPossibleConceptInstancesCount(reqConfPreCompItem); |
| 4070 |
instantiatedItem->incPossibleInstantiatedCount(); |
| 4071 |
updateInstanceItem->addPossibleInstance(instantiatedItem); |
| 4072 |
if (updateInstanceItem->hasToProcessPossibleInstancesFlag()) { |
| 4073 |
reqConfPreCompItem->addConceptInstanceItemToProcessPossibleInstances(updateInstanceItem); |
| 4074 |
} |
| 4075 |
} |
| 4076 |
} |
| 4077 |
} |
| 4078 |
} |
| 4079 |
return this; |
| 4080 |
} |
| 4081 |
|
| 4082 |
|
| 4083 |
|
| 4084 |
|
| 4085 |
|
| 4086 |
|
| 4087 |
|
| 4088 |
|
| 4089 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::updateCalculatedKnownRoleInstance(COptimizedKPSetIndividualItemPair individualItemPair, COptimizedKPSetRoleInstancesItem* instancesItem, COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 4090 |
COptimizedKPSetIndividualItem* indiItem1 = individualItemPair.first; |
| 4091 |
COptimizedKPSetIndividualItem* indiItem2 = individualItemPair.second; |
| 4092 |
COptimizedKPSetRoleNeighbourInstancesHash* knownPossibleRoleNeighbourInstancesHash = indiItem1->getKnownPossibleRoleNeighboursInstancesHash(); |
| 4093 |
COptimizedKPSetRoleInstancesData* instanceItemData = knownPossibleRoleNeighbourInstancesHash->getRoleSuccessorInstanceItemData(instancesItem,indiItem2); |
| 4094 |
QList<TRoleItemInversionPair> updateItemList; |
| 4095 |
instanceItemData->mTestingInstance = false; |
| 4096 |
if (!instanceItemData->mKnownInstance) { |
| 4097 |
instancesItem->addKnownInstance(COptimizedKPSetIndividualItemPair(indiItem1,indiItem2)); |
| 4098 |
instanceItemData->mKnownInstance = true; |
| 4099 |
instanceItemData->mPossibleInstance = false; |
| 4100 |
instanceItemData->mMostSpecific = true; |
| 4101 |
instanceItemData->mTestedInstance = true; |
| 4102 |
updateItemList.append(*instancesItem->getParentItemList()); |
| 4103 |
} |
| 4104 |
while (!updateItemList.isEmpty()) { |
| 4105 |
TRoleItemInversionPair updateInstanceItemInversionPair = updateItemList.takeFirst(); |
| 4106 |
COptimizedKPSetRoleInstancesItem* updateInstanceItem = updateInstanceItemInversionPair.first; |
| 4107 |
if (updateInstanceItem != reqConfPreCompItem->getTopRoleInstancesItem()) { |
| 4108 |
bool updateInstanceItemInversion = updateInstanceItemInversionPair.second; |
| 4109 |
COptimizedKPSetRoleInstancesData* updateInstanceItemData = nullptr; |
| 4110 |
if (!updateInstanceItemInversion) { |
| 4111 |
updateInstanceItemData = knownPossibleRoleNeighbourInstancesHash->getRoleSuccessorInstanceItemData(updateInstanceItem,indiItem2, false); |
| 4112 |
} else { |
| 4113 |
updateInstanceItemData = knownPossibleRoleNeighbourInstancesHash->getRolePredecessorInstanceItemData(updateInstanceItem,indiItem2, false); |
| 4114 |
} |
| 4115 |
if (updateInstanceItemData) { |
| 4116 |
if (!updateInstanceItemData->mKnownInstance) { |
| 4117 |
updateInstanceItemData->mKnownInstance = true; |
| 4118 |
updateInstanceItemData->mPossibleInstance = false; |
| 4119 |
updateInstanceItemData->mMostSpecific = false; |
| 4120 |
updateInstanceItemData->mDerived = true; |
| 4121 |
updateItemList.append(*updateInstanceItem->getParentItemList()); |
| 4122 |
} else if (updateInstanceItemData->mMostSpecific) { |
| 4123 |
updateInstanceItem->removeKnownInstance(COptimizedKPSetIndividualItemPair(indiItem1, indiItem2)); |
| 4124 |
updateInstanceItemData->mMostSpecific = false; |
| 4125 |
} |
| 4126 |
} |
| 4127 |
} |
| 4128 |
} |
| 4129 |
return this; |
| 4130 |
} |
| 4131 |
|
| 4132 |
|
| 4133 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::updateCalculatedNonRoleInstance(COptimizedKPSetIndividualItemPair individualItemPair, COptimizedKPSetRoleInstancesItem* instancesItem, COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 4134 |
COptimizedKPSetIndividualItem* indiItem1 = individualItemPair.first; |
| 4135 |
COptimizedKPSetIndividualItem* indiItem2 = individualItemPair.second; |
| 4136 |
COptimizedKPSetRoleNeighbourInstancesHash* knownPossibleRoleNeighbourInstancesHash = indiItem1->getKnownPossibleRoleNeighboursInstancesHash(); |
| 4137 |
COptimizedKPSetRoleInstancesData* instanceItemData = knownPossibleRoleNeighbourInstancesHash->getRoleSuccessorInstanceItemData(instancesItem,indiItem2); |
| 4138 |
QList<TRoleItemInversionPair> updateItemList; |
| 4139 |
instanceItemData->mTestingInstance = false; |
| 4140 |
if (!instanceItemData->mKnownInstance) { |
| 4141 |
if (instanceItemData->mPossibleInstance) { |
| 4142 |
instanceItemData->mPossibleInstance = false; |
| 4143 |
instanceItemData->mTestedInstance = true; |
| 4144 |
updateItemList.append(*instancesItem->getParentItemList()); |
| 4145 |
} |
| 4146 |
} |
| 4147 |
while (!updateItemList.isEmpty()) { |
| 4148 |
TRoleItemInversionPair updateInstanceItemInversionPair = updateItemList.takeFirst(); |
| 4149 |
COptimizedKPSetRoleInstancesItem* updateInstanceItem = updateInstanceItemInversionPair.first; |
| 4150 |
if (updateInstanceItem != reqConfPreCompItem->getTopRoleInstancesItem()) { |
| 4151 |
bool updateInstanceItemInversion = updateInstanceItemInversionPair.second; |
| 4152 |
COptimizedKPSetRoleInstancesData* updateInstanceItemData = nullptr; |
| 4153 |
if (!updateInstanceItemInversion) { |
| 4154 |
updateInstanceItemData = knownPossibleRoleNeighbourInstancesHash->getRoleSuccessorInstanceItemData(updateInstanceItem,indiItem2, false); |
| 4155 |
} else { |
| 4156 |
updateInstanceItemData = knownPossibleRoleNeighbourInstancesHash->getRolePredecessorInstanceItemData(updateInstanceItem,indiItem2, false); |
| 4157 |
} |
| 4158 |
if (updateInstanceItemData && !updateInstanceItemData->mKnownInstance) { |
| 4159 |
if (updateInstanceItemData->mPossibleInstance) { |
| 4160 |
if (!updateInstanceItemData->mMostSpecific && !updateInstanceItemData->mTestingInstance) { |
| 4161 |
updateInstanceItemData->mMostSpecific = true; |
| 4162 |
incOpenPossibleRoleInstancesCount(reqConfPreCompItem); |
| 4163 |
indiItem1->incPossibleRoleInstantiatedCount(); |
| 4164 |
indiItem2->incPossibleRoleInstantiatedCount(); |
| 4165 |
if (!updateInstanceItemInversion) { |
| 4166 |
updateInstanceItem->addPossibleInstance(COptimizedKPSetIndividualItemPair(indiItem1,indiItem2)); |
| 4167 |
} else { |
| 4168 |
updateInstanceItem->addPossibleInstance(COptimizedKPSetIndividualItemPair(indiItem2,indiItem1)); |
| 4169 |
} |
| 4170 |
if (updateInstanceItem->hasToProcessPossibleInstancesFlag()) { |
| 4171 |
reqConfPreCompItem->addRoleInstanceItemToProcessPossibleInstances(updateInstanceItem); |
| 4172 |
} |
| 4173 |
} |
| 4174 |
} |
| 4175 |
} |
| 4176 |
} |
| 4177 |
} |
| 4178 |
return this; |
| 4179 |
} |
| 4180 |
|
| 4181 |
|
| 4182 |
|
| 4183 |
|
| 4184 |
|
| 4185 |
|
| 4186 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::interpretConceptInstantiationResult(COntologyRealizingItem* ontPreCompItem, COptimizedKPSetConceptInstancesItem* instancesItem, COptimizedKPSetIndividualItem* instantiatedItem, bool isIndividualInstance) { |
| 4187 |
COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem = (COptimizedRepresentativeKPSetOntologyRealizingItem*)ontPreCompItem; |
| 4188 |
|
| 4189 |
|
| 4190 |
//CConcept* concept = instancesItem->getHierarchyNode()->getOneEquivalentConcept(); |
| 4191 |
//if (CIRIName::getRecentIRIName(concept->getNameLinker()) == "http://www.reactome.org/biopax/46/170905#Protein19") { |
| 4192 |
// bool debug = true; |
| 4193 |
//} |
| 4194 |
|
| 4195 |
|
| 4196 |
instancesItem->decTestingPossibleInstancesCount(); |
| 4197 |
instantiatedItem->decTestingPossibleInstantiatedCount(); |
| 4198 |
reqConfPreCompItem->decTestingPossibleConceptInstanceCount(); |
| 4199 |
|
| 4200 |
incTestedPossibleConceptInstancesCount(reqConfPreCompItem); |
| 4201 |
|
| 4202 |
if (!instantiatedItem->isItemSameIndividualMerged()) { |
| 4203 |
if (isIndividualInstance) { |
| 4204 |
updateCalculatedKnownConceptInstance(instantiatedItem, instancesItem, reqConfPreCompItem); |
| 4205 |
} |
| 4206 |
else { |
| 4207 |
updateCalculatedNonConceptInstance(instantiatedItem, instancesItem, reqConfPreCompItem); |
| 4208 |
} |
| 4209 |
} |
| 4210 |
|
| 4211 |
if (!instancesItem->hasTestingPossibleInstances() && !instancesItem->hasPossibleInstances()) { |
| 4212 |
QList<CPossibleInstancesIndividualsMergingData*>* possInstMergDataList = instancesItem->getPossibleInstanceMergingDataContainer(); |
| 4213 |
if (possInstMergDataList) { |
| 4214 |
for (CPossibleInstancesIndividualsMergingData* mergingData : *possInstMergDataList) { |
| 4215 |
reqConfPreCompItem->incAttemptedPossibleInstancesMergingsCount(mergingData->getMergingAttemptCount()); |
| 4216 |
} |
| 4217 |
} |
| 4218 |
instancesItem->clearPossibleInstanceMergingData(); |
| 4219 |
if (instancesItem->hasAllSuccessorProcessedFlag()) { |
| 4220 |
instancesItem->setSelfSuccessorProcessedFlag(true); |
| 4221 |
updateParentItemsSuccessorProcessed(instancesItem); |
| 4222 |
} |
| 4223 |
} |
| 4224 |
return true; |
| 4225 |
} |
| 4226 |
|
| 4227 |
|
| 4228 |
|
| 4229 |
|
| 4230 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::realizingTested(COntologyRealizingItem* ontPreCompItem, CRealizingTestingItem* preTestItem, CRealizingCalculatedCallbackEvent* pcce) { |
| 4231 |
COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem = (COptimizedRepresentativeKPSetOntologyRealizingItem*)ontPreCompItem; |
| 4232 |
QList<COntologyRealizingDynamicRequirmentProcessingData*> procDataList = preTestItem->getProcessingDataList(); |
| 4233 |
|
| 4234 |
bool processed = false; |
| 4235 |
if (!processed) { |
| 4236 |
CIndividualRoleCandidateConfirmationTestingItem* indiRoleCandConfTestItem = dynamic_cast<CIndividualRoleCandidateConfirmationTestingItem*>(preTestItem); |
| 4237 |
if (indiRoleCandConfTestItem) { |
| 4238 |
bool isIndividualInstance = !pcce->getTestResultSatisfiable(); |
| 4239 |
reqConfPreCompItem->decTestingRoleInstanceCandidatesCount(); |
| 4240 |
|
| 4241 |
CRealizationIndividualInstanceItemReference sourceIndividualItemReference = indiRoleCandConfTestItem->getSourceInstantiatedItemReference(); |
| 4242 |
COptimizedKPSetIndividualItem* sourceIndividualItem = (COptimizedKPSetIndividualItem*)sourceIndividualItemReference.getRealizationInstanceItem(); |
| 4243 |
|
| 4244 |
CRealizationIndividualInstanceItemReference targetIndividualItemReference = indiRoleCandConfTestItem->getTargetInstantiatedItemReference(); |
| 4245 |
COptimizedKPSetIndividualItem* targetIndividualItem = (COptimizedKPSetIndividualItem*)targetIndividualItemReference.getRealizationInstanceItem(); |
| 4246 |
|
| 4247 |
COptimizedKPSetRoleInstancesItem* roleInstancesItem = indiRoleCandConfTestItem->getRoleInstancesItem(); |
| 4248 |
if (roleInstancesItem) { |
| 4249 |
roleInstancesItem->decTestingComplexCandidateInstancesCount(); |
| 4250 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = roleInstancesItem->getIndividualIdComplexRoleData(sourceIndividualItemReference.getIndividualID(), true); |
| 4251 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 4252 |
|
| 4253 |
COptimizedKPSetRoleInstancesData* instanceData = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstanceItemData(false, targetIndividualItemReference.getIndividualID(), true); |
| 4254 |
instanceData->mKnownInstance = isIndividualInstance; |
| 4255 |
instanceData->mTestedInstance = true; |
| 4256 |
|
| 4257 |
checkFinishRoleInstancesProcessing(ontPreCompItem, roleInstancesItem); |
| 4258 |
} |
| 4259 |
|
| 4260 |
delete indiRoleCandConfTestItem; |
| 4261 |
processed = true; |
| 4262 |
|
| 4263 |
if (!procDataList.isEmpty()) { |
| 4264 |
setDynamicRequirementProcessed(ontPreCompItem, reqConfPreCompItem->getRealizeRoleProcessingStep(), procDataList); |
| 4265 |
} |
| 4266 |
|
| 4267 |
} |
| 4268 |
} |
| 4269 |
|
| 4270 |
if (!processed) { |
| 4271 |
CIndividualRoleCandidatePropagationTestingItem* indiRoleCandTestItem = dynamic_cast<CIndividualRoleCandidatePropagationTestingItem*>(preTestItem); |
| 4272 |
if (indiRoleCandTestItem) { |
| 4273 |
reqConfPreCompItem->decPropagatingRoleInstanceCandidatesCount(); |
| 4274 |
CRealizationIndividualInstanceItemReference individualItemReference = indiRoleCandTestItem->getInstantiatedItemReference(); |
| 4275 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)individualItemReference.getRealizationInstanceItem(); |
| 4276 |
|
| 4277 |
QList<CIndividualRoleCandidateTestingData>* indiRoleCandTestDataList = indiRoleCandTestItem->geIndividualRoleCandidateTestingDataList(); |
| 4278 |
|
| 4279 |
for (CIndividualRoleCandidateTestingData& indiRoleCandTestData : *indiRoleCandTestDataList) { |
| 4280 |
CConcept* markerConcept = indiRoleCandTestData.getMarkerConcept(); |
| 4281 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = indiRoleCandTestData.getIndividualComplexData(); |
| 4282 |
bool inversed = indiRoleCandTestData.getInversed(); |
| 4283 |
|
| 4284 |
|
| 4285 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 4286 |
indiExplicitIndirectLinkComplexRepresentationData->setInitialized(inversed, true); |
| 4287 |
if (inversed) { |
| 4288 |
indiExplicitIndirectLinkComplexRepresentationData->mRolePredecessorInstancesInitialized = true; |
| 4289 |
} else { |
| 4290 |
indiExplicitIndirectLinkComplexRepresentationData->mRoleSuccessorInstancesInitialized = true; |
| 4291 |
} |
| 4292 |
|
| 4293 |
COptimizedKPSetRoleInstancesItem* roleInstancesItem = indiRoleCandTestData.getRoleInstancesItem(); |
| 4294 |
if (roleInstancesItem) { |
| 4295 |
checkFinishRoleInstancesProcessing(ontPreCompItem, roleInstancesItem); |
| 4296 |
} |
| 4297 |
} |
| 4298 |
|
| 4299 |
if (individualItem) { |
| 4300 |
individualItem->decInitializingRoleCandidateCount(); |
| 4301 |
} |
| 4302 |
|
| 4303 |
CSatisfiableTaskRealizationMarkedCandidatesMessageAdapter* adapter = indiRoleCandTestItem->getRealizationMarkedCandidatesMessageAdapter(); |
| 4304 |
delete adapter; |
| 4305 |
delete indiRoleCandTestItem; |
| 4306 |
processed = true; |
| 4307 |
|
| 4308 |
if (!procDataList.isEmpty()) { |
| 4309 |
setDynamicRequirementProcessed(ontPreCompItem, reqConfPreCompItem->getRealizeRoleProcessingStep(), procDataList); |
| 4310 |
} |
| 4311 |
} |
| 4312 |
} |
| 4313 |
|
| 4314 |
if (!processed) { |
| 4315 |
CIndividualConceptInstanceTestingItem* indiConInstTestItem = dynamic_cast<CIndividualConceptInstanceTestingItem*>(preTestItem); |
| 4316 |
if (indiConInstTestItem) { |
| 4317 |
bool isIndividualInstance = !pcce->getTestResultSatisfiable(); |
| 4318 |
|
| 4319 |
|
| 4320 |
|
| 4321 |
COptimizedKPSetConceptInstancesItem* instancesItem = indiConInstTestItem->getInstancesItem(); |
| 4322 |
COptimizedKPSetIndividualItem* instantiatedItem = indiConInstTestItem->getInstantiatedItem(); |
| 4323 |
|
| 4324 |
//if (!isIndividualInstance) { |
| 4325 |
// createNextConceptInstantiationTest(reqConfPreCompItem, instancesItem, instantiatedItem); |
| 4326 |
// return true; |
| 4327 |
//} |
| 4328 |
|
| 4329 |
|
| 4330 |
KONCLUCE_DEBUG_PRINTING_REALIZATION_CONCEPT_INSTANCE_TESTING_TIME( |
| 4331 |
QString conceptName = CIRIName::getRecentIRIName(instancesItem->getHierarchyNode()->getOneEquivalentConcept()->getClassNameLinker()); |
| 4332 |
QString indiName = CIRIName::getRecentIRIName(instantiatedItem->getIndividual()->getIndividualNameLinker()); |
| 4333 |
|
| 4334 |
QFile testTimeReportFile("./Debugging/Realizing/individual-concept-possible-instance-testing-times.tsv"); |
| 4335 |
if (testTimeReportFile.open(QFile::Append)) { |
| 4336 |
QString reportingLine = QString("%1 \t%2 \t%3\t%4\t%5\r\n").arg(conceptName).arg(indiName).arg(indiConInstTestItem->startTime.elapsed()).arg(isIndividualInstance ? 1 : 0).arg(mCurrRunningTestParallelCount); |
| 4337 |
testTimeReportFile.write(reportingLine.toLocal8Bit()); |
| 4338 |
testTimeReportFile.close(); |
| 4339 |
} |
| 4340 |
) |
| 4341 |
|
| 4342 |
|
| 4343 |
instancesItem->getPossibleInstanceTestingItemHash()->remove(instantiatedItem->getIndividualId()); |
| 4344 |
|
| 4345 |
interpretConceptInstantiationResult(ontPreCompItem, instancesItem, instantiatedItem, isIndividualInstance); |
| 4346 |
|
| 4347 |
delete indiConInstTestItem; |
| 4348 |
processed = true; |
| 4349 |
|
| 4350 |
|
| 4351 |
checkFinishConceptInstancesProcessing(ontPreCompItem, instancesItem); |
| 4352 |
|
| 4353 |
|
| 4354 |
if (!procDataList.isEmpty()) { |
| 4355 |
setDynamicRequirementProcessed(ontPreCompItem, reqConfPreCompItem->getRealizeConceptProcessingStep(), procDataList); |
| 4356 |
} |
| 4357 |
|
| 4358 |
|
| 4359 |
} |
| 4360 |
} |
| 4361 |
|
| 4362 |
if (!processed) { |
| 4363 |
CIndividualPairRoleInstanceTestingItem* indiPairRoleInstTestItem = dynamic_cast<CIndividualPairRoleInstanceTestingItem*>(preTestItem); |
| 4364 |
if (indiPairRoleInstTestItem) { |
| 4365 |
bool isIndividualPairInstance = !pcce->getTestResultSatisfiable(); |
| 4366 |
|
| 4367 |
COptimizedKPSetRoleInstancesItem* instancesItem = indiPairRoleInstTestItem->getInstancesItem(); |
| 4368 |
COptimizedKPSetIndividualItemPair indiItemPair = indiPairRoleInstTestItem->getIndividualItemPair(); |
| 4369 |
COptimizedKPSetIndividualItem* indiItem1 = indiItemPair.first; |
| 4370 |
COptimizedKPSetIndividualItem* indiItem2 = indiItemPair.second; |
| 4371 |
|
| 4372 |
instancesItem->decTestingPossibleInstancesCount(); |
| 4373 |
indiItem1->decTestingPossibleRoleInstantiatedCount(); |
| 4374 |
indiItem2->decTestingPossibleRoleInstantiatedCount(); |
| 4375 |
reqConfPreCompItem->decTestingPossibleRoleInstanceCount(); |
| 4376 |
|
| 4377 |
incTestedPossibleRoleInstancesCount(reqConfPreCompItem); |
| 4378 |
|
| 4379 |
//bool repeat = false; |
| 4380 |
//if (repeat) { |
| 4381 |
// createNextRoleInstantiationTest(reqConfPreCompItem, instancesItem, COptimizedKPSetIndividualItemPair(indiItem1, indiItem2), nullptr); |
| 4382 |
// return true; |
| 4383 |
//} |
| 4384 |
|
| 4385 |
if (!indiItem1->isItemSameIndividualMerged() && !indiItem2->isItemSameIndividualMerged()) { |
| 4386 |
if (isIndividualPairInstance) { |
| 4387 |
updateCalculatedKnownRoleInstance(indiItemPair, instancesItem, reqConfPreCompItem); |
| 4388 |
} else { |
| 4389 |
updateCalculatedNonRoleInstance(indiItemPair, instancesItem, reqConfPreCompItem); |
| 4390 |
} |
| 4391 |
} |
| 4392 |
|
| 4393 |
if (!instancesItem->hasTestingPossibleInstances() && !instancesItem->hasPossibleInstances()) { |
| 4394 |
if (instancesItem->hasAllSuccessorProcessedFlag()) { |
| 4395 |
instancesItem->setSelfSuccessorProcessedFlag(true); |
| 4396 |
updateParentItemsSuccessorProcessed(instancesItem); |
| 4397 |
} |
| 4398 |
} |
| 4399 |
|
| 4400 |
indiItem1->getPossibleSameIndividualTestingItemHash()->remove(indiItem2->getIndividualId()); |
| 4401 |
indiItem2->getPossibleSameIndividualTestingItemHash()->remove(indiItem1->getIndividualId()); |
| 4402 |
|
| 4403 |
|
| 4404 |
delete indiPairRoleInstTestItem; |
| 4405 |
processed = true; |
| 4406 |
|
| 4407 |
checkFinishRoleInstancesProcessing(ontPreCompItem, instancesItem); |
| 4408 |
|
| 4409 |
if (!procDataList.isEmpty()) { |
| 4410 |
setDynamicRequirementProcessed(ontPreCompItem, reqConfPreCompItem->getRealizeRoleProcessingStep(), procDataList); |
| 4411 |
} |
| 4412 |
|
| 4413 |
} |
| 4414 |
} |
| 4415 |
|
| 4416 |
|
| 4417 |
if (!processed) { |
| 4418 |
CIndividualSameTestingItem* indiSameTestItem = dynamic_cast<CIndividualSameTestingItem*>(preTestItem); |
| 4419 |
if (indiSameTestItem) { |
| 4420 |
bool isIndividualSame = !pcce->getTestResultSatisfiable(); |
| 4421 |
|
| 4422 |
COptimizedKPSetIndividualItem* instantiatedItem1 = indiSameTestItem->getInstantiatedItem1(); |
| 4423 |
COptimizedKPSetIndividualItem* instantiatedItem2 = indiSameTestItem->getInstantiatedItem2(); |
| 4424 |
|
| 4425 |
|
| 4426 |
//if (!isIndividualSame) { |
| 4427 |
// createNextSameIndividualsTest(reqConfPreCompItem, instantiatedItem1, instantiatedItem2); |
| 4428 |
// return true; |
| 4429 |
//} |
| 4430 |
|
| 4431 |
|
| 4432 |
incTestedPossibleSameIndividualsCount(reqConfPreCompItem); |
| 4433 |
|
| 4434 |
instantiatedItem1->decTestingPossibleSameIndividualCount(); |
| 4435 |
instantiatedItem2->decTestingPossibleSameIndividualCount(); |
| 4436 |
reqConfPreCompItem->decTestingPossibleSameIndividualCount(); |
| 4437 |
|
| 4438 |
if (isIndividualSame) { |
| 4439 |
if (!instantiatedItem1->isItemSameIndividualMerged() && !instantiatedItem2->isItemSameIndividualMerged()) { |
| 4440 |
mergeSameIndividualItems(instantiatedItem1, instantiatedItem2, reqConfPreCompItem); |
| 4441 |
} |
| 4442 |
} |
| 4443 |
|
| 4444 |
checkFinishSameIndividualProcessing(ontPreCompItem, instantiatedItem1); |
| 4445 |
checkFinishSameIndividualProcessing(ontPreCompItem, instantiatedItem2); |
| 4446 |
|
| 4447 |
delete indiSameTestItem; |
| 4448 |
processed = true; |
| 4449 |
|
| 4450 |
if (!procDataList.isEmpty()) { |
| 4451 |
setDynamicRequirementProcessed(ontPreCompItem, reqConfPreCompItem->getRealizeSameIndividualsProcessingStep(), procDataList); |
| 4452 |
} |
| 4453 |
|
| 4454 |
} |
| 4455 |
} |
| 4456 |
if (!processed) { |
| 4457 |
CIndividualsConsistencyTestingItem* indiConsTest = dynamic_cast<CIndividualsConsistencyTestingItem*>(preTestItem); |
| 4458 |
if (indiConsTest) { |
| 4459 |
reqConfPreCompItem->setExtraConsistencyTested(true); |
| 4460 |
reqConfPreCompItem->setExtraConsistencyTesting(false); |
| 4461 |
} |
| 4462 |
} |
| 4463 |
return processed; |
| 4464 |
} |
| 4465 |
|
| 4466 |
|
| 4467 |
|
| 4468 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::checkFinishSameIndividualProcessing(COntologyRealizingItem* ontRealItem, COptimizedKPSetIndividualItem* instantiatedItem) { |
| 4469 |
COptimizedRepresentativeKPSetOntologyRealizingItem* realItem = (COptimizedRepresentativeKPSetOntologyRealizingItem*)ontRealItem; |
| 4470 |
if (instantiatedItem) { |
| 4471 |
if (instantiatedItem->isItemSameIndividualMerged()) { |
| 4472 |
instantiatedItem->getItemSameIndividualMerged()->addRequirementProcessingDataLinker(instantiatedItem->takeRequirmentProcessingDataLinkers()); |
| 4473 |
checkFinishSameIndividualProcessing(ontRealItem, instantiatedItem->getItemSameIndividualMerged()); |
| 4474 |
return true; |
| 4475 |
} else if (!instantiatedItem->hasPossibleSameIndividualsTesting() && !instantiatedItem->hasPossibleSameIndividuals()) { |
| 4476 |
setDynamicRequirementProcessed(ontRealItem, realItem->getRealizeSameIndividualsProcessingStep(), instantiatedItem->takeRequirmentProcessingDataLinkers()); |
| 4477 |
return true; |
| 4478 |
} |
| 4479 |
} |
| 4480 |
return false; |
| 4481 |
} |
| 4482 |
|
| 4483 |
|
| 4484 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::checkFinishConceptInstancesProcessing(COntologyRealizingItem* ontRealItem, COptimizedKPSetConceptInstancesItem* conceptItem) { |
| 4485 |
COptimizedRepresentativeKPSetOntologyRealizingItem* realItem = (COptimizedRepresentativeKPSetOntologyRealizingItem*)ontRealItem; |
| 4486 |
if (conceptItem) { |
| 4487 |
if (!conceptItem->hasPossibleInstances() && !conceptItem->hasTestingPossibleInstances()) { |
| 4488 |
conceptItem->setConceptInstancesTestingFinished(true); |
| 4489 |
setDynamicRequirementProcessed(ontRealItem, realItem->getRealizeConceptProcessingStep(), conceptItem->takeRequirmentProcessingDataLinkers()); |
| 4490 |
return true; |
| 4491 |
} |
| 4492 |
} |
| 4493 |
return false; |
| 4494 |
} |
| 4495 |
|
| 4496 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::checkFinishRoleInstancesProcessing(COntologyRealizingItem* ontRealItem, COptimizedKPSetRoleInstancesItem* roleItem) { |
| 4497 |
COptimizedRepresentativeKPSetOntologyRealizingItem* realItem = (COptimizedRepresentativeKPSetOntologyRealizingItem*)ontRealItem; |
| 4498 |
if (roleItem) { |
| 4499 |
if (!roleItem->hasPossibleInstances() && !roleItem->hasTestingPossibleInstances() && roleItem->isCandidateSuccessorInitializationCompleted() && !roleItem->hasComplexInstanceCandidates() && !roleItem->hasTestingComplexCandidateInstancesCount() && !roleItem->hasTestingInitializationPropagationCount()) { |
| 4500 |
setDynamicRequirementProcessed(ontRealItem, realItem->getRealizeRoleProcessingStep(), roleItem->takeRequirmentProcessingDataLinkers()); |
| 4501 |
return true; |
| 4502 |
} |
| 4503 |
} |
| 4504 |
return false; |
| 4505 |
} |
| 4506 |
|
| 4507 |
|
| 4508 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::setDynamicRequirementProcessed(COntologyRealizingItem* ontRealItem, CRealizingTestingStep* realizingStep, const QList<COntologyRealizingDynamicRequirmentProcessingData*>& procDataList) { |
| 4509 |
for (COntologyRealizingDynamicRequirmentProcessingData* procData : procDataList) { |
| 4510 |
setDynamicRequirementProcessed(ontRealItem, realizingStep, procData); |
| 4511 |
} |
| 4512 |
return this; |
| 4513 |
} |
| 4514 |
|
| 4515 |
|
| 4516 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::setDynamicRequirementProcessed(COntologyRealizingItem* ontRealItem, CRealizingTestingStep* realizingStep, COntologyRealizingDynamicRequirmentProcessingData* procData) { |
| 4517 |
procData->decProcessingItemCount(realizingStep); |
| 4518 |
if (!procData->hasAssociatedRelizationTestingStepProcessingItemCount(realizingStep)) { |
| 4519 |
CRealizingTestingStep* realStep = procData->getAssociatedRelizationTestingStep(realizingStep->getRealizingTestingType()); |
| 4520 |
if (realStep) { |
| 4521 |
procData->clearAssociatedRelizationTestingStep(realizingStep->getRealizingTestingType()); |
| 4522 |
realStep->removeRequirementProcessingData(procData); |
| 4523 |
} |
| 4524 |
} |
| 4525 |
if (!procData->hasCurrentProcessingItemCount()) { |
| 4526 |
COntologyProcessingRequirement* procReq = procData->getProcessingRequirement(); |
| 4527 |
if (procReq) { |
| 4528 |
procReq->submitRequirementUpdate(COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, COntologyProcessingStatus::PSSUCESSFULL); |
| 4529 |
} |
| 4530 |
COntologyRealizingDynamicRequirmentCallbackData* callbackData = procData->getCallbackData(); |
| 4531 |
if (callbackData) { |
| 4532 |
callbackData->decProcessingRequirmentCount(); |
| 4533 |
if (!callbackData->hasCurrentProcessingRequirmentCount()) { |
| 4534 |
ontRealItem->logRequirementProcessingFinishStatistics(procData->getStatistics()); |
| 4535 |
CCallbackData* callback = callbackData->getProcessingFinishedCallback(); |
| 4536 |
callback->doCallback(); |
| 4537 |
delete callbackData; |
| 4538 |
} |
| 4539 |
} |
| 4540 |
delete procData; |
| 4541 |
} |
| 4542 |
return this; |
| 4543 |
} |
| 4544 |
|
| 4545 |
|
| 4546 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::setDynamicRequirementProcessed(COntologyRealizingItem* ontRealItem, CRealizingTestingStep* realizingStep, CLinker<COntologyRealizingDynamicRequirmentProcessingData*>* procDataLinker) { |
| 4547 |
CLinker<COntologyRealizingDynamicRequirmentProcessingData*>* procDataLinkerIt = procDataLinker; |
| 4548 |
while (procDataLinkerIt) { |
| 4549 |
COntologyRealizingDynamicRequirmentProcessingData* procData = procDataLinkerIt->getData(); |
| 4550 |
setDynamicRequirementProcessed(ontRealItem, realizingStep, procData); |
| 4551 |
procDataLinkerIt = procDataLinkerIt->getNext(); |
| 4552 |
} |
| 4553 |
if (procDataLinker) { |
| 4554 |
ontRealItem->releaseRequirementProcessingDataLinker(procDataLinker); |
| 4555 |
} |
| 4556 |
return this; |
| 4557 |
} |
| 4558 |
|
| 4559 |
|
| 4560 |
|
| 4561 |
|
| 4562 |
|
| 4563 |
|
| 4564 |
|
| 4565 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::addComplexRoleExplicitIndirectNeighbourLink(COptimizedKPSetRoleInstancesItem* roleInstItem, bool inversed, |
| 4566 |
const CRealizationIndividualInstanceItemReference& indiRealItemRef, COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData, |
| 4567 |
COptimizedKPSetRoleNeighbourInstancesHashData* indiRoleNeighbourHashData, COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* combinedNeighbourCacheLabelItemData, CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* assNeighbourRoleSetHash, |
| 4568 |
const CIndividualReference& neighbourIndi, COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* neighbourIndiExplicitIndirectLinkComplexRepresentationData, |
| 4569 |
bool deterministic, COptimizedRepresentativeKPSetOntologyRealizingItem* realItem) { |
| 4570 |
|
| 4571 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 4572 |
CIndividualReference individualReference = indiRealItemRef; |
| 4573 |
|
| 4574 |
|
| 4575 |
//if (CIRIName::getRecentIRIName(indiRealItemRef.getIndividual()->getIndividualNameLinker()) == "http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BordeauxRegion") { |
| 4576 |
// bool debug = true; |
| 4577 |
//} |
| 4578 |
|
| 4579 |
|
| 4580 |
bool isAlreadyDirectLink = false; |
| 4581 |
if (indiRoleNeighbourHashData) { |
| 4582 |
COptimizedKPSetRoleInstancesData* instanceData = indiRoleNeighbourHashData->getRoleNeighbourInstanceItemData(inversed, neighbourIndi.getIndividualID(), false); |
| 4583 |
if (instanceData && (instanceData->mPossibleInstance || instanceData->mKnownInstance)) { |
| 4584 |
isAlreadyDirectLink = true; |
| 4585 |
} |
| 4586 |
} |
| 4587 |
if (!isAlreadyDirectLink && combinedNeighbourCacheLabelItemData) { |
| 4588 |
CBackendRepresentativeMemoryLabelCacheItem* cacheLabelItem = assNeighbourRoleSetHash->getNeighbourRoleSetLabel(neighbourIndi.getIndividualID()); |
| 4589 |
if (cacheLabelItem) { |
| 4590 |
if (combinedNeighbourCacheLabelItemData->hasKnownInstancesLabelItem(cacheLabelItem)) { |
| 4591 |
// must be deterministic, otherwise the neighbour would be referenced in the individual item |
| 4592 |
isAlreadyDirectLink = true; |
| 4593 |
} |
| 4594 |
} |
| 4595 |
} |
| 4596 |
|
| 4597 |
if (!isAlreadyDirectLink) { |
| 4598 |
COptimizedKPSetRoleInstancesHashData& instanceHashData = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstancesHash(inversed, true)->operator[](neighbourIndi.getIndividualID()); |
| 4599 |
COptimizedKPSetRoleInstancesData* instanceData = instanceHashData.mInstanceItemData; |
| 4600 |
|
| 4601 |
if (instanceData && instanceData->mKnownInstance) { |
| 4602 |
return false; |
| 4603 |
} |
| 4604 |
if (instanceData && instanceData->mPossibleInstance && !deterministic) { |
| 4605 |
return false; |
| 4606 |
} |
| 4607 |
|
| 4608 |
if (!instanceData) { |
| 4609 |
instanceData = new COptimizedKPSetRoleInstancesData(); |
| 4610 |
instanceData->mInstanceItem = roleInstItem; |
| 4611 |
|
| 4612 |
instanceHashData.mInstanceItemData = instanceData; |
| 4613 |
|
| 4614 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* otherIndiExplicitIndirectLinkComplexRepresentationData = neighbourIndiExplicitIndirectLinkComplexRepresentationData; |
| 4615 |
if (!otherIndiExplicitIndirectLinkComplexRepresentationData) { |
| 4616 |
otherIndiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)roleInstItem->getIndividualIdComplexRoleData(neighbourIndi.getIndividualID(), true); |
| 4617 |
} |
| 4618 |
COptimizedKPSetRoleInstancesHashData& otherInstanceHashData = otherIndiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstancesHash(!inversed, true)->operator[](indiRealItemRef.getIndividualID()); |
| 4619 |
otherInstanceHashData.mInstanceItemData = instanceData; |
| 4620 |
|
| 4621 |
|
| 4622 |
#ifdef REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 4623 |
mDebugTransitiveCollectionStringList.append(QString("Added connection between %1 and %2 over role %3%4").arg(CIRIName::getRecentIRIName(indiRealItemRef.getIndividual()->getIndividualNameLinker())).arg(CIRIName::getRecentIRIName(neighbourIndi.getIndividual()->getIndividualNameLinker())).arg(CIRIName::getRecentIRIName(roleInstItem->getRole()->getPropertyNameLinker())).arg(inversed ? " inversed" : "")); |
| 4624 |
mDebugTransitiveCollectionString = mDebugTransitiveCollectionStringList.join("\r\n"); |
| 4625 |
#endif // REALIZATION_TRANSITIVE_EXTRACTION_DEBUG_STRINGS |
| 4626 |
|
| 4627 |
} |
| 4628 |
|
| 4629 |
bool wasAlreadyPossibleMarked = instanceData->mPossibleInstance; |
| 4630 |
instanceData->mPossibleInstance = true; |
| 4631 |
if (deterministic) { |
| 4632 |
instanceData->mKnownInstance = true; |
| 4633 |
instanceData->mPossibleInstance = false; |
| 4634 |
} |
| 4635 |
|
| 4636 |
if (!wasAlreadyPossibleMarked && !instanceData->mKnownInstance) { |
| 4637 |
// add to testing queue |
| 4638 |
roleInstItem->addComplexCandidateInstance(COptimizedKPSetIndividualItemReferencePair(indiRealItemRef, CRealizationIndividualInstanceItemReference(neighbourIndi, realItem->getIndividualInstantiatedItem(neighbourIndi.getIndividual(), false))), inversed); |
| 4639 |
} |
| 4640 |
if (wasAlreadyPossibleMarked && instanceData->mKnownInstance) { |
| 4641 |
// remove from testing queue |
| 4642 |
roleInstItem->removeComplexCandidateInstance(COptimizedKPSetIndividualItemReferencePair(indiRealItemRef, CRealizationIndividualInstanceItemReference(neighbourIndi, realItem->getIndividualInstantiatedItem(neighbourIndi.getIndividual(), false))), inversed); |
| 4643 |
} |
| 4644 |
|
| 4645 |
return true; |
| 4646 |
} |
| 4647 |
return false; |
| 4648 |
|
| 4649 |
} |
| 4650 |
|
| 4651 |
|
| 4652 |
|
| 4653 |
|
| 4654 |
|
| 4655 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::processRealizationMessage(COntologyRealizingItem* ontRealItem, CRealizationMessageData* messageData, CMemoryPool* memoryPools) { |
| 4656 |
COptimizedRepresentativeKPSetOntologyRealizingItem* realItem = (COptimizedRepresentativeKPSetOntologyRealizingItem*)ontRealItem; |
| 4657 |
for (CRealizationMessageData* messageDataIt = messageData; messageDataIt; messageDataIt = messageDataIt->getNext()) { |
| 4658 |
if (messageDataIt->getRealizationMessageDataType() == CRealizationMessageData::TELLREALIZATIONMARKERCANDIDATES) { |
| 4659 |
CRealizationMarkerCandidatesMessageData* rmcmd = (CRealizationMarkerCandidatesMessageData*)messageDataIt; |
| 4660 |
CIndividualReference individualReference = rmcmd->getIndividualReference(); |
| 4661 |
CConcept* markerConcept = rmcmd->getMarkerConcept(); |
| 4662 |
CIndividualRoleCandidateTestingData indiRoleCandTestData = rmcmd->getIndividualRoleCandidateTestingData(); |
| 4663 |
COptimizedKPSetRoleInstancesItem* roleInstItem = indiRoleCandTestData.getRoleInstancesItem(); |
| 4664 |
bool inversed = indiRoleCandTestData.getInversed(); |
| 4665 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = indiRoleCandTestData.getIndividualComplexData(); |
| 4666 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 4667 |
|
| 4668 |
|
| 4669 |
|
| 4670 |
COptimizedKPSetIndividualItem* individualItem = realItem->getIndividualInstantiatedItem(individualReference.getIndividualID(),false); |
| 4671 |
CRealizationIndividualInstanceItemReference indiRealItemRef(individualReference, individualItem); |
| 4672 |
COptimizedKPSetRoleNeighbourInstancesHashData* indiRoleNeighbourHashData = nullptr; |
| 4673 |
if (individualItem && individualItem->getKnownPossibleRoleNeighboursInstancesHash()->contains(roleInstItem)) { |
| 4674 |
COptimizedKPSetRoleNeighbourInstancesHashData& roleNeighbourHashData = individualItem->getKnownPossibleRoleNeighboursInstancesHash()->operator[](roleInstItem); |
| 4675 |
indiRoleNeighbourHashData = &roleNeighbourHashData; |
| 4676 |
} |
| 4677 |
|
| 4678 |
|
| 4679 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = realItem->getBackendAssociationCacheReader()->getIndividualAssociationData(individualReference.getIndividualID()); |
| 4680 |
CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* assNeighbourRoleSetHash = indiAssData->getNeighbourRoleSetHash(); |
| 4681 |
CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetCompinationLabelItem = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 4682 |
|
| 4683 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash* combinedNeighbourCacheLabelItemDataHash = roleInstItem->getCombinedNeighbourCacheLabelItemDataHash(inversed); |
| 4684 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* combinedNeighbourCacheLabelItemData = combinedNeighbourCacheLabelItemDataHash->value(neighbourRoleSetCompinationLabelItem); |
| 4685 |
|
| 4686 |
|
| 4687 |
function<void(const CIndividualReference& candIndi, bool deterministic)> candidateIndiHandleFunction = [&](const CIndividualReference& candIndi, bool deterministic) { |
| 4688 |
addComplexRoleExplicitIndirectNeighbourLink(roleInstItem, inversed, indiRealItemRef, indiExplicitIndirectLinkComplexRepresentationData, indiRoleNeighbourHashData, combinedNeighbourCacheLabelItemData, assNeighbourRoleSetHash, candIndi, nullptr, deterministic, realItem); |
| 4689 |
}; |
| 4690 |
|
| 4691 |
CXLinker<CIndividualReference>* detIndiLinker = rmcmd->getDeterministicIndividualReferenceLinker(); |
| 4692 |
for (CXLinker<CIndividualReference>* detIndiLinkerIt = detIndiLinker; detIndiLinkerIt; detIndiLinkerIt = detIndiLinkerIt->getNext()) { |
| 4693 |
CIndividualReference candIndi = detIndiLinkerIt->getData(); |
| 4694 |
candidateIndiHandleFunction(candIndi, true); |
| 4695 |
} |
| 4696 |
CXLinker<CIndividualReference>* ndetIndiLinker = rmcmd->getNondeterministicIndividualReferenceLinker(); |
| 4697 |
for (CXLinker<CIndividualReference>* ndetIndiLinkerIt = ndetIndiLinker; ndetIndiLinkerIt; ndetIndiLinkerIt = ndetIndiLinkerIt->getNext()) { |
| 4698 |
CIndividualReference candIndi = ndetIndiLinkerIt->getData(); |
| 4699 |
candidateIndiHandleFunction(candIndi, false); |
| 4700 |
} |
| 4701 |
|
| 4702 |
realItem->incInitializedRoleInstancesCount(); |
| 4703 |
|
| 4704 |
} |
| 4705 |
} |
| 4706 |
return true; |
| 4707 |
} |
| 4708 |
|
| 4709 |
|
| 4710 |
|
| 4711 |
|
| 4712 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::addKPSetDirectSuperInstances(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem, COptimizedKPSetRoleInstancesItem* roleInstItem, bool inversed, COptimizedKPSetIndividualItem* indiItem1, COptimizedKPSetIndividualItem* indiItem2, bool knownInstance) { |
| 4713 |
QList<TRoleItemInversionPair> tmpInstancesList; |
| 4714 |
COptimizedKPSetIndividualItem* succIndiItem = indiItem1; |
| 4715 |
COptimizedKPSetIndividualItem* precIndiItem = indiItem2; |
| 4716 |
COptimizedKPSetRoleInstancesHash* succNeighbourHash = nullptr; |
| 4717 |
COptimizedKPSetRoleInstancesHash* precNeighbourHash = nullptr; |
| 4718 |
if (inversed) { |
| 4719 |
succIndiItem = indiItem2; |
| 4720 |
precIndiItem = indiItem1; |
| 4721 |
} |
| 4722 |
|
| 4723 |
|
| 4724 |
//QString indi1String = CIRIName::getRecentIRIName(indiItem1->getIndividual()->getIndividualNameLinker()); |
| 4725 |
//QString indi2String = CIRIName::getRecentIRIName(indiItem2->getIndividual()->getIndividualNameLinker()); |
| 4726 |
//QString roleString = CIRIName::getRecentIRIName(roleInstItem->getRole()->getPropertyNameLinker()); |
| 4727 |
//QString inverseRoleString; |
| 4728 |
//if (roleInstItem->getInverseRole()) { |
| 4729 |
// inverseRoleString = CIRIName::getRecentIRIName(roleInstItem->getInverseRole()->getPropertyNameLinker()); |
| 4730 |
//} |
| 4731 |
|
| 4732 |
////if (indi2String == "file:/Users/liebig/Ontologien/reasoner-eval/30.owl#Act5") { |
| 4733 |
//// if ((roleString == "file:/Users/liebig/Ontologien/reasoner-eval/30.owl#inv-first")) { |
| 4734 |
//// bool bug = true; |
| 4735 |
//// } |
| 4736 |
////} |
| 4737 |
//if (indi2String == "http://www.semanticweb.org/ontologies/2008/1/Ontology1204037102846.owl#Denied" || indi1String == "http://www.semanticweb.org/ontologies/2008/1/Ontology1204037102846.owl#Denied") { |
| 4738 |
// if ((roleString == "http://www.semanticweb.org/ontologies/2008/1/Ontology1204037102846.owl#hasEmployer" || inverseRoleString == "http://www.semanticweb.org/ontologies/2008/1/Ontology1204037102846.owl#hasEmployer")) { |
| 4739 |
// bool bug = true; |
| 4740 |
// } |
| 4741 |
//} |
| 4742 |
|
| 4743 |
COptimizedKPSetRoleNeighbourInstancesHashData& succRoleNeighbourData = succIndiItem->getKnownPossibleRoleNeighboursInstancesHash()->operator[](roleInstItem); |
| 4744 |
succNeighbourHash = succRoleNeighbourData.getRoleSuccessorInstancesHash(true); |
| 4745 |
|
| 4746 |
COptimizedKPSetRoleInstancesHashData& succHashData = (*succNeighbourHash)[precIndiItem->getIndividualId()]; |
| 4747 |
|
| 4748 |
//if (indi1String == "http://www.co-ode.org/roberts/family-tree.owl#john_archer_1804") { |
| 4749 |
// if ((roleString == "http://www.co-ode.org/roberts/family-tree.owl#isFatherOf" || inverseRoleString == "http://www.co-ode.org/roberts/family-tree.owl#isFatherOf")) { |
| 4750 |
// if (succNeighbourHash->size() >= 10) { |
| 4751 |
// bool bug = true; |
| 4752 |
// } |
| 4753 |
// } |
| 4754 |
//} |
| 4755 |
|
| 4756 |
if (succHashData.mInstanceItemData == nullptr) { |
| 4757 |
|
| 4758 |
COptimizedKPSetRoleNeighbourInstancesHashData& precRoleNeighbourData = precIndiItem->getKnownPossibleRoleNeighboursInstancesHash()->operator[](roleInstItem); |
| 4759 |
precNeighbourHash = precRoleNeighbourData.getRolePredecessorInstancesHash(true); |
| 4760 |
COptimizedKPSetRoleInstancesHashData& precHashData = (*precNeighbourHash)[succIndiItem->getIndividualId()]; |
| 4761 |
|
| 4762 |
COptimizedKPSetRoleInstancesData* data = new COptimizedKPSetRoleInstancesData(); |
| 4763 |
succHashData.mNeighbourIndividualItem = precIndiItem; |
| 4764 |
precHashData.mNeighbourIndividualItem = succIndiItem; |
| 4765 |
succHashData.mInstanceItemData = data; |
| 4766 |
precHashData.mInstanceItemData = data; |
| 4767 |
data->mInstanceItem = roleInstItem; |
| 4768 |
data->mKnownInstance = knownInstance; |
| 4769 |
data->mPossibleInstance = !knownInstance; |
| 4770 |
data->mMostSpecific = true; |
| 4771 |
if (knownInstance) { |
| 4772 |
roleInstItem->addKnownInstance(COptimizedKPSetIndividualItemPair(succIndiItem,precIndiItem),inversed); |
| 4773 |
} else { |
| 4774 |
roleInstItem->addPossibleInstance(COptimizedKPSetIndividualItemPair(succIndiItem,precIndiItem),inversed); |
| 4775 |
incOpenPossibleRoleInstancesCount(reqConfPreCompItem); |
| 4776 |
succIndiItem->incPossibleRoleInstantiatedCount(); |
| 4777 |
precIndiItem->incPossibleRoleInstantiatedCount(); |
| 4778 |
if (roleInstItem->hasToProcessPossibleInstancesFlag()) { |
| 4779 |
reqConfPreCompItem->addRoleInstanceItemToProcessPossibleInstances(roleInstItem); |
| 4780 |
} |
| 4781 |
} |
| 4782 |
tmpInstancesList.append(*roleInstItem->getParentItemList()); |
| 4783 |
} |
| 4784 |
|
| 4785 |
if (succHashData.mInstanceItemData->mPossibleInstance && knownInstance) { |
| 4786 |
if (succHashData.mInstanceItemData->mMostSpecific) { |
| 4787 |
decOpenPossibleRoleInstancesCount(reqConfPreCompItem); |
| 4788 |
succIndiItem->decPossibleRoleInstantiatedCount(); |
| 4789 |
precIndiItem->decPossibleRoleInstantiatedCount(); |
| 4790 |
roleInstItem->removePossibleInstance(COptimizedKPSetIndividualItemPair(succIndiItem,precIndiItem),inversed); |
| 4791 |
} |
| 4792 |
roleInstItem->addKnownInstance(COptimizedKPSetIndividualItemPair(succIndiItem,precIndiItem),inversed); |
| 4793 |
succHashData.mInstanceItemData->mKnownInstance = true; |
| 4794 |
succHashData.mInstanceItemData->mPossibleInstance = false; |
| 4795 |
tmpInstancesList.append(*roleInstItem->getParentItemList()); |
| 4796 |
} |
| 4797 |
|
| 4798 |
|
| 4799 |
while (!tmpInstancesList.isEmpty()) { |
| 4800 |
|
| 4801 |
TRoleItemInversionPair superRoleItemInvPair = tmpInstancesList.takeFirst(); |
| 4802 |
bool superRoleItemInversed = superRoleItemInvPair.second; |
| 4803 |
COptimizedKPSetRoleInstancesItem* superRoleInstanceItem = superRoleItemInvPair.first; |
| 4804 |
|
| 4805 |
if (superRoleInstanceItem != reqConfPreCompItem->getTopRoleInstancesItem()) { |
| 4806 |
|
| 4807 |
COptimizedKPSetIndividualItem* superSuccIndiItem = indiItem1; |
| 4808 |
COptimizedKPSetIndividualItem* superPrecIndiItem = indiItem2; |
| 4809 |
COptimizedKPSetRoleInstancesHash* superSuccNeighbourHash = nullptr; |
| 4810 |
COptimizedKPSetRoleInstancesHash* superPrecNeighbourHash = nullptr; |
| 4811 |
if (superRoleItemInversed ^ inversed) { |
| 4812 |
superSuccIndiItem = indiItem2; |
| 4813 |
superPrecIndiItem = indiItem1; |
| 4814 |
} |
| 4815 |
COptimizedKPSetRoleNeighbourInstancesHashData& superSuccRoleNeighbourData = superSuccIndiItem->getKnownPossibleRoleNeighboursInstancesHash()->operator[](superRoleInstanceItem); |
| 4816 |
superSuccNeighbourHash = superSuccRoleNeighbourData.getRoleSuccessorInstancesHash(true); |
| 4817 |
COptimizedKPSetRoleInstancesHashData& superSuccHashData = (*superSuccNeighbourHash)[superPrecIndiItem->getIndividualId()]; |
| 4818 |
|
| 4819 |
//QString superRoleString = CIRIName::getRecentIRIName(superRoleInstanceItem->getRole()->getPropertyNameLinker()); |
| 4820 |
//QString superInverseRoleString; |
| 4821 |
//if (superRoleInstanceItem->getInverseRole()) { |
| 4822 |
// superInverseRoleString = CIRIName::getRecentIRIName(superRoleInstanceItem->getInverseRole()->getPropertyNameLinker()); |
| 4823 |
//} |
| 4824 |
//if (indi2String == "http://www.co-ode.org/roberts/family-tree.owl#john_archer_1804" && indi1String == "http://www.co-ode.org/roberts/family-tree.owl#john_archer_1804" && (superRoleString == "http://www.co-ode.org/roberts/family-tree.owl#isFatherOf" || superInverseRoleString == "http://www.co-ode.org/roberts/family-tree.owl#isFatherOf")) { |
| 4825 |
// bool bug = true; |
| 4826 |
//} |
| 4827 |
|
| 4828 |
|
| 4829 |
if (superSuccHashData.mInstanceItemData == nullptr) { |
| 4830 |
|
| 4831 |
COptimizedKPSetRoleNeighbourInstancesHashData& superPrecRoleNeighbourData = superPrecIndiItem->getKnownPossibleRoleNeighboursInstancesHash()->operator[](superRoleInstanceItem); |
| 4832 |
superPrecNeighbourHash = superPrecRoleNeighbourData.getRolePredecessorInstancesHash(true); |
| 4833 |
COptimizedKPSetRoleInstancesHashData& superPrecHashData = (*superPrecNeighbourHash)[superSuccIndiItem->getIndividualId()]; |
| 4834 |
|
| 4835 |
COptimizedKPSetRoleInstancesData* superData = new COptimizedKPSetRoleInstancesData(); |
| 4836 |
superSuccHashData.mNeighbourIndividualItem = superPrecIndiItem; |
| 4837 |
superPrecHashData.mNeighbourIndividualItem = superSuccIndiItem; |
| 4838 |
superSuccHashData.mInstanceItemData = superData; |
| 4839 |
superPrecHashData.mInstanceItemData = superData; |
| 4840 |
superData->mInstanceItem = superRoleInstanceItem; |
| 4841 |
superData->mKnownInstance = knownInstance; |
| 4842 |
superData->mPossibleInstance = !knownInstance; |
| 4843 |
superData->mMostSpecific = false; |
| 4844 |
tmpInstancesList.append(*superRoleInstanceItem->getParentItemList()); |
| 4845 |
} else { |
| 4846 |
if (knownInstance) { |
| 4847 |
if (superSuccHashData.mInstanceItemData->mPossibleInstance) { |
| 4848 |
superSuccHashData.mInstanceItemData->mPossibleInstance = false; |
| 4849 |
superSuccHashData.mInstanceItemData->mKnownInstance = true; |
| 4850 |
if (superSuccHashData.mInstanceItemData->mMostSpecific) { |
| 4851 |
decOpenPossibleRoleInstancesCount(reqConfPreCompItem); |
| 4852 |
superSuccIndiItem->decPossibleRoleInstantiatedCount(); |
| 4853 |
superPrecIndiItem->decPossibleRoleInstantiatedCount(); |
| 4854 |
superRoleInstanceItem->removePossibleInstance(COptimizedKPSetIndividualItemPair(superSuccIndiItem,superPrecIndiItem),inversed); |
| 4855 |
superSuccHashData.mInstanceItemData->mMostSpecific = false; |
| 4856 |
} |
| 4857 |
tmpInstancesList.append(*superRoleInstanceItem->getParentItemList()); |
| 4858 |
} else if (superSuccHashData.mInstanceItemData->mKnownInstance && superSuccHashData.mInstanceItemData->mMostSpecific) { |
| 4859 |
superSuccHashData.mInstanceItemData->mMostSpecific = false; |
| 4860 |
superRoleInstanceItem->removeKnownInstance(COptimizedKPSetIndividualItemPair(superSuccIndiItem,superPrecIndiItem),superRoleItemInversed); |
| 4861 |
} |
| 4862 |
} else { |
| 4863 |
if (superSuccHashData.mInstanceItemData->mPossibleInstance && superSuccHashData.mInstanceItemData->mMostSpecific) { |
| 4864 |
superRoleInstanceItem->removePossibleInstance(COptimizedKPSetIndividualItemPair(superSuccIndiItem,superPrecIndiItem),inversed); |
| 4865 |
superSuccHashData.mInstanceItemData->mMostSpecific = false; |
| 4866 |
} |
| 4867 |
} |
| 4868 |
} |
| 4869 |
} |
| 4870 |
} |
| 4871 |
return true; |
| 4872 |
} |
| 4873 |
|
| 4874 |
|
| 4875 |
|
| 4876 |
|
| 4877 |
|
| 4878 |
|
| 4879 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::mergeSameIndividualItems(COptimizedKPSetIndividualItem* instantiatedItem1, COptimizedKPSetIndividualItem* instantiatedItem2, COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 4880 |
COptimizedKPSetIndividualItem* mergedIntoInstantiatedItem = instantiatedItem1; |
| 4881 |
COptimizedKPSetIndividualItem* mergingInstantiatedItem = instantiatedItem2; |
| 4882 |
if (instantiatedItem2->getPossibleInstantiatedCount() + instantiatedItem2->getPossibleSameInstantiatedItemSet() < instantiatedItem1->getPossibleInstantiatedCount() + instantiatedItem1->getPossibleSameInstantiatedItemSet()) { |
| 4883 |
mergedIntoInstantiatedItem = instantiatedItem2; |
| 4884 |
mergingInstantiatedItem = instantiatedItem1; |
| 4885 |
} |
| 4886 |
mergingInstantiatedItem->setItemSameIndividualMerged(mergedIntoInstantiatedItem); |
| 4887 |
COptimizedKPSetIndividualInstantiatedItemMultiHash* indiInstantiatedItemHash = reqConfPreCompItem->getIndividualInstantiatedItemHash(); |
| 4888 |
QSet<CIndividualReference>* individualSet = mergingInstantiatedItem->getKnownSameIndividualSet(); |
| 4889 |
for (QSet<CIndividualReference>::const_iterator it = individualSet->constBegin(), itEnd = individualSet->constEnd(); it != itEnd; ++it) { |
| 4890 |
CIndividualReference sameIndividual(*it); |
| 4891 |
mergedIntoInstantiatedItem->addKnownSameIndividual(sameIndividual); |
| 4892 |
indiInstantiatedItemHash->updateIndividualInstantiatedItem(sameIndividual.getIndividualID(),mergedIntoInstantiatedItem); |
| 4893 |
} |
| 4894 |
return this; |
| 4895 |
} |
| 4896 |
|
| 4897 |
|
| 4898 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::updateParentItemsSuccessorProcessed(COptimizedKPSetConceptInstancesItem* item) { |
| 4899 |
QList<COptimizedKPSetConceptInstancesItem*> updateList; |
| 4900 |
QList<COptimizedKPSetConceptInstancesItem*>* parentItemList = item->getParentItemList(); |
| 4901 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = parentItemList->constBegin(), itEnd = parentItemList->constEnd(); it != itEnd; ++it) { |
| 4902 |
COptimizedKPSetConceptInstancesItem* parentItem = *it; |
| 4903 |
updateList.append(parentItem); |
| 4904 |
} |
| 4905 |
while (!updateList.isEmpty()) { |
| 4906 |
COptimizedKPSetConceptInstancesItem* parentItem = updateList.takeFirst(); |
| 4907 |
parentItem->decUnprocessedSuccessorItemCount(); |
| 4908 |
if (parentItem->getUnprocessedSuccessorItemCount() <= 0) { |
| 4909 |
parentItem->setAllSuccessorProcessedFlag(true); |
| 4910 |
if (!parentItem->hasPossibleInstances() && !parentItem->hasTestingPossibleInstances()) { |
| 4911 |
parentItem->setSelfSuccessorProcessedFlag(true); |
| 4912 |
QList<COptimizedKPSetConceptInstancesItem*>* parentParentItemList = parentItem->getParentItemList(); |
| 4913 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = parentParentItemList->constBegin(), itEnd = parentParentItemList->constEnd(); it != itEnd; ++it) { |
| 4914 |
COptimizedKPSetConceptInstancesItem* parentParentItem = *it; |
| 4915 |
updateList.append(parentParentItem); |
| 4916 |
} |
| 4917 |
} |
| 4918 |
} |
| 4919 |
} |
| 4920 |
return this; |
| 4921 |
} |
| 4922 |
|
| 4923 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::updateParentItemsSuccessorProcessed(COptimizedKPSetRoleInstancesItem* item) { |
| 4924 |
QList<COptimizedKPSetRoleInstancesItem*> updateList; |
| 4925 |
QList<TRoleItemInversionPair>* parentItemList = item->getParentItemList(); |
| 4926 |
for (QList<TRoleItemInversionPair>::const_iterator it = parentItemList->constBegin(), itEnd = parentItemList->constEnd(); it != itEnd; ++it) { |
| 4927 |
COptimizedKPSetRoleInstancesItem* parentItem = it->first; |
| 4928 |
updateList.append(parentItem); |
| 4929 |
} |
| 4930 |
while (!updateList.isEmpty()) { |
| 4931 |
COptimizedKPSetRoleInstancesItem* parentItem = updateList.takeFirst(); |
| 4932 |
parentItem->decUnprocessedSuccessorItemCount(); |
| 4933 |
if (parentItem->getUnprocessedSuccessorItemCount() <= 0) { |
| 4934 |
parentItem->setAllSuccessorProcessedFlag(true); |
| 4935 |
if (!parentItem->hasPossibleInstances() && !parentItem->hasTestingPossibleInstances()) { |
| 4936 |
parentItem->setSelfSuccessorProcessedFlag(true); |
| 4937 |
QList<TRoleItemInversionPair>* parentParentItemList = parentItem->getParentItemList(); |
| 4938 |
for (QList<TRoleItemInversionPair>::const_iterator it = parentParentItemList->constBegin(), itEnd = parentParentItemList->constEnd(); it != itEnd; ++it) { |
| 4939 |
COptimizedKPSetRoleInstancesItem* parentParentItem = it->first; |
| 4940 |
updateList.append(parentParentItem); |
| 4941 |
} |
| 4942 |
} |
| 4943 |
} |
| 4944 |
} |
| 4945 |
return this; |
| 4946 |
} |
| 4947 |
|
| 4948 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::finishOntologyRealizing(COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem) { |
| 4949 |
if (reqConfPreCompItem->areAllStepFinished()) { |
| 4950 |
if (reqConfPreCompItem->isRealizingFinished()) { |
| 4951 |
reqConfPreCompItem->setRealizingFinished(true); |
| 4952 |
CConcreteOntology* ontology = reqConfPreCompItem->getOntology(); |
| 4953 |
CRealization* realization = ontology->getRealization(); |
| 4954 |
realization->setRealized(true); |
| 4955 |
} |
| 4956 |
} |
| 4957 |
mActiveOntItemSet.remove(reqConfPreCompItem); |
| 4958 |
mInactiveOntItemSet.insert(reqConfPreCompItem); |
| 4959 |
|
| 4960 |
|
| 4961 |
//debugWriteIndividualTypesToFile(reqConfPreCompItem); |
| 4962 |
//debugCheckIndividualTypesFromFile(reqConfPreCompItem); |
| 4963 |
|
| 4964 |
reqConfPreCompItem->doRealizingFinishedCallback(true); |
| 4965 |
return true; |
| 4966 |
} |
| 4967 |
|
| 4968 |
|
| 4969 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::incTestedPossibleConceptInstancesCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 incCount) { |
| 4970 |
if (item->isCountingPossibleConceptInstancesTesting()) { |
| 4971 |
mTestedPossibleInstancesCount += incCount; |
| 4972 |
} |
| 4973 |
item->incTestedPossibleConceptInstancesCount(incCount); |
| 4974 |
return this; |
| 4975 |
} |
| 4976 |
|
| 4977 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::incOpenPossibleConceptInstancesCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 incCount) { |
| 4978 |
if (item->isCountingPossibleConceptInstancesTesting()) { |
| 4979 |
mOpenPossibleInstancesCount += incCount; |
| 4980 |
} |
| 4981 |
item->incOpenPossibleConceptInstancesCount(incCount); |
| 4982 |
return this; |
| 4983 |
} |
| 4984 |
|
| 4985 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::decTestedPossibleConceptInstancesCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 decCount) { |
| 4986 |
if (item->isCountingPossibleConceptInstancesTesting()) { |
| 4987 |
mTestedPossibleInstancesCount -= decCount; |
| 4988 |
} |
| 4989 |
item->decTestedPossibleConceptInstancesCount(decCount); |
| 4990 |
return this; |
| 4991 |
} |
| 4992 |
|
| 4993 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::decOpenPossibleConceptInstancesCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 decCount) { |
| 4994 |
if (item->isCountingPossibleConceptInstancesTesting()) { |
| 4995 |
mOpenPossibleInstancesCount -= decCount; |
| 4996 |
} |
| 4997 |
item->decOpenPossibleConceptInstancesCount(decCount); |
| 4998 |
return this; |
| 4999 |
} |
| 5000 |
|
| 5001 |
|
| 5002 |
|
| 5003 |
|
| 5004 |
|
| 5005 |
|
| 5006 |
|
| 5007 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::incTestedPossibleRoleInstancesCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 incCount) { |
| 5008 |
if (item->isCountingPossibleRoleInstancesTesting()) { |
| 5009 |
mTestedPossibleInstancesCount += incCount; |
| 5010 |
} |
| 5011 |
item->incTestedPossibleRoleInstancesCount(incCount); |
| 5012 |
return this; |
| 5013 |
} |
| 5014 |
|
| 5015 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::incOpenPossibleRoleInstancesCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 incCount) { |
| 5016 |
if (item->isCountingPossibleRoleInstancesTesting()) { |
| 5017 |
mOpenPossibleInstancesCount += incCount; |
| 5018 |
} |
| 5019 |
item->incOpenPossibleRoleInstancesCount(incCount); |
| 5020 |
return this; |
| 5021 |
} |
| 5022 |
|
| 5023 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::decTestedPossibleRoleInstancesCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 decCount) { |
| 5024 |
if (item->isCountingPossibleRoleInstancesTesting()) { |
| 5025 |
mTestedPossibleInstancesCount -= decCount; |
| 5026 |
} |
| 5027 |
item->decTestedPossibleRoleInstancesCount(decCount); |
| 5028 |
return this; |
| 5029 |
} |
| 5030 |
|
| 5031 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::decOpenPossibleRoleInstancesCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 decCount) { |
| 5032 |
if (item->isCountingPossibleRoleInstancesTesting()) { |
| 5033 |
mOpenPossibleInstancesCount -= decCount; |
| 5034 |
} |
| 5035 |
item->decOpenPossibleRoleInstancesCount(decCount); |
| 5036 |
return this; |
| 5037 |
} |
| 5038 |
|
| 5039 |
|
| 5040 |
|
| 5041 |
|
| 5042 |
|
| 5043 |
|
| 5044 |
|
| 5045 |
|
| 5046 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::incTestedPossibleSameIndividualsCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 incCount) { |
| 5047 |
if (item->isCountingPossibleSameInstancesTesting()) { |
| 5048 |
mTestedPossibleInstancesCount += incCount; |
| 5049 |
} |
| 5050 |
item->incTestedPossibleSameIndividualsCount(incCount); |
| 5051 |
return this; |
| 5052 |
} |
| 5053 |
|
| 5054 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::incOpenPossibleSameIndividualsCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 incCount) { |
| 5055 |
if (item->isCountingPossibleSameInstancesTesting()) { |
| 5056 |
mOpenPossibleInstancesCount += incCount; |
| 5057 |
} |
| 5058 |
item->incOpenPossibleSameIndividualsCount(incCount); |
| 5059 |
return this; |
| 5060 |
} |
| 5061 |
|
| 5062 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::decTestedPossibleSameIndividualsCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 decCount) { |
| 5063 |
if (item->isCountingPossibleSameInstancesTesting()) { |
| 5064 |
mTestedPossibleInstancesCount -= decCount; |
| 5065 |
} |
| 5066 |
item->decTestedPossibleSameIndividualsCount(decCount); |
| 5067 |
return this; |
| 5068 |
} |
| 5069 |
|
| 5070 |
COptimizedRepresentativeKPSetOntologyRealizingThread* COptimizedRepresentativeKPSetOntologyRealizingThread::decOpenPossibleSameIndividualsCount(COptimizedRepresentativeKPSetOntologyRealizingItem* item, cint64 decCount) { |
| 5071 |
if (item->isCountingPossibleSameInstancesTesting()) { |
| 5072 |
mOpenPossibleInstancesCount -= decCount; |
| 5073 |
} |
| 5074 |
item->decOpenPossibleSameIndividualsCount(decCount); |
| 5075 |
return this; |
| 5076 |
} |
| 5077 |
|
| 5078 |
|
| 5079 |
|
| 5080 |
|
| 5081 |
|
| 5082 |
|
| 5083 |
CRealizationProgress* COptimizedRepresentativeKPSetOntologyRealizingThread::getRealizationProgress() { |
| 5084 |
|
| 5085 |
bool hasProcessingRequirements = false; |
| 5086 |
|
| 5087 |
for (COntologyRealizingItem* ontPreCompItem : mActiveOntItemSet) { |
| 5088 |
COptimizedRepresentativeKPSetOntologyRealizingItem* reqConfPreCompItem = (COptimizedRepresentativeKPSetOntologyRealizingItem*)ontPreCompItem; |
| 5089 |
if (reqConfPreCompItem->hasRemainingProcessingRequirements()) { |
| 5090 |
hasProcessingRequirements = true; |
| 5091 |
} |
| 5092 |
} |
| 5093 |
|
| 5094 |
if (mOpenPossibleInstancesCount != mTestedPossibleInstancesCount && hasProcessingRequirements) { |
| 5095 |
cint64 tested = mTestedPossibleInstancesCount; |
| 5096 |
cint64 total = mOpenPossibleInstancesCount; |
| 5097 |
cint64 elapsedTime = mRealStartTime.elapsed(); |
| 5098 |
double remainingMilliSeconds = 0.; |
| 5099 |
double progessPercent = 0.; |
| 5100 |
if (elapsedTime <= 0 && total > 0) { |
| 5101 |
remainingMilliSeconds = 0.; |
| 5102 |
} else { |
| 5103 |
remainingMilliSeconds = ((double)elapsedTime / (double)tested) * (total-tested); |
| 5104 |
} |
| 5105 |
if (total <= 0) { |
| 5106 |
progessPercent = 0.; |
| 5107 |
} else { |
| 5108 |
progessPercent = ((double)tested / (double)total) * 100.; |
| 5109 |
} |
| 5110 |
cint64 classificCount = mRealizingCount; |
| 5111 |
mRealProgress.setRealizationCount(classificCount); |
| 5112 |
mRealProgress.setProgessPercent(progessPercent); |
| 5113 |
mRealProgress.setRemainingMilliSeconds(remainingMilliSeconds); |
| 5114 |
mRealProgress.setTestedClasses(tested); |
| 5115 |
mRealProgress.setTotalClasses(total); |
| 5116 |
} else { |
| 5117 |
mRealProgress.setProgessPercent(0.); |
| 5118 |
mRealProgress.setRemainingMilliSeconds(0.); |
| 5119 |
mRealProgress.setTestedClasses(mTestedPossibleInstancesCount); |
| 5120 |
mRealProgress.setTotalClasses(mTestedPossibleInstancesCount); |
| 5121 |
} |
| 5122 |
return &mRealProgress; |
| 5123 |
} |
| 5124 |
|
| 5125 |
|
| 5126 |
|
| 5127 |
|
| 5128 |
|
| 5129 |
QSet<QString> COptimizedRepresentativeKPSetOntologyRealizingThread::debugGetIndividualTypesStringSet(COptimizedRepresentativeKPSetOntologyRealizingItem* realizingItem) { |
| 5130 |
QSet<QString> indiTypeStringSet; |
| 5131 |
QHash<CConcept*, COptimizedKPSetConceptInstancesItem*>* conInstHash = realizingItem->getConceptInstancesItemHash(); |
| 5132 |
for (QHash<CConcept*, COptimizedKPSetConceptInstancesItem*>::const_iterator it = conInstHash->constBegin(), itEnd = conInstHash->constEnd(); it != itEnd; ++it) { |
| 5133 |
CConcept* concept = it.key(); |
| 5134 |
COptimizedKPSetConceptInstancesItem* instanceItem = it.value(); |
| 5135 |
QMap<cint64, COptimizedKPSetIndividualItem*>* knownInstancesSet = instanceItem->getKnownInstancesMap(); |
| 5136 |
for (QMap<cint64, COptimizedKPSetIndividualItem*>::const_iterator indiItemIt = knownInstancesSet->constBegin(), indiItemItEnd = knownInstancesSet->constEnd(); indiItemIt != indiItemItEnd; ++indiItemIt) { |
| 5137 |
COptimizedKPSetIndividualItem* indiItem(*indiItemIt); |
| 5138 |
QSet<CIndividualReference>* sameIndiSet = indiItem->getKnownSameIndividualSet(); |
| 5139 |
for (QSet<CIndividualReference>::const_iterator sameIndiIt = sameIndiSet->constBegin(), sameIndiItEnd = sameIndiSet->constEnd(); sameIndiIt != sameIndiItEnd; ++ sameIndiIt) { |
| 5140 |
CIndividualReference indiRef = *sameIndiIt; |
| 5141 |
CIndividual* indi = realizingItem->getOntology()->getABox()->getIndividualVector(false)->getData(indiRef.getIndividualID()); |
| 5142 |
indiTypeStringSet.insert(CIRIName::getRecentIRIName(indi->getIndividualNameLinker()) + " rdf:type " + CIRIName::getRecentIRIName(concept->getClassNameLinker()) + " ."); |
| 5143 |
} |
| 5144 |
} |
| 5145 |
} |
| 5146 |
return indiTypeStringSet; |
| 5147 |
} |
| 5148 |
|
| 5149 |
|
| 5150 |
|
| 5151 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::debugWriteIndividualTypesToFile(COptimizedRepresentativeKPSetOntologyRealizingItem* realizingItem) { |
| 5152 |
QFile indiTypesFile("Debugging/Realizing/individual-types.ttl"); |
| 5153 |
if (indiTypesFile.open(QIODevice::WriteOnly)) { |
| 5154 |
QSet<QString> indiTypeStringSet = debugGetIndividualTypesStringSet(realizingItem); |
| 5155 |
for (QString indiTypeString : indiTypeStringSet) { |
| 5156 |
indiTypesFile.write(indiTypeString.toLocal8Bit()); |
| 5157 |
indiTypesFile.write(QString("\r\n").toLocal8Bit()); |
| 5158 |
} |
| 5159 |
indiTypesFile.close(); |
| 5160 |
} |
| 5161 |
return true; |
| 5162 |
} |
| 5163 |
|
| 5164 |
|
| 5165 |
|
| 5166 |
|
| 5167 |
bool COptimizedRepresentativeKPSetOntologyRealizingThread::debugCheckIndividualTypesFromFile(COptimizedRepresentativeKPSetOntologyRealizingItem* realizingItem) { |
| 5168 |
|
| 5169 |
QFile indiTypesFile("Debugging/Realizing/individual-types.ttl"); |
| 5170 |
|
| 5171 |
QSet<QString> indiTypesStringSet = debugGetIndividualTypesStringSet(realizingItem); |
| 5172 |
QSet<QString> fileIndiTypesStringSet; |
| 5173 |
|
| 5174 |
if (indiTypesFile.open(QIODevice::ReadOnly)) { |
| 5175 |
while (!indiTypesFile.atEnd()) { |
| 5176 |
fileIndiTypesStringSet.insert(indiTypesFile.readLine().trimmed()); |
| 5177 |
} |
| 5178 |
indiTypesFile.close(); |
| 5179 |
} |
| 5180 |
|
| 5181 |
QStringList itemAdditionalIndiTypes; |
| 5182 |
for (QString indiType : indiTypesStringSet) { |
| 5183 |
if (!fileIndiTypesStringSet.contains(indiType)) { |
| 5184 |
itemAdditionalIndiTypes.append(indiType); |
| 5185 |
} |
| 5186 |
} |
| 5187 |
|
| 5188 |
QStringList fileAdditionalIndiTypes; |
| 5189 |
for (QString indiType : fileIndiTypesStringSet) { |
| 5190 |
if (!indiTypesStringSet.contains(indiType)) { |
| 5191 |
fileAdditionalIndiTypes.append(indiType); |
| 5192 |
} |
| 5193 |
} |
| 5194 |
|
| 5195 |
if (fileAdditionalIndiTypes.size() > 0 || itemAdditionalIndiTypes.size() > 0) { |
| 5196 |
LOG(ERROR, getDomain(), logTr("Additional individual types in file:\r\n %1").arg(fileAdditionalIndiTypes.join("\r\n")), this); |
| 5197 |
LOG(ERROR, getDomain(), logTr("Additional individual types in current process:\r\n %1").arg(itemAdditionalIndiTypes.join("\r\n")), this); |
| 5198 |
bool debug = true; |
| 5199 |
} |
| 5200 |
|
| 5201 |
//QSet<QString> fileAdditionalIndiNames; |
| 5202 |
//for (QString fileAdditionalIndiType : fileAdditionalIndiTypes) { |
| 5203 |
// QString indiName = fileAdditionalIndiType.split(" ")[0]; |
| 5204 |
// fileAdditionalIndiNames.insert(indiName); |
| 5205 |
//} |
| 5206 |
|
| 5207 |
|
| 5208 |
//QList<COptimizedKPSetConceptInstancesItem*> equivClassList; |
| 5209 |
//initializeEquivalentClassList(&equivClassList, realizingItem); |
| 5210 |
|
| 5211 |
//CIndividualVector* indiVec = realizingItem->getOntology()->getABox()->getIndividualVector(false); |
| 5212 |
//CIndividualProcessNodeVector* indiProcVector = nullptr; |
| 5213 |
//CConsistence* consistence = realizingItem->getOntology()->getConsistence(); |
| 5214 |
//if (consistence) { |
| 5215 |
// CConsistenceData* consData = consistence->getConsistenceModelData(); |
| 5216 |
// if (consData) { |
| 5217 |
// CConsistenceTaskData* consTaskData = dynamic_cast<CConsistenceTaskData*>(consData); |
| 5218 |
// CSatisfiableCalculationTask* satConsTask = consTaskData->getCompletionGraphCachedSatisfiableTask(); |
| 5219 |
// if (!satConsTask) { |
| 5220 |
// satConsTask = consTaskData->getDeterministicSatisfiableTask(); |
| 5221 |
// } |
| 5222 |
// if (satConsTask) { |
| 5223 |
// CProcessingDataBox* procDataBox = satConsTask->getProcessingDataBox(); |
| 5224 |
// if (procDataBox) { |
| 5225 |
// indiProcVector = procDataBox->getIndividualProcessNodeVector(); |
| 5226 |
// } |
| 5227 |
// } |
| 5228 |
// } |
| 5229 |
//} |
| 5230 |
|
| 5231 |
// |
| 5232 |
//cint64 indiCount = indiVec->getItemCount(); |
| 5233 |
//for (cint64 indiID = 0; indiID < indiCount; ++indiID) { |
| 5234 |
|
| 5235 |
// CIndividual* individual = indiVec->getData(indiID); |
| 5236 |
// if (individual) { |
| 5237 |
// QString indiName = CIRIName::getRecentIRIName(individual->getIndividualNameLinker()); |
| 5238 |
|
| 5239 |
// if (fileAdditionalIndiNames.contains(indiName)) { |
| 5240 |
|
| 5241 |
|
| 5242 |
// QList<COptimizedKPSetConceptInstancesItem*> knownInstancesList; |
| 5243 |
// QList<COptimizedKPSetConceptInstancesItem*> possibleInstancesList; |
| 5244 |
|
| 5245 |
// QList<CIndividual*> knownSameIndividualList; |
| 5246 |
// QList<CIndividual*> possibleSameIndividualList; |
| 5247 |
|
| 5248 |
// extractKnownPossibleIndividualDataFromConsistencyData(individual, &knownInstancesList, &possibleInstancesList, &knownSameIndividualList, &possibleSameIndividualList, indiProcVector, equivClassList, realizingItem); |
| 5249 |
// } |
| 5250 |
// } |
| 5251 |
//} |
| 5252 |
|
| 5253 |
|
| 5254 |
return true; |
| 5255 |
} |
| 5256 |
|
| 5257 |
|
| 5258 |
|
| 5259 |
|
| 5260 |
}; // end namespace Realizer |
| 5261 |
|
| 5262 |
}; // end namespace Reasoner |
| 5263 |
|
| 5264 |
}; // end namespace Konclude |