| 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 "CCalculationAlgorithmContextBase.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Algorithm { |
| 31 |
|
| 32 |
|
| 33 |
CCalculationAlgorithmContextBase::CCalculationAlgorithmContextBase() { |
| 34 |
|
| 35 |
mTempMemMan = nullptr; |
| 36 |
mConceptPriorityStrategy = nullptr; |
| 37 |
mIndividualPriorityStrategy = nullptr; |
| 38 |
mProcessingDataBox = nullptr; |
| 39 |
mProcessContext = nullptr; |
| 40 |
mPrTaskMemMan = nullptr; |
| 41 |
mProcessTagger = nullptr; |
| 42 |
mSatCalcTask = nullptr; |
| 43 |
mTaskProcessorContext = nullptr; |
| 44 |
mTaskPriorityStrategy = nullptr; |
| 45 |
mProcStatGath = nullptr; |
| 46 |
mBranchTreeNode = nullptr; |
| 47 |
mBaseDepNode = nullptr; |
| 48 |
mUnsatCacheHandler = nullptr; |
| 49 |
mIndiNodeManager = nullptr; |
| 50 |
mClashDescriptorFactory = nullptr; |
| 51 |
mUnsatCachRetStrategy = nullptr; |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
CCalculationAlgorithmContextBase::~CCalculationAlgorithmContextBase() { |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
CCalculationAlgorithmContextBase* CCalculationAlgorithmContextBase::initCalculationAlgorithmContext(CTaskProcessorContext* taskHandleContext) { |
| 61 |
initCalculationAlgorithmContext(taskHandleContext,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr); |
| 62 |
return this; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
CCalculationAlgorithmContextBase* CCalculationAlgorithmContextBase::initCalculationAlgorithmContext(CTaskProcessorContext* taskProcessorContext, CConceptProcessingPriorityStrategy* conceptPriorityStrategy, |
| 67 |
CIndividualProcessingPriorityStrategy* individualPriorityStrategy, CTaskProcessingPriorityStrategy* taskPriorityStrategy, CUnsatisfiableCacheRetrievalStrategy* unsatCacheRetrievalStrategy, |
| 68 |
CIndividualNodeManager* indiNodeManager, CClashDescriptorFactory* clashDesFactory, CDependencyFactory* depFactory, CUnsatisfiableCacheHandler* unsatCacheHandler, CSatisfiableExpanderCacheHandler* satExpCacheHandler, CSaturationNodeExpansionCacheHandler* satNodeExpCacheHandler) { |
| 69 |
mTaskProcessorContext = taskProcessorContext; |
| 70 |
mUsedTaskProcessorContext = mTaskProcessorContext; |
| 71 |
mTempMemMan = mTaskProcessorContext->getTaskHandleMemoryAllocationManager(); |
| 72 |
mUsedTempMemMan = mTempMemMan; |
| 73 |
mIndividualPriorityStrategy = individualPriorityStrategy; |
| 74 |
mUsedIndividualPriorityStrategy = mIndividualPriorityStrategy; |
| 75 |
mConceptPriorityStrategy = conceptPriorityStrategy; |
| 76 |
mUsedConceptPriorityStrategy = mConceptPriorityStrategy; |
| 77 |
mTaskPriorityStrategy = taskPriorityStrategy; |
| 78 |
mUsedTaskPriorityStrategy = mTaskPriorityStrategy; |
| 79 |
mUnsatCachRetStrategy = unsatCacheRetrievalStrategy; |
| 80 |
mUsedUnsatCachRetStrategy = mUnsatCachRetStrategy; |
| 81 |
|
| 82 |
mUnsatCacheHandler = unsatCacheHandler; |
| 83 |
mUsedUnsatCacheHandler = mUnsatCacheHandler; |
| 84 |
mClashDescriptorFactory = clashDesFactory; |
| 85 |
mUsedClashDescriptorFactory = mClashDescriptorFactory; |
| 86 |
mIndiNodeManager = indiNodeManager; |
| 87 |
mUsedIndividualNodeManager = mIndiNodeManager; |
| 88 |
|
| 89 |
mDepFactory = depFactory; |
| 90 |
mUsedDepFactory = mDepFactory; |
| 91 |
|
| 92 |
mSatExpCacheHandler = satExpCacheHandler; |
| 93 |
mUsedSatExpCacheHandler = mSatExpCacheHandler; |
| 94 |
|
| 95 |
|
| 96 |
mSatNodeExpCacheHandler = satNodeExpCacheHandler; |
| 97 |
mUsedSatNodeExpCacheHandler = mSatNodeExpCacheHandler; |
| 98 |
|
| 99 |
return this; |
| 100 |
} |
| 101 |
|
| 102 |
CCalculationAlgorithmContextBase* CCalculationAlgorithmContextBase::initTaskProcessContext(CProcessContext* processContext, CSatisfiableCalculationTask* satCalcTask) { |
| 103 |
mProcessContext = processContext; |
| 104 |
mUsedProcessContext = mProcessContext; |
| 105 |
mSatCalcTask = satCalcTask; |
| 106 |
mUsedSatCalcTask = satCalcTask; |
| 107 |
mProcessingDataBox = mSatCalcTask->getProcessingDataBox(); |
| 108 |
mUsedProcessingDataBox = mProcessingDataBox; |
| 109 |
|
| 110 |
mPrTaskMemMan = mProcessContext->getUsedMemoryAllocationManager(); |
| 111 |
mUsedPrTaskMemMan = mPrTaskMemMan; |
| 112 |
mProcessTagger = mProcessContext->getUsedProcessTagger(); |
| 113 |
mUsedProcessTagger = mProcessTagger; |
| 114 |
mProcStatGath = mProcessContext->getUsedProcessingStatisticsGathering(); |
| 115 |
mUsedProcessStatGath = mProcStatGath; |
| 116 |
|
| 117 |
CBranchingTree* branchingTree = mProcessingDataBox->getBranchingTree(true); |
| 118 |
|
| 119 |
mBranchTreeNode = branchingTree->getBranchTreeNode(satCalcTask); |
| 120 |
mUsedBranchTreeNode = mBranchTreeNode; |
| 121 |
|
| 122 |
mBaseDepNode = branchingTree->getBaseDependencyNode(true); |
| 123 |
mUsedBaseDepNode = mBaseDepNode; |
| 124 |
|
| 125 |
mMaxCompletionGraphCachedIndiNodeID = std::numeric_limits < qint64 >::min(); |
| 126 |
CConsistence* consistence = mProcessingDataBox->getOntology()->getConsistence(); |
| 127 |
if (consistence) { |
| 128 |
CConsistenceData* consData = consistence->getConsistenceModelData(); |
| 129 |
if (consData) { |
| 130 |
CConsistenceTaskData* consTaskData = dynamic_cast<CConsistenceTaskData*>(consData); |
| 131 |
if (consTaskData) { |
| 132 |
CSatisfiableCalculationTask* detSatCalcTask = consTaskData->getDeterministicSatisfiableTask(); |
| 133 |
CSatisfiableCalculationTask* compGraphCachedCalcTask = consTaskData->getCompletionGraphCachedSatisfiableTask(); |
| 134 |
if (detSatCalcTask && compGraphCachedCalcTask) { |
| 135 |
mMaxCompletionGraphCachedIndiNodeID = detSatCalcTask->getProcessingDataBox()->getIndividualProcessNodeVector()->getItemMaxIndex(); |
| 136 |
mCompletionGraphCachedLocalizationTag = detSatCalcTask->getProcessingDataBox()->getProcessContext()->getProcessTagger()->getCurrentLocalizationTag(); |
| 137 |
} |
| 138 |
} |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
return this; |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
CProcessTagger* CCalculationAlgorithmContextBase::getProcessTagger() { |
| 148 |
return mProcessTagger; |
| 149 |
} |
| 150 |
|
| 151 |
CProcessContext* CCalculationAlgorithmContextBase::getProcessContext() { |
| 152 |
return mProcessContext; |
| 153 |
} |
| 154 |
|
| 155 |
CMemoryAllocationManager* CCalculationAlgorithmContextBase::getProcessTaskMemoryAllocationManager() { |
| 156 |
return mPrTaskMemMan; |
| 157 |
} |
| 158 |
|
| 159 |
CMemoryAllocationManager* CCalculationAlgorithmContextBase::getMemoryAllocationManager() { |
| 160 |
return mPrTaskMemMan; |
| 161 |
} |
| 162 |
|
| 163 |
CTaskHandleMemoryAllocationManager* CCalculationAlgorithmContextBase::getTemporaryMemoryAllocationManager() { |
| 164 |
return mTempMemMan; |
| 165 |
} |
| 166 |
|
| 167 |
CConceptProcessingPriorityStrategy* CCalculationAlgorithmContextBase::getConceptPriorityStrategy() { |
| 168 |
return mConceptPriorityStrategy; |
| 169 |
} |
| 170 |
|
| 171 |
CIndividualProcessingPriorityStrategy* CCalculationAlgorithmContextBase::getIndividualPriorityStrategy() { |
| 172 |
return mIndividualPriorityStrategy; |
| 173 |
} |
| 174 |
|
| 175 |
CProcessingDataBox* CCalculationAlgorithmContextBase::getProcessingDataBox() { |
| 176 |
return mProcessingDataBox; |
| 177 |
} |
| 178 |
|
| 179 |
CSatisfiableCalculationTask* CCalculationAlgorithmContextBase::getSatisfiableCalculationTask() { |
| 180 |
return mSatCalcTask; |
| 181 |
} |
| 182 |
|
| 183 |
CTaskProcessorContext* CCalculationAlgorithmContextBase::getTaskProcessorContext() { |
| 184 |
return mTaskProcessorContext; |
| 185 |
} |
| 186 |
|
| 187 |
CTaskProcessingPriorityStrategy* CCalculationAlgorithmContextBase::getTaskPriorityStrategy() { |
| 188 |
return mTaskPriorityStrategy; |
| 189 |
} |
| 190 |
|
| 191 |
CProcessingStatisticGathering* CCalculationAlgorithmContextBase::getProcessingStatisticsGathering() { |
| 192 |
return mProcStatGath; |
| 193 |
} |
| 194 |
|
| 195 |
CBranchTreeNode* CCalculationAlgorithmContextBase::getBranchTreeNode() { |
| 196 |
return mBranchTreeNode; |
| 197 |
} |
| 198 |
|
| 199 |
|
| 200 |
CBranchTreeNode* CCalculationAlgorithmContextBase::getNewBranchTreeNode() { |
| 201 |
mBranchTreeNode = getUsedProcessingDataBox()->getBranchingTree(true)->getBranchTreeNode(mSatCalcTask,true); |
| 202 |
mUsedBranchTreeNode = mBranchTreeNode; |
| 203 |
return mBranchTreeNode; |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
CDependencyNode* CCalculationAlgorithmContextBase::getBaseDependencyNode() { |
| 208 |
return mBaseDepNode; |
| 209 |
} |
| 210 |
|
| 211 |
|
| 212 |
CUnsatisfiableCacheHandler* CCalculationAlgorithmContextBase::getUnsatisfiableCacheHandler() { |
| 213 |
return mUnsatCacheHandler; |
| 214 |
} |
| 215 |
|
| 216 |
CIndividualNodeManager* CCalculationAlgorithmContextBase::getIndividualNodeManager() { |
| 217 |
return mIndiNodeManager; |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
CClashDescriptorFactory* CCalculationAlgorithmContextBase::getClashDescriptorFactory() { |
| 222 |
return mClashDescriptorFactory; |
| 223 |
} |
| 224 |
|
| 225 |
CUnsatisfiableCacheRetrievalStrategy* CCalculationAlgorithmContextBase::getUnsatisfiableCacheRetrievalStrategy() { |
| 226 |
return mUnsatCachRetStrategy; |
| 227 |
} |
| 228 |
|
| 229 |
CDependencyFactory* CCalculationAlgorithmContextBase::getDependencyFactory() { |
| 230 |
return mDepFactory; |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
CSatisfiableExpanderCacheHandler* CCalculationAlgorithmContextBase::getSatisfiableExpanderCacheHandler() { |
| 235 |
return mSatExpCacheHandler; |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
CSaturationNodeExpansionCacheHandler* CCalculationAlgorithmContextBase::getSaturationNodeExpansionCacheHandler() { |
| 240 |
return mSatNodeExpCacheHandler; |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
}; // end namespace Algorithm |
| 245 |
|
| 246 |
}; // end namespace Kernel |
| 247 |
|
| 248 |
}; // end namespace Reasoner |
| 249 |
|
| 250 |
}; // end namespace Konclude |