aGrUM  0.14.2
DBTranslator4ContinuousVariable.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program 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 *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
25 #ifndef GUM_LEARNING_DB_TRANSLATOR_4_CONTINUOUS_VARIABLE_H
26 #define GUM_LEARNING_DB_TRANSLATOR_4_CONTINUOUS_VARIABLE_H
27 
28 #include <string>
29 
30 #include <agrum/agrum.h>
31 #include <agrum/core/hashTable.h>
34 
35 
36 namespace gum {
37 
38  namespace learning {
39 
40 
123  template < template < typename > class ALLOC = std::allocator >
125  public:
128 
129 
130  // ##########################################################################
132  // ##########################################################################
133 
135 
137 
150  template < template < typename > class XALLOC >
152  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
153  const bool fit_range = false,
154  const allocator_type& alloc = allocator_type());
155 
157 
169  const bool fit_range = false,
170  const allocator_type& alloc = allocator_type());
171 
173 
186  template < typename GUM_SCALAR, template < typename > class XALLOC >
189  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
190  const bool fit_range = false,
191  const allocator_type& alloc = allocator_type());
192 
207  template < typename GUM_SCALAR >
210  const bool fit_range = false,
211  const allocator_type& alloc = allocator_type());
212 
214 
227  template < template < typename > class XALLOC >
229  const IContinuousVariable& var,
230  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
231  const bool fit_range = false,
232  const allocator_type& alloc = allocator_type());
233 
249  const IContinuousVariable& var,
250  const bool fit_range = false,
251  const allocator_type& alloc = allocator_type());
252 
256 
260  const allocator_type& alloc);
261 
265 
269  const allocator_type& alloc);
270 
273 
276  clone(const allocator_type& alloc) const;
277 
280 
282 
283 
284  // ##########################################################################
286  // ##########################################################################
287 
289 
293 
297 
299 
300 
301  // ##########################################################################
303  // ##########################################################################
304 
306 
308 
343  virtual DBTranslatedValue translate(const std::string& str) final;
344 
346 
350  virtual std::string
351  translateBack(const DBTranslatedValue translated_val) const final;
352 
354  virtual std::size_t domainSize() const final;
355 
357  virtual bool needsReordering() const final;
358 
361  virtual HashTable< std::size_t,
362  std::size_t,
363  ALLOC< std::pair< std::size_t, std::size_t > > >
364  reorder() final;
365 
367  virtual const IContinuousVariable* variable() const final;
368 
370  virtual DBTranslatedValue missingValue() const final;
371 
373 
374 
375 #ifndef DOXYGEN_SHOULD_SKIP_THIS
376 
377  private:
378  // the ContinuousVariable really used by the translator. As its values
379  // are floats, this speeds-up translations
380  ContinuousVariable< float > __variable;
381 
382  // the ContinuousVariablee returned by method variable ()
383  // We must return a IContinuousVariable because the user may have
384  // saved into the translator a ContinuousVariable<X>, with X != float
385  IContinuousVariable* __real_variable;
386 
387  // assign to each float missing symbol a Boolean indicating whether
388  // we already translated it or not. If we translated it, then we cannot
389  // change the range of the variable so that this range contains the symbol.
391  __status_float_missing_symbols;
392 
393  // a string containing a non real missing symbol
394  // (useful for back translations)
395  std::string __nonfloat_missing_symbol;
396 
397  // indicates whether we should fit the range of the observed values
398  bool __fit_range;
399 
400 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
401  };
402 
403  } /* namespace learning */
404 
405 } /* namespace gum */
406 
407 
408 // always include the template implementation
410 
411 #endif /* GUM_LEARNING_DB_TRANSLATOR_4_CONTINUOUS_VARIABLE_H */
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
Defines a continuous random variable.
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
Definition: DBTranslator.h:117
typename DBTranslator< ALLOC >::allocator_type allocator_type
type for the allocators passed in arguments of methods
A base class for continuous variables, independent of the GUM_SCALAR type.
virtual DBTranslator4ContinuousVariable< ALLOC > * clone() const
virtual copy constructor
STL namespace.
Header of ContinuousVariable.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The union class for storing the translated values in learning databases.
The databases&#39; cell translators for continuous variables.
The class for generic Hash Tables.
Definition: hashTable.h:676
DBTranslator4ContinuousVariable< ALLOC > & operator=(const DBTranslator4ContinuousVariable< ALLOC > &from)
copy operator
virtual std::size_t domainSize() const final
returns std::numeric_limits<std::size_t>::max ()
DBTranslator4ContinuousVariable(const std::vector< std::string, XALLOC< std::string > > &missing_symbols, const bool fit_range=false, const allocator_type &alloc=allocator_type())
default constructor without any initial variable
virtual bool needsReordering() const final
indicates that the translations should never be reordered
The base class for all the tabular database cell translators.
Definition: DBTranslator.h:114
virtual HashTable< std::size_t, std::size_t, ALLOC< std::pair< std::size_t, std::size_t > > > reorder() final
returns an empty mapping, indicating that old tanslations are equal to the newly reordered ones...
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
The databases&#39; cell translators for continuous variables.
The base class for all the tabular databases&#39; cell translators.
Class hash tables iterators.
virtual const IContinuousVariable * variable() const final
returns the variable stored into the translator
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value