aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
o4DGContext_inl.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#pragma once
41
42
51
53
54namespace gum {
55
56 // Set DG1 diagram current explored Node
57 INLINE void O4DGContext::setDG1Node(const NodeId& exploredNode) {
58 _DG1ExploredNode_ = exploredNode;
59 }
60
61 // Set DG2 diagram current explored Node
62 INLINE void O4DGContext::setDG2Node(const NodeId& exploredNode) {
63 _DG2ExploredNode_ = exploredNode;
64 }
65
66 // Changes given variable modality
67 INLINE void O4DGContext::chgVarModality(Idx varIndex, Idx newModality) {
68 _varInstantiation_[varIndex] = newModality;
69 }
70
71 // Changes given variable modality
72 INLINE Idx O4DGContext::varModality(Idx varIndex) { return _varInstantiation_[varIndex]; }
73
74 // Returns o4DGContext key
75 INLINE const double& O4DGContext::key(short int* instNeeded) {
77
78 for (Idx varPos = 0, offset = _offsetv_; varPos < _nbVar_; varPos++, offset--)
79 if (instNeeded[varPos]) _key_ += _varInstantiation_[varPos] * _logPrime_[offset];
80
81 return _key_;
82 }
83
84 INLINE void* O4DGContext::operator new(size_t s) {
86 }
87
88 INLINE void O4DGContext::operator delete(void* p) {
90 }
91
93
94
95} /* end of namespace gum */
void setDG2Node(const NodeId &)
Set DG2 diagram current explored Node.
static const Idx _offset2_
NodeId _DG2ExploredNode_
DG2 Diagram current explored node.
void chgVarModality(Idx, Idx)
Changes given variable modality.
void setDG1Node(const NodeId &)
Set DG1 diagram current explored Node.
static const Idx _offset1_
double _key_
The key use to store the context as a key in the hashtable.
const double & key(short int *instNeeded)
Returns o4DGContext key.
Idx varModality(Idx)
Changes given variable modality.
static const double _logPrime_[]
Table containing the log2 of prime numbers.
static const Idx _offsetv_
Idx * _varInstantiation_
Vector containing for each retrograde variable its current modality 0 meaning no instantiation done =...
NodeId _DG1ExploredNode_
DG1 Diagram current explored node.
O4DGContext(Idx *, Idx)
Default constructor.
static SmallObjectAllocator & instance()
void * allocate(const size_t &objectSize)
Allocates a block.
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
Size Idx
Type for indexes.
Definition types.h:79
Size NodeId
Type for node ids.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Class used to manipulate o4DGContext in Function Graph Operations.