aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::SetInst Class Reference

Class for assigning/browsing values to tuples of discrete variables. More...

#include <agrum/tools/multidim/SetInst.h>

+ Collaboration diagram for gum::SetInst:

Public Member Functions

Constructors / Destructors
 SetInst ()
 Default constructor: creates an empty tuple. More...
 
 SetInst (const SetInst &aI)
 Copy constructor. More...
 
 SetInst (const Instantiation &aI)
 Copy constructor. More...
 
SetInstoperator= (const SetInst &aI)
 Copy operator. More...
 
 SetInst (MultiDimAdressable &aMD)
 Constructor for a SetInst of all the variables of a MultiDimAdressable. More...
 
 SetInst (const MultiDimAdressable &aMD)
 Constructor for a SetInst of all the variables of a MultiDimAdressable. More...
 
 SetInst (MultiDimAdressable *aMD)
 Constructor for a SetInst of all the variables of a MultiDimAdressable. More...
 
 SetInst (const MultiDimAdressable *aMD)
 Constructor for a SetInst of all the variables of a MultiDimAdressable. More...
 
 ~SetInst ()
 Class destructor. More...
 
Accessors / Modifiers
Idx nbrDim () const
 Returns the number of variables in the SetInst. More...
 
void add (const DiscreteVariable &v)
 Adds a new variable in the SetInst. More...
 
void erase (const DiscreteVariable &v)
 Removes a variable from the SetInst. More...
 
void clear ()
 Erase all variables from an SetInst. More...
 
Size domainSize () const
 Returns the product of the variable's domain size in the SetInst. More...
 
Idx pos (const DiscreteVariable &v) const
 Returns the position of the variable v. More...
 
Size vals (Idx i) const
 Returns the current value of the variable at position i. More...
 
Size vals (const DiscreteVariable &var) const
 Returns the current value of a given variable. More...
 
Size vals (const DiscreteVariable *var) const
 Returns the current value of a given variable. More...
 
Idx nbrOccurences (const DiscreteVariable &var) const
 Returns the current value of the variable at position i. More...
 
Idx val (Idx i) const
 Returns the current value of a variable at a given position. More...
 
Idx val (const DiscreteVariable &var) const
 Returns the current value of a given variable. More...
 
Idx val (const DiscreteVariable *var) const
 Returns the current value of a given variable. More...
 
const DiscreteVariablevariable (Idx i) const
 Returns the variable at position i in the tuple. More...
 
SetInstchgVal (const DiscreteVariable &v, Idx newVal)
 Assign newVal to variable v in the SetInst. More...
 
SetInstchgVal (const DiscreteVariable *v, Idx newVal)
 Assign newVal to variable v in the SetInst. More...
 
SetInstchgVal (Idx varPos, Idx newVal)
 Assign newVal to variable at position varPos in the SetInst. More...
 
SetInstchgVals (const DiscreteVariable &v, const Size newVal)
 Assign newVal to variable v in the SetInst. More...
 
SetInstaddVal (const DiscreteVariable &v, Idx newVal)
 Add newVal to variable v in the SetInst. More...
 
SetInstaddVals (const DiscreteVariable &v, const Size newVal)
 Add newVal to variable v in the SetInst. More...
 
SetInstremVal (const DiscreteVariable &v, Idx newVal)
 Remove newVal from the variable v in the SetInst. More...
 
SetInstremVals (const DiscreteVariable &v, const Size newVal)
 Remove newVal from the variable v in the SetInst. More...
 
SetInstinterVals (const DiscreteVariable &v, const Size newVal)
 Does an intersection (binary and) between the old value and new value. More...
 
SetInstinterVal (const DiscreteVariable &v, Idx newVal)
 Does an intersection (binary and) between the old value and new value. More...
 
SetInstchgVals (const DiscreteVariable *v, const Size newVal)
 Assign newVal to variable v in the SetInst. More...
 
SetInstaddVal (const DiscreteVariable *v, Idx newVal)
 Add newVal to variable v in the SetInst. More...
 
SetInstaddVals (const DiscreteVariable *v, const Size newVal)
 Add newVal to variable v in the SetInst. More...
 
SetInstremVal (const DiscreteVariable *v, Idx newVal)
 Remove newVal from the variable v in the SetInst. More...
 
SetInstremVals (const DiscreteVariable *v, const Size newVal)
 Remove newVal from the variable v in the SetInst. More...
 
