Debian Codegraph @

Kernel/CWDArray.cpp

raw symbols SCIP
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 "CWDArray.h"
21 #include "tRestorer.h"
22
23 /// restore dep-set of the duplicated label element of the merged node
24 class UnMerge: public TRestorer
25 {
26 protected:
27 CWDArray& label;
28 int offset;
29 DepSet dep;
30 public:
31 UnMerge ( CWDArray& lab, CWDArray::iterator p )
32 : label(lab)
33 , offset(int(p-lab.begin()))
34 , dep(p->getDep())
35 {}
36 void restore ( void ) override
37 {
38 CWDArray::iterator p = label.Base.begin() + offset;
39 *p = ConceptWDep(p->bp(),dep);
40 }
41 }; // UnMerge
42
43 TRestorer*
44 CWDArray :: updateDepSet ( BipolarPointer bp, const DepSet& dep )
45 {
46 if ( dep.empty() )
47 return nullptr;
48
49 for ( iterator i = Base.begin(), i_end = Base.end(); i < i_end; ++i )
50 if ( i->bp() == bp )
51 {
52 TRestorer* ret = new UnMerge ( *this, i );
53 // DepSet odep(i->getDep());
54 i->addDep(dep);
55 /* if ( odep == i->getDep() )
56 {
57 delete ret;
58 ret = nullptr;
59 }*/
60 return ret;
61 }
62 return nullptr;
63 }
64
65 /// restore label to given LEVEL using given SS
66 void
67 CWDArray :: restore ( const SaveState& ss, unsigned int level ATTR_UNUSED )
68 {
69 if ( RKG_USE_DYNAMIC_BACKJUMPING )
70 {
71 for ( size_t j = ss.ep; j < Base.size(); ++j )
72 if ( Base[j].getDep().contains(level) )
73 {
74 // replace concept that depend on a given BC with TOP
75 Base[j] = ConceptWDep(1,DepSet());
76 }
77 }
78 else
79 Base.resize(ss.ep);
80 }
81
82 /// print label part between given iterators
83 void
84 CWDArray :: print ( std::ostream& o ) const
85 {
86 o << " [";
87 const_iterator p = begin(), p_end = end();
88
89 if ( p != p_end )
90 {
91 o << *p;
92
93 while ( ++p < p_end )
94 o << ", " << *p;
95 }
96 o << "]";
97 }