aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
rangeVariable.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
48
49
#ifndef GUM_RANGE_VARIABLE_H
50
#define GUM_RANGE_VARIABLE_H
51
52
#include <ostream>
53
#include <sstream>
54
#include <string>
55
56
#include <
agrum/agrum.h
>
57
58
#include <
agrum/base/variables/discreteVariable.h
>
59
60
namespace
gum
{
61
71
72
class
GUM_SHARED_PUBLIC
RangeVariable
final:
public
DiscreteVariable
{
73
public
:
75
78
RangeVariable
(std::string_view aName, std::string_view aDesc,
long
minVal
,
long
maxVal
);
79
81
RangeVariable
(std::string_view aName, std::string_view aDesc);
82
89
RangeVariable
(
const
RangeVariable
& aDRV);
90
92
~RangeVariable
()
final
;
93
96
[[nodiscard]]
RangeVariable
*
clone
()
const
final
;
97
99
101
109
Size
domainSize
()
const
final
;
110
112
113
VarType
varType
()
const
final
;
114
115
// returns the variable in fast syntax
116
std::string
toFast
()
const
final
;
118
123
std::string
label
(
Idx
index
)
const
final
;
124
126
double
numerical
(
Idx
index
)
const
final
;
127
131
long
minVal
()
const
;
132
136
void
setMinVal
(
long
minVal
);
137
141
long
maxVal
()
const
;
142
146
void
setMaxVal
(
long
maxVal
);
147
151
bool
belongs
(
long
val)
const
;
152
157
Idx
index
(std::string_view)
const
final
;
158
160
Idx
closestIndex
(
double
val)
const
final
;
161
163
166
170
RangeVariable
&
operator=
(
const
RangeVariable
& aRV);
171
173
174
std::string
domain
() const final;
175
177
std
::
string
stype
() const final;
178
179
private:
181
184
bool
_checkSameDomain_
(const
Variable
& aRV) const final;
185
189
long
_minBound_
;
190
192
long
_maxBound_
;
193
195
};
196
197
}
/* namespace gum */
198
199
#ifndef GUM_NO_INLINE
200
# include <
agrum/base/variables/rangeVariable_inl.h
>
201
#endif
/* GUM_NO_INLINE */
202
203
#endif
/* GUM_RANGE_VARIABLE_H */
agrum.h
gum::DiscreteVariable::DiscreteVariable
DiscreteVariable(std::string_view aName, std::string_view aDesc)
Default constructor.
gum::RangeVariable::setMaxVal
void setMaxVal(long maxVal)
Set a new value of the upper bound.
Definition
rangeVariable_inl.h:120
gum::RangeVariable::clone
RangeVariable * clone() const final
Copy Factory.
Definition
rangeVariable_inl.h:60
gum::RangeVariable::closestIndex
Idx closestIndex(double val) const final
returns the closest index of the value
Definition
rangeVariable_inl.h:95
gum::RangeVariable::label
std::string label(Idx index) const final
Get the index-th label.
Definition
rangeVariable_inl.h:70
gum::RangeVariable::maxVal
long maxVal() const
Returns the upper bound.
Definition
rangeVariable_inl.h:117
gum::RangeVariable::_minBound_
long _minBound_
The upper bound.
Definition
rangeVariable.h:189
gum::RangeVariable::belongs
bool belongs(long val) const
Returns true if the param belongs to the variable's interval.
Definition
rangeVariable_inl.h:123
gum::RangeVariable::_checkSameDomain_
bool _checkSameDomain_(const Variable &aRV) const final
check the domain
Definition
rangeVariable_inl.h:134
gum::RangeVariable::setMinVal
void setMinVal(long minVal)
Set a new value for the lower bound.
Definition
rangeVariable_inl.h:114
gum::RangeVariable::domainSize
Size domainSize() const final
returns the size of the random discrete variable domain
Definition
rangeVariable_inl.h:63
gum::RangeVariable::varType
VarType varType() const final
returns the type of variable
Definition
rangeVariable_inl.h:132
gum::RangeVariable::toFast
std::string toFast() const final
returns the size of the random discrete variable domain
Definition
rangeVariable.cpp:93
gum::RangeVariable::operator=
RangeVariable & operator=(const RangeVariable &aRV)
Copy operator.
gum::RangeVariable::numerical
double numerical(Idx index) const final
get a numerical representation of the index-the value.
Definition
rangeVariable_inl.h:80
gum::RangeVariable::stype
std::string stype() const final
string represent the type of the variable
Definition
rangeVariable_inl.h:142
gum::RangeVariable::domain
std::string domain() const final
string represent the domain of the variable
Definition
rangeVariable.cpp:91
gum::RangeVariable::minVal
long minVal() const
Returns the lower bound.
Definition
rangeVariable_inl.h:111
gum::RangeVariable::RangeVariable
RangeVariable(std::string_view aName, std::string_view aDesc, long minVal, long maxVal)
constructors
Definition
rangeVariable.cpp:60
gum::RangeVariable::_maxBound_
long _maxBound_
The upper bound.
Definition
rangeVariable.h:192
gum::RangeVariable::index
Idx index(std::string_view) const final
Definition
rangeVariable_inl.h:84
gum::Variable
Base class for every random variable.
Definition
variable.h:81
discreteVariable.h
Base class for discrete random variable.
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
gum::Idx
Size Idx
Type for indexes.
Definition
types.h:79
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::VarType
VarType
Definition
variable.h:62
std
STL namespace.
rangeVariable_inl.h
Inline implementation of gumRangeVariable.
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0