SetInstinterVals (const DiscreteVariable *v, const Size newVal)
 Does an intersection (binary and) between the old value and new value. More...
 
SetInstinterVal (const DiscreteVariable *v, Idx newVal)
 Does an intersection (binary and) between the old value and new value. More...
 
SetInstchgVals (Idx varPos, const Size newVal)
 Assign newVal to variable at position varPos in the SetInst. More...
 
SetInstaddVal (Idx varPos, Idx newVal)
 Add newVal to variable v in the SetInst. More...
 
SetInstaddVals (Idx varPos, const Size newVal)
 Add newVal to variable varPos in the SetInst. More...
 
SetInstremVal (Idx varPos, Idx newVal)
 Remove newVal from the variable varPos in the SetInst. More...
 
SetInstremVals (Idx varPos, const Size newVal)
 Remove newVal from the variable varPos in the SetInst. More...
 
SetInstinterVals (Idx varPos, const Size newVal)
 Does an intersection (binary and) between the old value and new value. More...
 
SetInstinterVal (Idx varPos, Idx newVal)
 Does an intersection (binary and) between the old value and new value. More...
 
SetInstchgDifVal (Idx varPos, const Size newVal)
 Does the difference (binary or) between the old value and new value. More...
 
SetInstchgValIn (const SetInst &i)
 Change all the values to match does in i. More...
 
bool contains (const DiscreteVariable &v) const
 Indicates whether a given variable belongs to the SetInst. More...
 
bool contains (const DiscreteVariable *v) const
 Indicates whether a given variable belongs to the SetInst. More...
 
const Sequence< const DiscreteVariable *> & variablesSequence () const
 Returns the sequence of DiscreteVariable of this SetInst. More...
 
virtual bool empty () const
 Returns true if the SetInst is empty. More...
 
std::string toString () const
 Give a string version of SetInst. More...
 
void reorder (const Sequence< const DiscreteVariable * > &v)
 Reorder the variables given v. More...
 
void reorder (const SetInst &i)
 Reorder the variables given i. More...
 
Overflow management methods.
bool inOverflow () const
 Indicates whether the current value of the tuple is correct or not. More...
 
void unsetOverflow ()
 Removes the flag overflow. More...
 
void unsetEnd ()
 Alias for unsetOverflow(). More...
 
bool end () const
 Returns true if the SetInst reached the end. More...
 
bool rend () const
 Returns true if the SetInst reached the rend. More...
 

Static Public Member Functions

Static methods
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. More...
 

Protected Member Functions

virtual void replace_ (const DiscreteVariable *x, const DiscreteVariable *y)
 

Detailed Description

Class for assigning/browsing values to tuples of discrete variables.

SetInst is designed to assign a set of deterministic values to tuples of variables for contextual dependencies detection.

For a variable I of possible determinstic instances \(i1, i2, i3, \ldots\) in the expresion of a set of instantiations is express by the boolean state of each instance transform in an integer. For example: \(i1\) or \(i2\) or \(i4\) will be :

i4 i3 i2 i1
1 0 1 1 -> 11

There is two different types of setters:

  • function ending in val take the instance and encode it.
  • function ending in vals take allready the encoded expression of the intances union.
Warning
The model is based on the implementation of aGrUM Instantiation source code. The only difference is the impossibility to loop since the SetInst is not create to run through, but to collect all union of the possible instantiations of each variable, on the multiDimAdressable.

To print information about a SetInst use the following function:

See also
operator<<(std::ostream&, const SetInst&)

Definition at line 81 of file setInst.h.

Constructor & Destructor Documentation

◆ SetInst() [1/7]

gum::SetInst::SetInst ( )

Default constructor: creates an empty tuple.

◆ SetInst() [2/7]

gum::SetInst::SetInst ( const SetInst aI)

Copy constructor.

Parameters
aIThe SetInst to copy.

◆ SetInst() [3/7]

gum::SetInst::SetInst ( const Instantiation aI)

Copy constructor.

Parameters
aIThe SetInst to copy.

◆ SetInst() [4/7]

gum::SetInst::SetInst ( MultiDimAdressable aMD)

Constructor for a SetInst of all the variables of a MultiDimAdressable.

Parameters
aMDThe array the variables of which are those of the SetInst.

◆ SetInst() [5/7]

gum::SetInst::SetInst ( const MultiDimAdressable aMD)

Constructor for a SetInst of all the variables of a MultiDimAdressable.

