aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
decisionTensor.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
49#ifndef GUM_DECISIONTENSOR_H
50#define GUM_DECISIONTENSOR_H
51
53
54#include <string_view>
55
56namespace gum {
62 template < GUM_Numeric GUM_SCALAR >
64 public:
65 Tensor< GUM_SCALAR > probPot;
66 Tensor< GUM_SCALAR > utilPot;
67
68 explicit DecisionTensor();
69
71
72 DecisionTensor(const Tensor< GUM_SCALAR >& prob, const Tensor< GUM_SCALAR >& util);
73
75
76 void clear();
77
79
81
83
84 bool operator==(const DecisionTensor< GUM_SCALAR >& p) const;
85
86 const DiscreteVariable* variable(std::string_view name) const;
87
88 void insertProba(const gum::Tensor< GUM_SCALAR >& proba);
89
91
93
95
97
98 DecisionTensor< GUM_SCALAR > operator^(const std::vector< std::string >& ontonames) const;
99
100 static Tensor< GUM_SCALAR > divideEvenZero(const Tensor< GUM_SCALAR >& p1,
101 const Tensor< GUM_SCALAR >& p2);
102
105
107 const gum::VariableSet& onto);
108
111 const std::vector< std::string >& ontonames);
112
113 std::pair< GUM_SCALAR, GUM_SCALAR > meanVar();
114
115 virtual std::string toString() const;
116 };
117
118 template < GUM_Numeric GUM_SCALAR >
119 std::ostream& operator<<(std::ostream& out, const DecisionTensor< GUM_SCALAR >& array);
120} // namespace gum
121
123
124#endif // GUM_DECISIONTENSOR_H
<agrum/ID/inference/decisionTensor.h>
bool operator==(const DecisionTensor< GUM_SCALAR > &p) const
static DecisionTensor< GUM_SCALAR > marginalization(const DecisionTensor< GUM_SCALAR > &dp, const gum::VariableSet &onto)
void insertProba(const gum::Tensor< GUM_SCALAR > &proba)
std::pair< GUM_SCALAR, GUM_SCALAR > meanVar()
static Tensor< GUM_SCALAR > divideEvenZero(const Tensor< GUM_SCALAR > &p1, const Tensor< GUM_SCALAR > &p2)
virtual std::string toString() const
DecisionTensor< GUM_SCALAR > & operator=(const DecisionTensor< GUM_SCALAR > &src)
void insertUtility(const gum::Tensor< GUM_SCALAR > &util)
DecisionTensor< GUM_SCALAR > operator^(const gum::VariableSet &onto) const
const DiscreteVariable * variable(std::string_view name) const
Tensor< GUM_SCALAR > utilPot
DecisionTensor< GUM_SCALAR > operator*=(const DecisionTensor< GUM_SCALAR > &dp1)
Tensor< GUM_SCALAR > probPot
static DecisionTensor< GUM_SCALAR > combination(const DecisionTensor< GUM_SCALAR > &dp1, const DecisionTensor< GUM_SCALAR > &dp2)
Base class for discrete random variable.
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Definition tensor.h:85
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
value_type & operator*()
Returns the value pointed to by the iterator.
Set< const DiscreteVariable * > VariableSet
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree
Header of the Tensor class.