aGrUM  0.14.2
triangulation.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
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  ***************************************************************************/
26 #include <agrum/agrum.h>
27 #include <agrum/core/math/math.h>
29 
30 #ifdef GUM_NO_INLINE
32 #endif // GUM_NO_INLINE
33 
34 namespace gum {
35 
36  // constructor
38  // for debugging purposes
39  GUM_CONSTRUCTOR(Triangulation);
40  }
41 
42  // constructor with a domain size specified
44  _domain_sizes(domsizes) {
45  GUM_CONSTRUCTOR(Triangulation);
46  }
47 
48  // destructor
50  // for debugging purposes
51  GUM_DESTRUCTOR(Triangulation);
52  }
53 
54  // copy constructor
57  GUM_CONS_CPY(Triangulation);
58  }
59 
60  // move constructor
63  GUM_CONS_MOV(Triangulation);
64  }
65 
66  // returns the max of log10DomainSize of cliques in the junction tree
68  double res = 0.0;
69  double dSize;
70  const JunctionTree& jt = junctionTree(); // here, the fact that we get
71  // a junction tree ensures that _domain_sizes is different from nullptr
72 
73  for (const NodeId cl : jt) {
74  dSize = 0.0;
75 
76  for (const auto node : jt.clique(cl))
77  dSize += std::log10((*_domain_sizes)[node]);
78 
79  if (res < dSize) res = dSize;
80  }
81 
82  return res;
83  }
84 
85 } /* namespace gum */
Useful macros for maths.
double maxLog10CliqueDomainSize()
returns the max of log10DomainSize of the cliques in the junction tree.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:676
const NodeProperty< Size > * _domain_sizes
the domain sizes of the variables/nodes of the graph
Abstract base class for computing triangulations of graphs.
Basic graph of cliques.
Definition: cliqueGraph.h:55
Triangulation()
default constructor
virtual ~Triangulation()
destructor
Abstract base class for computing triangulations of graphs.
Interface for all the triangulation methods.
Definition: triangulation.h:44
virtual const CliqueGraph & junctionTree()=0
returns a compatible junction tree
Size NodeId
Type for node ids.
Definition: graphElements.h:97