Parameters
aMDThe array the variables of which are those of the SetInst.

◆ SetInst() [6/7]

gum::SetInst::SetInst ( MultiDimAdressable aMD)

Constructor for a SetInst of all the variables of a MultiDimAdressable.

Parameters
aMDThe array the variables of which are those of the SetInst.

◆ SetInst() [7/7]

gum::SetInst::SetInst ( const MultiDimAdressable aMD)

Constructor for a SetInst of all the variables of a MultiDimAdressable.

Parameters
aMDThe array the variables of which are those of the SetInst

◆ ~SetInst()

gum::SetInst::~SetInst ( )

Class destructor.

Member Function Documentation

◆ _add_()

void gum::SetInst::_add_ ( const DiscreteVariable v)
private

Adds a new var to the sequence of vars.

If variable v already belongs to the SetInst tuple of variables, then nothing is done. In particular, no exception is thrown in this case.

@ warning note that this function does not deassociate the SetInst from its master MultiDimAdressable, if any. To do so, use function add instead.

Warning
this function does not notify the master MultiDimAdressable, if any. Use in addition function chgVal or chgVal if need be.
variable v is known to the SetInst only by a pointer to it. As a result, this is not a copy of v that is used by SetInst but rather v itself. As such, v should never be deleted from memory until the SetInst is removed.
Parameters
vThe new var.
Exceptions
DuplicateElementRaised if v is already in the SetInst.

◆ _chgVal_()

void gum::SetInst::_chgVal_ ( Idx  varPos,
Idx  newVal 
)
private

Change the value of a variable.

Parameters
varPosThe variable index.
newValThe new value.

◆ _chgVals_()

void gum::SetInst::_chgVals_ ( Idx  varPos,
const Size  newVal 
)
private

Change the value of a variable.

Parameters
varPosThe variable index.
newValThe new value.

◆ _erase_()

void gum::SetInst::_erase_ ( const DiscreteVariable v)
private

Removes a variable from the sequence of vars.

If variable v does not belong to the SetInst tuple of variables, then nothing is done. In particular, no exception is thrown in this case.

Warning
this function does not notify the master MultiDimAdressable, if any.
note that this function does not deassociate the SetInst from its master MultiDimAdressable, if any. To do so, use function removeDim instead.
Parameters
vThe variable to remove.

◆ _init_()

void gum::SetInst::_init_ ( MultiDimAdressable master)
private

Intialize the SetInst.

Parameters
masterThe master of this SetInst.

◆ _swap_()

void gum::SetInst::_swap_ ( Idx  i,
Idx  j 
)
private

Swap 2 vars in the SetInst.

Parameters
iThe first variable to swap.
jThe second variable to swap.

◆ add()

void gum::SetInst::add ( const DiscreteVariable v)

Adds a new variable in the SetInst.

Warning
Variable v is known to the SetInst only by a pointer to it. As a result, this is not a copy of v that is used by SetInst But rather v itself. As such, v should never be deleted from memory until the SetInst is removed.
Parameters
vThe new variable.
Exceptions
DuplicateElementRaised if c is already in this SetInst.
OperationNotAllowedRaised if the SetInst is a slave.

◆ addVal() [1/3]

SetInst& gum::SetInst::addVal ( const DiscreteVariable v,
Idx  newVal 
)

Add newVal to variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe value added to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ addVal() [2/3]

SetInst& gum::SetInst::addVal ( const DiscreteVariable v,
Idx  newVal 
)

Add newVal to variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe value added to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ addVal() [3/3]

SetInst& gum::SetInst::addVal ( Idx  varPos,
Idx  newVal 
)

Add newVal to variable v in the SetInst.

Parameters
varPosThe variable whose value is assigned.
newValThe value added to the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable varPos does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for varPos.

◆ addVals() [1/3]

SetInst& gum::SetInst::addVals ( const DiscreteVariable v,
const Size  newVal 
)

Add newVal to variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe value added to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ addVals() [2/3]

SetInst& gum::SetInst::addVals ( const DiscreteVariable v,
const Size  newVal 
)

Add newVal to variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe value added to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ addVals() [3/3]

SetInst& gum::SetInst::addVals ( Idx  varPos,
const Size  newVal 
)

Add newVal to variable varPos in the SetInst.

Parameters
varPosThe variable whose value is assigned.
newValThe value added to the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable varPos does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for varPos.

◆ assign_values()

