parse.
83 prm::o3prm::O3prmReader< GUM_SCALAR > reader;
91 std::string instanceName =
"";
95 ParseError warn(
false,
97 +
"' found but class found. Generating unnamed instance.",
107 }
else if (prm->
classes().size() == 1) {
108 const std::string& entityName = (*prm->
classes().begin())->name();
109 ParseError warn(
false,
110 "Unique class '" + entityName +
"' found. Generating unnamed instance.",
123 _bn_->setProperty(
"name", entityName);
127 "Neither system nor class '" +
_entityName_ +
"' and more than one class.",
135 for (
auto node:
_bn_->nodes()) {
137 const std::string& nn =
_bn_->variable(node).name();
138 _bn_->variable(node).setDescription(nn);
141 auto start = nn.find_first_of(
'(');
142 auto end = nn.find_first_of(
')');
143 if (0 < start && start < end && end < nn.size()) {
144 auto path = nn.substr(0, start);
145 auto type = nn.substr(start + 1, end - start - 1);
146 auto name = nn.substr(end + 1, std::string::npos);
150 std::string newName = newNameRadical;
158 _bn_->changeVariableName(node, newName);
160 ParseError warn(
false,
"Name " + nn +
" cannot be simplified.",
_filename_, 0);
void _generateBN_(prm::PRMSystem< GUM_SCALAR > &system)
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
bool isClass(const std::string &name) const
void add(NodeId id, PRMInstance< GUM_SCALAR > &instance)
Add an PRMInstance<GUM_SCALAR> to a given PRMReferenceSlot, PRMSlotChain<GUM_SCALAR> or output node...
static std::string _getVariableName_(const std::string &path, const std::string &type, const std::string &name, const std::string &toRemove="")
An PRMInstance is a Bayesian network fragment defined by a Class and used in a PRMSystem.
const Set< PRMClass< GUM_SCALAR > *> & classes() const
Returns the Set of all Class<GUM_SCALAR> in this PRM.
void add(ParseError error)
Add an error object to the container.
static std::string _getInstanceName_(const std::string &classname)
std::string to_string(const Formula &f)
bool isSystem(const std::string &name) const
PRMSystem< GUM_SCALAR > & getSystem(const std::string &name)
Returns a constant reference on a PRMSystem<GUM_SCALAR> given it's name.
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
BayesNet< GUM_SCALAR > * _bn_
PRMClass< GUM_SCALAR > & getClass(const std::string &name)
Returns a constant reference on a Class<GUM_SCALAR> given it's name.
Size errors()
publishing Errors API
void insert(const Key &k)
Inserts a new element into the set.