aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
O3ClassFactory.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
49
50#include <algorithm>
51#include <memory>
52#include <string>
53
56
57#ifndef GUM_PRM_O3PRM_O3CLASS_FACTORY_H
58# define GUM_PRM_O3PRM_O3CLASS_FACTORY_H
59
60namespace gum {
61 namespace prm {
62 namespace o3prm {
63
73 template < typename GUM_SCALAR >
75 public:
77 O3PRM& o3_prm,
79 ErrorsContainer& errors);
85
86 void buildClasses();
87
89
90 void buildParameters();
91
93
94 void declareAggregates();
95
96 void completeAggregates();
97
98 void declareAttributes();
99
100 void completeAttributes();
101
102
103 private:
108
113 std::vector< O3Class* > _o3Classes_;
114
118
120
122
123 bool _checkO3Classes_();
125
129
131 O3Label& i,
135
136 bool _checkImplementation_(O3Label& o3_type, const PRMType& type);
137
138 bool _checkImplementation_(O3Label& o3_type,
141
145
147
151
152
155
159
161
163
164 bool _checkAttributeForCompletion_(const O3Class& o3_c, O3Attribute& attr);
165
166 bool _checkParent_(const PRMClass< GUM_SCALAR >& c, const O3Label& prnt);
167
168 bool _checkLocalParent_(const PRMClass< GUM_SCALAR >& c, const O3Label& prnt);
169
171 const O3Label& prnt);
172
173 bool _checkRawCPT_(const PRMClass< GUM_SCALAR >& c, O3RawCPT& attr);
174
175 bool _checkRuleCPT_(const PRMClass< GUM_SCALAR >& c, O3RuleCPT& attr);
176
177 bool _checkLabelsNumber_(const O3RuleCPT& attr, const O3RuleCPT::O3Rule& rule);
178
180 const O3RuleCPT& attr,
181 const O3RuleCPT::O3Rule& rule);
182
184 const HashTable< std::string, const PRMParameter< GUM_SCALAR >* >& scope,
185 O3RuleCPT::O3Rule& rule);
186
188 const O3RuleCPT& attr,
189 const O3RuleCPT::O3Rule& rule);
190
192
197 const O3Label& chain);
198
200 const O3Label& chain,
201 const std::string& s);
203
208
211
212 const PRMType* _checkAggParents_(O3Class& o3class, O3Aggregate& agg);
213
214 bool _checkAggTypeLegality_(O3Class& o3class, O3Aggregate& agg);
215
216
217 bool _checkAggParameters_(O3Class& o3class, O3Aggregate& agg, const PRMType* t);
218
220
222
223 // @}
224 };
225
226 } // namespace o3prm
227 } // namespace prm
228} // namespace gum
229
230// always include the implementation of the templates
232
233
234# ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
236# endif
237
238
239#endif // GUM_PRM_O3PRM_O3CLASS_FACTORY_H
Implementation for the O3ClassFactory class.
Headers for the O3NameSolver class.
Headers of PRMFactory.
Base class for dag.
Definition DAG.h:121
This class is used contain and manipulate gum::ParseError.
<agrum/PRM/classElementContainer.h>
Abstract class representing an element of PRM class.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
Definition PRMClass.h:75
Factory which builds a PRM<GUM_SCALAR>.
Definition PRMFactory.h:88
PRMParameter is a member of a Class in a PRM.
This is a decoration of the DiscreteVariable class.
Definition PRMType.h:78
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
Definition PRM.h:74
The O3Aggregate is part of the AST of the O3PRM language.
Definition O3prm.h:598
The O3Attribute is part of the AST of the O3PRM language.
Definition O3prm.h:486
Builds gum::prm::Class from gum::prm::o3prm::O3Class.
bool _checkRemoteParent_(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &prnt)
O3NameSolver< GUM_SCALAR > * _solver_
bool _checkLabelsNumber_(const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
bool _checkAggTypeLegality_(O3Class &o3class, O3Aggregate &agg)
bool _checkImplementation_(O3Class &c, O3Label &i, HashTable< std::string, O3Attribute * > &attrMap, HashTable< std::string, O3Aggregate * > &aggMap, HashTable< std::string, O3ReferenceSlot * > &refMap)
bool _checkRawCPT_(const PRMClass< GUM_SCALAR > &c, O3RawCPT &attr)
const PRMClassElement< GUM_SCALAR > * _resolveSlotChain_(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain)
HashTable< std::string, gum::NodeId > _nameMap_
O3ClassFactory(PRM< GUM_SCALAR > &prm, O3PRM &o3_prm, O3NameSolver< GUM_SCALAR > &solver, ErrorsContainer &errors)
bool _checkAggParameters_(O3Class &o3class, O3Aggregate &agg, const PRMType *t)
bool _checkLocalParent_(const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
void _addParamsToForms_(const HashTable< std::string, const PRMParameter< GUM_SCALAR > * > &scope, O3RuleCPT::O3Rule &rule)
bool _checkAggregateForDeclaration_(O3Class &o3class, O3Aggregate &agg)
bool _checkRuleCPT_(const PRMClass< GUM_SCALAR > &c, O3RuleCPT &attr)
std::vector< O3Class * > _o3Classes_
void _addParameters_(PRMFactory< GUM_SCALAR > &factory, O3Class &c)
bool _checkAttributeForDeclaration_(O3Class &o3_c, O3Attribute &attr)
bool _checkParameterValue_(O3Aggregate &agg, const gum::prm::PRMType &t)
const PRMType * _checkAggParents_(O3Class &o3class, O3Aggregate &agg)
void _completeAttribute_(PRMFactory< GUM_SCALAR > &factory, O3Class &c)
bool _checkSlotChainLink_(const PRMClassElementContainer< GUM_SCALAR > &c, const O3Label &chain, const std::string &s)
bool _checkLabelsValues_(const PRMClass< GUM_SCALAR > &c, const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
void _completeAggregates_(PRMFactory< GUM_SCALAR > &factory, O3Class &c)
bool _checkAttributeForCompletion_(const O3Class &o3_c, O3Attribute &attr)
bool _checkReferenceSlot_(O3Class &c, O3ReferenceSlot &ref)
bool _checkParent_(const PRMClass< GUM_SCALAR > &c, const O3Label &prnt)
bool _checkParametersNumber_(O3Aggregate &agg, Size n)
bool _checkAggregateForCompletion_(O3Class &o3class, O3Aggregate &agg)
O3ClassFactory< GUM_SCALAR > & operator=(const O3ClassFactory< GUM_SCALAR > &src)
HashTable< std::string, O3Class * > _classMap_
HashTable< NodeId, O3Class * > _nodeMap_
bool _checkRuleCPTSumsTo1_(const PRMClass< GUM_SCALAR > &c, const O3RuleCPT &attr, const O3RuleCPT::O3Rule &rule)
The O3Class is part of the AST of the O3PRM language.
Definition O3prm.h:640
The O3Label is part of the AST of the O3PRM language.
Definition O3prm.h:192
Resolves names for the different O3PRM factories.
The O3PRM is part of the AST of the O3PRM language.
Definition O3prm.h:913
The O3RawCPT is part of the AST of the O3PRM language.
Definition O3prm.h:523
The O3ReferenceSlot is part of the AST of the O3PRM language.
Definition O3prm.h:453
The O3RuleCPT is part of the AST of the O3PRM language.
Definition O3prm.h:559
std::pair< O3LabelList, O3FormulaList > O3Rule
Definition O3prm.h:563
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46