static void gum::SetInst::assign_values ( Bijection< const DiscreteVariable *, const DiscreteVariable * > &  bij,
const SetInst i,
SetInst j 
)
static

Assign the values of i in j, using bij as a bijection between i and j variables.

Parameters
bijFirsts are variables in i and seconds are variables in j.
iAn SetInst used to change the values in j.
jAn SetInst which receives new values from i using bij.
Exceptions
NotFoundraised if a variable in i does not point to a variable in j or if a variable in i is missing in bij.

◆ chgDifVal()

SetInst& gum::SetInst::chgDifVal ( Idx  varPos,
const Size  newVal 
)

Does the difference (binary or) between the old value and new value.

Parameters
varPosThe variable whose value is assigned.
newValThe value intersected with the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable varPos does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for varPos.

◆ chgVal() [1/3]

SetInst& gum::SetInst::chgVal ( const DiscreteVariable v,
Idx  newVal 
)

Assign newVal to variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ chgVal() [2/3]

SetInst& gum::SetInst::chgVal ( const DiscreteVariable v,
Idx  newVal 
)

Assign newVal to variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ chgVal() [3/3]

SetInst& gum::SetInst::chgVal ( Idx  varPos,
Idx  newVal 
)

Assign newVal to variable at position varPos in the SetInst.

