aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
O3prmBNReader.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
51
#ifndef GUM_PRM_O3PRM_BNREADER_H
52
#define GUM_PRM_O3PRM_BNREADER_H
53
54
#include <algorithm>
55
#include <string>
56
57
#include <
agrum/BN/io/BNReader.h
>
58
#include <
agrum/PRM/o3prm/O3prmReader.h
>
59
60
#include <string_view>
61
62
namespace
gum
{
74
template
< GUM_Numeric GUM_SCALAR >
75
class
O3prmBNReader
:
public
BNReader
< GUM_SCALAR > {
76
public
:
77
O3prmBNReader
(BayesNet< GUM_SCALAR >* bn,
78
const
std::string& filename,
79
const
std::string& entityName =
""
,
80
const
std::string& classPath =
""
);
81
82
~O3prmBNReader
()
override
;
83
87
Size
proceed
()
override
;
88
91
93
Size
errors
();
94
96
Size
warnings
();
97
98
Idx
errLine
(
Idx
i);
99
101
Idx
errCol
(
Idx
i);
102
104
bool
errIsError
(
Idx
i);
105
107
std::string
errMsg
(
Idx
i);
108
110
void
showElegantErrors
(std::ostream& o = std::cerr);
111
113
void
showElegantErrorsAndWarnings
(std::ostream& o = std::cerr);
114
116
void
showErrorCounts
(std::ostream& o = std::cerr);
117
119
120
private
:
121
std::string
_filename_
;
122
123
std::string
_classpath_
;
124
std::string
_entityName_
;
125
126
BayesNet< GUM_SCALAR >*
_bn_
;
127
ErrorsContainer
_errors_
;
128
129
void
_generateBN_
(
prm::PRMSystem< GUM_SCALAR >
& system);
130
static
std::string
_getVariableName_
(std::string_view path,
131
std::string_view type,
132
std::string_view name,
133
std::string_view toRemove =
""
);
134
static
std::string
_getEntityName_
(std::string_view filename);
135
static
std::string
_getInstanceName_
(std::string_view classname);
136
};
137
138
}
// namespace gum
139
140
// always include the implementation of the templates
141
#include <
agrum/PRM/o3prm/O3prmBNReader_tpl.h
>
142
143
144
#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
145
extern
template
class
gum::O3prmBNReader< double >
;
146
#endif
147
148
149
#endif
// GUM_PRM_O3PRM_BNREADER_H
BNReader.h
Definition of abstract classes for file input manipulation of Bayesian networks.
O3prmBNReader_tpl.h
Inline implementation of O3prmReader.
O3prmReader.h
Headers for the O3prmReader class.
gum::BNReader::BNReader
BNReader(BayesNet< GUM_SCALAR > *bn, std::string_view filename)
Constructor A reader is defined for reading a defined file.
gum::ErrorsContainer
This class is used contain and manipulate gum::ParseError.
Definition
errorsContainer.h:180
gum::O3prmBNReader
Read an O3PRM and transform the gum::prm::PRMSystem into gum::BayesNet.
Definition
O3prmBNReader.h:75
gum::O3prmBNReader::errors
Size errors()
publishing Errors API
Definition
O3prmBNReader_tpl.h:201
gum::O3prmBNReader::_filename_
std::string _filename_
Definition
O3prmBNReader.h:121
gum::O3prmBNReader::showElegantErrorsAndWarnings
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
Definition
O3prmBNReader_tpl.h:236
gum::O3prmBNReader::proceed
Size proceed() override
parse the file
Definition
O3prmBNReader_tpl.h:105
gum::O3prmBNReader::_getInstanceName_
static std::string _getInstanceName_(std::string_view classname)
Definition
O3prmBNReader_tpl.h:69
gum::O3prmBNReader::_getVariableName_
static std::string _getVariableName_(std::string_view path, std::string_view type, std::string_view name, std::string_view toRemove="")
Definition
O3prmBNReader_tpl.h:56
gum::O3prmBNReader::errLine
Idx errLine(Idx i)
publishing Errors API
Definition
O3prmBNReader_tpl.h:211
gum::O3prmBNReader::_entityName_
std::string _entityName_
Definition
O3prmBNReader.h:124
gum::O3prmBNReader::_errors_
ErrorsContainer _errors_
Definition
O3prmBNReader.h:127
gum::O3prmBNReader::O3prmBNReader
O3prmBNReader(BayesNet< GUM_SCALAR > *bn, const std::string &filename, const std::string &entityName="", const std::string &classPath="")
Definition
O3prmBNReader_tpl.h:84
gum::O3prmBNReader::showElegantErrors
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errors
Definition
O3prmBNReader_tpl.h:231
gum::O3prmBNReader::showErrorCounts
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
Definition
O3prmBNReader_tpl.h:241
gum::O3prmBNReader::_getEntityName_
static std::string _getEntityName_(std::string_view filename)
Definition
O3prmBNReader_tpl.h:76
gum::O3prmBNReader::errIsError
bool errIsError(Idx i)
type of ith error or warning
Definition
O3prmBNReader_tpl.h:221
gum::O3prmBNReader::_generateBN_
void _generateBN_(prm::PRMSystem< GUM_SCALAR > &system)
Definition
O3prmBNReader_tpl.h:193
gum::O3prmBNReader::_classpath_
std::string _classpath_
Definition
O3prmBNReader.h:123
gum::O3prmBNReader::warnings
Size warnings()
Definition
O3prmBNReader_tpl.h:206
gum::O3prmBNReader::_bn_
BayesNet< GUM_SCALAR > * _bn_
Definition
O3prmBNReader.h:126
gum::O3prmBNReader::errMsg
std::string errMsg(Idx i)
message of ith error or warning
Definition
O3prmBNReader_tpl.h:226
gum::O3prmBNReader::errCol
Idx errCol(Idx i)
col of ith error or warning
Definition
O3prmBNReader_tpl.h:216
gum::prm::PRMSystem
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition
PRMSystem.h:72
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
gum::Idx
Size Idx
Type for indexes.
Definition
types.h:79
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0