| 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 "CSatisfiableCalculationJobGenerator.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Generator { |
| 29 |
|
| 30 |
|
| 31 |
CSatisfiableCalculationJobGenerator::CSatisfiableCalculationJobGenerator(CConcreteOntology *ontology) { |
| 32 |
mOntology = ontology; |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
CSatisfiableCalculationJobGenerator::~CSatisfiableCalculationJobGenerator() { |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
CSatisfiableCalculationJob* CSatisfiableCalculationJobGenerator::getSatisfiableCalculationJob(CConcept* concept, bool negation, CIndividual* individual, CSatisfiableCalculationJob* satCalcJob) { |
| 42 |
return getSatisfiableCalculationJob(concept, negation,CIndividualReference(individual),satCalcJob); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
CSatisfiableCalculationJob* CSatisfiableCalculationJobGenerator::getSatisfiableCalculationJob(CConcept* concept, bool negation, const CIndividualReference& indiRef, CSatisfiableCalculationJob* satCalcJob) { |
| 47 |
return getSatisfiableCalculationJob(QList< QPair<CConcept*, bool> >() << QPair<CConcept*, bool>(concept, negation), indiRef, satCalcJob); |
| 48 |
} |
| 49 |
|
| 50 |
CSatisfiableCalculationJob* CSatisfiableCalculationJobGenerator::getSatisfiableCalculationJob(CConcept* concept1, bool negation1, CConcept* concept2, bool negation2, CIndividual* individual, CSatisfiableCalculationJob* satCalcJob) { |
| 51 |
return getSatisfiableCalculationJob(QList< QPair<CConcept*,bool> >()<<QPair<CConcept*,bool>(concept1,negation1)<<QPair<CConcept*,bool>(concept2,negation2),individual,satCalcJob); |
| 52 |
} |
| 53 |
|
| 54 |
CSatisfiableCalculationJob* CSatisfiableCalculationJobGenerator::getSatisfiableCalculationJob(const QList<CConcept*>& conceptList, CIndividual* individual, CSatisfiableCalculationJob* satCalcJob) { |
| 55 |
QList< QPair<CConcept*,bool> > conNegList; |
| 56 |
FOREACHIT (CConcept* concept, conceptList) { |
| 57 |
conNegList.append(QPair<CConcept*,bool>(concept,false)); |
| 58 |
} |
| 59 |
return getSatisfiableCalculationJob(conNegList,individual,satCalcJob); |
| 60 |
} |
| 61 |
|
| 62 |
CSatisfiableCalculationJob* CSatisfiableCalculationJobGenerator::getSatisfiableCalculationJob(const QList< QPair<CConcept*, bool> >& conceptNegationList, CIndividual* individual, CSatisfiableCalculationJob* satCalcJob) { |
| 63 |
return getSatisfiableCalculationJob(conceptNegationList, CIndividualReference(individual), satCalcJob); |
| 64 |
} |
| 65 |
|
| 66 |
CSatisfiableCalculationJob* CSatisfiableCalculationJobGenerator::getSatisfiableCalculationJob(const QList< QPair<CConcept*,bool> >& conceptNegationList, const CIndividualReference& indiRef, CSatisfiableCalculationJob* satCalcJob) { |
| 67 |
if (!satCalcJob) { |
| 68 |
satCalcJob = new CSatisfiableCalculationJob(); |
| 69 |
} |
| 70 |
satCalcJob->setOntology(mOntology); |
| 71 |
CSatisfiableCalculationConceptConstruct* satCalcConstruct = new CSatisfiableCalculationConceptConstruct(); |
| 72 |
|
| 73 |
for (QList< QPair<CConcept*,bool> >::const_iterator it = conceptNegationList.constBegin(), itEnd = conceptNegationList.constEnd(); it != itEnd; ++it) { |
| 74 |
CConcept* concept = it->first; |
| 75 |
bool negation = it->second; |
| 76 |
|
| 77 |
CXSortedNegLinker<CConcept*>* conNegLinker = new CXSortedNegLinker<CConcept*>(concept,negation); |
| 78 |
satCalcConstruct->addConstructConceptLinker(conNegLinker); |
| 79 |
} |
| 80 |
|
| 81 |
if (indiRef.isNonEmpty()) { |
| 82 |
if (indiRef.getIndividual()) { |
| 83 |
satCalcConstruct->setIndividual(indiRef.getIndividual()); |
| 84 |
} else { |
| 85 |
satCalcConstruct->setIndividualID(indiRef.getIndividualID()); |
| 86 |
} |
| 87 |
} else { |
| 88 |
satCalcConstruct->setRelativeNewNodeID(satCalcJob->getNextRelativeNodeID()); |
| 89 |
} |
| 90 |
satCalcJob->addSatisfiableCalculationConstruct(satCalcConstruct); |
| 91 |
return satCalcJob; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
CSatisfiableCalculationJob* CSatisfiableCalculationJobGenerator::getSatisfiableCalculationJob(const QList< CIndividual* >& indiList, CSatisfiableCalculationJob* satCalcJob) { |
| 97 |
if (!satCalcJob) { |
| 98 |
satCalcJob = new CSatisfiableCalculationJob(); |
| 99 |
} |
| 100 |
satCalcJob->setOntology(mOntology); |
| 101 |
for (QList< CIndividual* >::const_iterator it = indiList.constBegin(), itEnd = indiList.constEnd(); it != itEnd; ++it) { |
| 102 |
CIndividual* individual = (*it); |
| 103 |
CSatisfiableCalculationConceptConstruct* satCalcConstruct = new CSatisfiableCalculationConceptConstruct(); |
| 104 |
if (individual) { |
| 105 |
satCalcConstruct->setIndividual(individual); |
| 106 |
} else { |
| 107 |
satCalcConstruct->setRelativeNewNodeID(satCalcJob->getNextRelativeNodeID()); |
| 108 |
} |
| 109 |
satCalcJob->addSatisfiableCalculationConstruct(satCalcConstruct); |
| 110 |
} |
| 111 |
return satCalcJob; |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
CSatisfiableCalculationJob* CSatisfiableCalculationJobGenerator::getSatisfiableCalculationJob(const QList<CIndividualReference>& indiList, CSatisfiableCalculationJob* satCalcJob) { |
| 116 |
if (!satCalcJob) { |
| 117 |
satCalcJob = new CSatisfiableCalculationJob(); |
| 118 |
} |
| 119 |
satCalcJob->setOntology(mOntology); |
| 120 |
for (QList<CIndividualReference>::const_iterator it = indiList.constBegin(), itEnd = indiList.constEnd(); it != itEnd; ++it) { |
| 121 |
CIndividualReference individualReference = (*it); |
| 122 |
CSatisfiableCalculationConceptConstruct* satCalcConstruct = new CSatisfiableCalculationConceptConstruct(); |
| 123 |
if (individualReference.isNonEmpty()) { |
| 124 |
if (individualReference.getIndividual()) { |
| 125 |
satCalcConstruct->setIndividual(individualReference.getIndividual()); |
| 126 |
} else { |
| 127 |
satCalcConstruct->setIndividualID(individualReference.getIndividualID()); |
| 128 |
} |
| 129 |
} |
| 130 |
satCalcJob->addSatisfiableCalculationConstruct(satCalcConstruct); |
| 131 |
} |
| 132 |
return satCalcJob; |
| 133 |
} |
| 134 |
|
| 135 |
}; // end namespace Generator |
| 136 |
|
| 137 |
}; // end namespace Reasoner |
| 138 |
|
| 139 |
}; // end namespace Konclude |