31 #ifndef DOXYGEN_SHOULD_SKIP_THIS 37 const Sequence< const DiscreteVariable* >& v = master->variablesSequence();
42 for (
const auto var : v)
52 GUM_CONSTRUCTOR(SetInst);
59 GUM_CONSTRUCTOR(SetInst);
60 __init(const_cast< MultiDimAdressable* >(&d));
67 GUM_CONSTRUCTOR(SetInst);
79 GUM_CONSTRUCTOR(SetInst);
81 if (const_d) __init(const_cast< MultiDimAdressable* >(const_d));
89 GUM_CONS_CPY(SetInst);
93 __overflow = aI.__overflow;
101 GUM_CONS_CPY(SetInst);
102 const Sequence< const DiscreteVariable* >& v = aI.variablesSequence();
103 __vars.resize(v.size());
107 for (
const auto var : v) {
109 __vals[__vars.pos(var)] = (
Size(1) << (aI.val(*var)));
118 __overflow = aI.__overflow;
125 std::stringstream sstr;
128 if (__overflow) { sstr <<
"<invalid>"; }
134 if (iter != __vars.end()) {
135 std::stringstream sstr2;
138 Size valb = vals(iter.pos());
141 std::stringstream sstr4;
142 sstr4 << ((valb & 1) ?
"1" :
"0") << sstr2.str();
146 sstr2 << sstr4.str();
149 sstr <<
variable(iter.pos()).name() <<
":" << sstr2.str();
152 while (iter != __vars.end()) {
153 std::stringstream sstr3;
157 valb = vals(iter.pos());
160 std::stringstream sstr4;
162 sstr4 << ((valb & 1) ?
"1" :
"0") << sstr3.str();
165 sstr3 << sstr4.str();
168 sstr <<
"|" <<
variable(iter.pos()).name() <<
":" << sstr3.str();
179 std::ostream&
operator<<(std::ostream& aStream,
const SetInst& i) {
180 aStream << i.toString();
207 #endif // DOXYGEN_SHOULD_SKIP_THIS const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
virtual Size domainSize() const final
Returns the product of the variables domain size.
static void assign_values(Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const SetInst &i, SetInst &j)
Assign the values of i in j, using bij as a bijection between i and j variables.
SetInst & chgVal(const DiscreteVariable &v, Idx newVal)
Assign newVal to variable v in the SetInst.
void add(const DiscreteVariable &v)
Adds a new variable in the SetInst.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::string toString() const
Give a string version of SetInst.
const Sequence< const DiscreteVariable *> & variablesSequence() const
Returns the sequence of DiscreteVariable of this SetInst.
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map's DAG in output using the Graphviz-dot format.
Class for assigning/browsing values to tuples of discrete variables.
void __add(const DiscreteVariable &v)
Adds a new var to the sequence of vars.
virtual const DiscreteVariable & variable(Idx) const final
Returns a const ref to the ith var.
SequenceIteratorSafe< Key > iterator_safe
Types for STL compliance.
Set of pairs of elements with fast search for both elements.
std::vector< Size > __vals
The current SetInst: the value of the tuple.
bool __overflow
The overflow flag.
Sequence< const DiscreteVariable *> __vars
The tuple of variables to be instantiated.
void erase(const DiscreteVariable &v)
Removes a variable from the SetInst.
MultiDimAdressable()
Default constructor.
SetInst()
Default constructor: creates an empty tuple.
Idx val(Idx i) const
Returns the current value of a variable at a given position.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
void __init(MultiDimAdressable *master)
Intialize the SetInst.
MultiDimInterface & operator>>(MultiDimInterface &c, const DiscreteVariable &v)
Removes a var from the variables of the MutliDimAdressing.
SetInst & operator=(const SetInst &aI)
Copy operator.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
#define GUM_ERROR(type, msg)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.