| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester |
| 3 | Copyright (C) 2015-2017 Dmitry Tsarkov |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <iomanip> |
| 21 | |
| 22 | #include "Reasoner.h"cxx . . $ `<file>/Kernel/Reasoner.h`/ |
| 23 | #include "logging.h"cxx . . $ `<file>/Kernel/logging.h`/ |
| 24 | #include "eFPPTimeout.h"cxx . . $ `<file>/Kernel/eFPPTimeout.h`/ |
| 25 | |
| 26 | // comment the line out for printing tree info before save and after restoring |
| 27 | //#define __DEBUG_SAVE_RESTORE |
| 28 | // comment the line out for flushing LL after dumping significant piece of info |
| 29 | //#define __DEBUG_FLUSH_LL |
| 30 | |
| 31 | #ifdef USE_REASONING_STATISTICS |
| 32 | AccumulatedStatistic* AccumulatedStatistic::root = nullptr; |
| 33 | #endif |
| 34 | |
| 35 | DlSatTestercxx . . $ DlSatTester# :: DlSatTestercxx . . $ DlSatTester#DlSatTester(8683a8a7d2fb73f). ( TBoxcxx . . $ TBox#& tbox ) |
| 36 | : tBoxcxx . . $ DlSatTester#tBox.(tbox) |
| 37 | , DLHeapcxx . . $ DlSatTester#DLHeap.(tbox.DLHeapcxx . . $ TBox#DLHeap.) |
| 38 | , Managercxx . . $ DlSatTester#Manager.(64) |
| 39 | , CGraphcxx . . $ DlSatTester#CGraph.(1,this) |
| 40 | , TODOcxx . . $ DlSatTester#TODO.(tBoxcxx . . $ DlSatTester#tBox..PriorityMatrixcxx . . $ TBox#PriorityMatrix.,CGraphcxx . . $ DlSatTester#CGraph..getRareStackcxx . . $ DlCompletionGraph#getRareStack(f4029463feb83669).()) |
| 41 | , DTReasonercxx . . $ DlSatTester#DTReasoner.(tbox.DLHeapcxx . . $ TBox#DLHeap.) |
| 42 | // It's unsafe to have a cache that touches a nominal in a node; set flagNominals to prevent it |
| 43 | , newNodeCachecxx . . $ DlSatTester#newNodeCache. ( true, tBoxcxx . . $ DlSatTester#tBox..nCcxx . . $ TBox#nC., tBoxcxx . . $ DlSatTester#tBox..nRcxx . . $ TBox#nR. ) |
| 44 | , newNodeEdgescxx . . $ DlSatTester#newNodeEdges. ( false, tBoxcxx . . $ DlSatTester#tBox..nCcxx . . $ TBox#nC., tBoxcxx . . $ DlSatTester#tBox..nRcxx . . $ TBox#nR. ) |
| 45 | , GCIscxx . . $ DlSatTester#GCIs.(tbox.GCIscxx . . $ TBox#GCIs.) |
| 46 | { |
| 47 | // init static part of CTree |
| 48 | CGraphcxx . . $ DlSatTester#CGraph..initContextcxx . . $ DlCompletionGraph#initContext(d06ec138c316ab3d). ( tBoxcxx . . $ DlSatTester#tBox..nSkipBeforeBlockcxx . . $ TBox#nSkipBeforeBlock., tBoxcxx . . $ DlSatTester#tBox..useLazyBlockingcxx . . $ TBox#useLazyBlocking., tBoxcxx . . $ DlSatTester#tBox..useAnywhereBlockingcxx . . $ TBox#useAnywhereBlocking. ); |
| 49 | // init datatype reasoner |
| 50 | tBoxcxx . . $ DlSatTester#tBox..getDataTypeCentercxx . . $ TBox#getDataTypeCenter(dd641241804ece05).().initDataTypeReasonercxx . . $ DataTypeCenter#initDataTypeReasoner(2eaf9760777a0523).(DTReasonercxx . . $ DlSatTester#DTReasoner.); |
| 51 | // init set of reflexive roles |
| 52 | tBoxcxx . . $ DlSatTester#tBox..getORMcxx . . $ TBox#getORM(94330852db6e789a).().fillReflexiveRolescxx . . $ RoleMaster#fillReflexiveRoles(da57d95ee989ac99).(ReflexiveRolescxx . . $ DlSatTester#ReflexiveRoles.); |
| 53 | // init blocking statistics |
| 54 | clearBlockingStatcxx . . $ `Kernel/dlCompletionTree.h:49:10`!(); |
| 55 | |
| 56 | resetSessionFlagscxx . . $ DlSatTester#resetSessionFlags(49f6e7a06ebc5aa8).(); |
| 57 | } |
| 58 | |
| 59 | /// prepare Nominal Reasoner to a new job |
| 60 | void |
| 61 | DlSatTestercxx . . $ DlSatTester# :: prepareReasonercxx . . $ DlSatTester#prepareReasoner(49f6e7a06ebc5aa8). ( void ) |
| 62 | { |
| 63 | CGraphcxx . . $ DlSatTester#CGraph..clearcxx . . $ DlCompletionGraph#clear(49f6e7a06ebc5aa8).(); |
| 64 | Stackcxx . . $ DlSatTester#Stack..clearcxx . . $ DlSatTester#BCStack#clear(49f6e7a06ebc5aa8).(); |
| 65 | TODOcxx . . $ DlSatTester#TODO..clearcxx . . $ ToDoList#clear(49f6e7a06ebc5aa8).(); |
| 66 | |
| 67 | pUsedcxx . . $ DlSatTester#pUsed..clearcxx . . $ TFastSet#clear(49f6e7a06ebc5aa8).(); |
| 68 | nUsedcxx . . $ DlSatTester#nUsed..clearcxx . . $ TFastSet#clear(49f6e7a06ebc5aa8).(); |
| 69 | SessionGCIscxx . . $ DlSatTester#SessionGCIs..clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).(); |
| 70 | |
| 71 | curNodecxx . . $ DlSatTester#curNode. = nullptr; |
| 72 | bContextcxx . . $ DlSatTester#bContext. = nullptr; |
| 73 | tryLevelcxx . . $ DlSatTester#tryLevel. = InitBranchingLevelValuecxx . . $ InitBranchingLevelValue.; |
| 74 | |
| 75 | // clear last session information |
| 76 | resetSessionFlagscxx . . $ DlSatTester#resetSessionFlags(49f6e7a06ebc5aa8).(); |
| 77 | } |
| 78 | |
| 79 | bool |
| 80 | DlSatTestercxx . . $ DlSatTester# :: findConceptcxx . . $ DlSatTester#findConcept(887bff1c1e5f863e). ( const CWDArraycxx . . $ CWDArray#& lab, BipolarPointercxx . . $ BipolarPointer# p ) |
| 81 | { |
| 82 | #ifdef ENABLE_CHECKING |
| 83 | fpp_assert ( isCorrect(p) ); // sanity checking |
| 84 | // constants are not allowed here |
| 85 | fpp_assert ( p != bpTOP ); |
| 86 | fpp_assert ( p != bpBOTTOM ); |
| 87 | #endif |
| 88 | |
| 89 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nLookups); |
| 90 | return lab.containscxx . . $ CWDArray#contains(4a668f6de69bf818).(p); |
| 91 | } |
| 92 | |
| 93 | bool |
| 94 | DlSatTestercxx . . $ DlSatTester# :: findConceptClashcxx . . $ DlSatTester#findConceptClash(770c5e45e3d3d307). ( const CWDArraycxx . . $ CWDArray#& lab, BipolarPointercxx . . $ BipolarPointer# p, const DepSetcxx . . $ DepSet#& dep ) |
| 95 | { |
| 96 | #ifdef ENABLE_CHECKING |
| 97 | fpp_assert ( isCorrect(p) ); // sanity checking |
| 98 | // constants are not allowed here |
| 99 | fpp_assert ( p != bpTOP ); |
| 100 | fpp_assert ( p != bpBOTTOM ); |
| 101 | #endif |
| 102 | |
| 103 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nLookups); |
| 104 | |
| 105 | for ( const auto& C: lab ) |
| 106 | if ( C.bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).() == p ) |
| 107 | { |
| 108 | // create clashSet |
| 109 | clashSetcxx . . $ DlSatTester#clashSet. =cxx . . $ TDepSet#`operator=`(6a948e2ed08fa462). C.getDepcxx . . $ ConceptWDep#getDep(bce6462a16d96b29).(); |
| 110 | clashSetcxx . . $ DlSatTester#clashSet..addcxx . . $ TDepSet#add(d0e32107376501c0).(dep); |
| 111 | return true; |
| 112 | } |
| 113 | |
| 114 | // we are able to insert a concept |
| 115 | return false; |
| 116 | } |
| 117 | |
| 118 | addConceptResultcxx . . $ addConceptResult# |
| 119 | DlSatTestercxx . . $ DlSatTester# :: checkAddedConceptcxx . . $ DlSatTester#checkAddedConcept(64ab7a30545240e0). ( const CWDArraycxx . . $ CWDArray#& lab, BipolarPointercxx . . $ BipolarPointer# p, const DepSetcxx . . $ DepSet#& dep ) |
| 120 | { |
| 121 | #ifdef ENABLE_CHECKING |
| 122 | fpp_assert ( isCorrect(p) ); // sanity checking |
| 123 | // constants are not allowed here |
| 124 | fpp_assert ( p != bpTOP ); |
| 125 | fpp_assert ( p != bpBOTTOM ); |
| 126 | #endif |
| 127 | |
| 128 | if ( findConceptcxx . . $ DlSatTester#findConcept(887bff1c1e5f863e). ( lab, p ) ) |
| 129 | return acrExistcxx . . $ acrExist.; |
| 130 | |
| 131 | if ( findConceptClashcxx . . $ DlSatTester#findConceptClash(770c5e45e3d3d307). ( lab, inversecxx . . $ inverse(7864480464b09eea).(p), dep ) ) |
| 132 | return acrClashcxx . . $ acrClash.; |
| 133 | |
| 134 | // we are able to insert a concept |
| 135 | return acrDonecxx . . $ acrDone.; |
| 136 | } |
| 137 | |
| 138 | addConceptResultcxx . . $ addConceptResult# |
| 139 | DlSatTestercxx . . $ DlSatTester# :: tryAddConceptcxx . . $ DlSatTester#tryAddConcept(64ab7a30545240e0). ( const CWDArraycxx . . $ CWDArray#& lab, BipolarPointercxx . . $ BipolarPointer# bp, const DepSetcxx . . $ DepSet#& dep ) |
| 140 | { |
| 141 | // check whether C or ~C can occurs in a node label |
| 142 | const BipolarPointercxx . . $ BipolarPointer# inv_p = inversecxx . . $ inverse(7864480464b09eea).(bp); |
| 143 | bool canC = isUsedcxx . . $ DlSatTester#isUsed(4a668f6de69bf818).(bp); |
| 144 | bool canNegC = isUsedcxx . . $ DlSatTester#isUsed(4a668f6de69bf818).(inv_p); |
| 145 | |
| 146 | // if either C or ~C is used already, it's not new in a label |
| 147 | if ( canC ) |
| 148 | { |
| 149 | if ( canNegC ) // both C and ~C can be in the label |
| 150 | return checkAddedConceptcxx . . $ DlSatTester#checkAddedConcept(64ab7a30545240e0). ( lab, bp, dep ); |
| 151 | else // C but not ~C can be in the label |
| 152 | return findConceptcxx . . $ DlSatTester#findConcept(887bff1c1e5f863e). ( lab, bp ) ? acrExistcxx . . $ acrExist. : acrDonecxx . . $ acrDone.; |
| 153 | } |
| 154 | else |
| 155 | { |
| 156 | if ( canNegC ) // ~C but not C can be in the label |
| 157 | return findConceptClashcxx . . $ DlSatTester#findConceptClash(770c5e45e3d3d307). ( lab, inv_p, dep ) ? acrClashcxx . . $ acrClash. : acrDonecxx . . $ acrDone.; |
| 158 | else // neither C nor ~C can be in the label |
| 159 | return acrDonecxx . . $ acrDone.; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | bool |
| 164 | DlSatTestercxx . . $ DlSatTester# :: addToDoEntrycxx . . $ DlSatTester#addToDoEntry(14ef716f111d87ae). ( DlCompletionTreecxx . . $ DlCompletionTree#* node, const ConceptWDepcxx . . $ ConceptWDep#& C, const char* reason ) |
| 165 | { |
| 166 | if ( C ==cxx . . $ ConceptWDep#`operator==`(4a668f6de69bf818). bpTOPcxx . . $ bpTOP. ) // simplest things first |
| 167 | return false; |
| 168 | if ( C ==cxx . . $ ConceptWDep#`operator==`(4a668f6de69bf818). bpBOTTOMcxx . . $ bpBOTTOM. ) |
| 169 | { |
| 170 | setClashSetcxx . . $ DlSatTester#setClashSet(d0e32107376501c0).(C.getDepcxx . . $ ConceptWDep#getDep(bce6462a16d96b29).()); |
| 171 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 172 | logClashcxx . . $ DlSatTester#logClash(a520327312b37f83). ( node, C ); |
| 173 | return true; |
| 174 | } |
| 175 | |
| 176 | const DLVertexcxx . . $ DLVertex#& v = DLHeapcxx . . $ DlSatTester#DLHeap.[cxx . . $ DLDag#`operator[]`(b4043884e5934906).C]; |
| 177 | DagTagcxx . . $ DagTag# tag = v.Typecxx . . $ DLVertexTagDFS#Type(d9c59f5f195b46b8).(); |
| 178 | |
| 179 | // try to add a concept to a node label |
| 180 | switch ( tryAddConceptcxx . . $ DlSatTester#tryAddConcept(64ab7a30545240e0). ( node->labelcxx . . $ DlCompletionTree#label(d7a009c437cd4657).().getLabelcxx . . $ CGLabel#getLabel(f501173caf11fe67).(tag), C.bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).(), C.getDepcxx . . $ ConceptWDep#getDep(bce6462a16d96b29).() ) ) |
| 181 | { |
| 182 | case acrClashcxx . . $ acrClash.: // clash -- return |
| 183 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 184 | logClashcxx . . $ DlSatTester#logClash(a520327312b37f83). ( node, C ); |
| 185 | return true; |
| 186 | case acrExistcxx . . $ acrExist.: // already exists -- nothing new |
| 187 | return false; |
| 188 | case acrDonecxx . . $ acrDone.: // try was done |
| 189 | return insertToDoEntrycxx . . $ DlSatTester#insertToDoEntry(47bd769b3ba2342c). ( node, C, tag, reason ); |
| 190 | default: // safety check |
| 191 | fpp_unreachablecxx . . $ `Kernel/fpp_assert.h:49:9`!(); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | /// insert P to the label of N; do necessary updates; may return Clash in case of data node N |
| 196 | bool |
| 197 | DlSatTestercxx . . $ DlSatTester# :: insertToDoEntrycxx . . $ DlSatTester#insertToDoEntry(47bd769b3ba2342c). ( DlCompletionTreecxx . . $ DlCompletionTree#* node, const ConceptWDepcxx . . $ ConceptWDep#& C, |
| 198 | DagTagcxx . . $ DagTag# tag, const char* reason = nullptr ) |
| 199 | { |
| 200 | // we will change current Node => save it if necessary |
| 201 | updateLevelcxx . . $ DlSatTester#updateLevel(745f507b4f58d579). ( node, C.getDepcxx . . $ ConceptWDep#getDep(bce6462a16d96b29).() ); |
| 202 | CGraphcxx . . $ DlSatTester#CGraph..addConceptToNodecxx . . $ DlCompletionGraph#addConceptToNode(df4560871dbcb770). ( node, C, CGLabelcxx . . $ CGLabel#::isComplexConceptcxx . . $ CGLabel#isComplexConcept(7b512e7165d9f2af).(tag) ); |
| 203 | |
| 204 | auto bp = C.bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).(); |
| 205 | setUsedcxx . . $ DlSatTester#setUsed(d4f767463ce0a6b3).(bp); |
| 206 | |
| 207 | if ( node->isCachedcxx . . $ DlCompletionTree#isCached(50ce9a9e25b4a850).() ) |
| 208 | return correctCachedEntrycxx . . $ DlSatTester#correctCachedEntry(4899fbe844c80f28).(node); |
| 209 | |
| 210 | // add new info in TODO list |
| 211 | TODOcxx . . $ DlSatTester#TODO..addEntrycxx . . $ ToDoList#addEntry(554b0186d7b682ae). ( node, tag, bp ); |
| 212 | |
| 213 | if ( node->isDataNodecxx . . $ DlCompletionTree#isDataNode(50ce9a9e25b4a850).() ) // data concept -- run data center for it |
| 214 | return checkDataNodecxx . . $ DlSatTester#checkDataNode. ? checkDataClashcxx . . $ DlSatTester#checkDataClash(6c1e73ffdfd78b24).(node) : false; |
| 215 | else if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) // inform about it |
| 216 | logEntrycxx . . $ DlSatTester#logEntry(d13ce3616f4e8cf5). ( node, C, reason ); |
| 217 | |
| 218 | return false; |
| 219 | } |
| 220 | |
| 221 | //----------------------------------------------------------------------------- |
| 222 | //-- internal cache support |
| 223 | //----------------------------------------------------------------------------- |
| 224 | |
| 225 | bool |
| 226 | DlSatTestercxx . . $ DlSatTester# :: canBeCachedcxx . . $ DlSatTester#canBeCached(4899fbe844c80f28). ( DlCompletionTreecxx . . $ DlCompletionTree#* node ) |
| 227 | { |
| 228 | DlCompletionTreecxx . . $ DlCompletionTree#::const_label_iteratorcxx . . $ DlCompletionTree#const_label_iterator# pcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(49f6e7a06ebc5aa8).; |
| 229 | bool shallow = true; |
| 230 | unsigned int size = 0; |
| 231 | |
| 232 | // check whether node cache is allowed |
| 233 | if ( unlikelycxx . . $ `Kernel/globaldef.h:29:10`!(!tBox.useNodeCache) ) |
| 234 | return false; |
| 235 | |
| 236 | // nominal nodes can not be cached |
| 237 | if ( unlikelycxx . . $ `Kernel/globaldef.h:29:10`!(node->isNominalNode()) ) |
| 238 | return false; |
| 239 | |
| 240 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nCacheTry); |
| 241 | |
| 242 | // check applicability of the caching |
| 243 | for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(8a166801ba8fe87b). node->beginl_sccxx . . $ DlCompletionTree#beginl_sc(e55d760a93e9f197).(); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). node->endl_sccxx . . $ DlCompletionTree#endl_sc(e55d760a93e9f197).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 244 | { |
| 245 | if ( DLHeapcxx . . $ DlSatTester#DLHeap..getCachecxx . . $ DLDag#getCache(a400da756ae1652b).(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).()) == nullptr ) |
| 246 | { |
| 247 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nCacheFailedNoCache); |
| 248 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 249 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " cf(" <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")"; |
| 250 | return false; |
| 251 | } |
| 252 | |
| 253 | shallow &= DLHeapcxx . . $ DlSatTester#DLHeap..getCachecxx . . $ DLDag#getCache(a400da756ae1652b).(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).())->shallowCachecxx . . $ modelCacheInterface#shallowCache(50ce9a9e25b4a850).(); |
| 254 | ++size; |
| 255 | } |
| 256 | |
| 257 | for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(8a166801ba8fe87b). node->beginl_cccxx . . $ DlCompletionTree#beginl_cc(e55d760a93e9f197).(); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). node->endl_cccxx . . $ DlCompletionTree#endl_cc(e55d760a93e9f197).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 258 | { |
| 259 | if ( DLHeapcxx . . $ DlSatTester#DLHeap..getCachecxx . . $ DLDag#getCache(a400da756ae1652b).(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).()) == nullptr ) |
| 260 | { |
| 261 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nCacheFailedNoCache); |
| 262 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 263 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " cf(" <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")"; |
| 264 | return false; |
| 265 | } |
| 266 | |
| 267 | shallow &= DLHeapcxx . . $ DlSatTester#DLHeap..getCachecxx . . $ DLDag#getCache(a400da756ae1652b).(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).())->shallowCachecxx . . $ modelCacheInterface#shallowCache(50ce9a9e25b4a850).(); |
| 268 | ++size; |
| 269 | } |
| 270 | |
| 271 | // it's useless to cache shallow nodes |
| 272 | if ( shallow && size != 0 ) |
| 273 | { |
| 274 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nCacheFailedShallow); |
| 275 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 276 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " cf(s)"; |
| 277 | return false; |
| 278 | } |
| 279 | |
| 280 | return true; |
| 281 | } |
| 282 | |
| 283 | /// perform caching of the node (it is known that caching is possible) |
| 284 | void |
| 285 | DlSatTestercxx . . $ DlSatTester# :: doCacheNodecxx . . $ DlSatTester#doCacheNode(3bf754c9a531d7e6). ( DlCompletionTreecxx . . $ DlCompletionTree#* node ) |
| 286 | { |
| 287 | DlCompletionTreecxx . . $ DlCompletionTree#::const_label_iteratorcxx . . $ DlCompletionTree#const_label_iterator# pcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(49f6e7a06ebc5aa8).; |
| 288 | DepSetcxx . . $ DepSet# depcxx . . $ TDepSet#TDepSet(49f6e7a06ebc5aa8).; |
| 289 | |
| 290 | newNodeCachecxx . . $ DlSatTester#newNodeCache..clearcxx . . $ modelCacheIan#clear(49f6e7a06ebc5aa8).(); |
| 291 | |
| 292 | for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(8a166801ba8fe87b). node->beginl_sccxx . . $ DlCompletionTree#beginl_sc(e55d760a93e9f197).(); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). node->endl_sccxx . . $ DlCompletionTree#endl_sc(e55d760a93e9f197).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 293 | { |
| 294 | dep.addcxx . . $ TDepSet#add(d0e32107376501c0).(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).getDepcxx . . $ ConceptWDep#getDep(bce6462a16d96b29).()); |
| 295 | // try to merge cache of a node label element with accumulator |
| 296 | switch ( newNodeCachecxx . . $ DlSatTester#newNodeCache..mergecxx . . $ modelCacheIan#merge(3c316d00313db7eb).(DLHeapcxx . . $ DlSatTester#DLHeap..getCachecxx . . $ DLDag#getCache(a400da756ae1652b).(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).())) ) |
| 297 | { |
| 298 | case csValidcxx . . $ csValid.: // continue |
| 299 | break; |
| 300 | case csInvalidcxx . . $ csInvalid.: // clash: set the clash-set |
| 301 | setClashSetcxx . . $ DlSatTester#setClashSet(d0e32107376501c0).(dep); |
| 302 | // fall through |
| 303 | default: // caching of node fails |
| 304 | return; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | for ( p =cxx . . $ __gnu_cxx/__normal_iterator#`operator=`(8a166801ba8fe87b). node->beginl_cccxx . . $ DlCompletionTree#beginl_cc(e55d760a93e9f197).(); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). node->endl_cccxx . . $ DlCompletionTree#endl_cc(e55d760a93e9f197).(); ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 309 | { |
| 310 | dep.addcxx . . $ TDepSet#add(d0e32107376501c0).(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).getDepcxx . . $ ConceptWDep#getDep(bce6462a16d96b29).()); |
| 311 | // try to merge cache of a node label element with accumulator |
| 312 | switch ( newNodeCachecxx . . $ DlSatTester#newNodeCache..mergecxx . . $ modelCacheIan#merge(3c316d00313db7eb).(DLHeapcxx . . $ DlSatTester#DLHeap..getCachecxx . . $ DLDag#getCache(a400da756ae1652b).(p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).())) ) |
| 313 | { |
| 314 | case csValidcxx . . $ csValid.: // continue |
| 315 | break; |
| 316 | case csInvalidcxx . . $ csInvalid.: // clash: set the clash-set |
| 317 | setClashSetcxx . . $ DlSatTester#setClashSet(d0e32107376501c0).(dep); |
| 318 | // fall through |
| 319 | default: // caching of node fails |
| 320 | return; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | // all concepts in label are mergeable; now try to add input arc |
| 325 | newNodeEdgescxx . . $ DlSatTester#newNodeEdges..clearcxx . . $ modelCacheIan#clear(49f6e7a06ebc5aa8).(); |
| 326 | newNodeEdgescxx . . $ DlSatTester#newNodeEdges..initRolesFromArcscxx . . $ modelCacheIan#initRolesFromArcs(43c45bc7ff600176).(node); |
| 327 | newNodeCachecxx . . $ DlSatTester#newNodeCache..mergecxx . . $ modelCacheIan#merge(3c316d00313db7eb).(&newNodeEdgescxx . . $ DlSatTester#newNodeEdges.); |
| 328 | } |
| 329 | |
| 330 | modelCacheStatecxx . . $ modelCacheState# |
| 331 | DlSatTestercxx . . $ DlSatTester# :: reportNodeCachedcxx . . $ DlSatTester#reportNodeCached(f00754d885c410ab). ( DlCompletionTreecxx . . $ DlCompletionTree#* node ) |
| 332 | { |
| 333 | doCacheNodecxx . . $ DlSatTester#doCacheNode(3bf754c9a531d7e6).(node); |
| 334 | enum modelCacheStatecxx . . $ modelCacheState# status = newNodeCachecxx . . $ DlSatTester#newNodeCache..getStatecxx . . $ modelCacheIan#getState(2c070a27c5715e50).(); |
| 335 | switch ( status ) |
| 336 | { |
| 337 | case csValidcxx . . $ csValid.: |
| 338 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nCachedSat); |
| 339 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 340 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " cached(" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). node->getIdcxx . . $ DlCompletionTree#getId(ddd8539a2fcdd4ce).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")"; |
| 341 | break; |
| 342 | case csInvalidcxx . . $ csInvalid.: |
| 343 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nCachedUnsat); |
| 344 | break; |
| 345 | case csFailedcxx . . $ csFailed.: |
| 346 | case csUnknowncxx . . $ csUnknown.: |
| 347 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nCacheFailed); |
| 348 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 349 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " cf(c)"; |
| 350 | status = csFailedcxx . . $ csFailed.; |
| 351 | break; |
| 352 | default: |
| 353 | fpp_unreachablecxx . . $ `Kernel/fpp_assert.h:49:9`!(); |
| 354 | } |
| 355 | return status; |
| 356 | } |
| 357 | |
| 358 | bool DlSatTestercxx . . $ DlSatTester# :: correctCachedEntrycxx . . $ DlSatTester#correctCachedEntry(4899fbe844c80f28). ( DlCompletionTreecxx . . $ DlCompletionTree#* n ) |
| 359 | { |
| 360 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( n->isCached() ); // safety check |
| 361 | |
| 362 | // FIXME!! check if it is possible to leave node cached in more efficient way |
| 363 | modelCacheStatecxx . . $ modelCacheState# status = tryCacheNodecxx . . $ DlSatTester#tryCacheNode(f00754d885c410ab).(n); |
| 364 | |
| 365 | // uncheck cached node status and add all elements in TODO list |
| 366 | if ( status == csFailedcxx . . $ csFailed. ) |
| 367 | redoNodeLabelcxx . . $ DlSatTester#redoNodeLabel(d88b49f725c82ece). ( n, "uc" ); |
| 368 | |
| 369 | return usageByStatecxx . . $ DlSatTester#usageByState(fcb1385b525cf1b).(status); |
| 370 | } |
| 371 | |
| 372 | //----------------------------------------------------------------------------- |
| 373 | //-- internal datatype support |
| 374 | //----------------------------------------------------------------------------- |
| 375 | |
| 376 | /// @return true iff given data node contains data contradiction |
| 377 | bool |
| 378 | DlSatTestercxx . . $ DlSatTester# :: hasDataClashcxx . . $ DlSatTester#hasDataClash(6c1e73ffdfd78b24). ( const DlCompletionTreecxx . . $ DlCompletionTree#* Node ) |
| 379 | { |
| 380 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( Node && Node->isDataNode() ); // safety check |
| 381 | |
| 382 | DTReasonercxx . . $ DlSatTester#DTReasoner..clearcxx . . $ DataTypeReasoner#clear(49f6e7a06ebc5aa8).(); |
| 383 | |
| 384 | // data node may contain only "simple" concepts in there |
| 385 | for ( DlCompletionTreecxx . . $ DlCompletionTree#::const_label_iteratorcxx . . $ DlCompletionTree#const_label_iterator# p = Node->beginl_sccxx . . $ DlCompletionTree#beginl_sc(e55d760a93e9f197).(), p_end = Node->endl_sccxx . . $ DlCompletionTree#endl_sc(e55d760a93e9f197).(); p !=cxx . . $ __gnu_cxx/`operator!=`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 386 | if ( DTReasonercxx . . $ DlSatTester#DTReasoner..addDataEntrycxx . . $ DataTypeReasoner#addDataEntry(cbd92d0fb85c8e0). ( p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).(), p->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).getDepcxx . . $ ConceptWDep#getDep(bce6462a16d96b29).() ) ) // clash found |
| 387 | return true; |
| 388 | |
| 389 | return false; |
| 390 | } |
| 391 | |
| 392 | bool DlSatTestercxx . . $ DlSatTester# :: runSatcxx . . $ DlSatTester#runSat(c9857a73d68e59ba). ( void ) |
| 393 | { |
| 394 | testTimercxx . . $ DlSatTester#testTimer..Startcxx . . $ TsProcTimer#Start(49f6e7a06ebc5aa8).(); |
| 395 | bool result = checkSatisfiabilitycxx . . $ DlSatTester#checkSatisfiability(c9857a73d68e59ba). (); |
| 396 | testTimercxx . . $ DlSatTester#testTimer..Stopcxx . . $ TsProcTimer#Stop(49f6e7a06ebc5aa8).(); |
| 397 | |
| 398 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llSatTimecxx . . $ llSatTime.) ) |
| 399 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nChecking time was " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). testTimercxx . . $ DlSatTester#testTimer. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " seconds"; |
| 400 | |
| 401 | testTimercxx . . $ DlSatTester#testTimer..Resetcxx . . $ TsProcTimer#Reset(49f6e7a06ebc5aa8).(); |
| 402 | |
| 403 | finaliseStatisticcxx . . $ DlSatTester#finaliseStatistic(49f6e7a06ebc5aa8).(); |
| 404 | |
| 405 | if ( result ) |
| 406 | writeRootcxx . . $ DlSatTester#writeRoot(cb2f890c2fdad230).(llRStatcxx . . $ llRStat.); |
| 407 | |
| 408 | return result; |
| 409 | } |
| 410 | |
| 411 | void |
| 412 | DlSatTestercxx . . $ DlSatTester# :: finaliseStatisticcxx . . $ DlSatTester#finaliseStatistic(49f6e7a06ebc5aa8). ( void ) |
| 413 | { |
| 414 | #ifdef USE_REASONING_STATISTICS |
| 415 | // add the integer stat values |
| 416 | nNodeSaves.set(CGraph.getNNodeSaves()); |
| 417 | nNodeRestores.set(CGraph.getNNodeRestores()); |
| 418 | |
| 419 | // log statistics data |
| 420 | if ( LLM.isWritable(llRStat) ) |
| 421 | logStatisticData ( LL, /*needLocal=*/true ); |
| 422 | |
| 423 | // merge local statistics with the global one |
| 424 | AccumulatedStatistic::accumulateAll(); |
| 425 | #endif |
| 426 | |
| 427 | // clear global statistics |
| 428 | CGraphcxx . . $ DlSatTester#CGraph..clearStatisticscxx . . $ DlCompletionGraph#clearStatistics(49f6e7a06ebc5aa8).(); |
| 429 | } |
| 430 | |
| 431 | bool DlSatTestercxx . . $ DlSatTester# :: applyReflexiveRolescxx . . $ DlSatTester#applyReflexiveRoles(9c3f4bbfaa7a98e6). ( DlCompletionTreecxx . . $ DlCompletionTree#* node, const DepSetcxx . . $ DepSet#& dep ) |
| 432 | { |
| 433 | for ( const auto& R: ReflexiveRolescxx . . $ DlSatTester#ReflexiveRoles. ) |
| 434 | { |
| 435 | // create R-loop through the NODE |
| 436 | DlCompletionTreeArccxx . . $ DlCompletionTreeArc#* pA = CGraphcxx . . $ DlSatTester#CGraph..addRoleLabelcxx . . $ DlCompletionGraph#addRoleLabel(2369b4bf26f5db64). ( node, node, /*isPredEdge=*/false, R, dep ); |
| 437 | if ( setupEdgecxx . . $ DlSatTester#setupEdge(4031d85ce7510aa7). ( pA, dep ) ) |
| 438 | return true; |
| 439 | } |
| 440 | |
| 441 | // no clash found |
| 442 | return false; |
| 443 | } |
| 444 | |
| 445 | bool DlSatTestercxx . . $ DlSatTester# :: checkSatisfiabilitycxx . . $ DlSatTester#checkSatisfiability(c9857a73d68e59ba). ( void ) |
| 446 | { |
| 447 | unsigned int loop = 0; |
| 448 | for (;;) |
| 449 | { |
| 450 | if ( curNodecxx . . $ DlSatTester#curNode. == nullptr ) |
| 451 | { |
| 452 | if ( TODOcxx . . $ DlSatTester#TODO..emptycxx . . $ ToDoList#empty(50ce9a9e25b4a850).() ) // no applicable rules |
| 453 | { // do run-once things |
| 454 | if ( performAfterReasoningcxx . . $ DlSatTester#performAfterReasoning(c9857a73d68e59ba).() ) // clash found |
| 455 | if ( tunedRestorecxx . . $ DlSatTester#tunedRestore(c9857a73d68e59ba).() ) // no more alternatives |
| 456 | return false; |
| 457 | // if nothing added -- that's it |
| 458 | if ( TODOcxx . . $ DlSatTester#TODO..emptycxx . . $ ToDoList#empty(50ce9a9e25b4a850).() ) |
| 459 | return true; |
| 460 | } |
| 461 | |
| 462 | const ToDoEntrycxx . . $ ToDoEntry#* curTDE = TODOcxx . . $ DlSatTester#TODO..getNextEntrycxx . . $ ToDoList#getNextEntry(f5089fa5cf30e3eb). (); |
| 463 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( curTDE != nullptr ); |
| 464 | |
| 465 | // setup current context |
| 466 | curNodecxx . . $ DlSatTester#curNode. = curTDE->Nodecxx . . $ ToDoEntry#Node.; |
| 467 | curConceptcxx . . $ DlSatTester#curConcept. =cxx . . $ ConceptWDep#`operator=`(53d048f7c804eb56). curNodecxx . . $ DlSatTester#curNode.->labelcxx . . $ DlCompletionTree#label(d7a009c437cd4657).().getConceptcxx . . $ CGLabel#getConcept(ea7a63ba58262a62).(curTDE->offsetcxx . . $ ToDoEntry#offset.); |
| 468 | } |
| 469 | |
| 470 | if ( ++loop == 5000 ) |
| 471 | { |
| 472 | loop = 0; |
| 473 | if ( tBoxcxx . . $ DlSatTester#tBox..isCancelledcxx . . $ TBox#isCancelled(50ce9a9e25b4a850).() ) |
| 474 | return false; |
| 475 | unsigned long timeout = getSatTimeoutcxx . . $ DlSatTester#getSatTimeout(fe4d2d262d4164a8).(); |
| 476 | if ( unlikelycxx . . $ `Kernel/globaldef.h:29:10`!(timeout > 0) && 1000*(float)testTimercxx . . $ DlSatTester#testTimer. >= timeout ) |
| 477 | throw EFPPTimeoutcxx . . $ EFPPTimeout#EFPPTimeout(49f6e7a06ebc5aa8).(); |
| 478 | } |
| 479 | // here curNode/curConcept are set |
| 480 | if ( commonTacticcxx . . $ DlSatTester#commonTactic(c9857a73d68e59ba).() ) // clash found |
| 481 | { |
| 482 | if ( tunedRestorecxx . . $ DlSatTester#tunedRestore(c9857a73d68e59ba).() ) // the concept is unsatisfiable |
| 483 | return false; |
| 484 | } |
| 485 | else |
| 486 | curNodecxx . . $ DlSatTester#curNode. = nullptr; |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | /// perform all the actions that should be done once, after all normal rules are not applicable. @return true if the concept is unsat |
| 491 | bool |
| 492 | DlSatTestercxx . . $ DlSatTester# :: performAfterReasoningcxx . . $ DlSatTester#performAfterReasoning(c9857a73d68e59ba). ( void ) |
| 493 | { |
| 494 | // make sure all blocked nodes are still blocked |
| 495 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 496 | { |
| 497 | logIndentationcxx . . $ DlSatTester#logIndentation(83f5f38750778ac8).(); |
| 498 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "ub:"; |
| 499 | } |
| 500 | CGraphcxx . . $ DlSatTester#CGraph..retestCGBlockedStatuscxx . . $ DlCompletionGraph#retestCGBlockedStatus(49f6e7a06ebc5aa8).(); |
| 501 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llGTAcxx . . $ llGTA.) ) |
| 502 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "]"; |
| 503 | if ( !TODOcxx . . $ DlSatTester#TODO..emptycxx . . $ ToDoList#empty(50ce9a9e25b4a850).() ) |
| 504 | return false; |
| 505 | |
| 506 | // check fairness constraints |
| 507 | if ( RKG_USE_FAIRNESScxx . . $ `Kernel/globaldef.h:65:10`! && tBoxcxx . . $ DlSatTester#tBox..hasFCcxx . . $ TBox#hasFC(50ce9a9e25b4a850).() ) |
| 508 | { |
| 509 | DlCompletionTreecxx . . $ DlCompletionTree#* violator = nullptr; |
| 510 | // for every given FC, if it is violated, reject current model |
| 511 | for ( TBoxcxx . . $ TBox#::ConceptVectorcxx . . $ TBox#ConceptVector#::const_iteratorcxx . . $ std/vector#const_iterator# p = tBoxcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0)..Fairnesscxx . . $ TBox#Fairness..begincxx . . $ std/vector#begin(33b10a496a38335b).(), p_end = tBoxcxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(ea0f1a22ba5f21a0)..Fairnesscxx . . $ TBox#Fairness..endcxx . . $ std/vector#end(33b10a496a38335b).(); p <cxx . . $ __gnu_cxx/`operator<`(ef3c5749062e825c). p_end; ++cxx . . $ __gnu_cxx/__normal_iterator#operator++(93f2e9c3bc4efc49).p ) |
| 512 | { |
| 513 | violator = CGraphcxx . . $ DlSatTester#CGraph..getFCViolatorcxx . . $ DlCompletionGraph#getFCViolator(d75bf3f3e31659ef).((*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->pNamecxx . . $ TConcept#pName.); |
| 514 | if ( violator ) |
| 515 | { |
| 516 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nFairnessViolations); |
| 517 | // try to fix violators |
| 518 | if ( addToDoEntrycxx . . $ DlSatTester#addToDoEntry(50176c0f88cf3d4f). ( violator, (*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).p)->pNamecxx . . $ TConcept#pName., getCurDepSetcxx . . $ DlSatTester#getCurDepSet(6e9566718b894103).(), "fair" ) ) |
| 519 | return true; |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | if ( !TODOcxx . . $ DlSatTester#TODO..emptycxx . . $ ToDoList#empty(50ce9a9e25b4a850).() ) |
| 524 | return false; |
| 525 | } |
| 526 | |
| 527 | return false; |
| 528 | } |
| 529 | |
| 530 | /******************************************************************************** |
| 531 | * |
| 532 | * Save/Restore section |
| 533 | * |
| 534 | ******************************************************************************/ |
| 535 | |
| 536 | /// restore local state from BContext |
| 537 | void DlSatTestercxx . . $ DlSatTester# :: restoreBCcxx . . $ DlSatTester#restoreBC(49f6e7a06ebc5aa8). ( void ) |
| 538 | { |
| 539 | // restore reasoning context |
| 540 | curNodecxx . . $ DlSatTester#curNode. = bContextcxx . . $ DlSatTester#bContext.->curNodecxx . . $ BranchingContext#curNode.; |
| 541 | curConceptcxx . . $ DlSatTester#curConcept. =cxx . . $ ConceptWDep#`operator=`(53d048f7c804eb56). bContextcxx . . $ DlSatTester#bContext.->curConceptcxx . . $ BranchingContext#curConcept.; |
| 542 | pUsedcxx . . $ DlSatTester#pUsed..resizecxx . . $ TFastSet#resize(2c44cd906ae4e829).(bContextcxx . . $ DlSatTester#bContext.->pUsedIndexcxx . . $ BranchingContext#pUsedIndex.); |
| 543 | nUsedcxx . . $ DlSatTester#nUsed..resizecxx . . $ TFastSet#resize(2c44cd906ae4e829).(bContextcxx . . $ DlSatTester#bContext.->nUsedIndexcxx . . $ BranchingContext#nUsedIndex.); |
| 544 | if ( unlikelycxx . . $ `Kernel/globaldef.h:29:10`! ( !SessionGCIs.empty() ) ) |
| 545 | SessionGCIscxx . . $ DlSatTester#SessionGCIs..resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(bContextcxx . . $ DlSatTester#bContext.->SGsizecxx . . $ BranchingContext#SGsize.); |
| 546 | |
| 547 | // we here after the clash so choose the next branching option |
| 548 | nextBranchingOptioncxx . . $ DlSatTester#nextBranchingOption(49f6e7a06ebc5aa8).(); |
| 549 | } |
| 550 | |
| 551 | void DlSatTestercxx . . $ DlSatTester# :: savecxx . . $ DlSatTester#save(49f6e7a06ebc5aa8). ( void ) |
| 552 | { |
| 553 | // save tree |
| 554 | CGraphcxx . . $ DlSatTester#CGraph..savecxx . . $ DlCompletionGraph#save(49f6e7a06ebc5aa8).(); |
| 555 | |
| 556 | // save ToDoList |
| 557 | TODOcxx . . $ DlSatTester#TODO..savecxx . . $ ToDoList#save(49f6e7a06ebc5aa8).(); |
| 558 | |
| 559 | // increase tryLevel |
| 560 | ++tryLevelcxx . . $ DlSatTester#tryLevel.; |
| 561 | Managercxx . . $ DlSatTester#Manager..ensureLevelcxx . . $ TDepSetManager#ensureLevel(cb2f890c2fdad230).(getCurLevelcxx . . $ DlSatTester#getCurLevel(ddd8539a2fcdd4ce).()); |
| 562 | |
| 563 | // init BC |
| 564 | clearBCcxx . . $ DlSatTester#clearBC(49f6e7a06ebc5aa8).(); |
| 565 | |
| 566 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nStateSaves); |
| 567 | |
| 568 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llSRStatecxx . . $ llSRState.) ) |
| 569 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " ss(" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). getCurLevelcxx . . $ DlSatTester#getCurLevel(ddd8539a2fcdd4ce).()-1 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")"; |
| 570 | #ifdef __DEBUG_SAVE_RESTORE |
| 571 | writeRoot(llSRState); |
| 572 | #endif |
| 573 | } |
| 574 | |
| 575 | void DlSatTestercxx . . $ DlSatTester# :: restorecxx . . $ DlSatTester#restore(cb2f890c2fdad230). ( unsigned int newTryLevel ) |
| 576 | { |
| 577 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( !Stack.empty () ); |
| 578 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( newTryLevel > 0 ); |
| 579 | |
| 580 | // skip all intermediate restores |
| 581 | setCurLevelcxx . . $ DlSatTester#setCurLevel(cb2f890c2fdad230).(newTryLevel); |
| 582 | |
| 583 | // restore local |
| 584 | bContextcxx . . $ DlSatTester#bContext. = Stackcxx . . $ DlSatTester#Stack..topcxx . . $ TSaveStack#top(18e8862a30c27574).(getCurLevelcxx . . $ DlSatTester#getCurLevel(ddd8539a2fcdd4ce).()); |
| 585 | restoreBCcxx . . $ DlSatTester#restoreBC(49f6e7a06ebc5aa8).(); |
| 586 | |
| 587 | // restore tree |
| 588 | CGraphcxx . . $ DlSatTester#CGraph..restorecxx . . $ DlCompletionGraph#restore(cb2f890c2fdad230).(getCurLevelcxx . . $ DlSatTester#getCurLevel(ddd8539a2fcdd4ce).()); |
| 589 | |
| 590 | // restore TODO list |
| 591 | TODOcxx . . $ DlSatTester#TODO..restorecxx . . $ ToDoList#restore(cb2f890c2fdad230).(getCurLevelcxx . . $ DlSatTester#getCurLevel(ddd8539a2fcdd4ce).()); |
| 592 | |
| 593 | incStatcxx . . $ `Kernel/Reasoner.h:341:10`!(nStateRestores); |
| 594 | |
| 595 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(llSRStatecxx . . $ llSRState.) ) |
| 596 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " sr(" <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). getCurLevelcxx . . $ DlSatTester#getCurLevel(ddd8539a2fcdd4ce).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")"; |
| 597 | #ifdef __DEBUG_SAVE_RESTORE |
| 598 | writeRoot(llSRState); |
| 599 | #endif |
| 600 | } |
| 601 | |
| 602 | /** |
| 603 | * logging methods |
| 604 | */ |
| 605 | |
| 606 | void DlSatTestercxx . . $ DlSatTester# :: logIndentationcxx . . $ DlSatTester#logIndentation(83f5f38750778ac8). ( void ) const |
| 607 | { |
| 608 | CHECK_LL_RETURNcxx . . $ `Kernel/LeveLogger.h:60:9`!(llGTA); // useless but safe |
| 609 | int level = int(getCurLevelcxx . . $ DlSatTester#getCurLevel(ddd8539a2fcdd4ce).()); |
| 610 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n" <<cxx . . $ std/`operator<<`(fe9a269018418773). stdcxx . . $ std/::setwcxx . . $ std/setw(f06ce2e9220601fb).(level) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "["; |
| 611 | } |
| 612 | void DlSatTestercxx . . $ DlSatTester# :: logStartEntrycxx . . $ DlSatTester#logStartEntry(83f5f38750778ac8). ( void ) const |
| 613 | { |
| 614 | CHECK_LL_RETURNcxx . . $ `Kernel/LeveLogger.h:60:9`!(llGTA); // useless but safe |
| 615 | logIndentationcxx . . $ DlSatTester#logIndentation(83f5f38750778ac8).(); |
| 616 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "("; |
| 617 | curNodecxx . . $ DlSatTester#curNode.->logNodecxx . . $ DlCompletionTree#logNode(83f5f38750778ac8). (); |
| 618 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "," <<cxx . . $ `operator<<`(658aaef1ace96007). curConceptcxx . . $ DlSatTester#curConcept. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "){"; |
| 619 | if ( isNegativecxx . . $ isNegative(83c267b20bac841a). (curConceptcxx . . $ DlSatTester#curConcept..bpcxx . . $ ConceptWDep#bp(455f465bc33b4cdf).()) ) |
| 620 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "~"; |
| 621 | const DLVertexcxx . . $ DLVertex#& v = DLHeapcxx . . $ DlSatTester#DLHeap.[cxx . . $ DLDag#`operator[]`(b4043884e5934906).curConceptcxx . . $ DlSatTester#curConcept.]; |
| 622 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). v.getTagNamecxx . . $ DLVertex#getTagName(a9f41ea0e82d88cf).(); |
| 623 | if ( const TNamedEntrycxx . . $ TNamedEntry#* entry = v.getConceptcxx . . $ DLVertex#getConcept(1867504d72698304).() ) |
| 624 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "(" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). entry->getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ")"; |
| 625 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "}:"; |
| 626 | } |
| 627 | |
| 628 | void DlSatTestercxx . . $ DlSatTester# :: logFinishEntrycxx . . $ DlSatTester#logFinishEntry(a85845bc2b7828e2). ( bool res ) const |
| 629 | { |
| 630 | CHECK_LL_RETURNcxx . . $ `Kernel/LeveLogger.h:60:9`!(llGTA); // useless but safe |
| 631 | |
| 632 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "]"; |
| 633 | if ( res ) |
| 634 | LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Clash" <<cxx . . $ `operator<<`(8df530197ee94a2e). getClashSetcxx . . $ DlSatTester#getClashSet(bce6462a16d96b29).(); |
| 635 | #ifdef __DEBUG_FLUSH_LL |
| 636 | LL.flush (); |
| 637 | #endif |
| 638 | } |
| 639 | |
| 640 | void DlSatTestercxx . . $ DlSatTester# :: logStatisticDatacxx . . $ DlSatTester#logStatisticData(25a4e5f405a65361). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o, bool needLocal ) const |
| 641 | { |
| 642 | #ifdef USE_REASONING_STATISTICS |
| 643 | nTacticCalls.Print ( o, needLocal, "\nThere were made ", " tactic operations, of which:" ); |
| 644 | nIdCalls.Print ( o, needLocal, "\n CN operations: ", "" ); |
| 645 | nSingletonCalls.Print(o, needLocal, "\n including ", " singleton ones" ); |
| 646 | nOrCalls.Print ( o, needLocal, "\n OR operations: ", "" ); |
| 647 | nOrBrCalls.Print ( o, needLocal, "\n ", " of which are branching" ); |
| 648 | nAndCalls.Print ( o, needLocal, "\n AND operations: ", "" ); |
| 649 | nSomeCalls.Print ( o, needLocal, "\n SOME operations: ", "" ); |
| 650 | nAllCalls.Print ( o, needLocal, "\n ALL operations: ", "" ); |
| 651 | nFuncCalls.Print ( o, needLocal, "\n Func operations: ", "" ); |
| 652 | nLeCalls.Print ( o, needLocal, "\n LE operations: ", "" ); |
| 653 | nGeCalls.Print ( o, needLocal, "\n GE operations: ", "" ); |
| 654 | nUseless.Print ( o, needLocal, "\n N/A operations: ", "" ); |
| 655 | |
| 656 | nNNCalls.Print ( o, needLocal, "\nThere were made ", " NN rule application" ); |
| 657 | nMergeCalls.Print ( o, needLocal, "\nThere were made ", " merging operations" ); |
| 658 | |
| 659 | nAutoEmptyLookups.Print ( o, needLocal, "\nThere were made ", " RA empty transition lookups" ); |
| 660 | nAutoTransLookups.Print ( o, needLocal, "\nThere were made ", " RA applicable transition lookups" ); |
| 661 | |
| 662 | nSRuleAdd.Print ( o, needLocal, "\nThere were made ", " simple rule additions" ); |
| 663 | nSRuleFire.Print ( o, needLocal, "\n of which ", " simple rules fired" ); |
| 664 | |
| 665 | nStateSaves.Print ( o, needLocal, "\nThere were made ", " save(s) of global state" ); |
| 666 | nStateRestores.Print ( o, needLocal, "\nThere were made ", " restore(s) of global state" ); |
| 667 | nNodeSaves.Print ( o, needLocal, "\nThere were made ", " save(s) of tree state" ); |
| 668 | nNodeRestores.Print ( o, needLocal, "\nThere were made ", " restore(s) of tree state" ); |
| 669 | nLookups.Print ( o, needLocal, "\nThere were made ", " concept lookups" ); |
| 670 | if ( RKG_USE_FAIRNESS ) |
| 671 | nFairnessViolations.Print ( o, needLocal, "\nThere were ", " fairness constraints violation" ); |
| 672 | |
| 673 | nCacheTry.Print ( o, needLocal, "\nThere were made ", " tries to cache completion tree node, of which:" ); |
| 674 | nCacheFailedNoCache.Print ( o, needLocal, "\n ", " fails due to cache absence" ); |
| 675 | nCacheFailedShallow.Print ( o, needLocal, "\n ", " fails due to shallow node" ); |
| 676 | nCacheFailed.Print ( o, needLocal, "\n ", " fails due to cache merge failure" ); |
| 677 | nCachedSat.Print ( o, needLocal, "\n ", " cached satisfiable nodes" ); |
| 678 | nCachedUnsat.Print ( o, needLocal, "\n ", " cached unsatisfiable nodes" ); |
| 679 | #endif |
| 680 | |
| 681 | if ( !needLocal ) |
| 682 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nThe maximal graph size is " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). CGraphcxx . . $ DlSatTester#CGraph..maxSizecxx . . $ DlCompletionGraph#maxSize(fe4d2d262d4164a8).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " nodes"; |
| 683 | } |
| 684 | |
| 685 | float |
| 686 | DlSatTestercxx . . $ DlSatTester# :: printReasoningTimecxx . . $ DlSatTester#printReasoningTime(aa6fa99658f404e2). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const |
| 687 | { |
| 688 | o <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n SAT takes " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). satTimercxx . . $ DlSatTester#satTimer. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " seconds\n SUB takes " <<cxx . . $ std/basic_ostream#`operator<<`(2b73cd0f0517cf77). subTimercxx . . $ DlSatTester#subTimer. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " seconds"; |
| 689 | return satTimercxx . . $ DlSatTester#satTimer. + subTimercxx . . $ DlSatTester#subTimer.; |
| 690 | } |
| 691 |