aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
graphicalModel.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 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-2025 *
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
49#ifndef GUM_GRAPHICALMODEL_H
50#define GUM_GRAPHICALMODEL_H
51#include <agrum/agrum.h>
52
56
57namespace gum {
58
66 public:
69
74
78 virtual ~GraphicalModel();
79
83 GraphicalModel(const GraphicalModel& source);
84
88
93 const std::string& property(const std::string& name) const;
94
99 const std::string& propertyWithDefault(const std::string& name,
100 const std::string& byDefault) const;
101
105 void setProperty(const std::string& name, const std::string& value);
106
110 std::vector< std::string > properties() const;
111
115
119 virtual const VariableNodeMap& variableNodeMap() const = 0;
120
124 virtual Size size() const = 0;
125
129 virtual bool empty() const;
130
134 virtual bool exists(NodeId node) const = 0;
135 virtual bool exists(const std::string& name) const = 0;
136
141 std::vector< std::string > names(const std::vector< NodeId >& ids) const;
142
147 std::vector< std::string > names(const NodeSet& ids) const;
148
153 std::vector< NodeId > ids(const std::vector< std::string >& names) const;
154
159 NodeSet nodeset(const std::vector< std::string >& names) const;
160
165 gum::VariableSet variables(const std::vector< std::string >& l) const;
166
172
173 virtual const NodeGraphPart& nodes() const = 0;
174
177
182 virtual const DiscreteVariable& variable(NodeId id) const = 0;
183
188 virtual NodeId nodeId(const DiscreteVariable& var) const = 0;
189
192 virtual NodeId idFromName(const std::string& name) const = 0;
193
196 virtual const DiscreteVariable& variableFromName(const std::string& name) const = 0;
197
199
200 double log10DomainSize() const;
201
204 virtual bool isIndependent(NodeId X, NodeId Y, const NodeSet& Z) const = 0;
205
208 virtual bool isIndependent(const NodeSet& X, const NodeSet& Y, const NodeSet& Z) const = 0;
209
210
218 static void spaceCplxToStream(std::stringstream& s, double dSize, int dim, Size usedMem);
219
221
225 virtual NodeSet family(const NodeId id) const = 0;
226 virtual NodeSet family(const std::string& name) const = 0;
227
228 protected:
233
234 private:
237
240 };
241} // namespace gum
242
243#ifndef GUM_NO_INLINE
245#endif /* GUM_NO_INLINE */
246
247#endif /* GUM_GRAPHICALMODEL_H */
Base classes for directed acyclic graphs.
Base class for discrete random variable.
const HashTable< std::string, std::string > & _properties_() const
Return the properties of this Directed Graphical Model.
virtual ~GraphicalModel()
Destructor.
virtual const DiscreteVariable & variable(NodeId id) const =0
Returns a constant reference over a variable given it's node id.
static void spaceCplxToStream(std::stringstream &s, double dSize, int dim, Size usedMem)
send to the stream the space complexity with 3 parametrs
void setProperty(const std::string &name, const std::string &value)
Add or change a property of this GraphicalModel.
GraphicalModel & operator=(const GraphicalModel &source)
Private copy operator.
virtual const VariableNodeMap & variableNodeMap() const =0
Returns a constant reference to the VariableNodeMap of this Graphical Model.
virtual bool exists(const std::string &name) const =0
Returns a constant reference to the VariableNodeMap of this Graphical Model.
virtual NodeSet family(const NodeId id) const =0
returns the family of a noe (parents or neighbours) of a node and the node
HashTable< std::string, std::string > _propertiesMap_
The properties of this Directed Graphical Model.
const std::string & property(const std::string &name) const
Return the value of the property name of this GraphicalModel.
const std::string & propertyWithDefault(const std::string &name, const std::string &byDefault) const
Return the value of the property name of this GraphicalModel.
std::vector< NodeId > ids(const std::vector< std::string > &names) const
transform a vector of names into a vector of nodeId
virtual const NodeGraphPart & nodes() const =0
Returns a constant reference to the VariableNodeMap of this Graphical Model.
std::vector< std::string > names(const std::vector< NodeId > &ids) const
transform a vector of NodeId in a vector of names
GraphicalModel()
Default constructor.
virtual bool exists(NodeId node) const =0
Return true if this node exists in this graphical model.
gum::VariableSet variables(const std::vector< std::string > &l) const
transform a vector of names into a VariableeSet
virtual bool isIndependent(const NodeSet &X, const NodeSet &Y, const NodeSet &Z) const =0
check if nodes X and nodes Y are independent given nodes Z
virtual bool isIndependent(NodeId X, NodeId Y, const NodeSet &Z) const =0
check if node X and node Y are independent given nodes Z
virtual NodeId idFromName(const std::string &name) const =0
Getter by name.
virtual const DiscreteVariable & variableFromName(const std::string &name) const =0
Getter by name.
double log10DomainSize() const
std::vector< std::string > properties() const
List of all the properties.
NodeSet nodeset(const std::vector< std::string > &names) const
transform a vector of names into a NodeSet
virtual NodeSet family(const std::string &name) const =0
virtual NodeId nodeId(const DiscreteVariable &var) const =0
Return id node src discrete var pointer.
Instantiation completeInstantiation() const
Get an instantiation over all the variables of the model.
virtual bool empty() const
Return true if this graphical model is empty.
virtual Size size() const =0
Returns the number of variables in this Directed Graphical Model.
Class for assigning/browsing values to tuples of discrete variables.
Class for node sets in graph.
Container used to map discrete variables with nodes.
Interface-like class encapsulating basic functionalities for both a IBayesNet and IMarkovRandomField.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size NodeId
Type for node ids.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Header files of gum::Instantiation.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet
Header of class VariableNodeMap.