aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
ShaferShenoyLIMIDInference.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
47
48#ifndef GUM_SHAFERSHENOY_LIMIDS_H
49#define GUM_SHAFERSHENOY_LIMIDS_H
50
51#include <iostream>
52#include <string>
53#include <utility>
54#include <vector>
55
56#include <agrum/agrum.h>
57
65
66#include <string_view>
67
68namespace gum {
69
80 template < GUM_Numeric GUM_SCALAR >
85
86
87 public:
88 // ====================================================================
90 // ====================================================================
92
98
103
105
106 void clear() override;
107
110 void addNoForgettingAssumption(const std::vector< NodeId >& ids);
111 void addNoForgettingAssumption(const std::vector< std::string >& names);
113
115
117
118 std::vector< NodeSet > reversePartialOrder() const;
119
121
122 bool isSolvable() const;
123
124
126
127 gum::Tensor< GUM_SCALAR > optimalDecision(std::string_view decisionName) final;
128
135 virtual const Tensor< GUM_SCALAR >& posterior(NodeId node) final;
136
137 const Tensor< GUM_SCALAR >& posterior(std::string_view name) final;
138
145 virtual const Tensor< GUM_SCALAR >& posteriorUtility(NodeId node) final;
146
147 virtual const Tensor< GUM_SCALAR >& posteriorUtility(std::string_view name) final;
148
155 virtual std::pair< GUM_SCALAR, GUM_SCALAR > meanVar(NodeId node) final;
156
157 std::pair< GUM_SCALAR, GUM_SCALAR > meanVar(std::string_view name) final;
158
164 std::pair< GUM_SCALAR, GUM_SCALAR > MEU() final;
165
166 protected:
167 void onStateChanged_() override;
168 void onEvidenceAdded_(NodeId id, bool isHardEvidence) override;
169 void onEvidenceErased_(NodeId id, bool isHardEvidence) override;
170 void onAllEvidenceErased_(bool contains_hard_evidence) override;
171 void onEvidenceChanged_(NodeId id, bool hasChangedSoftHard) override;
172 void onModelChanged_(const GraphicalModel* model) override;
174 void updateOutdatedTensors_() override;
175 void makeInference_() override;
176
179
187
192
193 private:
196 void _creatingPartialOrder_(const NodeSet& utilities);
197 void _checkingSolvability_(const NodeSet& utilities);
200
204 PsiArcProperty& psi,
205 NodeId fromClique,
206 NodeId toClique);
207 void deciding_(PhiNodeProperty& phi, PsiArcProperty& psi, NodeId decisionNode);
209 PsiArcProperty& psi,
210 NodeId fromClique,
211 NodeId toClique);
213 PsiArcProperty& psi,
214 NodeId fromClique,
215 NodeId toClique);
219 const PsiArcProperty& psi,
220 NodeId clique,
221 NodeId except) const;
222 DecisionTensor< double >
223 integrating_(const PhiNodeProperty& phi, const PsiArcProperty& psi, NodeId clique) const;
224 void binarizingMax_(const Tensor< GUM_SCALAR >& decision,
225 const Tensor< GUM_SCALAR >& proba) const;
226 };
227} /* namespace gum */
228
229#include <agrum/ID/inference/ShaferShenoyLIMIDInference_tpl.h>
230
231#endif /* GUM_SHAFERSHENOY_LIMIDS_H */
Basic graph of cliques.
Definition cliqueGraph.h:77
Base class for dag.
Definition DAG.h:121
<agrum/ID/inference/decisionTensor.h>
The default triangulation algorithm used by aGrUM.
virtual const GraphicalModel & model() const final
Returns a constant reference over the IBayesNet referenced by this class.
Virtual base class for probabilistic graphical models.
InfluenceDiagramInference(const InfluenceDiagram< GUM_SCALAR > *infDiag)
Default constructor.
Class representing an Influence Diagram.
NodeSet nonRequisiteNodes_(NodeId d) const
Returns the set of non-requisite for node d.
gum::Tensor< GUM_SCALAR > optimalDecision(std::string_view decisionName) final
NodeProperty< DecisionTensor< GUM_SCALAR > > posteriors_
void addNoForgettingAssumption(const std::vector< std::string > &names)
Default constructor.
void onEvidenceChanged_(NodeId id, bool hasChangedSoftHard) override
fired after an evidence is changed, in particular when its status (soft/hard) changes
void makeInference_() override
called when the inference has to be performed effectively
void collectingToFollowingRoot_(PhiNodeProperty &phi, PsiArcProperty &psi, NodeId fromClique, NodeId toClique)
void onEvidenceAdded_(NodeId id, bool isHardEvidence) override
fired after a new evidence is inserted
std::pair< GUM_SCALAR, GUM_SCALAR > meanVar(std::string_view name) final
void onAllEvidenceErased_(bool contains_hard_evidence) override
fired before all the evidence are erased
virtual const Tensor< GUM_SCALAR > & posteriorUtility(std::string_view name) final
void onStateChanged_() override
fired when the stage is changed
void _creatingPartialOrder_(const NodeSet &utilities)
void _findingCliqueForEachNode_(DefaultTriangulation &triangulation)
void updateOutdatedStructure_() override
prepares inference when the latter is in OutdatedStructure state
void updateOutdatedTensors_() override
prepares inference when the latter is in OutdatedTensors state
void deciding_(PhiNodeProperty &phi, PsiArcProperty &psi, NodeId decisionNode)
void clear() override
Default constructor.
void addNoForgettingAssumption(const std::vector< NodeId > &ids)
No forgetting rule assumption.
virtual ~ShaferShenoyLIMIDInference()
Destructor.
const Tensor< GUM_SCALAR > & posterior(std::string_view name) final
NodeProperty< DecisionTensor< GUM_SCALAR > > PhiNodeProperty
void collectingMessage_(PhiNodeProperty &phi, PsiArcProperty &psi, NodeId rootClique)
void transmittingMessage_(PhiNodeProperty &phi, PsiArcProperty &psi, NodeId fromClique, NodeId toClique)
InfluenceDiagram< GUM_SCALAR > reducedLIMID() const
virtual const Tensor< GUM_SCALAR > & posterior(NodeId node) final
Return the posterior probability of a node.
NodeProperty< DecisionTensor< GUM_SCALAR > > unconditionalDecisions_
void onModelChanged_(const GraphicalModel *model) override
fired after a new Bayes net has been assigned to the engine
void _checkingSolvability_(const NodeSet &utilities)
void distributingMessage_(PhiNodeProperty &phi, PsiArcProperty &psi, NodeId rootClique)
void onEvidenceErased_(NodeId id, bool isHardEvidence) override
fired before an evidence is removed
virtual std::pair< GUM_SCALAR, GUM_SCALAR > meanVar(NodeId node) final
Return the pair (mean,variance) for a node.
ArcProperty< DecisionTensor< GUM_SCALAR > > PsiArcProperty
gum::Tensor< GUM_SCALAR > optimalDecision(NodeId decisionId) final
virtual const Tensor< GUM_SCALAR > & posteriorUtility(NodeId node) final
Return the posterior utility of a node.
std::vector< NodeSet > reversePartialOrder() const
bool hasNoForgettingAssumption() const
Default constructor.
ShaferShenoyLIMIDInference(const InfluenceDiagram< GUM_SCALAR > *infDiag)
Default constructor.
void binarizingMax_(const Tensor< GUM_SCALAR > &decision, const Tensor< GUM_SCALAR > &proba) const
void initializingInference_(PhiNodeProperty &phi, PsiArcProperty &psi)
std::pair< GUM_SCALAR, GUM_SCALAR > MEU() final
Return the pair (mean,variance) for the total utility (MEU).
DecisionTensor< double > integrating_(const PhiNodeProperty &phi, const PsiArcProperty &psi, NodeId clique, NodeId except) const
void computingPosteriors_(const PhiNodeProperty &phi, const PsiArcProperty &psi)
void transmittingFinalMessage_(PhiNodeProperty &phi, PsiArcProperty &psi, NodeId fromClique, NodeId toClique)
const JunctionTree * junctionTree() const
Default constructor.
NodeProperty< Tensor< GUM_SCALAR > > strategies_
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Definition tensor.h:85
This file contains abstract class definitions influence diagrams inference classes.
Class for computing default triangulations of graphs.
aGrUM's exceptions
Size NodeId
Type for node ids.
HashTable< Arc, VAL > ArcProperty
Property on graph elements.
HashTable< Edge, VAL > EdgeProperty
Property on graph elements.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
This file contains abstract class definitions influence diagrams inference classes.
Headers of the MultiDimBucket class.
Headers of MultiDimSparse.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet
CliqueGraph JunctionTree
a junction tree is a clique graph satisfying the running intersection property and such that no cliqu...
STL namespace.
class for graph triangulations for which we enforce a given partial ordering on the nodes elimination...