61 template <
typename GUM_SCALAR >
63 const std::string&
name,
73 template <
typename GUM_SCALAR >
81 template <
typename GUM_SCALAR >
89 template <
typename GUM_SCALAR >
93 for (
auto var:
_formulas_->variablesSequence()) {
94 if (var != &(
_type_->variable())) {
copy->_formulas_->add(*var); }
98 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end()); inst.inc(), jnst.
inc()) {
102 GUM_ASSERT(
copy->_formulas_->contains(
copy->_type_->variable()));
106 template <
typename GUM_SCALAR >
113 for (
const auto& var: source.
cpf().variablesSequence()) {
122 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
123 inst.inc(), jnst.inc()) {
124 _formulas_->set(inst, src._formulas_->get(jnst));
127 GUM_ASSERT(inst.end() && jnst.end());
132 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end());
133 inst.inc(), jnst.
inc()) {
134 auto val = std::to_string(source.
cpf().get(jnst));
138 GUM_ASSERT(inst.end() && jnst.
end());
150 template <
typename GUM_SCALAR >
156 template <
typename GUM_SCALAR >
161 template <
typename GUM_SCALAR >
166 template <
typename GUM_SCALAR >
172 template <
typename GUM_SCALAR >
184 elt.
name() <<
" of wrong type as parent of " << this->name();)
190 template <
typename GUM_SCALAR >
193 template <
typename GUM_SCALAR >
203 cast->addParent(*
this);
210 if (
type().label_map()[inst.
val(my_var)] == inst.
val(cast_var)) {
211 cast->cpf().set(inst, 1);
213 cast->cpf().set(inst, 0);
221 template <
typename GUM_SCALAR >
228 std::stringstream msg;
229 msg <<
type().name() <<
" is not a subtype of " <<
cast->type().name();
236 template <
typename GUM_SCALAR >
261 template <
typename GUM_SCALAR >
268 template <
typename GUM_SCALAR >
274 template <
typename GUM_SCALAR >
279 _cpf_ =
new Tensor< GUM_SCALAR >();
281 for (
auto var:
_formulas_->variablesSequence()) {
285 auto params =
_class_->scope();
294 if (val.empty()) { val =
"0.0"; }
298 for (
auto item: params) {
305 GUM_ASSERT(inst.
end() && jnst.
end());
311 template <
typename GUM_SCALAR >
320 template <
typename GUM_SCALAR >
325 template <
typename GUM_SCALAR >
327 if (&(old_type) ==
_type_) {
341 for (
auto var: old->variablesSequence()) {
342 if (var != &(old_type.
variable())) {
351 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end()); inst.inc(), jnst.
inc()) {
362 GUM_ASSERT(inst.end() && jnst.
end());
368 template <
typename GUM_SCALAR >
373 template <
typename GUM_SCALAR >
382 for (
auto var: old->variablesSequence()) {
383 if (var != &(
_type_->variable())) {
392 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end()); inst.inc(), jnst.
inc()) {
406 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.
Idx pos(const DiscreteVariable &v) const final
Returns the position of the variable v.
void inc()
Operator increment.
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.
virtual const Tensor< GUM_SCALAR > & cpf() const =0
See gum::PRMClassElement::cpf().
PRMAttribute(const std::string &name)
Destructor.
virtual PRMType & type()=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 LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
static std::string RIGHT_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