62 template < GUM_Numeric GUM_SCALAR >
64 std::string_view
name,
75 template < GUM_Numeric GUM_SCALAR >
83 template < GUM_Numeric GUM_SCALAR >
91 template < GUM_Numeric GUM_SCALAR >
95 for (
auto var:
_formulas_->variablesSequence()) {
96 if (var != &(
_type_->variable())) {
copy->_formulas_->add(*var); }
100 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end()); inst.inc(), jnst.
inc()) {
104 GUM_ASSERT(
copy->_formulas_->contains(
copy->_type_->variable()));
108 template < GUM_Numeric GUM_SCALAR >
115 for (
const auto& var: source.
cpf().variablesSequence()) {
124 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
125 inst.inc(), jnst.inc()) {
126 _formulas_->set(inst, src._formulas_->get(jnst));
129 GUM_ASSERT(inst.end() && jnst.end());
134 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end());
135 inst.inc(), jnst.
inc()) {
136 auto val = std::to_string(source.
cpf().get(jnst));
140 GUM_ASSERT(inst.end() && jnst.
end());
152 template < GUM_Numeric GUM_SCALAR >
158 template < GUM_Numeric GUM_SCALAR >
163 template < GUM_Numeric GUM_SCALAR >
168 template < GUM_Numeric GUM_SCALAR >
174 template < GUM_Numeric GUM_SCALAR >
186 elt.
name() <<
" of wrong type as parent of " << this->name();)
192 template < GUM_Numeric GUM_SCALAR >
195 template < GUM_Numeric GUM_SCALAR >
197 if (!
type().isSubType()) {
202 cast->addParent(*
this);
209 if (
type().label_map()[inst.
val(my_var)] == inst.
val(cast_var)) {
210 cast->cpf().set(inst, 1);
212 cast->cpf().set(inst, 0);
220 template < GUM_Numeric GUM_SCALAR >
228 std::format(
"{} is not a subtype of {}",
type().
name(),
cast->type().name()))
234 template < GUM_Numeric GUM_SCALAR >
259 template < GUM_Numeric GUM_SCALAR >
266 template < GUM_Numeric GUM_SCALAR >
272 template < GUM_Numeric GUM_SCALAR >
277 _cpf_ =
new Tensor< GUM_SCALAR >();
279 for (
auto var:
_formulas_->variablesSequence()) {
283 auto params =
_class_->scope();
292 if (val.empty()) { val =
"0.0"; }
296 for (
auto item: params) {
303 GUM_ASSERT(inst.
end() && jnst.
end());
309 template < GUM_Numeric GUM_SCALAR >
318 template < GUM_Numeric GUM_SCALAR >
323 template < GUM_Numeric GUM_SCALAR >
325 if (&(old_type) ==
_type_) {
339 for (
auto var: old->variablesSequence()) {
340 if (var != &(old_type.
variable())) {
349 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end()); inst.inc(), jnst.
inc()) {
360 GUM_ASSERT(inst.end() && jnst.
end());
366 template < GUM_Numeric GUM_SCALAR >
371 template < GUM_Numeric GUM_SCALAR >
380 for (
auto var: old->variablesSequence()) {
381 if (var != &(
_type_->variable())) {
390 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end()); inst.inc(), jnst.
inc()) {
404 GUM_ASSERT(inst.end() && jnst.
end());
Headers of gum::PRMScalarAttribute.
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
Set of pairs of elements with fast search for both elements.
Base class for discrete random variable.
virtual Size domainSize() const =0
Exception : a similar element already exists.
Base class for all aGrUM's exceptions.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Class for assigning/browsing values to tuples of discrete variables.
bool end() const
Returns true if the Instantiation reached the end.
void inc()
Operator increment.
Idx pos(const DiscreteVariable &v) const final
Returns the position of the variable v.
Idx val(Idx i) const
Returns the current value of the variable at position i.
void setFirst()
Assign the first values to the tuple of the Instantiation.
Multidimensional matrix stored as an array in memory.
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
Exception : wrong type for this operation.
PRMAttribute is a member of a Class in a PRM.
PRMAttribute(std::string_view name)
Destructor.
const Tensor< GUM_SCALAR > & cpf() const override=0
See gum::PRMClassElement::cpf().
PRMType & type() override=0
See gum::PRMClassElement::type().
Abstract class representing an element of PRM class.
virtual std::string cast(const PRMType &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.
ClassElementType
Returns true if obj_ptr is of type PRMReferenceSlot.
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.
std::string safeName_
The safe name of this PRMClassElement.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
const std::string & name() const
Returns the name of this object.
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
<agrum/PRM/elements/scalarAttribute.h>
This is a decoration of the DiscreteVariable class.
const std::vector< Idx > & label_map() const
Returns the vector in which the i-th element is the Idx of the super type's label for the i-th label ...
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
const std::string & name() const
Returns the name of this object.
#define GUM_ERROR(type, msg)
namespace for all probabilistic relational models entities
gum is the global namespace for all aGrUM entities