| 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 |
#ifndef KONCLUDE_REASONER_KERNEL_ALGORITHM_CCALCULATIONALGORITHMCONTEXT_H |
| 22 |
#define KONCLUDE_REASONER_KERNEL_ALGORITHM_CCALCULATIONALGORITHMCONTEXT_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
|
| 26 |
|
| 27 |
// Namespace includes |
| 28 |
#include "AlgorithmSettings.h" |
| 29 |
|
| 30 |
|
| 31 |
// Other includes |
| 32 |
#include "Scheduler/CTaskContext.h" |
| 33 |
#include "Scheduler/CTaskProcessorContext.h" |
| 34 |
|
| 35 |
#include "Reasoner/Kernel/Process/CProcessContext.h" |
| 36 |
#include "Reasoner/Kernel/Process/CProcessingDataBox.h" |
| 37 |
#include "Reasoner/Kernel/Process/CProcessingStatisticGathering.h" |
| 38 |
|
| 39 |
#include "Reasoner/Kernel/Strategy/CConceptProcessingPriorityStrategy.h" |
| 40 |
#include "Reasoner/Kernel/Strategy/CIndividualProcessingPriorityStrategy.h" |
| 41 |
#include "Reasoner/Kernel/Strategy/CTaskProcessingPriorityStrategy.h" |
| 42 |
#include "Reasoner/Kernel/Strategy/CUnsatisfiableCacheRetrievalStrategy.h" |
| 43 |
|
| 44 |
#include "Reasoner/Kernel/Task/CSatisfiableCalculationTask.h" |
| 45 |
|
| 46 |
// Logger includes |
| 47 |
#include "Logger/CLogger.h" |
| 48 |
|
| 49 |
|
| 50 |
namespace Konclude { |
| 51 |
|
| 52 |
using namespace Scheduler; |
| 53 |
|
| 54 |
namespace Reasoner { |
| 55 |
|
| 56 |
namespace Kernel { |
| 57 |
|
| 58 |
using namespace Process; |
| 59 |
using namespace Strategy; |
| 60 |
using namespace Task; |
| 61 |
|
| 62 |
namespace Algorithm { |
| 63 |
|
| 64 |
|
| 65 |
#ifdef KONCLUDE_FORCE_STATISTIC_DEACTIVATED |
| 66 |
#define STATINC(STATDESC,calcAlgContext) |
| 67 |
#define STATINCM(STATDESC,incCount,calcAlgContext) |
| 68 |
#else |
| 69 |
#define STATINC(STATDESC,calcAlgContext) STATDATAINC(STATDESC,calcAlgContext->getUsedProcessingStatisticsGathering()) |
| 70 |
#define STATINCM(STATDESC,incCount,calcAlgContext) STATDATAINCM(STATDESC,incCount,calcAlgContext->getUsedProcessingStatisticsGathering()) |
| 71 |
#endif |
| 72 |
|
| 73 |
|
| 74 |
/*! |
| 75 |
* |
| 76 |
* \class CCalculationAlgorithmContext |
| 77 |
* \author Andreas Steigmiller |
| 78 |
* \version 0.1 |
| 79 |
* \brief TODO |
| 80 |
* |
| 81 |
*/ |
| 82 |
class CCalculationAlgorithmContext : public CContext { |
| 83 |
// public methods |
| 84 |
public: |
| 85 |
//! Constructor |
| 86 |
CCalculationAlgorithmContext(); |
| 87 |
|
| 88 |
//! Destructor |
| 89 |
virtual ~CCalculationAlgorithmContext(); |
| 90 |
|
| 91 |
virtual CProcessTagger* getProcessTagger() = 0; |
| 92 |
virtual CProcessContext* getProcessContext() = 0; |
| 93 |
virtual CMemoryAllocationManager* getProcessTaskMemoryAllocationManager() = 0; |
| 94 |
virtual CTaskHandleMemoryAllocationManager* getTemporaryMemoryAllocationManager() = 0; |
| 95 |
virtual CConceptProcessingPriorityStrategy* getConceptPriorityStrategy() = 0; |
| 96 |
virtual CIndividualProcessingPriorityStrategy* getIndividualPriorityStrategy() = 0; |
| 97 |
virtual CProcessingDataBox* getProcessingDataBox() = 0; |
| 98 |
virtual CSatisfiableCalculationTask* getSatisfiableCalculationTask() = 0; |
| 99 |
virtual CTaskProcessorContext* getTaskProcessorContext() = 0; |
| 100 |
virtual CTaskProcessingPriorityStrategy* getTaskPriorityStrategy() = 0; |
| 101 |
virtual CProcessingStatisticGathering* getProcessingStatisticsGathering() = 0; |
| 102 |
virtual CBranchTreeNode* getBranchTreeNode() = 0; |
| 103 |
virtual CBranchTreeNode* getNewBranchTreeNode() = 0; |
| 104 |
virtual CDependencyNode* getBaseDependencyNode() = 0; |
| 105 |
virtual CUnsatisfiableCacheHandler* getUnsatisfiableCacheHandler() = 0; |
| 106 |
virtual CIndividualNodeManager* getIndividualNodeManager() = 0; |
| 107 |
virtual CClashDescriptorFactory* getClashDescriptorFactory() = 0; |
| 108 |
virtual CUnsatisfiableCacheRetrievalStrategy* getUnsatisfiableCacheRetrievalStrategy() = 0; |
| 109 |
virtual CDependencyFactory* getDependencyFactory() = 0; |
| 110 |
virtual CSatisfiableExpanderCacheHandler* getSatisfiableExpanderCacheHandler() = 0; |
| 111 |
virtual CSaturationNodeExpansionCacheHandler* getSaturationNodeExpansionCacheHandler() = 0; |
| 112 |
|
| 113 |
|
| 114 |
inline CProcessTagger* getUsedProcessTagger(); |
| 115 |
inline CMemoryAllocationManager* getUsedProcessTaskMemoryAllocationManager(); |
| 116 |
inline CTaskHandleMemoryAllocationManager* getUsedTemporaryMemoryAllocationManager(); |
| 117 |
inline CProcessContext* getUsedProcessContext(); |
| 118 |
inline CConceptProcessingPriorityStrategy* getUsedConceptPriorityStrategy(); |
| 119 |
inline CIndividualProcessingPriorityStrategy* getUsedIndividualPriorityStrategy(); |
| 120 |
inline CProcessingDataBox* getUsedProcessingDataBox(); |
| 121 |
inline CSatisfiableCalculationTask* getUsedSatisfiableCalculationTask(); |
| 122 |
inline CTaskProcessorContext* getUsedTaskProcessorContext(); |
| 123 |
inline CTaskProcessingPriorityStrategy* getUsedTaskPriorityStrategy(); |
| 124 |
inline CProcessingStatisticGathering* getUsedProcessingStatisticsGathering(); |
| 125 |
inline CBranchTreeNode* getUsedBranchTreeNode(); |
| 126 |
inline CDependencyNode* getUsedBaseDependencyNode(); |
| 127 |
inline CUnsatisfiableCacheHandler* getUsedUnsatisfiableCacheHandler(); |
| 128 |
inline CIndividualNodeManager* getUsedIndividualNodeManager(); |
| 129 |
inline CClashDescriptorFactory* getUsedClashDescriptorFactory(); |
| 130 |
inline CUnsatisfiableCacheRetrievalStrategy* getUsedUnsatisfiableCacheRetrievalStrategy(); |
| 131 |
inline CDependencyFactory* getUsedDependencyFactory(); |
| 132 |
inline CSatisfiableExpanderCacheHandler* getUsedSatisfiableExpanderCacheHandler(); |
| 133 |
inline CSaturationNodeExpansionCacheHandler* getUsedSaturationNodeExpansionCacheHandler(); |
| 134 |
|
| 135 |
inline bool setMinModificationAncestorDepthCandidate(cint64 ancDepthCandidate); |
| 136 |
inline bool setMinModificationIndividualIDCandidate(cint64 indiIDCandidate); |
| 137 |
inline bool setMinModificationIndividualCandidate(CIndividualProcessNode* indiNode); |
| 138 |
|
| 139 |
|
| 140 |
bool isMinModificationUpdated(); |
| 141 |
CCalculationAlgorithmContext* setMinModificationAncestorDepth(cint64 ancDepth); |
| 142 |
cint64 getMinModificationAncestorDepth(); |
| 143 |
CCalculationAlgorithmContext* setMinModificationIndividualID(cint64 indiID); |
| 144 |
cint64 getMinModificationIndividualID(); |
| 145 |
CCalculationAlgorithmContext* setMinModificationIndividual(CIndividualProcessNode* indiNode); |
| 146 |
|
| 147 |
cint64 getMaxCompletionGraphCachedIndividualNodeID(); |
| 148 |
cint64 getCompletionGraphCachedLocalizationTag(); |
| 149 |
bool hasCompletionGraphCachedIndividualNodes(); |
| 150 |
|
| 151 |
CIndividualProcessNode* getCurrentIndividualNode(); |
| 152 |
CCalculationAlgorithmContext* setCurrentIndividualNode(CIndividualProcessNode* indiNode); |
| 153 |
|
| 154 |
CTaskHandleMemoryAllocationManager* mUsedTempMemMan; |
| 155 |
|
| 156 |
// protected methods |
| 157 |
protected: |
| 158 |
|
| 159 |
// protected variables |
| 160 |
protected: |
| 161 |
CMemoryAllocationManager* mUsedPrTaskMemMan; |
| 162 |
CProcessTagger* mUsedProcessTagger; |
| 163 |
CProcessContext* mUsedProcessContext; |
| 164 |
CConceptProcessingPriorityStrategy* mUsedConceptPriorityStrategy; |
| 165 |
CIndividualProcessingPriorityStrategy* mUsedIndividualPriorityStrategy; |
| 166 |
CProcessingDataBox* mUsedProcessingDataBox; |
| 167 |
CSatisfiableCalculationTask* mUsedSatCalcTask; |
| 168 |
CTaskProcessorContext* mUsedTaskProcessorContext; |
| 169 |
CTaskProcessingPriorityStrategy* mUsedTaskPriorityStrategy; |
| 170 |
CProcessingStatisticGathering* mUsedProcessStatGath; |
| 171 |
CBranchTreeNode* mUsedBranchTreeNode; |
| 172 |
CDependencyNode* mUsedBaseDepNode; |
| 173 |
cint64 mMinModificationAncestorDepth; |
| 174 |
cint64 mMinModificationIndividualID; |
| 175 |
bool mMinModificationUpdated; |
| 176 |
CUnsatisfiableCacheHandler* mUsedUnsatCacheHandler; |
| 177 |
CIndividualNodeManager* mUsedIndividualNodeManager; |
| 178 |
CClashDescriptorFactory* mUsedClashDescriptorFactory; |
| 179 |
CUnsatisfiableCacheRetrievalStrategy* mUsedUnsatCachRetStrategy; |
| 180 |
CDependencyFactory* mUsedDepFactory; |
| 181 |
CSatisfiableExpanderCacheHandler* mUsedSatExpCacheHandler; |
| 182 |
cint64 mMaxCompletionGraphCachedIndiNodeID; |
| 183 |
CIndividualProcessNode* mCurrentIndiNode; |
| 184 |
cint64 mCompletionGraphCachedLocalizationTag; |
| 185 |
CSaturationNodeExpansionCacheHandler* mUsedSatNodeExpCacheHandler; |
| 186 |
|
| 187 |
|
| 188 |
// private methods |
| 189 |
private: |
| 190 |
|
| 191 |
// private variables |
| 192 |
private: |
| 193 |
|
| 194 |
}; |
| 195 |
|
| 196 |
|
| 197 |
CProcessTagger* CCalculationAlgorithmContext::getUsedProcessTagger() { |
| 198 |
return mUsedProcessTagger; |
| 199 |
} |
| 200 |
|
| 201 |
CProcessContext* CCalculationAlgorithmContext::getUsedProcessContext() { |
| 202 |
return mUsedProcessContext; |
| 203 |
} |
| 204 |
|
| 205 |
CMemoryAllocationManager* CCalculationAlgorithmContext::getUsedProcessTaskMemoryAllocationManager() { |
| 206 |
return mUsedPrTaskMemMan; |
| 207 |
} |
| 208 |
|
| 209 |
CTaskHandleMemoryAllocationManager* CCalculationAlgorithmContext::getUsedTemporaryMemoryAllocationManager() { |
| 210 |
return mUsedTempMemMan; |
| 211 |
} |
| 212 |
|
| 213 |
CConceptProcessingPriorityStrategy* CCalculationAlgorithmContext::getUsedConceptPriorityStrategy() { |
| 214 |
return mUsedConceptPriorityStrategy; |
| 215 |
} |
| 216 |
|
| 217 |
CIndividualProcessingPriorityStrategy* CCalculationAlgorithmContext::getUsedIndividualPriorityStrategy() { |
| 218 |
return mUsedIndividualPriorityStrategy; |
| 219 |
} |
| 220 |
|
| 221 |
CProcessingDataBox* CCalculationAlgorithmContext::getUsedProcessingDataBox() { |
| 222 |
return mUsedProcessingDataBox; |
| 223 |
} |
| 224 |
|
| 225 |
CSatisfiableCalculationTask* CCalculationAlgorithmContext::getUsedSatisfiableCalculationTask() { |
| 226 |
return mUsedSatCalcTask; |
| 227 |
} |
| 228 |
|
| 229 |
CTaskProcessorContext* CCalculationAlgorithmContext::getUsedTaskProcessorContext() { |
| 230 |
return mUsedTaskProcessorContext; |
| 231 |
} |
| 232 |
|
| 233 |
CTaskProcessingPriorityStrategy* CCalculationAlgorithmContext::getUsedTaskPriorityStrategy() { |
| 234 |
return mUsedTaskPriorityStrategy; |
| 235 |
} |
| 236 |
|
| 237 |
CProcessingStatisticGathering* CCalculationAlgorithmContext::getUsedProcessingStatisticsGathering() { |
| 238 |
return mUsedProcessStatGath; |
| 239 |
} |
| 240 |
|
| 241 |
CBranchTreeNode* CCalculationAlgorithmContext::getUsedBranchTreeNode() { |
| 242 |
return mUsedBranchTreeNode; |
| 243 |
} |
| 244 |
|
| 245 |
CDependencyNode* CCalculationAlgorithmContext::getUsedBaseDependencyNode() { |
| 246 |
return mUsedBaseDepNode; |
| 247 |
} |
| 248 |
|
| 249 |
|
| 250 |
bool CCalculationAlgorithmContext::setMinModificationAncestorDepthCandidate(cint64 ancDepthCandidate) { |
| 251 |
bool updated = ancDepthCandidate < mMinModificationIndividualID; |
| 252 |
mMinModificationIndividualID = qMin(ancDepthCandidate,mMinModificationIndividualID); |
| 253 |
return updated; |
| 254 |
} |
| 255 |
|
| 256 |
bool CCalculationAlgorithmContext::setMinModificationIndividualIDCandidate(cint64 indiIDCandidate) { |
| 257 |
bool updated = indiIDCandidate < mMinModificationIndividualID; |
| 258 |
mMinModificationIndividualID = qMin(indiIDCandidate,mMinModificationIndividualID); |
| 259 |
return updated; |
| 260 |
} |
| 261 |
|
| 262 |
bool CCalculationAlgorithmContext::setMinModificationIndividualCandidate(CIndividualProcessNode* indiNode) { |
| 263 |
return setMinModificationIndividualIDCandidate(indiNode->getIndividualNodeID()) || setMinModificationAncestorDepthCandidate(indiNode->getIndividualAncestorDepth()); |
| 264 |
} |
| 265 |
|
| 266 |
CUnsatisfiableCacheHandler* CCalculationAlgorithmContext::getUsedUnsatisfiableCacheHandler() { |
| 267 |
return mUsedUnsatCacheHandler; |
| 268 |
} |
| 269 |
|
| 270 |
CIndividualNodeManager* CCalculationAlgorithmContext::getUsedIndividualNodeManager() { |
| 271 |
return mUsedIndividualNodeManager; |
| 272 |
} |
| 273 |
|
| 274 |
CClashDescriptorFactory* CCalculationAlgorithmContext::getUsedClashDescriptorFactory() { |
| 275 |
return mUsedClashDescriptorFactory; |
| 276 |
} |
| 277 |
|
| 278 |
CUnsatisfiableCacheRetrievalStrategy* CCalculationAlgorithmContext::getUsedUnsatisfiableCacheRetrievalStrategy() { |
| 279 |
return mUsedUnsatCachRetStrategy; |
| 280 |
} |
| 281 |
|
| 282 |
CDependencyFactory* CCalculationAlgorithmContext::getUsedDependencyFactory() { |
| 283 |
return mUsedDepFactory; |
| 284 |
} |
| 285 |
|
| 286 |
CSatisfiableExpanderCacheHandler* CCalculationAlgorithmContext::getUsedSatisfiableExpanderCacheHandler() { |
| 287 |
return mUsedSatExpCacheHandler; |
| 288 |
} |
| 289 |
|
| 290 |
CSaturationNodeExpansionCacheHandler* CCalculationAlgorithmContext::getUsedSaturationNodeExpansionCacheHandler() { |
| 291 |
return mUsedSatNodeExpCacheHandler; |
| 292 |
} |
| 293 |
|
| 294 |
}; // end namespace Algorithm |
| 295 |
|
| 296 |
}; // end namespace Kernel |
| 297 |
|
| 298 |
}; // end namespace Reasoner |
| 299 |
|
| 300 |
}; // end namespace Konclude |
| 301 |
|
| 302 |
#endif // KONCLUDE_REASONER_KERNEL_ALGORITHM_CCALCULATIONALGORITHMCONTEXT_H |