| 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 "CIncrementalOntologyPrecomputationItem.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Consistiser { |
| 29 |
|
| 30 |
|
| 31 |
CIncrementalOntologyPrecomputationItem::CIncrementalOntologyPrecomputationItem() { |
| 32 |
} |
| 33 |
|
| 34 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::initTotallyPrecomputationItem(CConcreteOntology* ontology, CConfigurationBase* config) { |
| 35 |
COntologyPrecomputationItem::initPrecomputationItem(ontology,config); |
| 36 |
mConsistenceCheched = false; |
| 37 |
mConsistence = nullptr; |
| 38 |
mPrecomputation = ontology->getPrecomputation(); |
| 39 |
mCalculationConfig = new CCalculationConfigurationExtension(config,0); |
| 40 |
mConsistenceCheckCreated = false; |
| 41 |
mIndividualPrecomputationCreated = false; |
| 42 |
mIndividualPrecomputationChecked = false; |
| 43 |
|
| 44 |
COntologyProcessingStepDataVector* ontProStepDataVec = mOntology->getProcessingSteps()->getOntologyProcessingStepDataVector(); |
| 45 |
|
| 46 |
mConsistencePrecomputationStep = new CPrecomputationTestingStep(CPrecomputationTestingStep::CONSISTENCYPRECOMPUTATIONSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSCONSISTENCY),this); |
| 47 |
mCyclePrecomputationStep = new CPrecomputationTestingStep(CPrecomputationTestingStep::CYCLEPRECOMPUTATIONSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSPRECOMPUTECYCLES),this); |
| 48 |
mSaturationPrecomputationStep = new CPrecomputationTestingStep(CPrecomputationTestingStep::SATURATIONPRECOMPUTATIONSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSPRECOMPUTESATURATION),this); |
| 49 |
mIndividualPrecomputationStep = new CPrecomputationTestingStep(CPrecomputationTestingStep::INDIVIDUALPRECOMPUTATIONSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSPRECOMPUTEINDIVIDUAL),this); |
| 50 |
mProcessingSteps.append(mCyclePrecomputationStep); |
| 51 |
mProcessingSteps.append(mConsistencePrecomputationStep); |
| 52 |
mProcessingSteps.append(mSaturationPrecomputationStep); |
| 53 |
mProcessingSteps.append(mIndividualPrecomputationStep); |
| 54 |
|
| 55 |
mIndividualComputationRunning = false; |
| 56 |
|
| 57 |
mIndividualTestRunning = false; |
| 58 |
mLastConsistentlyTestedVersion = nullptr; |
| 59 |
mDirectlyChangedIndividualsIdentified = false; |
| 60 |
mInitTime.start(); |
| 61 |
return this; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
CIncrementalOntologyPrecomputationItem::~CIncrementalOntologyPrecomputationItem() { |
| 66 |
delete mCalculationConfig; |
| 67 |
delete mConsistencePrecomputationStep; |
| 68 |
delete mCyclePrecomputationStep; |
| 69 |
delete mSaturationPrecomputationStep; |
| 70 |
delete mIndividualPrecomputationStep; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
COntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::addPrecomputationRequirement(COntologyProcessingRequirement* ontoRequirement) { |
| 79 |
bool supportRequirement = false; |
| 80 |
COntologyProcessingStepRequirement* stepProcRequirement = dynamic_cast<COntologyProcessingStepRequirement*>(ontoRequirement); |
| 81 |
if (stepProcRequirement) { |
| 82 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSCONSISTENCY) { |
| 83 |
mConsistencePrecomputationStep->addProcessingRequirement(stepProcRequirement); |
| 84 |
supportRequirement = true; |
| 85 |
} |
| 86 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSPRECOMPUTESATURATION) { |
| 87 |
mSaturationPrecomputationStep->addProcessingRequirement(stepProcRequirement); |
| 88 |
supportRequirement = true; |
| 89 |
} |
| 90 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSPRECOMPUTECYCLES) { |
| 91 |
mCyclePrecomputationStep->addProcessingRequirement(stepProcRequirement); |
| 92 |
supportRequirement = true; |
| 93 |
} |
| 94 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSPRECOMPUTEINDIVIDUAL) { |
| 95 |
mIndividualPrecomputationStep->addProcessingRequirement(stepProcRequirement); |
| 96 |
supportRequirement = true; |
| 97 |
} |
| 98 |
} |
| 99 |
COntologyProcessingConceptSaturationRequirement* conSatRequirement = dynamic_cast<COntologyProcessingConceptSaturationRequirement*>(ontoRequirement); |
| 100 |
if (conSatRequirement) { |
| 101 |
mSaturationPrecomputationStep->addProcessingRequirement(conSatRequirement); |
| 102 |
supportRequirement = true; |
| 103 |
} |
| 104 |
|
| 105 |
if (!supportRequirement) { |
| 106 |
stepProcRequirement->submitRequirementUpdate(COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSUNSUPPORTED); |
| 107 |
} |
| 108 |
return this; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::setConsistenceCheched(bool consistenceChecked) { |
| 114 |
mConsistenceCheched = consistenceChecked; |
| 115 |
return this; |
| 116 |
} |
| 117 |
|
| 118 |
bool CIncrementalOntologyPrecomputationItem::hasConsistenceCheched() { |
| 119 |
return mConsistenceCheched; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::setConsistenceCheckCreated(bool consistenceCheckCreated) { |
| 124 |
mConsistenceCheckCreated = consistenceCheckCreated; |
| 125 |
return this; |
| 126 |
} |
| 127 |
|
| 128 |
bool CIncrementalOntologyPrecomputationItem::hasConsistenceCheckCreated() { |
| 129 |
return mConsistenceCheckCreated; |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
CConsistenceObserver* CIncrementalOntologyPrecomputationItem::tellConsistenceData(CConsistenceData* consData) { |
| 134 |
if (mConsData.testAndSetOrdered(nullptr,consData)) { |
| 135 |
consData->overtakeData(); |
| 136 |
} else { |
| 137 |
delete consData; |
| 138 |
} |
| 139 |
return this; |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
CConsistenceData* CIncrementalOntologyPrecomputationItem::getConsistenceData() { |
| 145 |
return mConsData.fetchAndAddRelaxed(0); |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
CConsistence* CIncrementalOntologyPrecomputationItem::getConsistence() { |
| 150 |
return mConsistence; |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::setConsistence(CConsistence* consistence) { |
| 155 |
mConsistence = consistence; |
| 156 |
return this; |
| 157 |
} |
| 158 |
|
| 159 |
CCalculationConfigurationExtension* CIncrementalOntologyPrecomputationItem::getCalculationConfiguration() { |
| 160 |
return mCalculationConfig; |
| 161 |
} |
| 162 |
|
| 163 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::setPrecomputation(CPrecomputation* precomputation) { |
| 164 |
mPrecomputation = precomputation; |
| 165 |
return this; |
| 166 |
} |
| 167 |
CPrecomputation* CIncrementalOntologyPrecomputationItem::getPrecomputation() { |
| 168 |
return mPrecomputation; |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
CPrecomputationTestingStep* CIncrementalOntologyPrecomputationItem::getConsistencePrecomputationStep() { |
| 174 |
return mConsistencePrecomputationStep; |
| 175 |
} |
| 176 |
|
| 177 |
bool CIncrementalOntologyPrecomputationItem::isConsistenceStepFinished() { |
| 178 |
return mConsistencePrecomputationStep->isStepFinished(); |
| 179 |
} |
| 180 |
|
| 181 |
bool CIncrementalOntologyPrecomputationItem::isConsistenceStepRequired() { |
| 182 |
return mConsistencePrecomputationStep->hasRequirements(); |
| 183 |
} |
| 184 |
|
| 185 |
bool CIncrementalOntologyPrecomputationItem::areConsistenceStepProcessingRequirementSatisfied() { |
| 186 |
return mConsistencePrecomputationStep->areStepProcessingRequirementSatisfied(); |
| 187 |
} |
| 188 |
|
| 189 |
bool CIncrementalOntologyPrecomputationItem::areCycleStepProcessingRequirementSatisfied() { |
| 190 |
return mCyclePrecomputationStep->areStepProcessingRequirementSatisfied(); |
| 191 |
} |
| 192 |
|
| 193 |
CPrecomputationTestingStep* CIncrementalOntologyPrecomputationItem::getCyclePrecomputationStep() { |
| 194 |
return mCyclePrecomputationStep; |
| 195 |
} |
| 196 |
|
| 197 |
bool CIncrementalOntologyPrecomputationItem::isCycleStepFinished() { |
| 198 |
return mCyclePrecomputationStep->isStepFinished(); |
| 199 |
} |
| 200 |
|
| 201 |
bool CIncrementalOntologyPrecomputationItem::isCycleStepRequired() { |
| 202 |
return mCyclePrecomputationStep->hasRequirements(); |
| 203 |
} |
| 204 |
|
| 205 |
bool CIncrementalOntologyPrecomputationItem::areSaturationStepProcessingRequirementSatisfied() { |
| 206 |
return mSaturationPrecomputationStep->areStepProcessingRequirementSatisfied(); |
| 207 |
} |
| 208 |
|
| 209 |
CPrecomputationTestingStep* CIncrementalOntologyPrecomputationItem::getSaturationPrecomputationStep() { |
| 210 |
return mSaturationPrecomputationStep; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
bool CIncrementalOntologyPrecomputationItem::isSaturationStepFinished() { |
| 216 |
return mSaturationPrecomputationStep->isStepFinished(); |
| 217 |
} |
| 218 |
|
| 219 |
bool CIncrementalOntologyPrecomputationItem::isSaturationStepRequired() { |
| 220 |
return mSaturationPrecomputationStep->hasRequirements(); |
| 221 |
} |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
bool CIncrementalOntologyPrecomputationItem::areAllStepFinished() { |
| 226 |
for (QList<CPrecomputationTestingStep*>::const_iterator it = mProcessingSteps.constBegin(), itEnd = mProcessingSteps.constEnd(); it != itEnd; ++it) { |
| 227 |
if (!(*it)->isStepFinished()) { |
| 228 |
return false; |
| 229 |
} |
| 230 |
} |
| 231 |
return true; |
| 232 |
} |
| 233 |
|
| 234 |
bool CIncrementalOntologyPrecomputationItem::hasRemainingProcessingRequirements() { |
| 235 |
for (QList<CPrecomputationTestingStep*>::const_iterator it = mProcessingSteps.constBegin(), itEnd = mProcessingSteps.constEnd(); it != itEnd; ++it) { |
| 236 |
if ((*it)->hasRequirements()) { |
| 237 |
return true; |
| 238 |
} |
| 239 |
} |
| 240 |
return false; |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
bool CIncrementalOntologyPrecomputationItem::areIndividualStepProcessingRequirementSatisfied() { |
| 248 |
return mIndividualPrecomputationStep->areStepProcessingRequirementSatisfied(); |
| 249 |
} |
| 250 |
|
| 251 |
CPrecomputationTestingStep* CIncrementalOntologyPrecomputationItem::getIndividualPrecomputationStep() { |
| 252 |
return mIndividualPrecomputationStep; |
| 253 |
} |
| 254 |
|
| 255 |
bool CIncrementalOntologyPrecomputationItem::isIndividualStepRunning() { |
| 256 |
return mIndividualTestRunning; |
| 257 |
} |
| 258 |
|
| 259 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::setIndividualStepRunning(bool satStepRunning) { |
| 260 |
mIndividualTestRunning = satStepRunning; |
| 261 |
return this; |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
bool CIncrementalOntologyPrecomputationItem::isIndividualComputationRunning() { |
| 267 |
return mIndividualComputationRunning; |
| 268 |
} |
| 269 |
|
| 270 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::setIndividualComputationRunning(bool indiCompRunning) { |
| 271 |
mIndividualComputationRunning = indiCompRunning; |
| 272 |
return this; |
| 273 |
} |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::setIndividualPrecomputationCreated(bool initialized) { |
| 280 |
mIndividualPrecomputationCreated = initialized; |
| 281 |
return this; |
| 282 |
} |
| 283 |
|
| 284 |
bool CIncrementalOntologyPrecomputationItem::hasIndividualPrecomputationCreated() { |
| 285 |
return mIndividualPrecomputationCreated; |
| 286 |
} |
| 287 |
|
| 288 |
|
| 289 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::setIndividualPrecomputationChecked(bool checked) { |
| 290 |
mIndividualPrecomputationChecked = checked; |
| 291 |
return this; |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
bool CIncrementalOntologyPrecomputationItem::hasIndividualPrecomputationChecked() { |
| 296 |
return mIndividualPrecomputationChecked; |
| 297 |
} |
| 298 |
|
| 299 |
|
| 300 |
bool CIncrementalOntologyPrecomputationItem::isIndividualStepFinished() { |
| 301 |
return mIndividualPrecomputationStep->isStepFinished(); |
| 302 |
} |
| 303 |
|
| 304 |
|
| 305 |
bool CIncrementalOntologyPrecomputationItem::isIndividualStepRequired() { |
| 306 |
return mIndividualPrecomputationStep->hasRequirements(); |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
CConcreteOntology* CIncrementalOntologyPrecomputationItem::getLastConsistentlyTestedVersion() { |
| 312 |
return mLastConsistentlyTestedVersion; |
| 313 |
} |
| 314 |
|
| 315 |
CIncrementalOntologyPrecomputationItem* CIncrementalOntologyPrecomputationItem::setLastConsistentlyTestedVersion(CConcreteOntology* ontology) { |
| 316 |
mLastConsistentlyTestedVersion = ontology; |
| 317 |
return this; |
| 318 |
} |
| 319 |
|
| 320 |
QSet<CIndividual*>* CIncrementalOntologyPrecomputationItem::getDirectlyChangedIndividualSet() { |
| 321 |
return &mDirectlyChangedIndividualSet; |
| 322 |
} |
| 323 |
|
| 324 |
bool CIncrementalOntologyPrecomputationItem::hasDirectlyChangedIndividualsIdentified() { |
| 325 |
return mDirectlyChangedIndividualsIdentified; |
| 326 |
} |
| 327 |
|
| 328 |
bool CIncrementalOntologyPrecomputationItem::setDirectlyChangedIndividualsIdentified(bool identified) { |
| 329 |
mDirectlyChangedIndividualsIdentified = identified; |
| 330 |
return this; |
| 331 |
} |
| 332 |
|
| 333 |
cint64 CIncrementalOntologyPrecomputationItem::getIncrementalExpansionID() { |
| 334 |
return mOntology->getOntologyID(); |
| 335 |
} |
| 336 |
|
| 337 |
QTime* CIncrementalOntologyPrecomputationItem::getInitializationTime() { |
| 338 |
return &mInitTime; |
| 339 |
} |
| 340 |
|
| 341 |
|
| 342 |
}; // end namespace Consistiser |
| 343 |
|
| 344 |
}; // end namespace Reasoner |
| 345 |
|
| 346 |
}; // end namespace Konclude |