aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
LpInterface_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
49
51
52#ifndef DOXYGEN_SHOULD_SKIP_THIS
53
54namespace gum {
55
57 return Size(key.id());
58 }
59
61 return (castToSize(key) * gum::HashFuncConst::gold) & this->hash_mask_;
62 }
63
64 namespace credal {
65 namespace lp {
69
70 INLINE unsigned int LpCol::id() const { return _id_; }
71
72 INLINE bool LpCol::operator<(const LpCol& col) const { return (_id_ < col.id()); }
73
74 INLINE bool LpCol::operator==(const LpCol& col) const { return (_id_ == col.id()); }
75
76 INLINE bool LpCol::operator!=(const LpCol& col) const { return (_id_ != col.id()); }
77
78 INLINE LpCol& LpCol::operator=(const LpCol& col) {
79 _id_ = col._id_;
80
81 return *this;
82 }
83
84 INLINE std::ostream& operator<<(std::ostream& out, const LpCol& col) {
85 out << col.toString();
86 return out;
87 }
88
89 INLINE std::string LpCol::toString() const {
90 std::string res = "V";
91 return res.append(std::to_string(_id_));
92 }
93
94 INLINE void swap(HashTable< LpCol, double >*& a, HashTable< LpCol, double >*& b) {
95 HashTable< LpCol, double >* tmp(a);
96 a = b;
97 b = tmp;
98 }
99
100 INLINE std::ostream& operator<<(std::ostream& out, const LpExpr& expr) {
101 out << expr.toString();
102 return out;
103 }
104 } // namespace lp
105
106 } // namespace credal
107
108} /* namespace gum */
109
110#endif /* DOXYGEN_SHOULD_SKIP_THIS */
Class representing a polytope ( credal set ) by a set of linear constraints.
virtual Size operator()(const credal::lp::LpCol &key) const override final
Overload of operator () to compute hash of a variable LpCol.
static Size castToSize(const credal::lp::LpCol &key)
Returns the value of a key as a Size.
Class representing a variable ( a column ) of a linear program, i.e.
Definition LpInterface.h:80
bool operator!=(const LpCol &col) const
Opposite of equality != test between two variables.
LpCol & operator=(const LpCol &col)
Assignment operator = by copy.
bool operator<(const LpCol &col) const
Test of ordering < between two variables.
std::string toString() const
Get the string representation of a calling variable.
unsigned int id() const
Variable id accessor.
unsigned int _id_
Variable id.
bool operator==(const LpCol &col) const
Test of equality == between two variables.
Class representing a linear expression.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
namespace for constraint-based description of credal sets
Definition agrum.h:64
std::ostream & operator<<(std::ostream &out, const LpRow &row)
void swap(HashTable< LpCol, double > *&a, HashTable< LpCol, double > *&b)
Swap the addresses of two pointers to hashTables.
namespace for all credal networks entities
Definition agrum.h:61
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
static constexpr Size gold
Definition hashFunc.h:98