Parameters
varPosThe index of the variable whose value is assigned in the tuple of variables of the SetInst.
newValThe index of the value assigned (consider the values of the variable as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by the variable.
Returns
A reference to *this in order to chain the chgVal.
Exceptions
NotFoundraised if the variable does not belong to this
OutOfBoundraised if newVal is not a possible value for the variable

◆ chgValIn()

SetInst& gum::SetInst::chgValIn ( const SetInst i)

Change all the values to match does in i.

Parameters
iThe new set of value for this SetInst.
Returns
Returns a reference to *this in order to chain the chgVal.

◆ chgVals() [1/3]

SetInst& gum::SetInst::chgVals ( const DiscreteVariable v,
const Size  newVal 
)

Assign newVal to variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ chgVals() [2/3]

SetInst& gum::SetInst::chgVals ( const DiscreteVariable v,
const Size  newVal 
)

Assign newVal to variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ chgVals() [3/3]

SetInst& gum::SetInst::chgVals ( Idx  varPos,
const Size  newVal 
)

Assign newVal to variable at position varPos in the SetInst.

Parameters
varPosThe index of the variable whose value is assigned in the tuple of variables of the SetInst.
newValThe index of the value assigned (consider the values of the variable as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by the variable.
Returns
A reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if the variable does not belong to this
OutOfBoundRaised if newVal is not a possible value for the variable

◆ clear()

void gum::SetInst::clear ( )

Erase all variables from an SetInst.

Exceptions
OperationNotAllowedRaised if the SetInst is a slave.

◆ contains() [1/2]

bool gum::SetInst::contains ( const DiscreteVariable v) const

Indicates whether a given variable belongs to the SetInst.

Parameters
vThe variable for which the test is made.
Returns
Returns true if v is in the SetInst.

◆ contains() [2/2]

bool gum::SetInst::contains ( const DiscreteVariable v) const

Indicates whether a given variable belongs to the SetInst.

Parameters
vA pointer on the variable for which the test is made.
Returns
Returns true if *v is in the SetInst.

◆ domainSize()

Size gum::SetInst::domainSize ( ) const

Returns the product of the variable's domain size in the SetInst.

Returns
Returns the product of the variable's domain size in the SetInst.

◆ empty()

virtual bool gum::SetInst::empty ( ) const
virtual

Returns true if the SetInst is empty.

Returns
Returns true if the SetInst is empty.

◆ end()

bool gum::SetInst::end ( ) const

Returns true if the SetInst reached the end.

Function end() should be used as in:

for(SetInst i.setFirst();! i.end(); ++i) {
// code
}

◆ erase()

void gum::SetInst::erase ( const DiscreteVariable v)

Removes a variable from the SetInst.

Parameters
vThe variable to erase.
Exceptions
NotFoundRaised if v is not in this SetInst.
OperationNotAllowedRaised if the SetInst is a slave.

◆ inOverflow()

bool gum::SetInst::inOverflow ( ) const

Indicates whether the current value of the tuple is correct or not.

for(SetInst i.setFirst(); !i.inOverflow(); ++i) {
// code...
}

◆ interVal() [1/3]

SetInst& gum::SetInst::interVal ( const DiscreteVariable v,
Idx  newVal 
)

Does an intersection (binary and) between the old value and new value.

Parameters
vThe variable whose value is assigned.
newValThe value intersected with the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ interVal() [2/3]

SetInst& gum::SetInst::interVal ( const DiscreteVariable v,
Idx  newVal 
)

Does an intersection (binary and) between the old value and new value.

Parameters
vThe variable whose value is assigned.
newValThe value intersected with the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ interVal() [3/3]

SetInst& gum::SetInst::interVal ( Idx  varPos,
Idx  newVal 
)

Does an intersection (binary and) between the old value and new value.

Parameters
varPosThe variable whose value is assigned.
newValThe value intersected with the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable varPos does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for varPos.

◆ interVals() [1/3]

SetInst& gum::SetInst::interVals ( const DiscreteVariable v,
const Size  newVal 
)

Does an intersection (binary and) between the old value and new value.

Parameters
vThe variable whose value is assigned.
newValThe value intersected with the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ interVals() [2/3]

SetInst& gum::SetInst::interVals ( const DiscreteVariable v,
const Size  newVal 
)

Does an intersection (binary and) between the old value and new value.

Parameters
vThe variable whose value is assigned.
newValThe value intersected with the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ interVals() [3/3]

SetInst& gum::SetInst::interVals ( Idx  varPos,
const Size  newVal 
)

Does an intersection (binary and) between the old value and new value.

Parameters
varPosThe variable whose value is assigned.
newValThe value intersected with the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable varPos does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for varPos.

◆ nbrDim()

Idx gum::SetInst::nbrDim ( ) const

Returns the number of variables in the SetInst.

Returns
Returns the number of variables in the SetInst.

◆ nbrOccurences()

Idx gum::SetInst::nbrOccurences ( const DiscreteVariable var) const

Returns the current value of the variable at position i.

Parameters
varthe variable.
Returns
Returns the current value of the variable at position i.
Exceptions
NotFoundraised if the element cannot be found.

◆ operator=()

SetInst& gum::SetInst::operator= ( const SetInst aI)

Copy operator.

Warning
An OperationNotAllowed will be raised if you use the copy operator.

◆ pos()

Idx gum::SetInst::pos ( const DiscreteVariable v) const

Returns the position of the variable v.

Exceptions
NotFoundRaised if v does not belong to the SetInst.

◆ remVal() [1/3]

SetInst& gum::SetInst::remVal ( const DiscreteVariable v,
Idx  newVal 
)

Remove newVal from the variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe value removed to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ remVal() [2/3]

SetInst& gum::SetInst::remVal ( const DiscreteVariable v,
Idx  newVal 
)

Remove newVal from the variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe value removed to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ remVal() [3/3]

SetInst& gum::SetInst::remVal ( Idx  varPos,
Idx  newVal 
)

Remove newVal from the variable varPos in the SetInst.

Parameters
varPosThe variable whose value is assigned.
newValThe value removed to the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable varPos does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for varPos.

◆ remVals() [1/3]

SetInst& gum::SetInst::remVals ( const DiscreteVariable v,
const Size  newVal 
)

Remove newVal from the variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe value removed to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ remVals() [2/3]

SetInst& gum::SetInst::remVals ( const DiscreteVariable v,
const Size  newVal 
)

Remove newVal from the variable v in the SetInst.

Parameters
vThe variable whose value is assigned.
newValThe value removed to the index of the value assigned (consider the values of v as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by v.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable v does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for v.

◆ remVals() [3/3]

SetInst& gum::SetInst::remVals ( Idx  varPos,
const Size  newVal 
)

Remove newVal from the variable varPos in the SetInst.

Parameters
varPosThe variable whose value is assigned.
newValThe value removed to the index of the value assigned (consider the values of varPos as an array indexed from 0 to n of values (which might be anything from real numbers to strings, etc). Parameter newVal indicates the index in this array of the new value taken by varPos.
Returns
Returns a reference to *this in order to chain the chgVal.
Exceptions
NotFoundRaised if variable varPos does not belong to the SetInst.
OutOfBoundRaised if newVal is not a possible value for varPos.

◆ rend()

bool gum::SetInst::rend ( ) const

Returns true if the SetInst reached the rend.

Function end() should be used as in:

for(SetInst i.setLast();! i.rend(); --i) {
// code
}

◆ reorder() [1/2]

void gum::SetInst::reorder ( const Sequence< const DiscreteVariable * > &  v)

Reorder the variables given v.

Parameters
vThe new order of variables in this SetInst.

◆ reorder() [2/2]

void gum::SetInst::reorder ( const SetInst i)

Reorder the variables given i.

Parameters
iThe new order of variables in this SetInst.

◆ replace_()

virtual void gum::SetInst::replace_ ( const DiscreteVariable x,
const DiscreteVariable y 
)
protectedvirtual

◆ toString()

std::string gum::SetInst::toString ( ) const

Give a string version of SetInst.

Returns
Returns a string version of SetInst.

◆ unsetEnd()

void gum::SetInst::unsetEnd ( )

Alias for unsetOverflow().

See also
unsetOverflow().

◆ unsetOverflow()

void gum::SetInst::unsetOverflow ( )

Removes the flag overflow.

See full documentation for details. (Recommended).

// assume the probability has been defined somewhere:
MultiDimArray<double> Prob;
// create 2 SetInsts for the 2 necessary loops
SetInst i(Prob), j;
j << a << c;
double delta;
// outer loop: loop over the values of b
for(i.setFirstIn(j); !i.end(); i.incIn(j))
{
delta = 0.0;
// inner loop: loop over the values of a and c
for(i.setFirstOut(j); !i.end(); i.incerr(j))
delta += dd[i];
for(i.setFirstOut(j); !i.end(); i.incerr(j))
dd[i] /= delta;
// indicate that the end() reached after looping over a and c does not
// correspond to an end() for the loop w.r.t. b
i.unsetOverflow();
}

◆ val() [1/3]

Idx gum::SetInst::val ( Idx  i) const

Returns the current value of a variable at a given position.

Parameters
iThe position of the variable for which its value is returned.
Returns
Returns the current value of a variable at a given position.
Exceptions
NotFoundraised it var does not belong to the SetInst.

◆ val() [2/3]

Idx gum::SetInst::val ( const DiscreteVariable var) const

Returns the current value of a given variable.

Parameters
varThe variable the value of which we wish to know.
Returns
Returns the current value of a given variable.
Exceptions
NotFoundRaised it var does not belong to the SetInst.

◆ val() [3/3]

Idx gum::SetInst::val ( const DiscreteVariable var) const

Returns the current value of a given variable.

Parameters
varThe variable the value of which we wish to know.
Returns
Returns the current value of a given variable.
Exceptions
NotFoundRaised if var does not belong to the SetInst.

◆ vals() [1/3]

Size gum::SetInst::vals ( Idx  i) const

Returns the current value of the variable at position i.

Parameters
iThe index of the variable.
Returns
Returns the current value of the variable at position i.
Exceptions
NotFoundRaised if the element cannot be found.

◆ vals() [2/3]

Size gum::SetInst::vals ( const DiscreteVariable var) const

Returns the current value of a given variable.

Parameters
varThe variable the value of which we wish to know.
Returns
Returns the current value of a given variable.
Exceptions
NotFoundRaised it var does not belong to the SetInst.

◆ vals() [3/3]

Size gum::SetInst::vals ( const DiscreteVariable var) const

Returns the current value of a given variable.

Parameters
varThe variable the value of which we wish to know.
Returns
Returns the current value of a given variable.
Exceptions
NotFoundRaised if var does not belong to the SetInst.

◆ variable()

const DiscreteVariable& gum::SetInst::variable ( Idx  i) const

Returns the variable at position i in the tuple.

Parameters
iThe index of the variable.
Returns
Returns the variable at position i in the tuple.
Exceptions
NotFoundRaised if the element cannot be found.

◆ variablesSequence()

const Sequence< const DiscreteVariable* >& gum::SetInst::variablesSequence ( ) const

Returns the sequence of DiscreteVariable of this SetInst.

Returns
Returns the sequence of DiscreteVariable of this SetInst.

Member Data Documentation

◆ _overflow_

bool gum::SetInst::_overflow_
private

The overflow flag.

Definition at line 850 of file setInst.h.

◆ _vals_

std::vector< Size > gum::SetInst::_vals_
private

The current SetInst: the value of the tuple.

Definition at line 847 of file setInst.h.

◆ _vars_

Sequence< const DiscreteVariable* > gum::SetInst::_vars_
private

The tuple of variables to be instantiated.

Definition at line 844 of file setInst.h.


The documentation for this class was generated from the following file: