aGrUM 3.1.1
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-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#pragma once
42
43
50
52
53#ifndef DOXYGEN_SHOULD_SKIP_THIS
54
55namespace gum {
56
58 return Size(key.id());
59 }
60
62 return (castToSize(key) * gum::HashFuncConst::gold) & this->hash_mask_;
63 }
64
65 namespace credal {
66 namespace lp {
70
71 INLINE unsigned int LpCol::id() const { return _id_; }
72
73 INLINE bool LpCol::operator<(const LpCol& col) const { return (_id_ < col.id()); }
74
75 INLINE bool LpCol::operator==(const LpCol& col) const { return (_id_ == col.id()); }
76
77 INLINE bool LpCol::operator!=(const LpCol& col) const { return (_id_ != col.id()); }
78
79 INLINE LpCol& LpCol::operator=(const LpCol& col) = default;
80
81 INLINE std::ostream& operator<<(std::ostream& out, const LpCol& col) {
82 out << col.toString();
83 return out;
84 }
85
86 INLINE std::string LpCol::toString() const {
87 std::string res = "V";
88 return res.append(std::to_string(_id_));
89 }
90
91 INLINE void swap(HashTable< LpCol, double >*& a, HashTable< LpCol, double >*& b) {
92 HashTable< LpCol, double >* tmp(a);
93 a = b;
94 b = tmp;
95 }
96
97 INLINE std::ostream& operator<<(std::ostream& out, const LpExpr& expr) {
98 out << expr.toString();
99 return out;
100 }
101 } // namespace lp
102
103 } // namespace credal
104
105} /* namespace gum */
106
107#endif /* DOXYGEN_SHOULD_SKIP_THIS */
Class representing a polytope ( credal set ) by a set of linear constraints.
Size operator()(const credal::lp::LpCol &key) const 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:101