aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
DBRowGenerator4CompleteRows_tpl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library 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 License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /** @file
23  * @brief A DBRowGenerator class that returns the rows that are complete
24  * (fully observed) w.r.t. the nodes of interest
25  *
26  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 #include <agrum/tools/database/DBRowGenerator4CompleteRows.h>
29 
30 #ifndef DOXYGEN_SHOULD_SKIP_THIS
31 
32 namespace gum {
33 
34  namespace learning {
35 
36  /// returns the allocator used
37  template < template < typename > class ALLOC >
40  return DBRowGenerator< ALLOC >::getAllocator();
41  }
42 
43 
44  /// default constructor
45  template < template < typename > class ALLOC >
50  alloc) :
53  alloc) {
55  }
56 
57 
58  /// copy constructor with a given allocator
59  template < template < typename > class ALLOC >
63  alloc) :
67  }
68 
69 
70  /// copy constructor
71  template < template < typename > class ALLOC >
75 
76 
77  /// move constructor with a given allocator
78  template < template < typename > class ALLOC >
82  alloc) :
86  }
87 
88 
89  /// move constructor
90  template < template < typename > class ALLOC >
94  from.getAllocator()) {}
95 
96 
97  /// virtual copy constructor with a given allocator
98  template < template < typename > class ALLOC >
102  alloc) const {
105  try {
107  } catch (...) {
109  throw;
110  }
111  return generator;
112  }
113 
114 
115  /// virtual copy constructor
116  template < template < typename > class ALLOC >
119  return clone(this->getAllocator());
120  }
121 
122 
123  /// destructor
124  template < template < typename > class ALLOC >
127  }
128 
129 
130  /// copy operator
131  template < template < typename > class ALLOC >
137  return *this;
138  }
139 
140 
141  /// move operator
142  template < template < typename > class ALLOC >
148  return *this;
149  }
150 
151 
152  /// generates new lines from those the generator gets in input
153  template < template < typename > class ALLOC >
156  this->decreaseRemainingRows();
157  return *input_row__;
158  }
159 
160 
161  /// computes the rows it will provide in output
162  template < template < typename > class ALLOC >
164  const DBRow< DBTranslatedValue, ALLOC >& row) {
165  // check that all the values are observed
166  const auto& xrow = row.row();
167  for (const auto col: this->columns_of_interest_) {
168  switch (this->column_types_[col]) {
170  if (xrow[col].discr_val == std::numeric_limits< std::size_t >::max()) {
171  input_row__ = nullptr;
172  return std::size_t(0);
173  }
174  break;
175 
177  if (xrow[col].cont_val == std::numeric_limits< float >::max()) {
178  input_row__ = nullptr;
179  return std::size_t(0);
180  }
181  break;
182 
183  default:
185  "DBTranslatedValueType " << int(this->column_types_[col])
186  << " is not supported yet");
187  break;
188  }
189  }
190  input_row__ = &row;
191  return std::size_t(1);
192  }
193 
194 
195  } /* namespace learning */
196 
197 } /* namespace gum */
198 
199 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)