| 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 | #ifndef TBRANCHINGCONTEXT_H |
| 21 | #define TBRANCHINGCONTEXT_Hcxx . . $ `Kernel/tBranchingContext.h:21:9`! |
| 22 | |
| 23 | #include "ConceptWithDep.h"cxx . . $ `<file>/Kernel/ConceptWithDep.h`/ |
| 24 | |
| 25 | class DlCompletionTreecxx . . $ DlCompletionTree#; |
| 26 | |
| 27 | /// class for saving branching context of a Reasoner |
| 28 | class BranchingContextcxx . . $ BranchingContext# |
| 29 | { |
| 30 | public: // members |
| 31 | /// currently processed node |
| 32 | DlCompletionTreecxx . . $ DlCompletionTree#* curNodecxx . . $ BranchingContext#curNode. = nullptr; |
| 33 | /// currently processed concept |
| 34 | ConceptWDepcxx . . $ ConceptWDep# curConceptcxx . . $ BranchingContext#curConcept. {cxx . . $ ConceptWDep#ConceptWDep(d4f767463ce0a6b3).bpINVALIDcxx . . $ bpINVALID.}; |
| 35 | /// positions of the Used members |
| 36 | size_tcxx . . $ size_t# pUsedIndexcxx . . $ BranchingContext#pUsedIndex. = 0, nUsedIndexcxx . . $ BranchingContext#nUsedIndex. = 0; |
| 37 | /// size of a session GCIs vector |
| 38 | size_tcxx . . $ size_t# SGsizecxx . . $ BranchingContext#SGsize. = 0; |
| 39 | /// dependencies for branching clashes |
| 40 | DepSetcxx . . $ DepSet# branchDepcxx . . $ BranchingContext#branchDep.; |
| 41 | |
| 42 | public: // interface |
| 43 | /// empty c'tor |
| 44 | BranchingContextcxx . . $ BranchingContext#BranchingContext(49f6e7a06ebc5aa8).() = default; |
| 45 | /// no copy c'tor |
| 46 | BranchingContextcxx . . $ BranchingContext#BranchingContext(86abef566440a122). ( const BranchingContextcxx . . $ BranchingContext#& ) = delete; |
| 47 | /// no assignment |
| 48 | BranchingContextcxx . . $ BranchingContext#& operatorcxx . . $ BranchingContext#`operator=`(76e19e29453dc45d). = ( const BranchingContextcxx . . $ BranchingContext#& ) = delete; |
| 49 | /// empty d'tor |
| 50 | virtual ~cxx . . $ BranchingContext#`~BranchingContext`(49f6e7a06ebc5aa8).BranchingContextcxx . . $ BranchingContext#() = default; |
| 51 | |
| 52 | /// init indices (if necessary) |
| 53 | virtual void initcxx . . $ BranchingContext#init(49f6e7a06ebc5aa8). ( void ) {} |
| 54 | /// give the next branching alternative |
| 55 | virtual void nextOptioncxx . . $ BranchingContext#nextOption(49f6e7a06ebc5aa8). ( void ) {} |
| 56 | }; // BranchingContext |
| 57 | |
| 58 | /// branching context for the OR operations |
| 59 | class BCOrcxx . . $ BCOr#: public BranchingContextcxx . . $ BranchingContext# |
| 60 | { |
| 61 | public: // types |
| 62 | /// short OR indexes |
| 63 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<BipolarPointercxx . . $ BipolarPointer#> OrIndexcxx . . $ BCOr#OrIndex#; |
| 64 | /// short OR index iterator |
| 65 | typedef OrIndexcxx . . $ BCOr#OrIndex#::const_iteratorcxx . . $ std/vector#const_iterator# or_iteratorcxx . . $ BCOr#or_iterator#; |
| 66 | |
| 67 | public: // members |
| 68 | /// relevant disjuncts (ready to add) |
| 69 | OrIndexcxx . . $ BCOr#OrIndex# applicableOrEntriescxx . . $ BCOr#applicableOrEntries.; |
| 70 | /// current branching index |
| 71 | size_tcxx . . $ size_t# branchIndexcxx . . $ BCOr#branchIndex. = 0; |
| 72 | |
| 73 | public: // interface |
| 74 | /// init branch index |
| 75 | void initcxx . . $ BCOr#init(49f6e7a06ebc5aa8). ( void ) override { branchIndexcxx . . $ BCOr#branchIndex. = 0; } |
| 76 | /// give the next branching alternative |
| 77 | void nextOptioncxx . . $ BCOr#nextOption(49f6e7a06ebc5aa8). ( void ) override { ++branchIndexcxx . . $ BCOr#branchIndex.; } |
| 78 | |
| 79 | // access to the fields |
| 80 | |
| 81 | /// check if the current processing OR entry is the last one |
| 82 | bool isLastOrEntrycxx . . $ BCOr#isLastOrEntry(50ce9a9e25b4a850). ( void ) const { return applicableOrEntriescxx . . $ BCOr#applicableOrEntries..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() == branchIndexcxx . . $ BCOr#branchIndex.+1; } |
| 83 | /// 1st element of OrIndex |
| 84 | or_iteratorcxx . . $ BCOr#or_iterator# orBegcxx . . $ BCOr#orBeg(d2502ee2ca3b883a). ( void ) const { return applicableOrEntriescxx . . $ BCOr#applicableOrEntries..begincxx . . $ std/vector#begin(359ca5030082c9f).(); } |
| 85 | /// current element of OrIndex |
| 86 | or_iteratorcxx . . $ BCOr#or_iterator# orCurcxx . . $ BCOr#orCur(d2502ee2ca3b883a). ( void ) const { return orBegcxx . . $ BCOr#orBeg(d2502ee2ca3b883a).() +cxx . . $ __gnu_cxx/__normal_iterator#operator+(d0cb2d2ebd313f38). branchIndexcxx . . $ BCOr#branchIndex.; } |
| 87 | }; // BCOr |
| 88 | |
| 89 | /// branching context for the Choose-rule |
| 90 | class BCChoosecxx . . $ BCChoose#: public BranchingContextcxx . . $ BranchingContext# |
| 91 | { |
| 92 | }; // BCChoose |
| 93 | |
| 94 | /// branching context for the NN-rule |
| 95 | class BCNNcxx . . $ BCNN#: public BranchingContextcxx . . $ BranchingContext# |
| 96 | { |
| 97 | public: // members |
| 98 | /// the value of M used in the NN rule |
| 99 | unsigned int valuecxx . . $ BCNN#value. = 0; |
| 100 | |
| 101 | public: // interface |
| 102 | /// init value |
| 103 | void initcxx . . $ BCNN#init(49f6e7a06ebc5aa8). ( void ) override { valuecxx . . $ BCNN#value. = 1; } |
| 104 | /// give the next branching alternative |
| 105 | void nextOptioncxx . . $ BCNN#nextOption(49f6e7a06ebc5aa8). ( void ) override { ++valuecxx . . $ BCNN#value.; } |
| 106 | |
| 107 | // access to the fields |
| 108 | |
| 109 | /// check if the NN has no option to process |
| 110 | bool noMoreNNOptionscxx . . $ BCNN#noMoreNNOptions(8de63fdb265b07c1). ( unsigned int n ) const { return valuecxx . . $ BCNN#value. > n; } |
| 111 | }; // BCNN |
| 112 | |
| 113 | /// branching context for the LE operations |
| 114 | template <typename T> |
| 115 | class BCLEcxx . . $ BCLE#: public BranchingContextcxx . . $ BranchingContext# |
| 116 | { |
| 117 | public: // types |
| 118 | /// Cardinality Restriction index type |
| 119 | // TODO: make it 8-bit or so |
| 120 | typedef unsigned short int CRIndexcxx . . $ BCLE#CRIndex#; |
| 121 | /// vector of edges |
| 122 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<T*> EdgeVectorcxx . . $ BCLE#EdgeVector#; |
| 123 | |
| 124 | public: // members |
| 125 | /// vector of edges to be merged |
| 126 | EdgeVectorcxx . . $ BCLE#EdgeVector# ItemsToMergecxx . . $ BCLE#ItemsToMerge.; |
| 127 | /// index of a edge into which the merge is performing |
| 128 | CRIndexcxx . . $ BCLE#CRIndex# toIndexcxx . . $ BCLE#toIndex. = 0; |
| 129 | /// index of a merge candidate |
| 130 | CRIndexcxx . . $ BCLE#CRIndex# fromIndexcxx . . $ BCLE#fromIndex. = 0; |
| 131 | |
| 132 | public: // interface |
| 133 | /// init indices |
| 134 | void initcxx . . $ BCLE#init(49f6e7a06ebc5aa8). ( void ) override |
| 135 | { |
| 136 | toIndexcxx . . $ BCLE#toIndex. = 0; |
| 137 | fromIndexcxx . . $ BCLE#fromIndex. = 0; |
| 138 | } |
| 139 | /// correct fromIndex after changing |
| 140 | void resetMCIcxx . . $ BCLE#resetMCI(49f6e7a06ebc5aa8). ( void ) { fromIndexcxx . . $ BCLE#fromIndex. = static_cast<CRIndexcxx . . $ BCLE#CRIndex#>(ItemsToMergecxx . . $ BCLE#ItemsToMerge..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).() - 1); } |
| 141 | /// give the next branching alternative |
| 142 | void nextOptioncxx . . $ BCLE#nextOption(49f6e7a06ebc5aa8). ( void ) override |
| 143 | { |
| 144 | --fromIndexcxx . . $ BCLE#fromIndex.; // get new merge candidate |
| 145 | if ( fromIndexcxx . . $ BCLE#fromIndex. == toIndexcxx . . $ BCLE#toIndex. ) // nothing more can be mergeable to BI node |
| 146 | { |
| 147 | ++toIndexcxx . . $ BCLE#toIndex.; // change the candidate to merge to |
| 148 | resetMCIcxx . . $ BCLE#resetMCI(49f6e7a06ebc5aa8).(); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // access to the fields |
| 153 | |
| 154 | /// get FROM pointer to merge |
| 155 | T* getFromcxx . . $ BCLE#getFrom(5a2a78a048fb49a8). ( void ) const { return ItemsToMergecxx . . $ BCLE#ItemsToMerge.[fromIndexcxx . . $ BCLE#fromIndex.]; } |
| 156 | /// get FROM pointer to merge |
| 157 | T* getTocxx . . $ BCLE#getTo(5a2a78a048fb49a8). ( void ) const { return ItemsToMergecxx . . $ BCLE#ItemsToMerge.[toIndexcxx . . $ BCLE#toIndex.]; } |
| 158 | /// check if the LE has no option to process |
| 159 | bool noMoreLEOptionscxx . . $ BCLE#noMoreLEOptions(50ce9a9e25b4a850). ( void ) const { return fromIndexcxx . . $ BCLE#fromIndex. <= toIndexcxx . . $ BCLE#toIndex.; } |
| 160 | }; // BCLE |
| 161 | |
| 162 | /// branching context for the barrier |
| 163 | class BCBarriercxx . . $ BCBarrier#: public BranchingContextcxx . . $ BranchingContext# |
| 164 | { |
| 165 | }; // BCBarrier |
| 166 | |
| 167 | #endif |