aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
scheduleMultiDim.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
41
47#ifndef GUM_SCHEDULE_MULTI_DIM_H
48#define GUM_SCHEDULE_MULTI_DIM_H
49
50#include <memory>
51#include <string>
52
53#include <agrum/agrum.h>
54
56
57namespace gum {
58
117 template < typename TABLE >
119 public:
120 // ############################################################################
122 // ############################################################################
124
126
135 explicit ScheduleMultiDim(const TABLE& table, const bool copy, const Idx id = 0);
136
138
144 explicit ScheduleMultiDim(TABLE&& table, const Idx id = 0);
145
147
154 explicit ScheduleMultiDim(const Sequence< const DiscreteVariable* >& vars, const Idx id = 0);
155
158
161
164
166 virtual ScheduleMultiDim< TABLE >* clone(bool force_copy) const;
167
170
172
173
174 // ############################################################################
176 // ############################################################################
177
179
182
185
187
189 virtual bool operator==(const ScheduleMultiDim< TABLE >&) const;
190
192
194 virtual bool operator==(const IScheduleMultiDim&) const;
195
197
199 virtual bool operator!=(const ScheduleMultiDim< TABLE >&) const;
200
202
204 virtual bool operator!=(const IScheduleMultiDim&) const;
205
207
208
209 // ############################################################################
211 // ############################################################################
213
215
220 virtual bool hasSameVariables(const IScheduleMultiDim& m) const;
221
223
228 virtual bool hasSameVariables(const ScheduleMultiDim< TABLE >& m) const;
229
231
235 virtual bool hasSameContent(const IScheduleMultiDim&) const;
236
238
242 virtual bool hasSameContent(const ScheduleMultiDim< TABLE >&) const;
243
245
247 bool isAbstract() const final;
248
250
253 bool containsMultiDim() const final;
254
256
266 void makeAbstract() final;
267
276
281 const TABLE& multiDim() const;
282
284 const Sequence< const DiscreteVariable* >& variablesSequence() const final;
285
287 Size domainSize() const final;
288
290
293 double sizeOfContent() const final;
294
296
301 void setMultiDim(const TABLE& table, const bool copy);
302
304 void setMultiDim(TABLE&& pot);
305
307 std::string toString() const final;
308
310
311
312 private:
314 TABLE* _table_{nullptr};
315
318
321
324
325
328
331 template < typename T >
332 struct ElementType {
333 using value_type = T;
334 };
335
336 template < template < typename, typename... > class CONTAINER, typename T, typename... Args >
337 struct ElementType< CONTAINER< T, Args... > > {
338 using value_type = T;
339 };
340 };
341
342} /* namespace gum */
343
344// always include the template implementation
346
347#endif /* GUM_SCHEDULE_MULTI_DIM_H */
The Table-agnostic base class of scheduleMultiDim.
Base class for discrete random variable.
IScheduleMultiDim(const Idx id=0)
constructs a IScheduleMultiDim
ScheduleMultiDim(const ScheduleMultiDim< TABLE > &from)
copy constructor
const TABLE & multiDim() const
returns the table actually contained in the ScheduleMultiDim
ScheduleMultiDim(TABLE &&table, const Idx id=0)
constructs a ScheduleMultiDim by moving a table inside it
ScheduleMultiDim(const TABLE &table, const bool copy, const Idx id=0)
constructs a ScheduleMultiDim by copying/referencing table
virtual bool hasSameVariables(const IScheduleMultiDim &m) const
checks whether two ScheduleMultiDim have the same variables and types
ScheduleMultiDim< TABLE > & operator=(const ScheduleMultiDim< TABLE > &from)
copy operator
virtual ~ScheduleMultiDim()
destructor
Size domainSize() const final
returns the domain size the table would have after its creation
Sequence< const DiscreteVariable * > _var_sequence_
returns the sequence of variables of the table
ScheduleMultiDim(ScheduleMultiDim< TABLE > &&from)
move constructor
virtual bool operator==(const IScheduleMultiDim &) const
checks whether two ScheduleMultiDim have the same ID and type
TABLE * exportMultiDim()
returns the contained multidimensional table, if any, and make the ScheduleMultiDim abstract
virtual bool hasSameVariables(const ScheduleMultiDim< TABLE > &m) const
checks whether two ScheduleMultiDim have the same variables
std::string toString() const final
displays the content of the ScheduleMultiDim
virtual bool hasSameContent(const IScheduleMultiDim &) const
checks whether two ScheduleMultiDim contain precisely the same table
virtual bool operator!=(const IScheduleMultiDim &) const
checks whether two ScheduleMultiDim have different IDs or types
virtual bool operator==(const ScheduleMultiDim< TABLE > &) const
checks whether two ScheduleMultiDim have exactly the same ID
void setMultiDim(const TABLE &table, const bool copy)
assigns a new table inside the wrapper
const Sequence< const DiscreteVariable * > & variablesSequence() const final
returns the set of variables involved in the ScheduleMultiDim
bool containsMultiDim() const final
indicates whether the ScheduleMultiDim contains a table and possesses it
void _removeTable_()
remove the table if it is contained in the ScheduleMultiDim
void makeAbstract() final
if the ScheduleMultiDim is not abstract, make it abstract again
ScheduleMultiDim(const Sequence< const DiscreteVariable * > &vars, const Idx id=0)
construct a ScheduleMultiDim for a multidimensional table yet to be built
double sizeOfContent() const final
returns the sizeof of the elements stored into the ScheduleMultiDim
bool _table_contained_
indicates whether table is contained or referenced
ScheduleMultiDim< TABLE > & operator=(ScheduleMultiDim< TABLE > &&from)
move operator
bool isAbstract() const final
returns whether the ScheduleMultiDim contains a real table or not
virtual ScheduleMultiDim< TABLE > * clone(bool force_copy) const
virtual copy constructor enabling to force a copy of the content
virtual ScheduleMultiDim< TABLE > * clone() const
virtual copy constructor
virtual bool hasSameContent(const ScheduleMultiDim< TABLE > &) const
checks whether two ScheduleMultiDim contain precisely the same table
Size _domain_size_
the domain size of the table
virtual bool operator!=(const ScheduleMultiDim< TABLE > &) const
checks whether two ScheduleMultiDim have different IDs
TABLE * _table_
the multidimensional table stored into the ScheduleMultiDim
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:972
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size Idx
Type for indexes.
Definition types.h:79
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.
a Wrapper for multi-dimensional tables used for scheduling inferences
metaprogramming to get the types of the elements stored into the ScheduleMultidims